Btk
button.hpp
1 #if !defined(_BTK_BUTTON_HPP_)
2 #define _BTK_BUTTON_HPP_
3 #include "widget.hpp"
4 #include "pixels.hpp"
5 #include "themes.hpp"
6 #include "font.hpp"
7 #include "defs.hpp"
8 namespace Btk{
9  class MouseEvent;
14  class BTKAPI AbstructButton:public Widget{
15  public:
16  //Process event
17  bool handle(Event &);
18  protected:
19  virtual void onclick(const MouseEvent &) = 0;
20  virtual void onenter();
21  virtual void onleave();
22  bool is_entered;//< Is mouse on the button?
23  bool is_pressed;//< Is mouse pressed the button?
24  Theme *theme;//< current theme
25  };
30  class BTKAPI Button:public AbstructButton{
31  public:
32  Button(Container&);
33  Button(Container&,std::string_view text);
34  Button(Container&,int x,int y,int w,int h);
35  ~Button();
36  void draw(Renderer &);
37  template<class ...T>
38  void on_click(T &&...args){
39  clicked.connect(std::forward<T>(args)...);
40  };
41  Signal<void()> &sig_click(){
42  return clicked;
43  };
44  void set_text(std::string_view text);
45  protected:
46  void onclick(const MouseEvent &);
47  void onleave();
48 
49  Signal<void()> clicked;
50 
51  //Button text
52  std::string btext;
53  PixBuf textbuf;
54  Texture texture;
55  Font textfont;
56  };
57 };
58 
59 
60 #endif // _BTK_BUTTON_HPP_
Definition: pixels.hpp:191
Basic button.
Definition: button.hpp:14
Definition: widget.hpp:219
This header include many useful containers.
Definition: async.hpp:7
Definition: themes.hpp:9
A event about mouse click.
Definition: event.hpp:106
Font Class.
Definition: font.hpp:26
Definition: pixels.hpp:32
A base event of all events.
Definition: event.hpp:17
A simple pushbutton.
Definition: button.hpp:30
A Container of Widget.
Definition: widget.hpp:108