Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
togglebutton.hpp
1 //////////////////////////////
2 //
3 // File: lxs/windowing/togglebutton.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Feb 12 2013
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef __LXS_TOGGLE_BUTTON_WINDOW__
15 #define __LXS_TOGGLE_BUTTON_WINDOW__
16 #include "lxs/windowing/button.hpp"
17 namespace LxS
18 {
19  class Font;
20  namespace Windowing
21  {
22  //! button allowing to disable/enable some parameters
23  class ToggleButton: public Button
24  {
25  protected:
26  //! name of button (will be displayed)
27  std::string base_text;
28  //! a boolean value to toggle
30  //! assemble text upon changing either base_text or boolean_value
31  virtual void AssembleActualText();
32  public:
33  //! constructor with preset base text and background texture
34  ToggleButton(const std::string & _text, const std::string & _background)
35  :Button(_text,_background),boolean_value(false)
36  {}
37  //! default constructor
39  :Button("",GET_CONFIG_STRING(UI_WIDGETS_ARROWS_BG)),boolean_value(false)
40  {}
41  //! set boolean value
43  //! get boolean value
44  bool GetBooleanValue() { return boolean_value;}
45  //! assemble base text. button will show "base [yes]" or "base [no]" or some variation of it
46  void SetBaseText(const std::string & t)
47  {
48  base_text.assign(t);
50  }
51  //! click handler
52  void Clicked(float x, float y);
53  //! reaction function (overload it to get your desired behavior)
54  virtual void OnToggle() {}
55  };
56  }
57 }
58 #endif