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_MOUSE_DOUBLE_CLICK,
    00105
    00108                 EMIE_MOUSE_TRIPLE_CLICK,
    00109
    00111                 EMIE_COUNT
    00112         };
    00113
    00115         enum E_MOUSE_BUTTON_STATE_MASK
    00116         {
    00117                 EMBSM_LEFT    = 0x01,
    00118                 EMBSM_RIGHT   = 0x02,
    00119                 EMBSM_MIDDLE  = 0x04,
    00120
    00122                 EMBSM_EXTRA1  = 0x08,
    00123
    00125                 EMBSM_EXTRA2  = 0x10,
    00126
    00127                 EMBSM_FORCE_32_BIT = 0x7fffffff
    00128         };
    00129
    00130         namespace gui
    00131         {
    00132
    00133                 class IGUIElement;
    00134
    00136                 enum EGUI_EVENT_TYPE
    00137                 {
    00139
    00141                         EGET_ELEMENT_FOCUS_LOST = 0,
    00142
    00144
    00145                         EGET_ELEMENT_FOCUSED,
    00146
    00148                         EGET_ELEMENT_HOVERED,
    00149
    00151                         EGET_ELEMENT_LEFT,
    00152
    00154
    00156                         EGET_ELEMENT_CLOSED,
    00157
    00159                         EGET_BUTTON_CLICKED,
    00160
    00162                         EGET_SCROLL_BAR_CHANGED,
    00163
    00165                         EGET_CHECKBOX_CHANGED,
    00166
    00168                         EGET_LISTBOX_CHANGED,
    00169
    00171                         EGET_LISTBOX_SELECTED_AGAIN,
    00172
    00174                         EGET_FILE_SELECTED,
    00175
    00177                         EGET_DIRECTORY_SELECTED,
    00178
    00180                         EGET_FILE_CHOOSE_DIALOG_CANCELLED,
    00181
    00183                         EGET_MESSAGEBOX_YES,
    00184
    00186                         EGET_MESSAGEBOX_NO,
    00187
    00189                         EGET_MESSAGEBOX_OK,
    00190
    00192                         EGET_MESSAGEBOX_CANCEL,
    00193
    00195                         EGET_EDITBOX_ENTER,
    00196
    00198                         EGET_EDITBOX_CHANGED,
    00199
    00201                         EGET_EDITBOX_MARKING_CHANGED,
    00202
    00204                         EGET_TAB_CHANGED,
    00205
    00207                         EGET_MENU_ITEM_SELECTED,
    00208
    00210                         EGET_COMBO_BOX_CHANGED,
    00211
    00213                         EGET_SPINBOX_CHANGED,
    00214
    00216                         EGET_TABLE_CHANGED,
    00217                         EGET_TABLE_HEADER_CHANGED,
    00218                         EGET_TABLE_SELECTED_AGAIN,
    00219
    00221                         EGET_TREEVIEW_NODE_DESELECT,
    00222
    00224                         EGET_TREEVIEW_NODE_SELECT,
    00225
    00227                         EGET_TREEVIEW_NODE_EXPAND,
    00228
    00230                         EGET_TREEVIEW_NODE_COLLAPS,
    00231
    00233                         EGET_COUNT
    00234                 };
    00235         } // end namespace gui
    00236
    00237
    00239 struct SEvent
    00240 {
    00242         struct SGUIEvent
    00243         {
    00245                 gui::IGUIElement* Caller;
    00246
    00248                 gui::IGUIElement* Element;
    00249
    00251                 gui::EGUI_EVENT_TYPE EventType;
    00252
    00253         };
    00254
    00256         struct SMouseInput
    00257         {
    00259                 s32 X;
    00260
    00262                 s32 Y;
    00263
    00265
    00266                 f32 Wheel;
    00267
    00269                 bool Shift:1;
    00270
    00272                 bool Control:1;
    00273
    00277                 u32 ButtonStates;
    00278
    00280                 bool isLeftPressed() const { return 0 != ( ButtonStates & EMBSM_LEFT ); }
    00281
    00283                 bool isRightPressed() const { return 0 != ( ButtonStates & EMBSM_RIGHT ); }
    00284
    00286                 bool isMiddlePressed() const { return 0 != ( ButtonStates & EMBSM_MIDDLE ); }
    00287
    00289                 EMOUSE_INPUT_EVENT Event;
    00290         };
    00291
    00293         struct SKeyInput
    00294         {
    00296                 wchar_t Char;
    00297
    00299                 EKEY_CODE Key;
    00300
    00302                 bool PressedDown:1;
    00303
    00305                 bool Shift:1;
    00306
    00308                 bool Control:1;
    00309         };
    00310
    00312
    00319         struct SJoystickEvent
    00320         {
    00321                 enum
    00322                 {
    00323                         NUMBER_OF_BUTTONS = 32,
    00324
    00325                         AXIS_X = 0, // e.g. analog stick 1 left to right
    00326                         AXIS_Y,         // e.g. analog stick 1 top to bottom
    00327                         AXIS_Z,         // e.g. throttle, or analog 2 stick 2 left to right
    00328                         AXIS_R,         // e.g. rudder, or analog 2 stick 2 top to bottom
    00329                         AXIS_U,
    00330                         AXIS_V,
    00331                         NUMBER_OF_AXES
    00332                 };
    00333
    00336                 u32 ButtonStates;
    00337
    00346                 s16 Axis[NUMBER_OF_AXES];
    00347
    00353                 u16 POV;
    00354
    00356
    00358                 u8 Joystick;
    00359
    00361                 bool IsButtonPressed(u32 button) const
    00362                 {
    00363                         if(button >= (u32)NUMBER_OF_BUTTONS)
    00364                                 return false;
    00365
    00366                         return (ButtonStates & (1 << button)) ? true : false;
    00367                 }
    00368         };
    00369
    00370
    00372         struct SLogEvent
    00373         {
    00375                 const c8* Text;
    00376
    00378                 ELOG_LEVEL Level;
    00379         };
    00380
    00382         struct SUserEvent
    00383         {
    00385                 s32 UserData1;
    00386
    00388                 s32 UserData2;
    00389         };
    00390
    00391         EEVENT_TYPE EventType;
    00392         union
    00393         {
    00394                 struct SGUIEvent GUIEvent;
    00395                 struct SMouseInput MouseInput;
    00396                 struct SKeyInput KeyInput;
    00397                 struct SJoystickEvent JoystickEvent;
    00398                 struct SLogEvent LogEvent;
    00399                 struct SUserEvent UserEvent;
    00400         };
    00401
    00402 };
    00403
    00405
    00410 class IEventReceiver
    00411 {
    00412 public:
    00413
    00415         virtual ~IEventReceiver() {}
    00416
    00418
    00419         virtual bool OnEvent(const SEvent& event) = 0;
    00420 };
    00421
    00422
    00424 struct SJoystickInfo
    00425 {
    00427
    00430         u8                              Joystick;
    00431
    00433         core::stringc   Name;
    00434
    00436         u32                             Buttons;
    00437
    00439
    00441         u32                             Axes;
    00442
    00444
    00446         enum
    00447         {
    00449                 POV_HAT_PRESENT,
    00450
    00452                 POV_HAT_ABSENT,
    00453
    00455                 POV_HAT_UNKNOWN
    00456         } PovHat;
    00457 }; // struct SJoystickInfo
    00458
    00459
    00460 } // end namespace irr
    00461
    00462 #endif
    00463

| The Irrlicht Engine Documentation © 2003-2009 by Nikolaus Gebhardt. Generated on Sun Jan 10 09:24:03 2010 by Doxygen (1.5.6)