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

SoQtComponent.h

00001 /**************************************************************************\
00002  *
00003  *  This file is part of the Coin 3D visualization library.
00004  *  Copyright (C) 1998-2005 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, Postboks 1283, Pirsenteret, 7462 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 <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   // About the wrapping below: this variable was added after SoQt 1.0,
00100   // and before SoXt 1.1. To be able to release SoQt 1.1 from this
00101   // same branch, sizeof(SoQtComponent) needs to be the same as for
00102   // SoQt 1.0, which means we can't add this variable for SoQt.
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   // FIXME!: audit and remove as much as possible of the remaining
00130   // toolkit specific parts below. 20020117 mortene.
00131 
00132 #ifdef __COIN_SOXT__
00133 public:
00134   Display * getDisplay(void);
00135   void fitSize(const SbVec2s size);
00136   // FIXME: I guess these should really be part of the common
00137   // API. 20011012 mortene.
00138   void addWindowCloseCallback(SoXtComponentCB * callback, void * closure = NULL);
00139   void removeWindowCloseCallback(SoXtComponentCB * callback, void * closure = NULL);
00140 
00141 protected:
00142   // FIXME: I guess this should perhaps be part of the common API?
00143   // 20011012 mortene.
00144   void invokeVisibilityChangeCallbacks(const SbBool enable) const;
00145   void invokeWindowCloseCallbacks(void) const;
00146   virtual void windowCloseAction(void);
00147 
00148 private:
00149   // FIXME: get rid of this? 20011012 mortene.
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

Copyright © 1998-2005 by Systems in Motion AS. All rights reserved.

Generated on Wed May 9 11:46:57 2007 for SoQt by Doxygen. 1.5.1