diff --git a/src/dialogxml/widgets/button.cpp b/src/dialogxml/widgets/button.cpp index 6f9862876..5e395afdb 100644 --- a/src/dialogxml/widgets/button.cpp +++ b/src/dialogxml/widgets/button.cpp @@ -21,18 +21,18 @@ cButton::cButton(sf::RenderWindow& parent) : cControl(CTRL_BTN,parent), wrapLabel(false), type(BTN_REG), + textSize(defaultTextSize(type)), textClr(sf::Color::Black), fromList("none") { - defaultTextSize(); } cButton::cButton(cDialog& parent) : cControl(CTRL_BTN,parent), wrapLabel(false), type(BTN_REG), + textSize(defaultTextSize(type)), textClr(parent.getDefTextClr()), fromList("none") { - defaultTextSize(); } /* This constructor is only called for LEDs. */ @@ -40,15 +40,12 @@ cButton::cButton(cDialog& parent,eControlType t) : cControl(t,parent), fromList("none"), wrapLabel(false) { - defaultTextSize(); } -void cButton::defaultTextSize() { - if(textSize != 0) return; - - if(type == BTN_TINY) textSize = 9; - else if(type == BTN_PUSH) textSize = 10; - else textSize = 12; +short cButton::defaultTextSize(eBtnType type) { + if(type == BTN_TINY) return 9; + else if(type == BTN_PUSH) return 10; + else return 12; } bool cButton::isClickable() const { diff --git a/src/dialogxml/widgets/button.hpp b/src/dialogxml/widgets/button.hpp index 9f73eb631..177ac4581 100644 --- a/src/dialogxml/widgets/button.hpp +++ b/src/dialogxml/widgets/button.hpp @@ -74,12 +74,12 @@ protected: cButton(cDialog& parent,eControlType t); private: bool manageFormat(eFormat prop, bool set, boost::any* val) override; - void defaultTextSize(); + static short defaultTextSize(eBtnType type); std::string fromList; static rectangle btnRects[13][2]; protected: /// Size of the button's descriptive text - short textSize = 0; + short textSize; /// Determines whether the button's label should be word wrapped. bool wrapLabel; /// The button's text colour; only used by LED and tiny buttons