Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SoQtComponent.h
1 #ifndef SOQT_COMPONENT_H
2 #define SOQT_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/Qt/SoQtObject.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 SoQtComponent;
56 class SoQtCursor;
57 
58 typedef void SoQtComponentCB(void * user, SoQtComponent * component);
59 typedef void SoQtComponentVisibilityCB(void * user, SbBool visible);
60 
61 // *************************************************************************
62 
63 class SOQT_DLL_API SoQtComponent : public SoQtObject {
64  SOQT_OBJECT_ABSTRACT_HEADER(SoQtComponent, SoQtObject);
65 
66 public:
67  virtual ~SoQtComponent();
68 
69  virtual void show(void);
70  virtual void hide(void);
71 
72  virtual void setComponentCursor(const SoQtCursor & cursor);
73  static void setWidgetCursor(QWidget* w, const SoQtCursor & 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  QWidget* getWidget(void) const;
82  QWidget* getBaseWidget(void) const;
83  QWidget* getShellWidget(void) const;
84  QWidget* 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(SoQtComponentCB * const func,
98  void * const user = NULL);
99  static SoQtComponent * getComponent(QWidget* widget);
100 
101  static void initClasses(void);
102 
103 protected:
104  SoQtComponent(QWidget* 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(QWidget* widget);
120 
121  void registerWidget(QWidget* widget);
122  void unregisterWidget(QWidget* 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(SoQtComponentVisibilityCB * const func,
131  void * const user = NULL);
132  void removeVisibilityChangeCallback(SoQtComponentVisibilityCB * const func,
133  void * const user = NULL);
134 
135 private:
136  class SoQtComponentP * pimpl;
137  friend class SoGuiComponentP;
138  friend class SoQtComponentP;
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 // ! SOQT_COMPONENT_H
The SoQtComponent class is the base class for all GUI components.
Definition: SoQtComponent.h:63
The SoQtObject class is the common superclass for all SoQt component classes.
Definition: SoQtObject.h:48
The SoQtCursor class is used to set cursors for GUI components.
Definition: SoQtCursor.h:41