Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
updownbutton.hpp
1 //////////////////////////////
2 //
3 // File: lxs/windowing/updownbutton.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_UPDOWN_BUTTON_WINDOW__
15 #define __LXS_UPDOWN_BUTTON_WINDOW__
16 #include "lxs/windowing/button.hpp"
17 namespace LxS
18 {
19  class Font;
20  namespace Windowing
21  {
22  //! for parameters that can be increased or decreased
23  class UpDownButton: public Button
24  {
25  protected:
26  //! description of a button (concatenated to numeric value)
27  std::string base_text;
28  //! a value to be set (increased/decreased after clicking)
30  //! stringify numeric value and add it to a base text
31  virtual void AssembleActualText();
32  public:
33  //! constructor with preset base text and background texture
34  UpDownButton(const std::string & _text, const std::string & _background)
35  :Button(_text,_background),numeric_value(0)
36  {}
37  //! default constructor
39  :Button("",GET_CONFIG_STRING(UI_WIDGETS_ARROWS_BG)),numeric_value(0)
40  {}
41  //! set starting numeric value (it will be increased and decreased)
43  //! set base text (numeric value will be automatically added to it)
44  void SetBaseText(const std::string & t)
45  {
46  base_text.assign(t);
48  }
49  void Clicked(float x, float y);
50  //! increase associated parameter
51  virtual void ValueUp();
52  //! decrease associated parameter
53  virtual void ValueDown();
54  };
55  }
56 }
57 #endif