make text-size an optional attribute of button

This commit is contained in:
2024-11-25 19:12:42 -06:00
committed by Celtic Minstrel
parent f47229417b
commit 2b01a18bb3
5 changed files with 14 additions and 8 deletions

View File

@@ -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;

View File

@@ -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