make button text size changeable
This commit is contained in:
@@ -22,19 +22,32 @@ cButton::cButton(sf::RenderWindow& parent) :
|
||||
wrapLabel(false),
|
||||
type(BTN_REG),
|
||||
textClr(sf::Color::Black),
|
||||
fromList("none") {}
|
||||
fromList("none") {
|
||||
defaultTextSize();
|
||||
}
|
||||
|
||||
cButton::cButton(cDialog& parent) :
|
||||
cControl(CTRL_BTN,parent),
|
||||
wrapLabel(false),
|
||||
type(BTN_REG),
|
||||
textClr(parent.getDefTextClr()),
|
||||
fromList("none") {}
|
||||
fromList("none") {
|
||||
defaultTextSize();
|
||||
}
|
||||
|
||||
/* This constructor is only called for LEDs. */
|
||||
cButton::cButton(cDialog& parent,eControlType t) :
|
||||
cControl(t,parent),
|
||||
fromList("none"),
|
||||
wrapLabel(false) {/* This constructor is only called for LEDs. */}
|
||||
wrapLabel(false) {
|
||||
defaultTextSize();
|
||||
}
|
||||
|
||||
void cButton::defaultTextSize() {
|
||||
if(type == BTN_TINY) textSize = 9;
|
||||
else if(type == BTN_PUSH) textSize = 10;
|
||||
else textSize = 12;
|
||||
}
|
||||
|
||||
bool cButton::isClickable() const {
|
||||
return true;
|
||||
@@ -55,9 +68,7 @@ void cButton::draw(){
|
||||
|
||||
if(visible){
|
||||
TextStyle style;
|
||||
if(type == BTN_TINY) style.pointSize = 9;
|
||||
else if(type == BTN_PUSH) style.pointSize = 10;
|
||||
else style.pointSize = 12;
|
||||
style.pointSize = textSize;
|
||||
from_rect = btnRects[type][depressed];
|
||||
to_rect = frame;
|
||||
if(type == BTN_TINY) {
|
||||
|
@@ -65,6 +65,7 @@ public:
|
||||
}
|
||||
cButton& operator=(cButton& other) = delete;
|
||||
cButton(cButton& other) = delete;
|
||||
void setTextSize(short size) { textSize = size; }
|
||||
protected:
|
||||
/// The type of button.
|
||||
eBtnType type;
|
||||
@@ -74,9 +75,12 @@ protected:
|
||||
cButton(cDialog& parent,eControlType t);
|
||||
private:
|
||||
bool manageFormat(eFormat prop, bool set, boost::any* val) override;
|
||||
void defaultTextSize();
|
||||
std::string fromList;
|
||||
static rectangle btnRects[13][2];
|
||||
protected:
|
||||
/// Size of the button's descriptive text
|
||||
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
|
||||
|
@@ -28,8 +28,8 @@ void cLed::init(){
|
||||
cLed::cLed(cDialog& parent) :
|
||||
cButton(parent,CTRL_LED),
|
||||
state(led_off),
|
||||
textFont(FONT_BOLD),
|
||||
textSize(10) {
|
||||
textFont(FONT_BOLD) {
|
||||
textSize = 10;
|
||||
type = BTN_LED;
|
||||
using namespace std::placeholders;
|
||||
attachEventHandler<EVT_CLICK>(std::bind(&cLed::defaultClickHandler, this, _1, _2, _3));
|
||||
|
@@ -60,7 +60,6 @@ private:
|
||||
bool manageFormat(eFormat prop, bool set, boost::any* val) override;
|
||||
eLedState state;
|
||||
eFont textFont;
|
||||
short textSize;
|
||||
static rectangle ledRects[3][2];
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user