Main Page | Modules | Class Hierarchy | Class List | File List | Class Members

SoQtComponent.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2003 by Systems in Motion.  All rights reserved.
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  ("GPL") version 2 as published by the Free Software Foundation.
00009  *  See the file LICENSE.GPL at the root directory of this source
00010  *  distribution for additional information about the GNU GPL.
00011  *
00012  *  For using Coin with software that can not be combined with the GNU
00013  *  GPL, and for taking advantage of the additional benefits of our
00014  *  support services, please contact Systems in Motion about acquiring
00015  *  a Coin Professional Edition License.
00016  *
00017  *  See <URL:http://www.coin3d.org> for more information.
00018  *
00019  *  Systems in Motion, Teknobyen, Abels Gate 5, 7030 Trondheim, NORWAY.
00020  *  <URL:http://www.sim.no>.
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 <wtypes.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   void setClassName(const char * const name);
00100   void setBaseWidget(QWidget * widget);
00101 
00102   void registerWidget(QWidget * widget);
00103   void unregisterWidget(QWidget * widget);
00104 
00105   virtual const char * getDefaultWidgetName(void) const;
00106   virtual const char * getDefaultTitle(void) const;
00107   virtual const char * getDefaultIconTitle(void) const;
00108 
00109   virtual void sizeChanged(const SbVec2s & size);
00110 
00111   void addVisibilityChangeCallback(SoQtComponentVisibilityCB * const func,
00112                                    void * const user = NULL);
00113   void removeVisibilityChangeCallback(SoQtComponentVisibilityCB * const func,
00114                                       void * const user = NULL);
00115 
00116 private:
00117   class SoQtComponentP * pimpl;
00118 #ifndef DOXYGEN_SKIP_THIS
00119   friend class SoGuiComponentP;
00120   friend class SoQtComponentP;
00121 #endif // DOXYGEN_SKIP_THIS
00122 
00123   // FIXME: get rid of remaining toolkit specifics below. 20020611 mortene.
00124 
00125 #ifdef __COIN_SOWIN__
00126 public:
00127   HWND setFocusProxy(HWND widget);
00128   HWND getFocusProxy(void);
00129 
00130 protected:
00131   HWND buildFormWidget(HWND parent);
00132   virtual void windowCloseAction(void);
00133   void setResize(SbBool set);
00134   SbBool getResize(void);
00135 #endif // __COIN_SOWIN__
00136 
00137 #ifdef __COIN_SOXT__
00138 public:
00139   Display * getDisplay(void);
00140   void fitSize(const SbVec2s size);
00141   // FIXME: I guess these should really be part of the common
00142   // API. 20011012 mortene.
00143   void addWindowCloseCallback(SoXtComponentCB * callback, void * closure = NULL);
00144   void removeWindowCloseCallback(SoXtComponentCB * callback, void * closure = NULL);
00145 
00146 protected:
00147   // FIXME: I guess this should perhaps be part of the common API?
00148   // 20011012 mortene.
00149   virtual void windowCloseAction(void);
00150   void invokeVisibilityChangeCallbacks(const SbBool enable) const;
00151   void invokeWindowCloseCallbacks(void) const;
00152 
00153   // FIXME: get rid of these two? 20011012 mortene.
00154   static char * getlabel(unsigned int what);
00155   SbBool firstRealize;
00156 
00157   // FIXME: should this really be protected? Same goes for the other
00158   // toolkits' eventHandler() functions. They also have nameclashes
00159   // with the static So*GLWidget::eventHandler() function. 20011024 mortene.
00160   virtual Boolean sysEventHandler(Widget widget, XEvent * event);
00161 
00162 private:
00163   // FIXME: get rid of this? 20011012 mortene.
00164   static void event_handler(Widget, XtPointer, XEvent *, Boolean *);
00165 #endif // __COIN_SOXT__
00166 
00167 #ifdef __COIN_SOGTK__
00168 protected:
00169   virtual SbBool eventFilter(GtkWidget * object, GdkEvent * event);
00170 private:
00171   static gint eventHandler(GtkWidget * object, GdkEvent * event, gpointer closure);
00172 #endif // __COIN_SOGTK__
00173 };
00174 
00175 // *************************************************************************
00176 
00177 #endif // ! SOQT_COMPONENT_H

Generated on Sat Dec 6 22:19:05 2003 for SoQt by doxygen 1.3.4