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-2009 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 "position2d.h"
    00010 #include "Keycodes.h"
    00011 #include "irrString.h"
    00012
    00013 namespace irr
    00014 {
    00016         enum EEVENT_TYPE
    00017         {
    00019
    00023                 EET_GUI_EVENT = 0,
    00024
    00026
    00031                 EET_MOUSE_INPUT_EVENT,
    00032
    00034
    00036                 EET_KEY_INPUT_EVENT,
    00037
    00039
    00046                 EET_JOYSTICK_INPUT_EVENT,
    00047
    00049
    00051                 EET_LOG_TEXT_EVENT,
    00052
    00054
    00066                 EET_USER_EVENT,
    00067
    00070                 EGUIET_FORCE_32_BIT = 0x7fffffff
    00071
    00072         };
    00073
    00075         enum EMOUSE_INPUT_EVENT
    00076         {
    00078                 EMIE_LMOUSE_PRESSED_DOWN = 0,
    00079
    00081                 EMIE_RMOUSE_PRESSED_DOWN,
    00082
    00084                 EMIE_MMOUSE_PRESSED_DOWN,
    00085
    00087                 EMIE_LMOUSE_LEFT_UP,
    00088
    00090                 EMIE_RMOUSE_LEFT_UP,
    00091
    00093                 EMIE_MMOUSE_LEFT_UP,
    00094
    00096                 EMIE_MOUSE_MOVED,
    00097
    00100                 EMIE_MOUSE_WHEEL,
    00101
    00104                 EMIE_LMOUSE_DOUBLE_CLICK,
    00105
    00108                 EMIE_RMOUSE_DOUBLE_CLICK,
    00109
    00112                 EMIE_MMOUSE_DOUBLE_CLICK,
    00113
    00116                 EMIE_LMOUSE_TRIPLE_CLICK,
    00117
    00120                 EMIE_RMOUSE_TRIPLE_CLICK,
    00121
    00124                 EMIE_MMOUSE_TRIPLE_CLICK,
    00125
    00127                 EMIE_COUNT
    00128         };
    00129
    00131         enum E_MOUSE_BUTTON_STATE_MASK
    00132         {
    00133                 EMBSM_LEFT    = 0x01,
    00134                 EMBSM_RIGHT   = 0x02,
    00135                 EMBSM_MIDDLE  = 0x04,
    00136
    00138                 EMBSM_EXTRA1  = 0x08,
    00139
    00141                 EMBSM_EXTRA2  = 0x10,
    00142
    00143                 EMBSM_FORCE_32_BIT = 0x7fffffff
    00144         };
    00145
    00146         namespace gui
    00147         {
    00148
    00149                 class IGUIElement;
    00150
    00152                 enum EGUI_EVENT_TYPE
    00153                 {
    00155
    00157                         EGET_ELEMENT_FOCUS_LOST = 0,
    00158
    00160
    00161                         EGET_ELEMENT_FOCUSED,
    00162
    00164                         EGET_ELEMENT_HOVERED,
    00165
    00167                         EGET_ELEMENT_LEFT,
    00168
    00170
    00172                         EGET_ELEMENT_CLOSED,
    00173
    00175                         EGET_BUTTON_CLICKED,
    00176
    00178                         EGET_SCROLL_BAR_CHANGED,
    00179
    00181                         EGET_CHECKBOX_CHANGED,
    00182
    00184
    00185                         EGET_LISTBOX_CHANGED,
    00186
    00188
    00189                         EGET_LISTBOX_SELECTED_AGAIN,
    00190
    00192                         EGET_FILE_SELECTED,
    00193
    00195                         EGET_DIRECTORY_SELECTED,
    00196
    00198                         EGET_FILE_CHOOSE_DIALOG_CANCELLED,
    00199
    00201                         EGET_MESSAGEBOX_YES,
    00202
    00204                         EGET_MESSAGEBOX_NO,
    00205
    00207                         EGET_MESSAGEBOX_OK,
    00208
    00210                         EGET_MESSAGEBOX_CANCEL,
    00211
    00213                         EGET_EDITBOX_ENTER,
    00214
    00216                         EGET_EDITBOX_CHANGED,
    00217
    00219                         EGET_EDITBOX_MARKING_CHANGED,
    00220
    00222                         EGET_TAB_CHANGED,
    00223
    00225                         EGET_MENU_ITEM_SELECTED,
    00226
    00228                         EGET_COMBO_BOX_CHANGED,
    00229
    00231                         EGET_SPINBOX_CHANGED,
    00232
    00234                         EGET_TABLE_CHANGED,
    00235                         EGET_TABLE_HEADER_CHANGED,
    00236                         EGET_TABLE_SELECTED_AGAIN,
    00237
    00239                         EGET_TREEVIEW_NODE_DESELECT,
    00240
    00242                         EGET_TREEVIEW_NODE_SELECT,
    00243
    00245                         EGET_TREEVIEW_NODE_EXPAND,
    00246
    00248                         EGET_TREEVIEW_NODE_COLLAPS,
    00249
    00251                         EGET_COUNT
    00252                 };
    00253         } // end namespace gui
    00254
    00255
    00257 struct SEvent
    00258 {
    00260         struct SGUIEvent
    00261         {
    00263                 gui::IGUIElement* Caller;
    00264
    00266                 gui::IGUIElement* Element;
    00267
    00269                 gui::EGUI_EVENT_TYPE EventType;
    00270
    00271         };
    00272
    00274         struct SMouseInput
    00275         {
    00277                 s32 X;
    00278
    00280                 s32 Y;
    00281
    00283
    00284                 f32 Wheel;
    00285
    00287                 bool Shift:1;
    00288
    00290                 bool Control:1;
    00291
    00295                 u32 ButtonStates;
    00296
    00298                 bool isLeftPressed() const { return 0 != ( ButtonStates & EMBSM_LEFT ); }
    00299
    00301                 bool isRightPressed() const { return 0 != ( ButtonStates & EMBSM_RIGHT ); }
    00302
    00304                 bool isMiddlePressed() const { return 0 != ( ButtonStates & EMBSM_MIDDLE ); }
    00305
    00307                 EMOUSE_INPUT_EVENT Event;
    00308         };
    00309
    00311         struct SKeyInput
    00312         {
    00314                 wchar_t Char;
    00315
    00317                 EKEY_CODE Key;
    00318
    00320                 bool PressedDown:1;
    00321
    00323                 bool Shift:1;
    00324
    00326                 bool Control:1;
    00327         };
    00328
    00330
    00337         struct SJoystickEvent
    00338         {
    00339                 enum
    00340                 {
    00341                         NUMBER_OF_BUTTONS = 32,
    00342
    00343                         AXIS_X = 0, // e.g. analog stick 1 left to right
    00344                         AXIS_Y,         // e.g. analog stick 1 top to bottom
    00345                         AXIS_Z,         // e.g. throttle, or analog 2 stick 2 left to right
    00346                         AXIS_R,         // e.g. rudder, or analog 2 stick 2 top to bottom
    00347                         AXIS_U,
    00348                         AXIS_V,
    00349                         NUMBER_OF_AXES
    00350                 };
    00351
    00354                 u32 ButtonStates;
    00355
    00364                 s16 Axis[NUMBER_OF_AXES];
    00365
    00371                 u16 POV;
    00372
    00374
    00376                 u8 Joystick;
    00377
    00379                 bool IsButtonPressed(u32 button) const
    00380                 {
    00381                         if(button >= (u32)NUMBER_OF_BUTTONS)
    00382                                 return false;
    00383
    00384                         return (ButtonStates & (1 << button)) ? true : false;
    00385                 }
    00386         };
    00387
    00388
    00390         struct SLogEvent
    00391         {
    00393                 const c8* Text;
    00394
    00396                 ELOG_LEVEL Level;
    00397         };
    00398
    00400         struct SUserEvent
    00401         {
    00403                 s32 UserData1;
    00404
    00406                 s32 UserData2;
    00407         };
    00408
    00409         EEVENT_TYPE EventType;
    00410         union
    00411         {
    00412                 struct SGUIEvent GUIEvent;
    00413                 struct SMouseInput MouseInput;
    00414                 struct SKeyInput KeyInput;
    00415                 struct SJoystickEvent JoystickEvent;
    00416                 struct SLogEvent LogEvent;
    00417                 struct SUserEvent UserEvent;
    00418         };
    00419
    00420 };
    00421
    00423
    00428 class IEventReceiver
    00429 {
    00430 public:
    00431
    00433         virtual ~IEventReceiver() {}
    00434
    00436
    00441         virtual bool OnEvent(const SEvent& event) = 0;
    00442 };
    00443
    00444
    00446 struct SJoystickInfo
    00447 {
    00449
    00452         u8                              Joystick;
    00453
    00455         core::stringc   Name;
    00456
    00458         u32                             Buttons;
    00459
    00461
    00463         u32                             Axes;
    00464
    00466
    00468         enum
    00469         {
    00471                 POV_HAT_PRESENT,
    00472
    00474                 POV_HAT_ABSENT,
    00475
    00477                 POV_HAT_UNKNOWN
    00478         } PovHat;
    00479 }; // struct SJoystickInfo
    00480
    00481
    00482 } // end namespace irr
    00483
    00484 #endif
    00485

| The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Sun Feb 14 13:06:56 2010 by Doxygen (1.6.2)