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