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='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='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>
|
<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)
|
Reset instant help (all help windows will reappear)
|
||||||
</button>
|
</button>
|
||||||
<button name='okay' relative='abs pos' rel-anchor='prev' type='regular' top='17' left='354'>OK</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:sequence>
|
||||||
<xs:attribute name="name" use="required" type="xs:token"/>
|
<xs:attribute name="name" use="required" type="xs:token"/>
|
||||||
<xs:attribute name="type" use="required" type="btntype"/>
|
<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 name="wrap" default="false" type="bool"/>
|
||||||
<xs:attribute ref="def-key"/>
|
<xs:attribute ref="def-key"/>
|
||||||
<xs:attribute name="fromlist" default="none" type="xs:string"/>
|
<xs:attribute name="fromlist" default="none" type="xs:string"/>
|
||||||
|
@@ -44,6 +44,8 @@ cButton::cButton(cDialog& parent,eControlType t) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cButton::defaultTextSize() {
|
void cButton::defaultTextSize() {
|
||||||
|
if(textSize != 0) return;
|
||||||
|
|
||||||
if(type == BTN_TINY) textSize = 9;
|
if(type == BTN_TINY) textSize = 9;
|
||||||
else if(type == BTN_PUSH) textSize = 10;
|
else if(type == BTN_PUSH) textSize = 10;
|
||||||
else textSize = 12;
|
else textSize = 12;
|
||||||
@@ -146,6 +148,11 @@ bool cButton::parseAttribute(ticpp::Attribute& attr, std::string tagName, std::s
|
|||||||
else if(val == "push") setBtnType(BTN_PUSH);
|
else if(val == "push") setBtnType(BTN_PUSH);
|
||||||
else throw xBadVal(tagName, name, val, attr.Row(), attr.Column(), fname);
|
else throw xBadVal(tagName, name, val, attr.Row(), attr.Column(), fname);
|
||||||
return true;
|
return true;
|
||||||
|
}else if(name == "text-size"){
|
||||||
|
std::string val = attr.Value();
|
||||||
|
short size = std::stoi(val);
|
||||||
|
textSize = size;
|
||||||
|
return true;
|
||||||
}else if(name == "def-key"){
|
}else if(name == "def-key"){
|
||||||
std::string val = attr.Value();
|
std::string val = attr.Value();
|
||||||
try{
|
try{
|
||||||
|
@@ -80,7 +80,7 @@ private:
|
|||||||
static rectangle btnRects[13][2];
|
static rectangle btnRects[13][2];
|
||||||
protected:
|
protected:
|
||||||
/// Size of the button's descriptive text
|
/// Size of the button's descriptive text
|
||||||
short textSize;
|
short textSize = 0;
|
||||||
/// Determines whether the button's label should be word wrapped.
|
/// Determines whether the button's label should be word wrapped.
|
||||||
bool wrapLabel;
|
bool wrapLabel;
|
||||||
/// The button's text colour; only used by LED and tiny buttons
|
/// 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"));
|
cDialog prefsDlog(*ResMgr::dialogs.get("preferences"));
|
||||||
prefsDlog.attachClickHandlers(&prefs_event_filter, {"okay", "cancel"});
|
prefsDlog.attachClickHandlers(&prefs_event_filter, {"okay", "cancel"});
|
||||||
|
|
||||||
prefsDlog.attachClickHandlers(&reset_help, {"resethelp"});
|
prefsDlog.attachClickHandlers(&reset_help, {"resethelp"});
|
||||||
dynamic_cast<cButton&>(prefsDlog["resethelp"]).setTextSize(10);
|
|
||||||
|
|
||||||
cLedGroup& displayMode = dynamic_cast<cLedGroup&>(prefsDlog["display"]);
|
cLedGroup& displayMode = dynamic_cast<cLedGroup&>(prefsDlog["display"]);
|
||||||
switch(get_int_pref("DisplayMode")) {
|
switch(get_int_pref("DisplayMode")) {
|
||||||
|
Reference in New Issue
Block a user