~ubuntu-branches/ubuntu/oneiric/soqt/oneiric

« back to all changes in this revision

Viewing changes to src/Inventor/Qt/common/devices/SoGuiMouse.cpp.in

  • Committer: Bazaar Package Importer
  • Author(s): Steve M. Robbins
  • Date: 2004-05-29 02:58:50 UTC
  • Revision ID: james.westby@ubuntu.com-20040529025850-phd20eva5uyhhdrf
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**************************************************************************\
 
2
 *
 
3
 *  This file is part of the Coin 3D visualization library.
 
4
 *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
 
5
 *
 
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.
 
11
 *
 
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.
 
16
 *
 
17
 *  See <URL:http://www.coin3d.org> for more information.
 
18
 *
 
19
 *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
 
20
 *  <URL:http://www.sim.no>.
 
21
 *
 
22
\**************************************************************************/
 
23
 
 
24
#if HAVE_CONFIG_H
 
25
#include <config.h>
 
26
#endif // HAVE_CONFIG_H
 
27
 
 
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>
 
32
 
 
33
/*!
 
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.
 
36
  \ingroup devices
 
37
 
 
38
  The So@Gui@Mouse class is the glue between native mouse handling and
 
39
  mouse interaction in the Inventor scenegraph.
 
40
 
 
41
  All components derived from the So@Gui@RenderArea have got an
 
42
  So@Gui@Mouse device attached by default.
 
43
 
 
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:
 
48
 
 
49
  <ul>
 
50
  <li>left button: SoMouseButtonEvent::BUTTON1</li>
 
51
  <li>middle button: SoMouseButtonEvent::BUTTON2</li>
 
52
  <li>right button: SoMouseButtonEvent::BUTTON3</li>
 
53
  </ul>
 
54
 
 
55
  While in this SIM So@Gui@ library the mappings are:
 
56
 
 
57
  <ul>
 
58
  <li>left button: SoMouseButtonEvent::BUTTON1</li>
 
59
  <li>middle button: SoMouseButtonEvent::BUTTON3</li>
 
60
  <li>right button: SoMouseButtonEvent::BUTTON2</li>
 
61
  </ul>
 
62
 
 
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.
 
66
*/
 
67
 
 
68
// *************************************************************************
 
69
 
 
70
SO@GUI@_OBJECT_SOURCE(So@Gui@Mouse);
 
71
 
 
72
// *************************************************************************
 
73
 
 
74
/*!
 
75
  \enum So@Gui@Mouse::Events
 
76
  Enumeration over supported mouse events.
 
77
*/
 
78
/*!
 
79
  \var So@Gui@Mouse::Events So@Gui@Mouse::BUTTON_PRESS
 
80
  Maskbit for mousebutton press events.
 
81
*/
 
82
/*!
 
83
  \var So@Gui@Mouse::Events So@Gui@Mouse::BUTTON_RELEASE
 
84
  Maskbit for mousebutton release events.
 
85
*/
 
86
/*!
 
87
  \var So@Gui@Mouse::Events So@Gui@Mouse::POINTER_MOTION
 
88
  Maskbit for mousepointer motion events.
 
89
*/
 
90
/*!
 
91
  \var So@Gui@Mouse::Events So@Gui@Mouse::BUTTON_MOTION
 
92
  Maskbit for mousepointer motion events with one or more mousebuttons
 
93
  pressed.
 
94
*/
 
95
/*!
 
96
  \var So@Gui@Mouse::Events So@Gui@Mouse::ALL_EVENTS
 
97
 
 
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).
 
100
*/
 
101
 
 
102
// *************************************************************************
 
103
 
 
104
/*!
 
105
  \fn So@Gui@Mouse::So@Gui@Mouse(int mask)
 
106
 
 
107
  Constructor. The \a mask argument should contain the set of
 
108
  So@Gui@Mouse::Events one is interested in tracking.
 
109
*/
 
110
 
 
111
/*!
 
112
  \fn So@Gui@Mouse::~So@Gui@Mouse()
 
113
  Destructor.
 
114
*/
 
115
 
 
116
/*!
 
117
  \fn const SoEvent * So@Gui@Mouse::translateEvent(@EVENT@ event)
 
118
 
 
119
  Translates a native event from the underlying toolkit into a generic
 
120
  event.
 
121
 
 
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.
 
126
 
 
127
  The mapping of the mousebuttons upon generation of
 
128
  SoMouseButtonEvent events will be done as follows:
 
129
 
 
130
  <ul>
 
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>
 
136
  </ul>
 
137
 
 
138
  Note that the rightmost mousebutton will always map to
 
139
  SoMouseButtonEvent::BUTTON2, even on a 3-button mouse.
 
140
*/
 
141
 
 
142
// *************************************************************************
 
143
 
 
144
#ifndef DOXYGEN_SKIP_THIS
 
145
 
 
146
SoGuiMouseP::SoGuiMouseP(So@Gui@Mouse * p)
 
147
{
 
148
  this->pub = p;
 
149
 
 
150
  // Allocate system-neutral event objects once and reuse.
 
151
  this->buttonevent = new SoMouseButtonEvent;
 
152
  this->locationevent = new SoLocation2Event;
 
153
}
 
154
 
 
155
SoGuiMouseP::~SoGuiMouseP()
 
156
{
 
157
  delete this->buttonevent;
 
158
  delete this->locationevent;
 
159
}
 
160
 
 
161
#endif // !DOXYGEN_SKIP_THIS
 
162
 
 
163
// *************************************************************************