[692] | 1 | /*
|
---|
| 2 | -----------------------------------------------------------------------------
|
---|
| 3 | This source file is part of OGRE
|
---|
| 4 | (Object-oriented Graphics Rendering Engine)
|
---|
| 5 | For the latest info, see http://www.ogre3d.org/
|
---|
| 6 |
|
---|
| 7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
| 8 | Also see acknowledgements in Readme.html
|
---|
| 9 |
|
---|
| 10 | This program is free software; you can redistribute it and/or modify it under
|
---|
| 11 | the terms of the GNU Lesser General License as published by the Free Software
|
---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later
|
---|
| 13 | version.
|
---|
| 14 |
|
---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General License for more details.
|
---|
| 18 |
|
---|
| 19 | You should have received a copy of the GNU Lesser General License along with
|
---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
| 22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
| 23 | -----------------------------------------------------------------------------
|
---|
| 24 | */
|
---|
| 25 |
|
---|
| 26 | /***************************************************************************
|
---|
| 27 | OgreInputEvent.h -
|
---|
| 28 | * The root event class for all GuiElement-level input events.
|
---|
| 29 | *
|
---|
| 30 | * Input events are delivered to listeners before they are
|
---|
| 31 | * processed normally by the source where they originated.
|
---|
| 32 | * This allows listeners and GuiElement subclasses to "consume"
|
---|
| 33 | * the event so that the source will not process them in their
|
---|
| 34 | * default manner. For example, consuming mousePressed events
|
---|
| 35 | * on a Button GuiElement will prevent the Button from being
|
---|
| 36 | * activated.
|
---|
| 37 | -------------------
|
---|
| 38 | begin : Nov 19 2002
|
---|
| 39 | copyright : (C) 2002 by Kenny Sabir
|
---|
| 40 | email : kenny@sparksuit.com
|
---|
| 41 | ***************************************************************************/
|
---|
| 42 |
|
---|
| 43 | #ifndef __InputEvent_H__
|
---|
| 44 | #define __InputEvent_H__
|
---|
| 45 |
|
---|
| 46 | #include "OgrePrerequisites.h"
|
---|
| 47 |
|
---|
| 48 | namespace Ogre {
|
---|
| 49 |
|
---|
| 50 | /** The root event class for all GuiElement-level input events.
|
---|
| 51 | @remarks
|
---|
| 52 | Input events are delivered to listeners before they are
|
---|
| 53 | processed normally by the source where they originated.
|
---|
| 54 | This allows listeners and GuiElement subclasses to "consume"
|
---|
| 55 | the event so that the source will not process them in their
|
---|
| 56 | default manner. For example, consuming mousePressed events
|
---|
| 57 | on a Button GuiElement will prevent the Button from being
|
---|
| 58 | activated.
|
---|
| 59 | */
|
---|
| 60 | class _OgreExport InputEvent
|
---|
| 61 | {
|
---|
| 62 | protected:
|
---|
| 63 |
|
---|
| 64 | /**
|
---|
| 65 | * Not implemented yet
|
---|
| 66 | */
|
---|
| 67 | Real mWhen;
|
---|
| 68 | /**
|
---|
| 69 | * The state of the modifier keys at the time the input
|
---|
| 70 | * event was fired.
|
---|
| 71 | */
|
---|
| 72 | int mModifiers;
|
---|
| 73 |
|
---|
| 74 | /**
|
---|
| 75 | * The target to process the event. This is ususally found by the dispatcher
|
---|
| 76 | */
|
---|
| 77 |
|
---|
| 78 | EventTarget* mSource;
|
---|
| 79 |
|
---|
| 80 | /**
|
---|
| 81 | * The ID of the event
|
---|
| 82 | */
|
---|
| 83 | int mId;
|
---|
| 84 |
|
---|
| 85 | /**
|
---|
| 86 | * whether the event has been consumed
|
---|
| 87 | */
|
---|
| 88 | bool mConsumed;
|
---|
| 89 |
|
---|
| 90 | public:
|
---|
| 91 |
|
---|
| 92 |
|
---|
| 93 | enum // using the enum hack cause VC6 doesn't support static const in classes
|
---|
| 94 | {
|
---|
| 95 | /**
|
---|
| 96 | * This flag indicates that the Shift key was down when the event
|
---|
| 97 | * occurred.
|
---|
| 98 | */
|
---|
| 99 | SHIFT_MASK = 1 << 0,
|
---|
| 100 |
|
---|
| 101 | /**
|
---|
| 102 | * This flag indicates that the Control key was down when the event
|
---|
| 103 | * occurred.
|
---|
| 104 | */
|
---|
| 105 | CTRL_MASK = 1 << 1,
|
---|
| 106 |
|
---|
| 107 | /**
|
---|
| 108 | * This flag indicates that the Meta key was down when the event
|
---|
| 109 | * occurred. For mouse events, this flag indicates that the right
|
---|
| 110 | * button was pressed or released.
|
---|
| 111 | */
|
---|
| 112 |
|
---|
| 113 | META_MASK = 1 << 2,
|
---|
| 114 | /**
|
---|
| 115 | * This flag indicates that the Alt key was down when
|
---|
| 116 | * the event occurred. For mouse events, this flag indicates that the
|
---|
| 117 | * middle mouse button was pressed or released.
|
---|
| 118 | */
|
---|
| 119 | ALT_MASK = 1 << 3,
|
---|
| 120 | BUTTON0_MASK = 1 << 4,
|
---|
| 121 | BUTTON1_MASK = 1 << 5,
|
---|
| 122 | BUTTON2_MASK = 1 << 6,
|
---|
| 123 | BUTTON3_MASK = 1 << 7,
|
---|
| 124 | BUTTON_ANY_MASK = 0xF << 4
|
---|
| 125 | };
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 |
|
---|
| 129 | /**
|
---|
| 130 | * Constructs an InputEvent object with the specified source GuiElement,
|
---|
| 131 | * modifiers, and type.
|
---|
| 132 | * @param source the object where the event originated
|
---|
| 133 | * @id the event type
|
---|
| 134 | * @when the time the event occurred
|
---|
| 135 | * @modifiers the modifier keys down while event occurred
|
---|
| 136 | */
|
---|
| 137 | InputEvent(EventTarget* source, int id, long when, int modifiers);
|
---|
| 138 |
|
---|
| 139 | /**
|
---|
| 140 | * Consumes this event so that it will not be processed
|
---|
| 141 | * in the default manner by the source which originated it.
|
---|
| 142 | */
|
---|
| 143 | void consume();
|
---|
| 144 |
|
---|
| 145 | /**
|
---|
| 146 | * Returns the modifiers flag for this event.
|
---|
| 147 | */
|
---|
| 148 | int getModifiers() const;
|
---|
| 149 |
|
---|
| 150 | /**
|
---|
| 151 | * Returns the timestamp of when this event occurred. Not implemented yet
|
---|
| 152 | */
|
---|
| 153 | Real getWhen() const;
|
---|
| 154 |
|
---|
| 155 | /**
|
---|
| 156 | * Returns whether or not the Alt modifier is down on this event.
|
---|
| 157 | */
|
---|
| 158 | bool isAltDown() const;
|
---|
| 159 |
|
---|
| 160 | /**
|
---|
| 161 | * Returns whether or not this event has been consumed.
|
---|
| 162 | * @see #consume
|
---|
| 163 | */
|
---|
| 164 | bool isConsumed() const;
|
---|
| 165 |
|
---|
| 166 | /**
|
---|
| 167 | * Returns whether or not the Control modifier is down on this event.
|
---|
| 168 | */
|
---|
| 169 | bool isControlDown() const;
|
---|
| 170 |
|
---|
| 171 | /**
|
---|
| 172 | * Returns whether or not the Meta modifier is down on this event.
|
---|
| 173 | */
|
---|
| 174 | bool isMetaDown() const;
|
---|
| 175 |
|
---|
| 176 | /**
|
---|
| 177 | * Returns whether or not the Shift modifier is down on this event.
|
---|
| 178 | */
|
---|
| 179 | bool isShiftDown() const;
|
---|
| 180 |
|
---|
| 181 | bool isEventBetween(int start, int end) const;
|
---|
| 182 | int getID() const;
|
---|
| 183 |
|
---|
| 184 | EventTarget* getSource() const;
|
---|
| 185 | };
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 |
|
---|
| 189 | #endif // __InputEvent_H__
|
---|
| 190 |
|
---|