Coin Logo http://www.sim.no
http://www.coin3d.org

SoQt.h
1 #ifndef SOQT_H
2 #define SOQT_H
3 
4 // src/Inventor/Qt/SoQt.h. Generated from SoGui.h.in by configure.
5 
6 /**************************************************************************\
7  *
8  * This file is part of the Coin 3D visualization library.
9  * Copyright (C) by Kongsberg Oil & Gas Technologies.
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * ("GPL") version 2 as published by the Free Software Foundation.
14  * See the file LICENSE.GPL at the root directory of this source
15  * distribution for additional information about the GNU GPL.
16  *
17  * For using Coin with software that can not be combined with the GNU
18  * GPL, and for taking advantage of the additional benefits of our
19  * support services, please contact Kongsberg Oil & Gas Technologies
20  * about acquiring a Coin Professional Edition License.
21  *
22  * See http://www.coin3d.org/ for more information.
23  *
24  * Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
25  * http://www.sim.no/ sales@sim.no coin-support@coin3d.org
26  *
27 \**************************************************************************/
28 
29 #include <Inventor/Qt/SoQtBasic.h>
30 
31 // FIXME: use configure defines for the header files.
32 // 20020613 mortene.
33 
34 #ifdef __COIN_SOQT__
35 
36 #if QT_VERSION >= 0x040000
37 #include <QtCore/QObject>
38 #else
39 #include <qobject.h>
40 #endif
41 
42 #endif // __COIN_SOQT__
43 #ifdef __COIN_SOXT__
44 #include <X11/Intrinsic.h>
45 #include <Xm/Xm.h>
46 #endif // __COIN_SOXT__
47 #ifdef __COIN_SOGTK__
48 // Fetch stdlib.h, so NULL is defined before glib.h is (indirectly)
49 // included. Otherwise we get a compile error with KCC on some
50 // systems.
51 #include <stdlib.h>
52 #include <gtk/gtk.h>
53 class SoGtkComponent;
54 class SbPList;
55 #endif // __COIN_SOGTK__
56 #ifdef __COIN_SOWIN__
57 #include <windows.h>
58 #endif // __COIN_SOWIN__
59 
60 #include <Inventor/SbBasic.h>
61 #include <Inventor/SbLinear.h>
62 #include <Inventor/SbString.h>
63 #include <Inventor/SoDB.h>
64 #include <Inventor/errors/SoDebugError.h>
65 
66 // *************************************************************************
67 
68 class SOQT_DLL_API SoQt
69 {
70 
71 public:
72  static QWidget * init(const char * appname, const char * classname = "SoQt");
73  static QWidget * init(int & argc, char ** argv,
74  const char * appname, const char * classname = "SoQt");
75  static void init(QWidget * toplevelwidget);
76 
77  static void mainLoop(void);
78  static void exitMainLoop(void);
79  static void done(void);
80 
81  static QWidget * getTopLevelWidget(void);
82  static QWidget * getShellWidget(const QWidget * w);
83 
84  static void show(QWidget * const widget);
85  static void hide(QWidget * const widget);
86 
87  static void setWidgetSize(QWidget * const widget, const SbVec2s size);
88  static SbVec2s getWidgetSize(const QWidget * widget);
89 
90  static void createSimpleErrorDialog(QWidget * widget,
91  const char * title,
92  const char * string1,
93  const char * string2 = NULL);
94 
95  static void getVersionInfo(int * major = NULL,
96  int * minor = NULL,
97  int * micro = NULL);
98  static const char * getVersionString(void);
99  static const char * getVersionToolkitString(void);
100 
101  enum FatalErrors {
102  UNSPECIFIED_ERROR = 0,
104  INTERNAL_ASSERT
105  };
106  typedef void FatalErrorCB(const SbString errmsg, SoQt::FatalErrors errcode,
107  void * userdata);
108  static FatalErrorCB * setFatalErrorHandler(SoQt::FatalErrorCB * cb,
109  void * userdata);
110 
111  static SbBool isDebugLibrary(void);
112  static SbBool isCompatible(unsigned int major, unsigned int minor);
113 
114  enum ABIType { DLL, LIB, UNKNOWN };
115  static ABIType getABIType(void);
116 
117  static void lockGL(void);
118  static void unlockGL(void);
119 
120 private:
121  // Since the class consists solely of static functions, hide the
122  // default constructor and the destructor so nobody can instantiate
123  // it.
124  SoQt(void);
125  virtual ~SoQt();
126 
127  friend class SoGuiP;
128  friend class SoQtP;
129 
130 
131  // FIXME!: audit and remove as much as possible of the remaining
132  // toolkit specific parts below. 20020117 mortene.
133 
134 #ifdef __COIN_SOXT__
135 public:
136  static void nextEvent(XtAppContext, XEvent *);
137  static Boolean dispatchEvent(XEvent * event);
138  static XtAppContext getAppContext(void);
139  static Display * getDisplay(void);
140  static XmString encodeString(const char * const str);
141  static char * decodeString(XmString xstring);
142  static void getPopupArgs(Display * display, int screen,
143  ArgList args, int * n);
144 
145  static void registerColormapLoad(Widget widget, Widget shell);
146  static void addColormapToShell(Widget widget, Widget shell);
147  static void removeColormapFromShell(Widget widget, Widget shell);
148 
149  static void addExtensionEventHandler(Widget widget,
150  int eventType, XtEventHandler proc,
151  XtPointer clientData);
152  static void removeExtensionEventHandler(Widget widget,
153  int eventType, XtEventHandler proc,
154  XtPointer clientData);
155 
156 protected:
157  static void getExtensionEventHandler(XEvent * event, Widget & widget,
158  XtEventHandler & proc,
159  XtPointer & clientData);
160 #endif // __COIN_SOXT__
161 
162 #ifdef __COIN_SOGTK__
163 public:
164  friend class SoGtkComponent;
165  enum SoGtkComponentAction { CREATION, DESTRUCTION, CHANGE };
166  typedef void SoGtkComponentActionCallback(SoGtkComponent *, SoGtk::SoGtkComponentAction, void *);
167 
168  static void addComponentActionCallback(SoGtkComponentActionCallback *, void *);
169  static void removeComponentActionCallback(SoGtkComponentActionCallback *, void *);
170 
171  static int getComponents(SbPList & components);
172 
173 protected:
174  static void invokeComponentActionCallbacks(SoGtkComponent * component,
175  SoGtkComponentAction action);
176 
177  static gint componentCreation(SoGtkComponent * component);
178  static gint componentDestruction(SoGtkComponent * component);
179  static gint componentChange(SoGtkComponent * component);
180 
181 private:
182  static gint timerSensorCB(gpointer data);
183  static gint idleSensorCB(gpointer data);
184  static gint delaySensorCB(gpointer data);
185 
186  static GtkWidget * mainWidget;
187  static SbPList * components;
188  static SbPList * component_callbacks;
189 #endif // __COIN_SOGTK__
190 };
191 
192 // *************************************************************************
193 // Here's something InventorWin provides for convenience. Belongs more
194 // in the application code domain, imo, but we provide these macros
195 // for better compile time compatibility with InventorWin. -mortene
196 
197 #define SOQT_ENTER_GL_SECTION() do { SoQt::lockGL(); } while(FALSE)
198 #define SOQT_LEAVE_GL_SECTION() do { SoQt::unlockGL(); } while(FALSE)
199 
200 // *************************************************************************
201 
202 #endif // ! SOQT_H

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated on Fri Aug 3 2012 for SoQt by Doxygen 1.8.1.1.