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_AUXILIARY_EVENT_DISTRIBUTOR_HPP_INCLUDED
00017 #define GUI_WIDGETS_AUXILIARY_EVENT_DISTRIBUTOR_HPP_INCLUDED
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "gui/auxiliary/event/dispatcher.hpp"
00043 #include "gui/widgets/event_executor.hpp"
00044 #include "gui/widgets/helper.hpp"
00045
00046 namespace gui2{
00047
00048 class twidget;
00049
00050 namespace event {
00051
00052
00053
00054 class tmouse_motion
00055 {
00056 public:
00057
00058 tmouse_motion(twidget& owner, const tdispatcher::tposition queue_position);
00059
00060 ~tmouse_motion();
00061
00062
00063
00064
00065
00066
00067
00068
00069 void capture_mouse(
00070 const bool capture = true);
00071 protected:
00072
00073
00074 twidget* mouse_focus_;
00075
00076
00077 bool mouse_captured_;
00078
00079
00080 twidget& owner_;
00081
00082
00083 unsigned long hover_timer_;
00084
00085
00086 twidget* hover_widget_;
00087
00088
00089 tpoint hover_position_;
00090
00091
00092
00093
00094
00095
00096
00097
00098 bool hover_shown_;
00099
00100
00101
00102
00103
00104
00105
00106 void start_hover_timer(twidget* widget, const tpoint& coordinate);
00107
00108
00109 void stop_hover_timer();
00110
00111
00112
00113
00114
00115
00116 void mouse_enter(twidget* mouse_over);
00117
00118
00119 void mouse_leave();
00120
00121 private:
00122
00123
00124
00125
00126
00127
00128
00129 void mouse_motion(twidget* mouse_over, const tpoint& coordinate);
00130
00131
00132 void show_tooltip();
00133
00134 bool signal_handler_sdl_mouse_motion_entered_;
00135 void signal_handler_sdl_mouse_motion(
00136 const event::tevent event
00137 , bool& handled
00138 , const tpoint& coordinate);
00139
00140 void signal_handler_sdl_wheel(
00141 const event::tevent event
00142 , bool& handled
00143 , const tpoint& coordinate);
00144
00145 void signal_handler_show_helptip(
00146 const event::tevent event
00147 , bool& handled
00148 , const tpoint& coordinate);
00149 };
00150
00151
00152
00153 template<
00154 tevent sdl_button_down
00155 , tevent sdl_button_up
00156 , tevent button_down
00157 , tevent button_up
00158 , tevent button_click
00159 , tevent button_double_click
00160 >
00161 class tmouse_button
00162 : public virtual tmouse_motion
00163 {
00164 public:
00165 tmouse_button(
00166 const std::string& name_
00167 , twidget& owner
00168 , const tdispatcher::tposition queue_position
00169 );
00170
00171
00172
00173
00174
00175
00176
00177 void initialize_state(const bool is_down);
00178
00179 protected:
00180
00181 Uint32 last_click_stamp_;
00182
00183
00184 twidget* last_clicked_widget_;
00185
00186
00187
00188
00189
00190
00191 twidget* focus_;
00192
00193 private:
00194
00195 const std::string name_;
00196
00197
00198 bool is_down_;
00199
00200 bool signal_handler_sdl_button_down_entered_;
00201 void signal_handler_sdl_button_down(
00202 const event::tevent event
00203 , bool& handled
00204 , const tpoint& coordinate);
00205
00206 bool signal_handler_sdl_button_up_entered_;
00207 void signal_handler_sdl_button_up(
00208 const event::tevent event
00209 , bool& handled
00210 , const tpoint& coordinate);
00211
00212
00213 void mouse_button_click(twidget* widget);
00214 };
00215
00216
00217
00218 typedef tmouse_button<
00219 SDL_LEFT_BUTTON_DOWN
00220 , SDL_LEFT_BUTTON_UP
00221 , LEFT_BUTTON_DOWN
00222 , LEFT_BUTTON_UP
00223 , LEFT_BUTTON_CLICK
00224 , LEFT_BUTTON_DOUBLE_CLICK
00225 > tmouse_button_left;
00226
00227 typedef tmouse_button<
00228 SDL_MIDDLE_BUTTON_DOWN
00229 , SDL_MIDDLE_BUTTON_UP
00230 , MIDDLE_BUTTON_DOWN
00231 , MIDDLE_BUTTON_UP
00232 , MIDDLE_BUTTON_CLICK
00233 , MIDDLE_BUTTON_DOUBLE_CLICK
00234 > tmouse_button_middle;
00235
00236 typedef tmouse_button<
00237 SDL_RIGHT_BUTTON_DOWN
00238 , SDL_RIGHT_BUTTON_UP
00239 , RIGHT_BUTTON_DOWN
00240 , RIGHT_BUTTON_UP
00241 , RIGHT_BUTTON_CLICK
00242 , RIGHT_BUTTON_DOUBLE_CLICK
00243 > tmouse_button_right;
00244
00245
00246
00247 class tdistributor
00248 : public tmouse_button_left
00249 , public tmouse_button_middle
00250 , public tmouse_button_right
00251 {
00252 public:
00253 tdistributor(twidget& owner
00254 , const tdispatcher::tposition queue_position);
00255
00256 ~tdistributor();
00257
00258
00259
00260
00261
00262
00263 void initialize_state();
00264
00265
00266
00267
00268
00269
00270
00271 void keyboard_capture(twidget* widget);
00272
00273
00274
00275
00276
00277
00278
00279
00280 void keyboard_add_to_chain(twidget* widget);
00281
00282
00283
00284
00285
00286
00287 void keyboard_remove_from_chain(twidget* widget);
00288
00289 private:
00290
00291 bool hover_pending_;
00292 unsigned hover_id_;
00293 SDL_Rect hover_box_;
00294
00295
00296
00297
00298 bool had_hover_;
00299
00300
00301
00302
00303 twidget* tooltip_;
00304
00305
00306 twidget* help_popup_;
00307
00308
00309 twidget* keyboard_focus_;
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321 std::vector<twidget*> keyboard_focus_chain_;
00322
00323
00324
00325
00326
00327
00328 void signal_handler_sdl_key_down(const SDLKey key
00329 , const SDLMod modifier
00330 , const Uint16 unicode);
00331
00332 void signal_handler_notify_removal(tdispatcher& widget, const tevent event);
00333 };
00334
00335 }
00336
00337 }
00338
00339 #endif