Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoWinComponent.h
1 #ifndef SOWIN_COMPONENT_H
2 #define SOWIN_COMPONENT_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 #include <Inventor/SbLinear.h>
39 #include <Inventor/Win/SoWinObject.h>
40 
41 #ifdef __COIN_SOQT__
42 class QWidget;
43 #endif // __COIN_SOQT__
44 #ifdef __COIN_SOXT__
45 #include <X11/Intrinsic.h>
46 #endif // __COIN_SOXT__
47 #ifdef __COIN_SOGTK__
48 #include <gtk/gtk.h>
49 #endif // __COIN_SOGTK__
50 #ifdef __COIN_SOWIN__
51 #include <windows.h>
52 #endif // __COIN_SOWIN__
53 
54 
55 class SoWinComponent;
56 class SoWinCursor;
57 
58 typedef void SoWinComponentCB(void * user, SoWinComponent * component);
59 typedef void SoWinComponentVisibilityCB(void * user, SbBool visible);
60 
61 // *************************************************************************
62 
63 class SOWIN_DLL_API SoWinComponent : public SoWinObject {
64  SOWIN_OBJECT_ABSTRACT_HEADER(SoWinComponent, SoWinObject);
65 
66 public:
67  virtual ~SoWinComponent();
68 
69  virtual void show(void);
70  virtual void hide(void);
71 
72  virtual void setComponentCursor(const SoWinCursor & cursor);
73  static void setWidgetCursor(HWND w, const SoWinCursor & cursor);
74 
75  SbBool isFullScreen(void) const;
76  SbBool setFullScreen(const SbBool onoff);
77 
78  SbBool isVisible(void);
79  SbBool isTopLevelShell(void) const;
80 
81  HWND getWidget(void) const;
82  HWND getBaseWidget(void) const;
83  HWND getShellWidget(void) const;
84  HWND getParentWidget(void) const;
85 
86  void setSize(const SbVec2s size);
87  SbVec2s getSize(void) const;
88 
89  void setTitle(const char * const title);
90  const char * getTitle(void) const;
91  void setIconTitle(const char * const title);
92  const char * getIconTitle(void) const;
93 
94  const char * getWidgetName(void) const;
95  const char * getClassName(void) const;
96 
97  void setWindowCloseCallback(SoWinComponentCB * const func,
98  void * const user = NULL);
99  static SoWinComponent * getComponent(HWND widget);
100 
101  static void initClasses(void);
102 
103 protected:
104  SoWinComponent(HWND const parent = NULL,
105  const char * const name = NULL,
106  const SbBool embed = TRUE);
107 
108  virtual void afterRealizeHook(void);
109 
110  // About the wrapping below: this variable was added after SoQt 1.0,
111  // and before SoXt 1.1. To be able to release SoQt 1.1 from this
112  // same branch, sizeof(SoQtComponent) needs to be the same as for
113  // SoQt 1.0, which means we can't add this variable for SoQt.
114 #ifndef __COIN_SOQT__
115  SbBool firstRealize;
116 #endif // __COIN_SOQT__
117 
118  void setClassName(const char * const name);
119  void setBaseWidget(HWND widget);
120 
121  void registerWidget(HWND widget);
122  void unregisterWidget(HWND widget);
123 
124  virtual const char * getDefaultWidgetName(void) const;
125  virtual const char * getDefaultTitle(void) const;
126  virtual const char * getDefaultIconTitle(void) const;
127 
128  virtual void sizeChanged(const SbVec2s & size);
129 
130  void addVisibilityChangeCallback(SoWinComponentVisibilityCB * const func,
131  void * const user = NULL);
132  void removeVisibilityChangeCallback(SoWinComponentVisibilityCB * const func,
133  void * const user = NULL);
134 
135 private:
136  class SoWinComponentP * pimpl;
137  friend class SoGuiComponentP;
138  friend class SoWinComponentP;
139 
140  // FIXME!: audit and remove as much as possible of the remaining
141  // toolkit specific parts below. 20020117 mortene.
142 
143 #ifdef __COIN_SOXT__
144 public:
145  Display * getDisplay(void);
146  void fitSize(const SbVec2s size);
147  // FIXME: I guess these should really be part of the common
148  // API. 20011012 mortene.
149  void addWindowCloseCallback(SoXtComponentCB * callback, void * closure = NULL);
150  void removeWindowCloseCallback(SoXtComponentCB * callback, void * closure = NULL);
151 
152 protected:
153  // FIXME: I guess this should perhaps be part of the common API?
154  // 20011012 mortene.
155  void invokeVisibilityChangeCallbacks(const SbBool enable) const;
156  void invokeWindowCloseCallbacks(void) const;
157  virtual void windowCloseAction(void);
158 
159 private:
160  // FIXME: get rid of this? 20011012 mortene.
161  static void event_handler(Widget, XtPointer, XEvent *, Boolean *);
162 #endif // __COIN_SOXT__
163 
164 #ifdef __COIN_SOGTK__
165 protected:
166  virtual SbBool eventFilter(GtkWidget * object, GdkEvent * event);
167 private:
168  static gint eventHandler(GtkWidget * object, GdkEvent * event, gpointer closure);
169 #endif // __COIN_SOGTK__
170 };
171 
172 // *************************************************************************
173 
174 #endif // ! SOWIN_COMPONENT_H
The SoWinCursor class is used to set cursors for GUI components.
Definition: SoWinCursor.h:41
The SoWinObject class is the common superclass for all SoWin component classes.
Definition: SoWinObject.h:48
The SoWinComponent class is the base class for all GUI components.
Definition: SoWinComponent.h:63