diff options
Diffstat (limited to 'plugingui')
| -rw-r--r-- | plugingui/checkbox.cc | 24 | ||||
| -rw-r--r-- | plugingui/checkbox.h | 4 | 
2 files changed, 22 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() diff --git a/plugingui/checkbox.h b/plugingui/checkbox.h index fd25081..1b8aa23 100644 --- a/plugingui/checkbox.h +++ b/plugingui/checkbox.h @@ -35,6 +35,8 @@ class CheckBox : public Widget {  public:    CheckBox(Widget *parent); +  void setText(std::string text); +    bool isFocusable() { return true; }    bool checked(); @@ -53,6 +55,8 @@ private:    void (*handler)(void *);    void *ptr; + +  std::string _text;  };  }; | 
