SoWx  0.1.0
Coin3D GUI toolkit binding
Loading...
Searching...
No Matches
SoWx.h
1#ifndef SOWX_H
2#define SOWX_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/Wx/SoWxBasic.h>
39
40// FIXME: use configure defines for the header files.
41// 20020613 mortene.
42
43#ifdef __COIN_SOQT__
44
45#if QT_VERSION >= 0x040000
46#include <QtCore/QObject>
47#else
48#include <qobject.h>
49#endif
50
51#endif // __COIN_SOQT__
52#ifdef __COIN_SOXT__
53#include <X11/Intrinsic.h>
54#include <Xm/Xm.h>
55#endif // __COIN_SOXT__
56#ifdef __COIN_SOGTK__
57// Fetch stdlib.h, so NULL is defined before glib.h is (indirectly)
58// included. Otherwise we get a compile error with KCC on some
59// systems.
60#include <cstdlib>
61#include <gtk/gtk.h>
62class SoGtkComponent;
63class SbPList;
64#endif // __COIN_SOGTK__
65#ifdef __COIN_SOWIN__
66#include <windows.h>
67#endif // __COIN_SOWIN__
68#ifdef __COIN_SOWX__
69#include <wx/wx.h>
70#endif // __COIN_SOWX__
71
72#include <Inventor/SbBasic.h>
73#include <Inventor/SbLinear.h>
74#include <Inventor/SbString.h>
75#include <Inventor/SoDB.h>
76#include <Inventor/errors/SoDebugError.h>
77
78// *************************************************************************
79
80class SOWX_DLL_API SoWx
81{
82
83public:
84 static wxWindow* init(const char * appname, const char * classname = "SoWx");
85 static wxWindow* init(int & argc, char ** argv,
86 const char * appname, const char * classname = "SoWx");
87 static void init(wxWindow* toplevelwidget);
88
89 static void mainLoop(void);
90 static void exitMainLoop(void);
91 static void done(void);
92
93 static wxWindow* getTopLevelWidget(void);
94 static wxWindow* getShellWidget(const wxWindow* w);
95
96 static void show(wxWindow* const widget);
97 static void hide(wxWindow* const widget);
98
99 static void setWidgetSize(wxWindow* const widget, const SbVec2s size);
100 static SbVec2s getWidgetSize(const wxWindow* widget);
101
102 static void createSimpleErrorDialog(wxWindow* widget,
103 const char * title,
104 const char * string1,
105 const char * string2 = NULL);
106
107 static void getVersionInfo(int * major = NULL,
108 int * minor = NULL,
109 int * micro = NULL);
110 static const char * getVersionString(void);
111 static const char * getVersionToolkitString(void);
112
114 UNSPECIFIED_ERROR = 0,
116 INTERNAL_ASSERT
117 };
118 typedef void FatalErrorCB(const SbString errmsg, SoWx::FatalErrors errcode,
119 void * userdata);
120 static FatalErrorCB * setFatalErrorHandler(SoWx::FatalErrorCB * cb,
121 void * userdata);
122
123 static SbBool isDebugLibrary(void);
124 static SbBool isCompatible(unsigned int major, unsigned int minor);
125
126 enum ABIType { DLL, LIB, UNKNOWN };
127 static ABIType getABIType(void);
128
129 static void lockGL(void);
130 static void unlockGL(void);
131
132private:
133 // Since the class consists solely of static functions, hide the
134 // default constructor and the destructor so nobody can instantiate
135 // it.
136 SoWx(void);
137 virtual ~SoWx();
138
139 friend class SoGuiP;
140 friend class SoWxP;
141
142
143 // FIXME!: audit and remove as much as possible of the remaining
144 // toolkit specific parts below. 20020117 mortene.
145
146#ifdef __COIN_SOWIN__
147public:
148 static void doIdleTasks(void);
149#endif // __COIN_SOWIN__
150
151#ifdef __COIN_SOXT__
152public:
153 static void nextEvent(XtAppContext, XEvent *);
154 static Boolean dispatchEvent(XEvent * event);
155 static XtAppContext getAppContext(void);
156 static Display * getDisplay(void);
157 static XmString encodeString(const char * const str);
158 static char * decodeString(XmString xstring);
159 static void getPopupArgs(Display * display, int screen,
160 ArgList args, int * n);
161
162 static void registerColormapLoad(Widget widget, Widget shell);
163 static void addColormapToShell(Widget widget, Widget shell);
164 static void removeColormapFromShell(Widget widget, Widget shell);
165
166 static void addExtensionEventHandler(Widget widget,
167 int eventType, XtEventHandler proc,
168 XtPointer clientData);
169 static void removeExtensionEventHandler(Widget widget,
170 int eventType, XtEventHandler proc,
171 XtPointer clientData);
172
173protected:
174 static void getExtensionEventHandler(XEvent * event, Widget & widget,
175 XtEventHandler & proc,
176 XtPointer & clientData);
177#endif // __COIN_SOXT__
178
179#ifdef __COIN_SOGTK__
180public:
181 friend class SoGtkComponent;
182 enum SoGtkComponentAction { CREATION, DESTRUCTION, CHANGE };
183 typedef void SoGtkComponentActionCallback(SoGtkComponent *, SoGtk::SoGtkComponentAction, void *);
184
185 static void addComponentActionCallback(SoGtkComponentActionCallback *, void *);
186 static void removeComponentActionCallback(SoGtkComponentActionCallback *, void *);
187
188 static int getComponents(SbPList & components);
189
190protected:
191 static void invokeComponentActionCallbacks(SoGtkComponent * component,
192 SoGtkComponentAction action);
193
194 static gint componentCreation(SoGtkComponent * component);
195 static gint componentDestruction(SoGtkComponent * component);
196 static gint componentChange(SoGtkComponent * component);
197
198private:
199 static gint timerSensorCB(gpointer data);
200 static gint idleSensorCB(gpointer data);
201 static gint delaySensorCB(gpointer data);
202
203 static GtkWidget * mainWidget;
204 static SbPList * components;
205 static SbPList * component_callbacks;
206#endif // __COIN_SOGTK__
207};
208
209// *************************************************************************
210// Here's something InventorWin provides for convenience. Belongs more
211// in the application code domain, imo, but we provide these macros
212// for better compile time compatibility with InventorWin. -mortene
213
214#define SOWX_ENTER_GL_SECTION() do { SoWx::lockGL(); } while(FALSE)
215#define SOWX_LEAVE_GL_SECTION() do { SoWx::unlockGL(); } while(FALSE)
216
217// *************************************************************************
218
219#endif // ! SOWX_H
The SoWx class takes care of Wx initialization and event dispatching.
Definition SoWx.h:81
FatalErrors
Definition SoWx.h:113
@ NO_OPENGL_CANVAS
Definition SoWx.h:115
ABIType
Definition SoWx.h:126
void FatalErrorCB(const SbString errmsg, SoWx::FatalErrors errcode, void *userdata)
Definition SoWx.h:118