Main Page   Modules   Compound List   File List   Compound Members  

SoGtk.h

00001 /**************************************************************************
00002  *
00003  *  This file is part of the Coin GUI binding libraries.
00004  *  Copyright (C) 1998-2001 by Systems in Motion.  All rights reserved.
00005  *
00006  *  The libraries this file is part of is free software; you can
00007  *  redistribute them and/or modify them under the terms of the GNU
00008  *  Lesser General Public License version 2.1 as published by the
00009  *  Free Software Foundation.  See the file LICENSE.LGPL at the root
00010  *  directory of the distribution for all the details.
00011  *
00012  *  If you want to use the Coin GUI binding libraries for applications
00013  *  not compatible with the LGPL, contact SIM about acquiring a
00014  *  Professional Edition License.
00015  *
00016  *  Systems in Motion, Prof Brochs gate 6, N-7030 Trondheim, NORWAY
00017  *  http://www.sim.no/ support@sim.no Voice: +47 22114160 Fax: +47 22207097
00018  *
00019  **************************************************************************/
00020 
00021 #ifndef SOGTK_H
00022 #define SOGTK_H
00023 
00024 #include <Inventor/Gtk/SoGtkBasic.h>
00025 
00026 #ifdef __COIN_SOQT__
00027 #include <qevent.h>
00028 #include <qobject.h>
00029 #endif // __COIN_SOQT__
00030 #ifdef __COIN_SOXT__
00031 #include <X11/Intrinsic.h>
00032 #include <Xm/Xm.h>
00033 #endif // __COIN_SOXT__
00034 #ifdef __COIN_SOGTK__
00035 #include <gtk/gtk.h>
00036 class SoGtkComponent;
00037 class SbPList;
00038 #endif // __COIN_SOGTK__
00039 #ifdef __COIN_SOWIN__
00040 #include <windows.h>
00041 #endif // __COIN_SOWIN__
00042 
00043 #include <Inventor/SbBasic.h>
00044 #include <Inventor/SbLinear.h>
00045 #include <Inventor/SbString.h>
00046 #include <Inventor/SoDB.h>
00047 #include <Inventor/errors/SoDebugError.h>
00048 
00049 // *************************************************************************
00050 
00051 class SOGTK_DLL_API SoGtk
00052 #ifdef __COIN_SOQT__
00053   : public QObject
00054 #endif // __COIN_SOQT__
00055 {
00056   
00057 
00058 public:
00059   static GtkWidget * init(const char * appname, const char * classname = "SoGtk")
00060   {
00061     SOGTK_SANITY_CHECK(GtkWidget * retval = SoGtk::internal_init(appname, classname));
00062     return retval;
00063   }
00064 
00065   static GtkWidget * init(int argc, char ** argv,
00066                        const char * appname, const char * classname = "SoGtk")
00067   {
00068     SOGTK_SANITY_CHECK(GtkWidget * retval = SoGtk::internal_init(argc, argv, appname, classname));
00069     return retval;
00070   }
00071 
00072   static void init(GtkWidget * toplevelwidget) { SOGTK_SANITY_CHECK(SoGtk::internal_init(toplevelwidget)); }
00073 
00074   static void mainLoop(void);
00075   static void exitMainLoop(void);
00076 
00077   static GtkWidget * getTopLevelWidget(void);
00078   static GtkWidget * getShellWidget(const GtkWidget * w);
00079 
00080   static void show(GtkWidget * const widget);
00081   static void hide(GtkWidget * const widget);
00082 
00083   static void setWidgetSize(GtkWidget * const widget, const SbVec2s size);
00084   static SbVec2s getWidgetSize(const GtkWidget * widget);
00085 
00086   static void createSimpleErrorDialog(GtkWidget * widget,
00087                                       const char * dialogTitle,
00088                                       const char * errorStr1,
00089                                       const char * errorStr2 = NULL);
00090 
00091   static void getVersionInfo(int * major = NULL,
00092                              int * minor = NULL,
00093                              int * micro = NULL);
00094   static const char * getVersionString(void);
00095 
00096   enum FatalErrors {
00097     NO_OPENGL_CANVAS = 0,
00098     INTERNAL_ASSERT,
00099     UNSPECIFIED_ERROR
00100   };
00101   typedef void FatalErrorCB(const SbString errmsg, SoGtk::FatalErrors errcode,
00102                             void * userdata);
00103   static FatalErrorCB * setFatalErrorHandler(SoGtk::FatalErrorCB * cb,
00104                                              void * userdata);
00105 
00106 protected:
00107   static SbBool isDebugLibrary(void);
00108   static SbBool isCompatible(unsigned int major, unsigned int minor);
00109   static SoGtkABIType getABIType(void);
00110   static void abort(SoGtkABIError error);
00111 
00112 private:
00113   // Since the class consists solely of static functions, hide the
00114   // default constructor and the destructor so nobody can instantiate
00115   // it.
00116   SoGtk(void);
00117   ~SoGtk();
00118   friend class SoGtkP; // SoQtP needs this to set up an object for the slots.
00119 
00120   static void sensorQueueChanged(void * cbdata);
00121 
00122   static GtkWidget * internal_init(const char * appname, const char * classname);
00123   static GtkWidget * internal_init(int & argc, char ** argv,
00124                                 const char * appname, const char * classname);
00125   static void internal_init(GtkWidget * toplevelwidget);
00126 
00127 
00129 
00130 #ifdef __COIN_SOXT__
00131 public:
00132   static void nextEvent(XtAppContext, XEvent *);
00133   static Boolean dispatchEvent(XEvent * event);
00134   static XtAppContext getAppContext(void);
00135   static Display * getDisplay(void);
00136   static XmString encodeString(const char * const str);
00137   static char * decodeString(XmString xstring);
00138   static void getPopupArgs(Display * display, int screen,
00139                            ArgList args, int * n);
00140 
00141   static void registerColormapLoad(Widget widget, Widget shell);
00142   static void addColormapToShell(Widget widget, Widget shell);
00143   static void removeColormapFromShell(Widget widget, Widget shell);
00144 
00145   static void addExtensionEventHandler(Widget widget,
00146                                        int eventType, XtEventHandler proc,
00147                                        XtPointer clientData);
00148   static void removeExtensionEventHandler(Widget widget,
00149                                           int eventType, XtEventHandler proc,
00150                                           XtPointer clientData);
00151 
00152   static void selectBestVisual(Display * dpy, Visual * & visual,
00153                                Colormap & cmap, int & depth);
00154 
00155   static const char * getAppName(void);
00156   static const char * getAppClass(void);
00157 
00158 protected:
00159   static void getExtensionEventHandler(XEvent * event, Widget & widget,
00160                                        XtEventHandler & proc,
00161                                        XtPointer & clientData);
00162 #endif // __COIN_SOXT__
00163 
00164 #ifdef __COIN_SOWIN__
00165 public:
00166   static BOOL dispatchEvent(MSG * msg);
00167   static SbBool nextEvent(int appContext, MSG * msg);
00168   static void setInstance(HINSTANCE instance);
00169   static HINSTANCE getInstance(void);
00170   static void errorHandlerCB(const class SoError * error, void * data);
00171   static void doIdleTasks(void);
00172 
00173 protected:
00174   friend class SoWinP;
00175 
00176   static void registerWindowClass(const char * const className);
00177   static void unRegisterWindowClass(const char * const className);
00178 
00179   static HWND createWindow(char * title, char * className,
00180                            SIZE size, HWND parent = NULL, HMENU menu = NULL);
00181 
00182   static LRESULT CALLBACK eventHandler(HWND window, UINT message,
00183                                        WPARAM wparam, LPARAM lparam);
00184 
00185 #endif // __COIN_SOWIN__
00186 
00187 #ifdef __COIN_SOQT__
00188 public:
00189   enum CustomEventId { SPACEBALL_EVENT = QEvent::User };
00190   static class QApplication * getApplication(void);
00191 
00192 protected:
00193   bool eventFilter(QObject *, QEvent *);
00194 
00195 private slots:
00196   void slot_timedOutSensor(void);
00197   void slot_idleSensor(void);
00198   void slot_delaytimeoutSensor(void);
00199 #endif // __COIN_SOQT__
00200 
00201 #ifdef __COIN_SOGTK__
00202 public:
00203   friend class SoGtkComponent;
00204   enum SoGtkComponentAction { CREATION, DESTRUCTION, CHANGE };
00205   typedef void SoGtkComponentActionCallback(SoGtkComponent *, SoGtk::SoGtkComponentAction, void *);
00206 
00207   static void addComponentActionCallback(SoGtkComponentActionCallback *, void *);
00208   static void removeComponentActionCallback(SoGtkComponentActionCallback *, void *);
00209 
00210   static int getComponents(SbPList & components);
00211 
00212 protected:
00213   static void invokeComponentActionCallbacks(SoGtkComponent * component,
00214                                              SoGtkComponentAction action);
00215 
00216   static gint componentCreation(SoGtkComponent * component);
00217   static gint componentDestruction(SoGtkComponent * component);
00218   static gint componentChange(SoGtkComponent * component);
00219 
00220 private:
00221   static gint timerSensorCB(gpointer data);
00222   static gint idleSensorCB(gpointer data);
00223   static gint delaySensorCB(gpointer data);
00224 
00225   static GtkWidget * mainWidget;
00226   static SbPList * components;
00227   static SbPList * component_callbacks;
00228 #endif // __COIN_SOGTK__
00229 };
00230 
00231 // *************************************************************************
00232 
00233 #endif // ! SOGTK_H

Generated at Tue Mar 5 03:33:42 2002 for SoGtk by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001