00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef SOQT_COMPONENT_H
00025 #define SOQT_COMPONENT_H
00026
00027 #include <Inventor/SbLinear.h>
00028 #include <Inventor/Qt/SoQtObject.h>
00029
00030 #ifdef __COIN_SOQT__
00031 class QWidget;
00032 #endif // __COIN_SOQT__
00033 #ifdef __COIN_SOXT__
00034 #include <X11/Intrinsic.h>
00035 #endif // __COIN_SOXT__
00036 #ifdef __COIN_SOGTK__
00037 #include <gtk/gtk.h>
00038 #endif // __COIN_SOGTK__
00039 #ifdef __COIN_SOWIN__
00040 #include <windows.h>
00041 #endif // __COIN_SOWIN__
00042
00043
00044 class SoQtComponent;
00045 class SoQtCursor;
00046
00047 typedef void SoQtComponentCB(void * user, SoQtComponent * component);
00048 typedef void SoQtComponentVisibilityCB(void * user, SbBool visible);
00049
00050
00051
00052 class SOQT_DLL_API SoQtComponent : public SoQtObject {
00053 SOQT_OBJECT_ABSTRACT_HEADER(SoQtComponent, SoQtObject);
00054
00055 public:
00056 virtual ~SoQtComponent();
00057
00058 virtual void show(void);
00059 virtual void hide(void);
00060
00061 virtual void setComponentCursor(const SoQtCursor & cursor);
00062 static void setWidgetCursor(QWidget * w, const SoQtCursor & cursor);
00063
00064 SbBool isFullScreen(void) const;
00065 SbBool setFullScreen(const SbBool onoff);
00066
00067 SbBool isVisible(void);
00068 SbBool isTopLevelShell(void) const;
00069
00070 QWidget * getWidget(void) const;
00071 QWidget * getBaseWidget(void) const;
00072 QWidget * getShellWidget(void) const;
00073 QWidget * getParentWidget(void) const;
00074
00075 void setSize(const SbVec2s size);
00076 SbVec2s getSize(void) const;
00077
00078 void setTitle(const char * const title);
00079 const char * getTitle(void) const;
00080 void setIconTitle(const char * const title);
00081 const char * getIconTitle(void) const;
00082
00083 const char * getWidgetName(void) const;
00084 const char * getClassName(void) const;
00085
00086 void setWindowCloseCallback(SoQtComponentCB * const func,
00087 void * const user = NULL);
00088 static SoQtComponent * getComponent(QWidget * widget);
00089
00090 static void initClasses(void);
00091
00092 protected:
00093 SoQtComponent(QWidget * const parent = NULL,
00094 const char * const name = NULL,
00095 const SbBool embed = TRUE);
00096
00097 virtual void afterRealizeHook(void);
00098
00099
00100
00101
00102
00103 #ifndef __COIN_SOQT__
00104 SbBool firstRealize;
00105 #endif // __COIN_SOQT__
00106
00107 void setClassName(const char * const name);
00108 void setBaseWidget(QWidget * widget);
00109
00110 void registerWidget(QWidget * widget);
00111 void unregisterWidget(QWidget * widget);
00112
00113 virtual const char * getDefaultWidgetName(void) const;
00114 virtual const char * getDefaultTitle(void) const;
00115 virtual const char * getDefaultIconTitle(void) const;
00116
00117 virtual void sizeChanged(const SbVec2s & size);
00118
00119 void addVisibilityChangeCallback(SoQtComponentVisibilityCB * const func,
00120 void * const user = NULL);
00121 void removeVisibilityChangeCallback(SoQtComponentVisibilityCB * const func,
00122 void * const user = NULL);
00123
00124 private:
00125 class SoQtComponentP * pimpl;
00126 friend class SoGuiComponentP;
00127 friend class SoQtComponentP;
00128
00129
00130
00131
00132 #ifdef __COIN_SOXT__
00133 public:
00134 Display * getDisplay(void);
00135 void fitSize(const SbVec2s size);
00136
00137
00138 void addWindowCloseCallback(SoXtComponentCB * callback, void * closure = NULL);
00139 void removeWindowCloseCallback(SoXtComponentCB * callback, void * closure = NULL);
00140
00141 protected:
00142
00143
00144 void invokeVisibilityChangeCallbacks(const SbBool enable) const;
00145 void invokeWindowCloseCallbacks(void) const;
00146 virtual void windowCloseAction(void);
00147
00148 private:
00149
00150 static void event_handler(Widget, XtPointer, XEvent *, Boolean *);
00151 #endif // __COIN_SOXT__
00152
00153 #ifdef __COIN_SOGTK__
00154 protected:
00155 virtual SbBool eventFilter(GtkWidget * object, GdkEvent * event);
00156 private:
00157 static gint eventHandler(GtkWidget * object, GdkEvent * event, gpointer closure);
00158 #endif // __COIN_SOGTK__
00159 };
00160
00161
00162
00163 #endif // ! SOQT_COMPONENT_H