2003-01-22 00:45:36 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
|
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2002-05-09 18:31:03 +08:00
|
|
|
|
|
|
|
#ifndef OSGGA_GUIEVENTADAPTER
|
|
|
|
#define OSGGA_GUIEVENTADAPTER 1
|
|
|
|
|
|
|
|
#include <osg/Referenced>
|
|
|
|
#include <osgGA/Export>
|
|
|
|
|
|
|
|
namespace osgGA{
|
|
|
|
|
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
/**
|
|
|
|
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
|
2002-05-09 18:31:03 +08:00
|
|
|
{
|
2002-08-28 22:27:18 +08:00
|
|
|
public:
|
2002-05-09 18:31:03 +08:00
|
|
|
|
|
|
|
enum MouseButtonMask {
|
2002-08-28 22:27:18 +08:00
|
|
|
LEFT_MOUSE_BUTTON=1,
|
|
|
|
MIDDLE_MOUSE_BUTTON=2,
|
|
|
|
RIGHT_MOUSE_BUTTON=4
|
2002-05-09 18:31:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
enum EventType {
|
2002-08-28 22:27:18 +08:00
|
|
|
PUSH,
|
|
|
|
RELEASE,
|
2003-01-17 03:27:30 +08:00
|
|
|
DOUBLECLICK,
|
2002-08-28 22:27:18 +08:00
|
|
|
DRAG,
|
|
|
|
MOVE,
|
2003-01-14 22:25:56 +08:00
|
|
|
KEYDOWN,
|
|
|
|
KEYUP,
|
2002-08-28 22:27:18 +08:00
|
|
|
FRAME,
|
|
|
|
RESIZE,
|
|
|
|
NONE
|
2002-05-09 18:31:03 +08:00
|
|
|
};
|
|
|
|
|
2003-01-14 22:25:56 +08:00
|
|
|
enum ModKeyMask {
|
2003-01-15 00:39:41 +08:00
|
|
|
MODKEY_LEFT_SHIFT = 0x0001,
|
|
|
|
MODKEY_RIGHT_SHIFT = 0x0002,
|
|
|
|
MODKEY_LEFT_CTRL = 0x0040,
|
|
|
|
MODKEY_RIGHT_CTRL = 0x0080,
|
|
|
|
MODKEY_LEFT_ALT = 0x0100,
|
|
|
|
MODKEY_RIGHT_ALT = 0x0200,
|
|
|
|
MODKEY_LEFT_META = 0x0400,
|
|
|
|
MODKEY_RIGHT_META = 0x0800,
|
|
|
|
MODKEY_NUM_LOCK = 0x1000,
|
|
|
|
MODKEY_CAPS_LOCK = 0x2000,
|
|
|
|
MODKEY_CTRL = (MODKEY_LEFT_CTRL|MODKEY_RIGHT_CTRL),
|
|
|
|
MODKEY_SHIFT = (MODKEY_LEFT_SHIFT|MODKEY_RIGHT_SHIFT),
|
|
|
|
MODKEY_ALT = (MODKEY_LEFT_ALT|MODKEY_RIGHT_ALT),
|
|
|
|
MODKEY_META = (MODKEY_LEFT_META|MODKEY_RIGHT_META)
|
2003-01-14 22:25:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-05-09 18:31:03 +08:00
|
|
|
/** Get the EventType of the GUI event.*/
|
|
|
|
virtual EventType getEventType() const = 0;
|
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
/** key pressed, return -1 if inappr opriate for this event. */
|
2002-05-09 18:31:03 +08:00
|
|
|
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;
|
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
/** window maximum y. */
|
2002-05-09 18:31:03 +08:00
|
|
|
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;
|
|
|
|
|
2003-01-14 22:25:56 +08:00
|
|
|
/** current modkey state */
|
|
|
|
virtual unsigned int getModKeyMask() const = 0;
|
|
|
|
|
2002-05-09 18:31:03 +08:00
|
|
|
/** time in seconds of event. */
|
2002-06-09 21:10:09 +08:00
|
|
|
virtual double time() const = 0;
|
2002-05-09 18:31:03 +08:00
|
|
|
|
2002-08-28 22:27:18 +08:00
|
|
|
protected:
|
|
|
|
|
|
|
|
GUIEventAdapter() {}
|
2002-05-09 18:31:03 +08:00
|
|
|
|
|
|
|
/** Force users to create on heap, so that multiple referencing is safe.*/
|
|
|
|
virtual ~GUIEventAdapter() {}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|