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