summaryrefslogtreecommitdiff
path: root/plugingui/checkbox.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-03-09 13:52:02 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2013-03-09 13:52:02 +0100
commit9d3ca6da69096d5904cbe16d0f8778e6c14537e8 (patch)
tree59d7604cec1e90773d6aab338e21a224118ba07a /plugingui/checkbox.cc
parentd556005df149558e2614b7019ca4b180f9c44fb8 (diff)
Add label to checkbox widget.
Diffstat (limited to 'plugingui/checkbox.cc')
-rw-r--r--plugingui/checkbox.cc24
1 files changed, 18 insertions, 6 deletions
diff --git a/plugingui/checkbox.cc b/plugingui/checkbox.cc
index e51f213..496de21 100644
--- a/plugingui/checkbox.cc
+++ b/plugingui/checkbox.cc
@@ -46,6 +46,12 @@ void GUI::CheckBox::buttonEvent(ButtonEvent *e)
}
}
+void GUI::CheckBox::setText(std::string text)
+{
+ _text = text;
+ repaintEvent(NULL);
+}
+
void GUI::CheckBox::registerClickHandler(void (*handler)(void *), void *ptr)
{
this->handler = handler;
@@ -60,21 +66,27 @@ void GUI::CheckBox::repaintEvent(GUI::RepaintEvent *e)
float alpha = 0.8;
+ int box = width()<height()?width():height();
+
p.setColour(Colour(0.5, alpha));
- p.drawFilledRectangle(0,0,width()-1,height()-1);
+ p.drawFilledRectangle(0,0,box-1,box-1);
p.setColour(Colour(0.1, alpha));
- p.drawRectangle(0,0,width()-1,height()-1);
+ p.drawRectangle(0,0,box-1,box-1);
if(state) {
p.setColour(Colour(0.8, alpha));
- p.drawLine(0,0,width()-1,height()-1);
- p.drawLine(0,width()-1,height()-1,0);
+ p.drawLine(0,0,box-1,box-1);
+ p.drawLine(0,box-1,box-1,0);
}
p.setColour(Colour(0.3, alpha));
- p.drawPoint(0,height()-1);
- p.drawPoint(width()-1,0);
+ p.drawPoint(0,box-1);
+ p.drawPoint(box-1,0);
+
+ p.setColour(Colour(1));
+ Font font;
+ p.drawText(box + 8, height() / 2 + 5, font, _text);
}
bool GUI::CheckBox::checked()