Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef GUI_WIDGETS_BUTTON_HPP_INCLUDED
00017 #define GUI_WIDGETS_BUTTON_HPP_INCLUDED
00018
00019 #include "gui/widgets/control.hpp"
00020 #include "gui/widgets/clickable.hpp"
00021
00022 namespace gui2 {
00023
00024
00025
00026
00027 class tbutton
00028 : public tcontrol
00029 , public tclickable_
00030 {
00031 public:
00032 tbutton();
00033
00034
00035
00036
00037 void set_active(const bool active)
00038 { if(get_active() != active) set_state(active ? ENABLED : DISABLED); };
00039
00040
00041 bool get_active() const { return state_ != DISABLED; }
00042
00043
00044 unsigned get_state() const { return state_; }
00045
00046
00047 void connect_click_handler(const event::tsignal_function& signal)
00048 {
00049 connect_signal_mouse_left_click(*this, signal);
00050 }
00051
00052
00053 void disconnect_click_handler(const event::tsignal_function& signal)
00054 {
00055 disconnect_signal_mouse_left_click(*this, signal);
00056 }
00057
00058
00059
00060 void set_retval(const int retval) { retval_ = retval; }
00061
00062 private:
00063
00064
00065
00066
00067
00068 enum tstate { ENABLED, DISABLED, PRESSED, FOCUSSED, COUNT };
00069
00070 void set_state(const tstate state);
00071
00072
00073
00074
00075
00076
00077 tstate state_;
00078
00079
00080
00081
00082
00083
00084
00085 int retval_;
00086
00087
00088 const std::string& get_control_type() const;
00089
00090
00091
00092 void signal_handler_mouse_enter(const event::tevent event, bool& handled);
00093
00094 void signal_handler_mouse_leave(const event::tevent event, bool& handled);
00095
00096 void signal_handler_left_button_down(
00097 const event::tevent event, bool& handled);
00098
00099 void signal_handler_left_button_up(
00100 const event::tevent event, bool& handled);
00101
00102 void signal_handler_left_button_click(
00103 const event::tevent event, bool& handled);
00104 };
00105
00106
00107 }
00108
00109 #endif
00110