Changed: Set <textarea>, <input> font style

This commit is contained in:
Nimetu 2016-06-12 10:30:16 +03:00
parent 0e3a6b8a3e
commit 76c8a8a055
2 changed files with 52 additions and 9 deletions

View file

@ -55,6 +55,7 @@ using namespace NLMISC;
// Allow up to 10 redirects, then give up // Allow up to 10 redirects, then give up
#define DEFAULT_RYZOM_REDIRECT_LIMIT (10) #define DEFAULT_RYZOM_REDIRECT_LIMIT (10)
// //
#define FONT_WEIGHT_NORMAL 400
#define FONT_WEIGHT_BOLD 700 #define FONT_WEIGHT_BOLD 700
namespace NLGUI namespace NLGUI
@ -1417,14 +1418,24 @@ namespace NLGUI
if (present[MY_HTML_INPUT_ALT] && value[MY_HTML_INPUT_ALT]) if (present[MY_HTML_INPUT_ALT] && value[MY_HTML_INPUT_ALT])
tooltip = value[MY_HTML_INPUT_ALT]; tooltip = value[MY_HTML_INPUT_ALT];
string type = toLower(value[MY_HTML_INPUT_TYPE]); // by default not inherited
if (type == "image")
{
CStyleParams style; CStyleParams style;
// width, height from inline css style.TextColor = TextColor;
style.FontSize = TextFontSize;
style.FontWeight = FONT_WEIGHT_NORMAL;
style.FontOblique = false;
if (present[MY_HTML_INPUT_STYLE] && value[MY_HTML_INPUT_STYLE]) if (present[MY_HTML_INPUT_STYLE] && value[MY_HTML_INPUT_STYLE])
getStyleParams(value[MY_HTML_INPUT_STYLE], style); getStyleParams(value[MY_HTML_INPUT_STYLE], style);
_TextColor.push_back(style.TextColor);
_FontSize.push_back(style.FontSize);
_FontWeight.push_back(style.FontWeight);
_FontOblique.push_back(style.FontOblique);
string type = toLower(value[MY_HTML_INPUT_TYPE]);
if (type == "image")
{
// The submit button // The submit button
string name; string name;
string normal; string normal;
@ -1632,6 +1643,11 @@ namespace NLGUI
_Forms.back().Entries.push_back (entry); _Forms.back().Entries.push_back (entry);
} }
} }
popIfNotEmpty(_FontSize);
popIfNotEmpty(_TextColor);
popIfNotEmpty(_FontWeight);
popIfNotEmpty(_FontOblique);
} }
} }
break; break;
@ -1871,6 +1887,21 @@ namespace NLGUI
// Got one form ? // Got one form ?
if (!(_Forms.empty())) if (!(_Forms.empty()))
{ {
// not inherited by default
CStyleParams style;
style.TextColor = TextColor;
style.FontWeight = FONT_WEIGHT_NORMAL;
style.FontOblique = false;
style.FontSize = TextFontSize;
if (present[MY_HTML_TEXTAREA_STYLE] && value[MY_HTML_TEXTAREA_STYLE])
getStyleParams(value[MY_HTML_TEXTAREA_STYLE], style);
_TextColor.push_back(style.TextColor);
_FontSize.push_back(style.FontSize);
_FontWeight.push_back(style.FontWeight);
_FontOblique.push_back(style.FontOblique);
// read general property // read general property
string templateName; string templateName;
@ -2187,6 +2218,11 @@ namespace NLGUI
entry.TextArea = textArea; entry.TextArea = textArea;
_Forms.back().Entries.push_back (entry); _Forms.back().Entries.push_back (entry);
} }
popIfNotEmpty (_FontSize);
popIfNotEmpty (_FontWeight);
popIfNotEmpty (_FontOblique);
popIfNotEmpty (_TextColor);
} }
} }
break; break;
@ -3988,11 +4024,16 @@ namespace NLGUI
{ {
// Not added ? // Not added ?
std::vector<std::pair<std::string,std::string> > templateParams; std::vector<std::pair<std::string,std::string> > templateParams;
templateParams.push_back (std::pair<std::string,std::string> ("w", toString (cols*12))); templateParams.push_back (std::pair<std::string,std::string> ("w", toString (cols*getFontSize())));
//templateParams.push_back (std::pair<std::string,std::string> ("h", toString (rows*12)));
templateParams.push_back (std::pair<std::string,std::string> ("id", name)); templateParams.push_back (std::pair<std::string,std::string> ("id", name));
templateParams.push_back (std::pair<std::string,std::string> ("prompt", "")); templateParams.push_back (std::pair<std::string,std::string> ("prompt", ""));
templateParams.push_back (std::pair<std::string,std::string> ("multiline", multiLine?"true":"false")); templateParams.push_back (std::pair<std::string,std::string> ("multiline", multiLine?"true":"false"));
templateParams.push_back (std::pair<std::string,std::string> ("fontsize", toString (getFontSize())));
templateParams.push_back (std::pair<std::string,std::string> ("color", getTextColor().toString()));
if (getFontWeight() >= FONT_WEIGHT_BOLD)
templateParams.push_back (std::pair<std::string,std::string> ("fontweight", "bold"));
if (getFontOblique())
templateParams.push_back (std::pair<std::string,std::string> ("fontstyle", "oblique"));
if (multiLine) if (multiLine)
templateParams.push_back (std::pair<std::string,std::string> ("multi_min_line", toString(rows))); templateParams.push_back (std::pair<std::string,std::string> ("multi_min_line", toString(rows)));
templateParams.push_back (std::pair<std::string,std::string> ("want_return", multiLine?"true":"false")); templateParams.push_back (std::pair<std::string,std::string> ("want_return", multiLine?"true":"false"));

View file

@ -112,6 +112,8 @@
keep="true" keep="true"
max_historic="40" max_historic="40"
fontsize="10" fontsize="10"
fontweight=""
fontstyle=""
backup_father_container_pos="false" backup_father_container_pos="false"
want_return="false" want_return="false"
color="255 255 255 255" color="255 255 255 255"
@ -122,7 +124,7 @@
<group id="#id" posref="#posref" x="#x" y="#y" posparent="#posparent" child_resize_h="#child_resize_h" sizeref="#sizeref" w="#w" h="#h" render_layer="#render_layer"> <group id="#id" posref="#posref" x="#x" y="#y" posparent="#posparent" child_resize_h="#child_resize_h" sizeref="#sizeref" w="#w" h="#h" render_layer="#render_layer">
<group type="edit_box" sizeref="#sizeref_eb" w="-16" id="eb" posref="TL TL" x="8" y="-8" child_resize_h="#child_resize_h" onenter="#onenter" params="#params" onchange="#onchange" onchange_params="#onchange_params" max_num_chars="#max_num_chars" prompt="#prompt" enter_loose_focus="#enter_loose_focus" enter_recover_focus="#enter_recover_focus" entry_type="#entry_type" reset_focus_on_hide="#reset_focus_on_hide" menu_r="#menu_r" max_historic="#max_historic" want_return="#want_return" backup_father_container_pos="#backup_father_container_pos" render_layer="#render_layer"> <group type="edit_box" sizeref="#sizeref_eb" w="-16" id="eb" posref="TL TL" x="8" y="-8" child_resize_h="#child_resize_h" onenter="#onenter" params="#params" onchange="#onchange" onchange_params="#onchange_params" max_num_chars="#max_num_chars" prompt="#prompt" enter_loose_focus="#enter_loose_focus" enter_recover_focus="#enter_recover_focus" entry_type="#entry_type" reset_focus_on_hide="#reset_focus_on_hide" menu_r="#menu_r" max_historic="#max_historic" want_return="#want_return" backup_father_container_pos="#backup_father_container_pos" render_layer="#render_layer">
<view type="bitmap" id="bg" scale="true" sizeref="hw" h="0" w="0" texture="log_eb_m.tga" inherit_gc_alpha="false" render_layer="#render_layer"/> <view type="bitmap" id="bg" scale="true" sizeref="hw" h="0" w="0" texture="log_eb_m.tga" inherit_gc_alpha="false" render_layer="#render_layer"/>
<view id="edit_text" type="text" x="#text_x" y="#text_y" posref="#text_ref" multi_line="#multi_line" multi_line_space="0" multi_min_line="#multi_min_line" fontsize="#fontsize" color="#color" shadow="true" hardtext="" global_color="false" render_layer="#render_layer"/> <view id="edit_text" type="text" x="#text_x" y="#text_y" posref="#text_ref" multi_line="#multi_line" multi_line_space="0" multi_min_line="#multi_min_line" fontsize="#fontsize" color="#color" fontweight="#fontweight" fontstyle="#fontstyle" shadow="true" hardtext="" global_color="false" render_layer="#render_layer"/>
</group> </group>
<!-- border around the list --> <!-- border around the list -->