1
/**************************************************************************\
3
* This file is part of the Coin 3D visualization library.
4
* Copyright (C) 1998-2003 by Systems in Motion. All rights reserved.
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* ("GPL") version 2 as published by the Free Software Foundation.
9
* See the file LICENSE.GPL at the root directory of this source
10
* distribution for additional information about the GNU GPL.
12
* For using Coin with software that can not be combined with the GNU
13
* GPL, and for taking advantage of the additional benefits of our
14
* support services, please contact Systems in Motion about acquiring
15
* a Coin Professional Edition License.
17
* See <URL:http://www.coin3d.org> for more information.
19
* Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
20
* <URL:http://www.sim.no>.
22
\**************************************************************************/
26
#endif // HAVE_CONFIG_H
28
#include <Inventor/@Gui@/devices/So@Gui@Mouse.h>
29
#include <Inventor/@Gui@/devices/SoGuiMouseP.h>
30
#include <Inventor/events/SoMouseButtonEvent.h>
31
#include <Inventor/events/SoLocation2Event.h>
34
\class So@Gui@Mouse So@Gui@Mouse.h Inventor/@Gui@/devices/So@Gui@Mouse.h
35
\brief The So@Gui@Mouse class is the mouse input device abstraction.
38
The So@Gui@Mouse class is the glue between native mouse handling and
39
mouse interaction in the Inventor scenegraph.
41
All components derived from the So@Gui@RenderArea have got an
42
So@Gui@Mouse device attached by default.
44
One important note for application programmers: our mappings to
45
SoMouseButtonEvent::BUTTON2 and SoMouseButtonEvent::BUTTON3 do not
46
match the mappings in SGI's InventorXt library or TGS's SoWin
47
library for 3-button mice. They map mouse buttons like this:
50
<li>left button: SoMouseButtonEvent::BUTTON1</li>
51
<li>middle button: SoMouseButtonEvent::BUTTON2</li>
52
<li>right button: SoMouseButtonEvent::BUTTON3</li>
55
While in this SIM So@Gui@ library the mappings are:
58
<li>left button: SoMouseButtonEvent::BUTTON1</li>
59
<li>middle button: SoMouseButtonEvent::BUTTON3</li>
60
<li>right button: SoMouseButtonEvent::BUTTON2</li>
63
This is a conscious design decision we've made. The reason is that
64
BUTTON2 should be the right mouse button whether you have a 2-button
65
mouse or a 3-button mouse.
68
// *************************************************************************
70
SO@GUI@_OBJECT_SOURCE(So@Gui@Mouse);
72
// *************************************************************************
75
\enum So@Gui@Mouse::Events
76
Enumeration over supported mouse events.
79
\var So@Gui@Mouse::Events So@Gui@Mouse::BUTTON_PRESS
80
Maskbit for mousebutton press events.
83
\var So@Gui@Mouse::Events So@Gui@Mouse::BUTTON_RELEASE
84
Maskbit for mousebutton release events.
87
\var So@Gui@Mouse::Events So@Gui@Mouse::POINTER_MOTION
88
Maskbit for mousepointer motion events.
91
\var So@Gui@Mouse::Events So@Gui@Mouse::BUTTON_MOTION
92
Maskbit for mousepointer motion events with one or more mousebuttons
96
\var So@Gui@Mouse::Events So@Gui@Mouse::ALL_EVENTS
98
Mask which includes all the maskbits in the enum (ie use this to
99
signal interest in all kinds of events for the mouse device).
102
// *************************************************************************
105
\fn So@Gui@Mouse::So@Gui@Mouse(int mask)
107
Constructor. The \a mask argument should contain the set of
108
So@Gui@Mouse::Events one is interested in tracking.
112
\fn So@Gui@Mouse::~So@Gui@Mouse()
117
\fn const SoEvent * So@Gui@Mouse::translateEvent(@EVENT@ event)
119
Translates a native event from the underlying toolkit into a generic
122
This is then returned in the form of an instance of a subclass of
123
the Inventor API's SoEvent class, either an SoMouseButtonEvent or an
124
SoLocation2Event, depending on whether the native event is a
125
mousebutton press / release, or a mousecursor movement event.
127
The mapping of the mousebuttons upon generation of
128
SoMouseButtonEvent events will be done as follows:
131
<li>left mousebutton: SoMouseButtonEvent::BUTTON1</li>
132
<li>right mousebutton: SoMouseButtonEvent::BUTTON2</li>
133
<li>middle mousebutton, if available: SoMouseButtonEvent::BUTTON3</li>
134
<li>forward motion on a wheel mouse: SoMouseButtonEvent::BUTTON4</li>
135
<li>backward motion on a wheel mouse: SoMouseButtonEvent::BUTTON5</li>
138
Note that the rightmost mousebutton will always map to
139
SoMouseButtonEvent::BUTTON2, even on a 3-button mouse.
142
// *************************************************************************
144
#ifndef DOXYGEN_SKIP_THIS
146
SoGuiMouseP::SoGuiMouseP(So@Gui@Mouse * p)
150
// Allocate system-neutral event objects once and reuse.
151
this->buttonevent = new SoMouseButtonEvent;
152
this->locationevent = new SoLocation2Event;
155
SoGuiMouseP::~SoGuiMouseP()
157
delete this->buttonevent;
158
delete this->locationevent;
161
#endif // !DOXYGEN_SKIP_THIS
163
// *************************************************************************