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_PANEL_HPP_INCLUDED
00017 #define GUI_WIDGETS_TOGGLE_PANEL_HPP_INCLUDED
00018
00019 #include "gui/widgets/panel.hpp"
00020 #include "gui/widgets/selectable.hpp"
00021
00022 namespace gui2 {
00023
00024
00025
00026
00027
00028
00029
00030
00031 class ttoggle_panel : public tpanel, public tselectable_
00032 {
00033 public:
00034 ttoggle_panel();
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 void set_child_members(const std::map<std::string /* widget id */, string_map>& data);
00045
00046
00047
00048
00049 twidget* find_at(const tpoint& coordinate, const bool must_be_active)
00050 {
00051
00052
00053
00054
00055
00056
00057
00058
00059 twidget* result = tcontainer_::find_at(coordinate, must_be_active);
00060 return result ? result : tcontrol::find_at(coordinate, must_be_active);
00061 }
00062
00063
00064 const twidget* find_at(
00065 const tpoint& coordinate, const bool must_be_active) const
00066 {
00067 const twidget* result =
00068 tcontainer_::find_at(coordinate, must_be_active);
00069 return result ? result : tcontrol::find_at(coordinate, must_be_active);
00070 }
00071
00072
00073 void set_active(const bool active);
00074
00075
00076 bool get_active() const
00077 { return state_ != DISABLED && state_ != DISABLED_SELECTED; }
00078
00079
00080 unsigned get_state() const { return state_; }
00081
00082
00083
00084
00085
00086
00087
00088
00089 SDL_Rect get_client_rect() const;
00090
00091
00092
00093
00094
00095
00096
00097
00098 tpoint border_space() const;
00099
00100
00101 bool get_value() const { return state_ >= ENABLED_SELECTED; }
00102
00103
00104 void set_value(const bool selected);
00105
00106
00107
00108 void set_retval(const int retval);
00109
00110
00111 void set_callback_state_change(boost::function<void (twidget*)> callback)
00112 { callback_state_change_ = callback; }
00113
00114 void set_callback_mouse_left_double_click(boost::function<void (twidget*)> callback)
00115 { callback_mouse_left_double_click_ = callback; }
00116 private:
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126 enum tstate {
00127 ENABLED, DISABLED, FOCUSSED,
00128 ENABLED_SELECTED, DISABLED_SELECTED, FOCUSSED_SELECTED,
00129 COUNT};
00130
00131 void set_state(const tstate state);
00132
00133
00134
00135
00136
00137
00138
00139 tstate state_;
00140
00141
00142
00143
00144
00145
00146
00147 int retval_;
00148
00149
00150 boost::function<void (twidget*)> callback_state_change_;
00151
00152
00153 boost::function<void (twidget*)> callback_mouse_left_double_click_;
00154
00155
00156 void impl_draw_background(surface& frame_buffer)
00157 {
00158
00159
00160 tcontrol::impl_draw_background(frame_buffer);
00161 }
00162
00163
00164 void impl_draw_background(surface& frame_buffer, int x_offset, int y_offset)
00165 {
00166
00167
00168 tcontrol::impl_draw_background(frame_buffer, x_offset, y_offset);
00169 }
00170
00171
00172 void impl_draw_foreground(surface& frame_buffer)
00173 {
00174
00175
00176 tcontrol::impl_draw_foreground(frame_buffer);
00177 }
00178
00179
00180 void impl_draw_foreground(surface& frame_buffer, int x_offset, int y_offset)
00181 {
00182
00183
00184 tcontrol::impl_draw_foreground(frame_buffer, x_offset, y_offset);
00185 }
00186
00187
00188
00189 const std::string& get_control_type() const;
00190
00191
00192
00193 void signal_handler_mouse_enter(const event::tevent event, bool& handled);
00194
00195 void signal_handler_mouse_leave(const event::tevent event, bool& handled);
00196
00197 void signal_handler_pre_left_button_click(const event::tevent event);
00198
00199 void signal_handler_left_button_click(
00200 const event::tevent event, bool& handled);
00201
00202 void signal_handler_left_button_double_click(
00203 const event::tevent event, bool& handled);
00204 };
00205
00206 }
00207
00208 #endif
00209
00210
00211