00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef SOQT_H
00027 #define SOQT_H
00028
00029 #include <Inventor/Qt/SoQtBasic.h>
00030
00031
00032
00033
00034 #ifdef __COIN_SOQT__
00035 #include <qobject.h>
00036 #endif // __COIN_SOQT__
00037 #ifdef __COIN_SOXT__
00038 #include <X11/Intrinsic.h>
00039 #include <Xm/Xm.h>
00040 #endif // __COIN_SOXT__
00041 #ifdef __COIN_SOGTK__
00042
00043
00044
00045 #include <stdlib.h>
00046 #include <gtk/gtk.h>
00047 class SoGtkComponent;
00048 class SbPList;
00049 #endif // __COIN_SOGTK__
00050 #ifdef __COIN_SOWIN__
00051 #include <windows.h>
00052 #endif // __COIN_SOWIN__
00053
00054 #include <Inventor/SbBasic.h>
00055 #include <Inventor/SbLinear.h>
00056 #include <Inventor/SbString.h>
00057 #include <Inventor/SoDB.h>
00058 #include <Inventor/errors/SoDebugError.h>
00059
00060
00061
00062 class SOQT_DLL_API SoQt
00063 {
00064
00065 public:
00066 static QWidget * init(const char * appname, const char * classname = "SoQt");
00067 static QWidget * init(int & argc, char ** argv,
00068 const char * appname, const char * classname = "SoQt");
00069 static void init(QWidget * toplevelwidget);
00070
00071 static void mainLoop(void);
00072 static void exitMainLoop(void);
00073 static void done(void);
00074
00075 static QWidget * getTopLevelWidget(void);
00076 static QWidget * getShellWidget(const QWidget * w);
00077
00078 static void show(QWidget * const widget);
00079 static void hide(QWidget * const widget);
00080
00081 static void setWidgetSize(QWidget * const widget, const SbVec2s size);
00082 static SbVec2s getWidgetSize(const QWidget * widget);
00083
00084 static void createSimpleErrorDialog(QWidget * widget,
00085 const char * title,
00086 const char * string1,
00087 const char * string2 = NULL);
00088
00089 static void getVersionInfo(int * major = NULL,
00090 int * minor = NULL,
00091 int * micro = NULL);
00092 static const char * getVersionString(void);
00093
00094 enum FatalErrors {
00095 UNSPECIFIED_ERROR = 0,
00096 NO_OPENGL_CANVAS,
00097 INTERNAL_ASSERT
00098 };
00099 typedef void FatalErrorCB(const SbString errmsg, SoQt::FatalErrors errcode,
00100 void * userdata);
00101 static FatalErrorCB * setFatalErrorHandler(SoQt::FatalErrorCB * cb,
00102 void * userdata);
00103
00104 static SbBool isDebugLibrary(void);
00105 static SbBool isCompatible(unsigned int major, unsigned int minor);
00106
00107 enum ABIType { DLL, LIB, UNKNOWN };
00108 static ABIType getABIType(void);
00109
00110 private:
00111
00112
00113
00114 SoQt(void);
00115 virtual ~SoQt();
00116
00117 #ifndef DOXYGEN_SKIP_THIS // To avoid having it show up in Doxygen doc.
00118 friend class SoGuiP;
00119 friend class SoQtP;
00120 #endif // DOXYGEN_SKIP_THIS
00121
00122
00124
00125 #ifdef __COIN_SOXT__
00126 public:
00127 static void nextEvent(XtAppContext, XEvent *);
00128 static Boolean dispatchEvent(XEvent * event);
00129 static XtAppContext getAppContext(void);
00130 static Display * getDisplay(void);
00131 static XmString encodeString(const char * const str);
00132 static char * decodeString(XmString xstring);
00133 static void getPopupArgs(Display * display, int screen,
00134 ArgList args, int * n);
00135
00136 static void registerColormapLoad(Widget widget, Widget shell);
00137 static void addColormapToShell(Widget widget, Widget shell);
00138 static void removeColormapFromShell(Widget widget, Widget shell);
00139
00140 static void addExtensionEventHandler(Widget widget,
00141 int eventType, XtEventHandler proc,
00142 XtPointer clientData);
00143 static void removeExtensionEventHandler(Widget widget,
00144 int eventType, XtEventHandler proc,
00145 XtPointer clientData);
00146
00147 static void selectBestVisual(Display * dpy, Visual * & visual,
00148 Colormap & cmap, int & depth);
00149
00150 static const char * getAppName(void);
00151 static const char * getAppClass(void);
00152
00153 protected:
00154 static void getExtensionEventHandler(XEvent * event, Widget & widget,
00155 XtEventHandler & proc,
00156 XtPointer & clientData);
00157 #endif // __COIN_SOXT__
00158
00159 #ifdef __COIN_SOWIN__
00160 public:
00161 static BOOL dispatchEvent(MSG * msg);
00162 static SbBool nextEvent(int appContext, MSG * msg);
00163 static void setInstance(HINSTANCE instance);
00164 static HINSTANCE getInstance(void);
00165 static void doIdleTasks(void);
00166
00167 protected:
00168 friend class SoWinP;
00169
00170 static void registerWindowClass(const char * const className);
00171 static void unRegisterWindowClass(const char * const className);
00172
00173 static HWND createWindow(char * title, char * className,
00174 SIZE size, HWND parent = NULL, HMENU menu = NULL);
00175
00176 static LRESULT CALLBACK eventHandler(HWND window, UINT message,
00177 WPARAM wparam, LPARAM lparam);
00178
00179 #endif // __COIN_SOWIN__
00180
00181 #ifdef __COIN_SOGTK__
00182 public:
00183 friend class SoGtkComponent;
00184 enum SoGtkComponentAction { CREATION, DESTRUCTION, CHANGE };
00185 typedef void SoGtkComponentActionCallback(SoGtkComponent *, SoGtk::SoGtkComponentAction, void *);
00186
00187 static void addComponentActionCallback(SoGtkComponentActionCallback *, void *);
00188 static void removeComponentActionCallback(SoGtkComponentActionCallback *, void *);
00189
00190 static int getComponents(SbPList & components);
00191
00192 protected:
00193 static void invokeComponentActionCallbacks(SoGtkComponent * component,
00194 SoGtkComponentAction action);
00195
00196 static gint componentCreation(SoGtkComponent * component);
00197 static gint componentDestruction(SoGtkComponent * component);
00198 static gint componentChange(SoGtkComponent * component);
00199
00200 private:
00201 static gint timerSensorCB(gpointer data);
00202 static gint idleSensorCB(gpointer data);
00203 static gint delaySensorCB(gpointer data);
00204
00205 static GtkWidget * mainWidget;
00206 static SbPList * components;
00207 static SbPList * component_callbacks;
00208 #endif // __COIN_SOGTK__
00209 };
00210
00211
00212
00213 #endif // ! SOQT_H