make text-size an optional attribute of button
This commit is contained in:
@@ -47,7 +47,7 @@
|
||||
<led name='lesswm' relative='pos-in pos' rel-anchor='prev' top='10' left='0'>Fewer wandering monsters</led>
|
||||
<led name='skipsplash' relative='pos-in pos' rel-anchor='prev' top='10' left='0'>Skip splash screen on startup</led>
|
||||
<led name='nohelp' relative='pos-in pos' rel-anchor='prev' top='10' left='0'>Never show instant help</led>
|
||||
<button name='resethelp' type='tiny' relative='pos-in pos' rel-anchor='prev' top='10' left='0'>
|
||||
<button name='resethelp' type='tiny' text-size='10' relative='pos-in pos' rel-anchor='prev' top='10' left='0'>
|
||||
Reset instant help (all help windows will reappear)
|
||||
</button>
|
||||
<button name='okay' relative='abs pos' rel-anchor='prev' type='regular' top='17' left='354'>OK</button>
|
||||
|
@@ -207,6 +207,7 @@
|
||||
</xs:sequence>
|
||||
<xs:attribute name="name" use="required" type="xs:token"/>
|
||||
<xs:attribute name="type" use="required" type="btntype"/>
|
||||
<xs:attribute name="text-size" type="xs:integer"/>
|
||||
<xs:attribute name="wrap" default="false" type="bool"/>
|
||||
<xs:attribute ref="def-key"/>
|
||||
<xs:attribute name="fromlist" default="none" type="xs:string"/>
|
||||
|
@@ -44,6 +44,8 @@ cButton::cButton(cDialog& parent,eControlType t) :
|
||||
}
|
||||
|
||||
void cButton::defaultTextSize() {
|
||||
if(textSize != 0) return;
|
||||
|
||||
if(type == BTN_TINY) textSize = 9;
|
||||
else if(type == BTN_PUSH) textSize = 10;
|
||||
else textSize = 12;
|
||||
@@ -129,7 +131,7 @@ bool cButton::manageFormat(eFormat prop, bool set, boost::any* val) {
|
||||
|
||||
bool cButton::parseAttribute(ticpp::Attribute& attr, std::string tagName, std::string fname) {
|
||||
std::string name = attr.Name();
|
||||
if(name == "type") {
|
||||
if(name == "type"){
|
||||
std::string val = attr.Value();
|
||||
if(val == "small") setBtnType(BTN_SM);
|
||||
else if(val == "regular") setBtnType(BTN_REG);
|
||||
@@ -146,11 +148,16 @@ bool cButton::parseAttribute(ticpp::Attribute& attr, std::string tagName, std::s
|
||||
else if(val == "push") setBtnType(BTN_PUSH);
|
||||
else throw xBadVal(tagName, name, val, attr.Row(), attr.Column(), fname);
|
||||
return true;
|
||||
} else if(name == "def-key") {
|
||||
}else if(name == "text-size"){
|
||||
std::string val = attr.Value();
|
||||
try {
|
||||
short size = std::stoi(val);
|
||||
textSize = size;
|
||||
return true;
|
||||
}else if(name == "def-key"){
|
||||
std::string val = attr.Value();
|
||||
try{
|
||||
attachKey(parseKey(val));
|
||||
} catch(int) {
|
||||
}catch(int){
|
||||
throw xBadVal(tagName, name, val, attr.Row(), attr.Column(), fname);
|
||||
}
|
||||
return true;
|
||||
|
@@ -80,7 +80,7 @@ private:
|
||||
static rectangle btnRects[13][2];
|
||||
protected:
|
||||
/// Size of the button's descriptive text
|
||||
short textSize;
|
||||
short textSize = 0;
|
||||
/// Determines whether the button's label should be word wrapped.
|
||||
bool wrapLabel;
|
||||
/// The button's text colour; only used by LED and tiny buttons
|
||||
|
@@ -1256,9 +1256,7 @@ void pick_preferences(bool record) {
|
||||
|
||||
cDialog prefsDlog(*ResMgr::dialogs.get("preferences"));
|
||||
prefsDlog.attachClickHandlers(&prefs_event_filter, {"okay", "cancel"});
|
||||
|
||||
prefsDlog.attachClickHandlers(&reset_help, {"resethelp"});
|
||||
dynamic_cast<cButton&>(prefsDlog["resethelp"]).setTextSize(10);
|
||||
|
||||
cLedGroup& displayMode = dynamic_cast<cLedGroup&>(prefsDlog["display"]);
|
||||
switch(get_int_pref("DisplayMode")) {
|
||||
|
Reference in New Issue
Block a user