Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
button.hpp
1 //////////////////////////////
2 //
3 // File: lxs/windowing/button.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Oct 24 2012
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_BUTTON_WINDOW__
15 #define __LXS_BUTTON_WINDOW__
16 #include "helper/opengl.h"
17 #include "helper/tr1.h"
18 #include <string>
19 #include "lxs/windowing/containerwindow.hpp"
20 #include "lxs/windowing/label.hpp"
21 #include "lxs/system/configuration.hpp"
22 namespace LxS
23 {
24  namespace CoreGraphics
25  {
26  class Font;
27  }
28  namespace Windowing
29  {
30  class Button;
31  //! type of smart function pointer
32  typedef std::tr1::function<void (Button*)> ButtonHandler;
33  class Rectangle2D;
34  //! button - something happens when it is pressed
35  class Button: public Label
36  {
37  protected:
38  //! functor to be called upon clicking
40  //! is button deactivated
41  bool active;
42  public:
43  //! constructor
44  Button(const std::string & _text, const std::string & _background);
45  Button();
46  ~Button();
47  //! cancel effects of Deactiva
48  void Activate();
49  //! when deactivated, button is grayed and does not react to clicking
50  void Deactivate();
51  void Clicked(float x, float y);
52  //! set function that will be called after clicking a button
54  {handler=h;}
55  };
56  }
57 }
58 #endif