libwtk-sdl2  0.0.1
button.hpp
1 #ifndef LIBWTK_SDL2_BUTTON_HPP
2 #define LIBWTK_SDL2_BUTTON_HPP
3 
4 #include <functional>
5 
6 #include "selectable.hpp"
7 
8 struct button : selectable
9 {
10  button(std::string text, std::function<void()> callback);
11 
12  void on_draw(draw_context & dc, selection_context const & sc) const override;
13  void on_mouse_up_event(mouse_up_event const & e) override;
14  void on_mouse_down_event(mouse_down_event const & e) override;
15  void on_key_event(key_event const & e) override;
16  void on_activate() override;
17  size_hint get_size_hint(int width, int height) const override;
18 
19  ~button() override;
20 
26  void set_label(std::string text);
27 
30  private:
31 
32  bool _pressed;
33  std::string _text;
34  std::function<void()> _callback;
35 };
36 
37 
38 #endif
39 
size_hint get_size_hint(int width, int height) const override
Definition: mouse_event.hpp:19
Definition: mouse_event.hpp:8
void on_draw(draw_context &dc, selection_context const &sc) const override
Definition: selectable.hpp:6
Definition: draw_context.hpp:126
Definition: button.hpp:8
void on_activate() override
Definition: key_event.hpp:4
Definition: selection_context.hpp:18
Definition: widget.hpp:35