Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://coin3d.github.io
https://www.kongsberg.com/en/kogt/
SoWinDevice.h
1 #ifndef SOWIN_DEVICE_H
2 #define SOWIN_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 SoWin 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/Win/SoWinBasic.h> // Contains __COIN_SOWIN__ define.
46 
47 #ifdef __COIN_SOQT__
48 #include <qevent.h>
49 typedef void SoWinEventHandler(HWND, void *, MSG*, bool *);
50 #endif // __COIN_SOQT__
51 #ifdef __COIN_SOXT__
52 #include <X11/Intrinsic.h>
53 typedef void SoWinEventHandler(HWND, XtPointer, XEvent *, Boolean *);
54 #endif // __COIN_SOXT__
55 #ifdef __COIN_SOGTK__
56 #include <gtk/gtk.h>
57 typedef gint SoWinEventHandler(HWND, MSG*, gpointer);
58 #endif // __COIN_SOGTK__
59 #ifdef __COIN_SOWIN__
60 #include <windows.h>
61 typedef LRESULT SoWinEventHandler(HWND, UINT, WPARAM, LPARAM);
62 #endif // __COIN_SOWIN__
63 
64 // *************************************************************************
65 
66 #include <Inventor/SbLinear.h>
67 #include <Inventor/Win/SoWinObject.h>
68 
69 class SoEvent;
70 
71 // *************************************************************************
72 
73 class SOWIN_DLL_API SoWinDevice : public SoWinObject {
74  SOWIN_OBJECT_ABSTRACT_HEADER(SoWinDevice, SoWinObject);
75 
76 public:
77  virtual ~SoWinDevice();
78 
79  virtual void enable(HWND w, SoWinEventHandler * handler, void * closure) = 0;
80  virtual void disable(HWND w, SoWinEventHandler * handler, void * closure) = 0;
81 
82  virtual const SoEvent * translateEvent(MSG* event) = 0;
83 
84  void setWindowSize(const SbVec2s size);
85  SbVec2s getWindowSize(void) const;
86 
87  static void initClasses(void);
88 
89 protected:
90  SoWinDevice(void);
91 
92  void setEventPosition(SoEvent * event, int x, int y) const;
93  static SbVec2s getLastEventPosition(void);
94 
95  void addEventHandler(HWND, SoWinEventHandler *, void *);
96  void removeEventHandler(HWND, SoWinEventHandler *, void *);
97  void invokeHandlers(MSG* event);
98 
99 private:
100  class SoWinDeviceP * pimpl;
101  friend class SoWinDeviceP;
102 };
103 
104 // *************************************************************************
105 
106 #endif // !SOWIN_DEVICE_H
The SoWinObject class is the common superclass for all SoWin component classes.
Definition: SoWinObject.h:48
The SoWinDevice class is the base class for the translation devices.
Definition: SoWinDevice.h:73