Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoQtDevice.h
1 #ifndef SOQT_DEVICE_H
2 #define SOQT_DEVICE_H
3 
4 //
5 
6 /**************************************************************************\
7  * Copyright (c) Kongsberg Oil & Gas Technologies AS
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are
12  * met:
13  *
14  * Redistributions of source code must retain the above copyright notice,
15  * this list of conditions and the following disclaimer.
16  *
17  * Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in the
19  * documentation and/or other materials provided with the distribution.
20  *
21  * Neither the name of the copyright holder nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 \**************************************************************************/
37 
38 // *************************************************************************
39 //
40 // Toolkit-specific typedef and include(s). Put these before any Coin
41 // and/or SoQt includes, in case there are any dependency bugs in
42 // the underlying native toolkit set of include files versus the
43 // compiler environment's include files.
44 
45 #include <Inventor/Qt/SoQtBasic.h> // Contains __COIN_SOQT__ define.
46 
47 #ifdef __COIN_SOQT__
48 #include <qevent.h>
49 typedef void SoQtEventHandler(QWidget*, void *, QEvent*, bool *);
50 #endif // __COIN_SOQT__
51 #ifdef __COIN_SOXT__
52 #include <X11/Intrinsic.h>
53 typedef void SoQtEventHandler(QWidget*, XtPointer, XEvent *, Boolean *);
54 #endif // __COIN_SOXT__
55 #ifdef __COIN_SOGTK__
56 #include <gtk/gtk.h>
57 typedef gint SoQtEventHandler(QWidget*, QEvent*, gpointer);
58 #endif // __COIN_SOGTK__
59 #ifdef __COIN_SOWIN__
60 #include <windows.h>
61 typedef LRESULT SoQtEventHandler(QWidget*, UINT, WPARAM, LPARAM);
62 #endif // __COIN_SOWIN__
63 
64 // *************************************************************************
65 
66 #include <Inventor/SbLinear.h>
67 #include <Inventor/Qt/SoQtObject.h>
68 
69 class SoEvent;
70 
71 // *************************************************************************
72 
73 class SOQT_DLL_API SoQtDevice : public SoQtObject {
74  SOQT_OBJECT_ABSTRACT_HEADER(SoQtDevice, SoQtObject);
75 
76 public:
77  virtual ~SoQtDevice();
78 
79  virtual void enable(QWidget* w, SoQtEventHandler * handler, void * closure) = 0;
80  virtual void disable(QWidget* w, SoQtEventHandler * handler, void * closure) = 0;
81 
82  virtual const SoEvent * translateEvent(QEvent* event) = 0;
83 
84  void setWindowSize(const SbVec2s size);
85  SbVec2s getWindowSize(void) const;
86 
87  static void initClasses(void);
88 
89 protected:
90  SoQtDevice(void);
91 
92  void setEventPosition(SoEvent * event, int x, int y) const;
93  static SbVec2s getLastEventPosition(void);
94 
95  void addEventHandler(QWidget*, SoQtEventHandler *, void *);
96  void removeEventHandler(QWidget*, SoQtEventHandler *, void *);
97  void invokeHandlers(QEvent* event);
98 
99 private:
100  class SoQtDeviceP * pimpl;
101  friend class SoQtDeviceP;
102 };
103 
104 // *************************************************************************
105 
106 #endif // !SOQT_DEVICE_H
The SoQtObject class is the common superclass for all SoQt component classes.
Definition: SoQtObject.h:48
The SoQtDevice class is the base class for the translation devices.
Definition: SoQtDevice.h:73