Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

# IEventReceiver.h

Go to the documentation of this file.

    00001 // Copyright (C) 2002-2010 Nikolaus Gebhardt
    00002 // This file is part of the "Irrlicht Engine".
    00003 // For conditions of distribution and use, see copyright notice in irrlicht.h
    00004
    00005 #ifndef __I_EVENT_RECEIVER_H_INCLUDED__
    00006 #define __I_EVENT_RECEIVER_H_INCLUDED__
    00007
    00008 #include "ILogger.h"
    00009 #include "Keycodes.h"
    00010 #include "irrString.h"
    00011
    00012 namespace irr
    00013 {
    00015         enum EEVENT_TYPE
    00016         {
    00018
    00022                 EET_GUI_EVENT = 0,
    00023
    00025
    00030                 EET_MOUSE_INPUT_EVENT,
    00031
    00033
    00035                 EET_KEY_INPUT_EVENT,
    00036
    00038
    00045                 EET_JOYSTICK_INPUT_EVENT,
    00046
    00048
    00050                 EET_LOG_TEXT_EVENT,
    00051
    00053
    00065                 EET_USER_EVENT,
    00066
    00069                 EGUIET_FORCE_32_BIT = 0x7fffffff
    00070
    00071         };
    00072
    00074         enum EMOUSE_INPUT_EVENT
    00075         {
    00077                 EMIE_LMOUSE_PRESSED_DOWN = 0,
    00078
    00080                 EMIE_RMOUSE_PRESSED_DOWN,
    00081
    00083                 EMIE_MMOUSE_PRESSED_DOWN,
    00084
    00086                 EMIE_LMOUSE_LEFT_UP,
    00087
    00089                 EMIE_RMOUSE_LEFT_UP,
    00090
    00092                 EMIE_MMOUSE_LEFT_UP,
    00093
    00095                 EMIE_MOUSE_MOVED,
    00096
    00099                 EMIE_MOUSE_WHEEL,
    00100
    00103                 EMIE_LMOUSE_DOUBLE_CLICK,
    00104
    00107                 EMIE_RMOUSE_DOUBLE_CLICK,
    00108
    00111                 EMIE_MMOUSE_DOUBLE_CLICK,
    00112
    00115                 EMIE_LMOUSE_TRIPLE_CLICK,
    00116
    00119                 EMIE_RMOUSE_TRIPLE_CLICK,
    00120
    00123                 EMIE_MMOUSE_TRIPLE_CLICK,
    00124
    00126                 EMIE_COUNT
    00127         };
    00128
    00130         enum E_MOUSE_BUTTON_STATE_MASK
    00131         {
    00132                 EMBSM_LEFT    = 0x01,
    00133                 EMBSM_RIGHT   = 0x02,
    00134                 EMBSM_MIDDLE  = 0x04,
    00135
    00137                 EMBSM_EXTRA1  = 0x08,
    00138
    00140                 EMBSM_EXTRA2  = 0x10,
    00141
    00142                 EMBSM_FORCE_32_BIT = 0x7fffffff
    00143         };
    00144
    00145         namespace gui
    00146         {
    00147
    00148                 class IGUIElement;
    00149
    00151                 enum EGUI_EVENT_TYPE
    00152                 {
    00154
    00156                         EGET_ELEMENT_FOCUS_LOST = 0,
    00157
    00159
    00160                         EGET_ELEMENT_FOCUSED,
    00161
    00163
    00164                         EGET_ELEMENT_HOVERED,
    00165
    00167
    00168                         EGET_ELEMENT_LEFT,
    00169
    00171
    00173                         EGET_ELEMENT_CLOSED,
    00174
    00176                         EGET_BUTTON_CLICKED,
    00177
    00179                         EGET_SCROLL_BAR_CHANGED,
    00180
    00182                         EGET_CHECKBOX_CHANGED,
    00183
    00185
    00186                         EGET_LISTBOX_CHANGED,
    00187
    00189
    00190                         EGET_LISTBOX_SELECTED_AGAIN,
    00191
    00193                         EGET_FILE_SELECTED,
    00194
    00196                         EGET_DIRECTORY_SELECTED,
    00197
    00199                         EGET_FILE_CHOOSE_DIALOG_CANCELLED,
    00200
    00202                         EGET_MESSAGEBOX_YES,
    00203
    00205                         EGET_MESSAGEBOX_NO,
    00206
    00208                         EGET_MESSAGEBOX_OK,
    00209
    00211                         EGET_MESSAGEBOX_CANCEL,
    00212
    00214                         EGET_EDITBOX_ENTER,
    00215
    00217                         EGET_EDITBOX_CHANGED,
    00218
    00220                         EGET_EDITBOX_MARKING_CHANGED,
    00221
    00223                         EGET_TAB_CHANGED,
    00224
    00226                         EGET_MENU_ITEM_SELECTED,
    00227
    00229                         EGET_COMBO_BOX_CHANGED,
    00230
    00232                         EGET_SPINBOX_CHANGED,
    00233
    00235                         EGET_TABLE_CHANGED,
    00236                         EGET_TABLE_HEADER_CHANGED,
    00237                         EGET_TABLE_SELECTED_AGAIN,
    00238
    00240                         EGET_TREEVIEW_NODE_DESELECT,
    00241
    00243                         EGET_TREEVIEW_NODE_SELECT,
    00244
    00246                         EGET_TREEVIEW_NODE_EXPAND,
    00247
    00249                         EGET_TREEVIEW_NODE_COLLAPS,
    00250
    00252                         EGET_TREEVIEW_NODE_COLLAPSE = EGET_TREEVIEW_NODE_COLLAPS,
    00253
    00255                         EGET_COUNT
    00256                 };
    00257         } // end namespace gui
    00258
    00259
    00261 struct SEvent
    00262 {
    00264         struct SGUIEvent
    00265         {
    00267                 gui::IGUIElement* Caller;
    00268
    00270                 gui::IGUIElement* Element;
    00271
    00273                 gui::EGUI_EVENT_TYPE EventType;
    00274
    00275         };
    00276
    00278         struct SMouseInput
    00279         {
    00281                 s32 X;
    00282
    00284                 s32 Y;
    00285
    00287
    00288                 f32 Wheel;
    00289
    00291                 bool Shift:1;
    00292
    00294                 bool Control:1;
    00295
    00299                 u32 ButtonStates;
    00300
    00302                 bool isLeftPressed() const { return 0 != ( ButtonStates & EMBSM_LEFT ); }
    00303
    00305                 bool isRightPressed() const { return 0 != ( ButtonStates & EMBSM_RIGHT ); }
    00306
    00308                 bool isMiddlePressed() const { return 0 != ( ButtonStates & EMBSM_MIDDLE ); }
    00309
    00311                 EMOUSE_INPUT_EVENT Event;
    00312         };
    00313
    00315         struct SKeyInput
    00316         {
    00318                 wchar_t Char;
    00319
    00321                 EKEY_CODE Key;
    00322
    00324                 bool PressedDown:1;
    00325
    00327                 bool Shift:1;
    00328
    00330                 bool Control:1;
    00331         };
    00332
    00334
    00341         struct SJoystickEvent
    00342         {
    00343                 enum
    00344                 {
    00345                         NUMBER_OF_BUTTONS = 32,
    00346
    00347                         AXIS_X = 0, // e.g. analog stick 1 left to right
    00348                         AXIS_Y,         // e.g. analog stick 1 top to bottom
    00349                         AXIS_Z,         // e.g. throttle, or analog 2 stick 2 left to right
    00350                         AXIS_R,         // e.g. rudder, or analog 2 stick 2 top to bottom
    00351                         AXIS_U,
    00352                         AXIS_V,
    00353                         NUMBER_OF_AXES
    00354                 };
    00355
    00358                 u32 ButtonStates;
    00359
    00368                 s16 Axis[NUMBER_OF_AXES];
    00369
    00375                 u16 POV;
    00376
    00378
    00380                 u8 Joystick;
    00381
    00383                 bool IsButtonPressed(u32 button) const
    00384                 {
    00385                         if(button >= (u32)NUMBER_OF_BUTTONS)
    00386                                 return false;
    00387
    00388                         return (ButtonStates & (1 << button)) ? true : false;
    00389                 }
    00390         };
    00391
    00392
    00394         struct SLogEvent
    00395         {
    00397                 const c8* Text;
    00398
    00400                 ELOG_LEVEL Level;
    00401         };
    00402
    00404         struct SUserEvent
    00405         {
    00407                 s32 UserData1;
    00408
    00410                 s32 UserData2;
    00411         };
    00412
    00413         EEVENT_TYPE EventType;
    00414         union
    00415         {
    00416                 struct SGUIEvent GUIEvent;
    00417                 struct SMouseInput MouseInput;
    00418                 struct SKeyInput KeyInput;
    00419                 struct SJoystickEvent JoystickEvent;
    00420                 struct SLogEvent LogEvent;
    00421                 struct SUserEvent UserEvent;
    00422         };
    00423
    00424 };
    00425
    00427
    00432 class IEventReceiver
    00433 {
    00434 public:
    00435
    00437         virtual ~IEventReceiver() {}
    00438
    00440
    00445         virtual bool OnEvent(const SEvent& event) = 0;
    00446 };
    00447
    00448
    00450 struct SJoystickInfo
    00451 {
    00453
    00456         u8                              Joystick;
    00457
    00459         core::stringc   Name;
    00460
    00462         u32                             Buttons;
    00463
    00465
    00467         u32                             Axes;
    00468
    00470
    00472         enum
    00473         {
    00475                 POV_HAT_PRESENT,
    00476
    00478                 POV_HAT_ABSENT,
    00479
    00481                 POV_HAT_UNKNOWN
    00482         } PovHat;
    00483 }; // struct SJoystickInfo
    00484
    00485
    00486 } // end namespace irr
    00487
    00488 #endif
    00489

| The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Sun Oct 24 12:41:56 2010 by Doxygen (1.6.2)