OpenSceneGraph/include/osgGA/GUIEventAdapter

111 lines
2.9 KiB
Plaintext
Raw Normal View History

2002-07-17 04:07:32 +08:00
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
//Distributed under the terms of the GNU Library General Public License (LGPL)
//as published by the Free Software Foundation.
#ifndef OSGGA_GUIEVENTADAPTER
#define OSGGA_GUIEVENTADAPTER 1
#include <osg/Referenced>
#include <osgGA/Export>
namespace osgGA{
/**
Pure virtual base class for adapting platform specific events into
generic keyboard and mouse events.
Used as GUI toolkit-independent input into GUIEventAdapters. Viewer
writers should subclass this base class to implement the functionality
to translate one of their GUI events, e.g. a Qt Event or an MFC Event,
as appropriate.
*/
class OSGGA_EXPORT GUIEventAdapter : public osg::Referenced
{
public:
enum MouseButtonMask {
LEFT_MOUSE_BUTTON=1,
MIDDLE_MOUSE_BUTTON=2,
RIGHT_MOUSE_BUTTON=4
};
enum EventType {
PUSH,
RELEASE,
DRAG,
MOVE,
KEYDOWN,
KEYUP,
FRAME,
RESIZE,
NONE
};
enum ModKeyMask {
MOD_LEFT_SHIFT = 0x0001,
MOD_RIGHT_SHIFT = 0x0002,
MOD_LEFT_CTRL = 0x0040,
MOD_RIGHT_CTRL = 0x0080,
MOD_LEFT_ALT = 0x0100,
MOD_RIGHT_ALT = 0x0200,
MOD_LEFT_META = 0x0400,
MOD_RIGHT_META = 0x0800,
MOD_NUM_LOCK = 0x1000,
MOD_CAPS_LOCK = 0x2000,
MOD_CTRL = (MOD_LEFT_CTRL|MOD_RIGHT_CTRL),
MOD_SHIFT = (MOD_LEFT_SHIFT|MOD_RIGHT_SHIFT),
MOD_ALT = (MOD_LEFT_ALT|MOD_RIGHT_ALT),
MOD_META = (MOD_LEFT_META|MOD_RIGHT_META)
};
/** Get the EventType of the GUI event.*/
virtual EventType getEventType() const = 0;
/** key pressed, return -1 if inappr opriate for this event. */
virtual int getKey() const = 0;
/** button pressed/released, return -1 if inappropriate for this event.*/
virtual int getButton() const = 0;
/** window minimum x. */
virtual int getXmin() const = 0;
/** window maximum x. */
virtual int getXmax() const = 0;
/** window minimum y. */
virtual int getYmin() const = 0;
/** window maximum y. */
virtual int getYmax() const = 0;
/** current mouse x position.*/
virtual int getX() const = 0;
/** current mouse y position.*/
virtual int getY() const = 0;
/** current mouse button state */
virtual unsigned int getButtonMask() const = 0;
/** current modkey state */
virtual unsigned int getModKeyMask() const = 0;
/** time in seconds of event. */
virtual double time() const = 0;
protected:
GUIEventAdapter() {}
/** Force users to create on heap, so that multiple referencing is safe.*/
virtual ~GUIEventAdapter() {}
};
}
#endif