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_TOGGLE_BUTTON_HPP_INCLUDED
00017 #define GUI_WIDGETS_TOGGLE_BUTTON_HPP_INCLUDED
00018
00019 #include "gui/widgets/control.hpp"
00020 #include "gui/widgets/selectable.hpp"
00021
00022 namespace gui2 {
00023
00024
00025
00026
00027
00028
00029
00030 class ttoggle_button : public tcontrol, public tselectable_
00031 {
00032 public:
00033 ttoggle_button();
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 void set_members(const string_map& data);
00044
00045
00046 void set_active(const bool active);
00047
00048
00049 bool get_active() const
00050 { return state_ != DISABLED && state_ != DISABLED_SELECTED; }
00051
00052
00053 unsigned get_state() const { return state_; }
00054
00055
00056 void update_canvas();
00057
00058
00059 bool get_value() const { return state_ >= ENABLED_SELECTED; }
00060
00061
00062 void set_value(const bool selected);
00063
00064
00065
00066 void set_retval(const int retval);
00067
00068
00069 void set_callback_state_change(boost::function<void (twidget*)> callback)
00070 { callback_state_change_ = callback; }
00071
00072 void set_icon_name(const std::string& icon_name)
00073 { icon_name_ = icon_name; update_canvas(); }
00074 const std::string& icon_name() const { return icon_name_; }
00075
00076 private:
00077
00078
00079
00080
00081
00082
00083
00084
00085 enum tstate {
00086 ENABLED, DISABLED, FOCUSSED,
00087 ENABLED_SELECTED, DISABLED_SELECTED, FOCUSSED_SELECTED,
00088 COUNT};
00089
00090 void set_state(const tstate state);
00091
00092
00093
00094
00095
00096
00097
00098 tstate state_;
00099
00100
00101
00102
00103
00104
00105
00106 int retval_;
00107
00108
00109 boost::function<void (twidget*)> callback_state_change_;
00110
00111
00112
00113
00114
00115 std::string icon_name_;
00116
00117
00118 const std::string& get_control_type() const;
00119
00120
00121
00122 void signal_handler_mouse_enter(const event::tevent event, bool& handled);
00123
00124 void signal_handler_mouse_leave(const event::tevent event, bool& handled);
00125
00126 void signal_handler_left_button_click(
00127 const event::tevent event, bool& handled);
00128
00129 void signal_handler_left_button_double_click(
00130 const event::tevent event, bool& handled);
00131 };
00132
00133 }
00134
00135 #endif
00136