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 #ifndef _SO_QT_COMPONENT_
00026 #define _SO_QT_COMPONENT_
00027
00028 #include <Inventor/Qt/OivQtCompat.h>
00029
00030 #include <QString>
00031 #include <QPointer>
00032
00033 #include <Inventor/Qt/SoQt.h>
00034 #include <Inventor/Gui/SoGuiComponent.h>
00035
00036 #include <Inventor/SbBasic.h>
00037 #include <Inventor/SbString.h>
00038 #include <Inventor/SbDict.h>
00039
00040 #if defined(__APPLE__)
00041 # undef Display
00042 #endif
00043
00044 class SoQtComponent;
00045
00046 typedef void SoQtComponentCB( void* userData, SoQtComponent* comp );
00047
00100 class SoQtComponent : public QObject
00101 {
00102 Q_OBJECT
00103
00104 public:
00105
00109 virtual void show();
00110
00114 virtual void hide();
00115
00121 SbBool isVisible();
00122
00126 virtual QWidget* getWidget() const { return _baseWidget; }
00127
00133 SbBool isTopLevelShell() const { return m_guiComponent->isTopLevelShell(); }
00134
00139 QWidget* getShellWidget() const { return m_guiComponent->isTopLevelShell() ? parentWidget : NULL; }
00140
00144 QWidget* getParentWidget() const { return parentWidget; }
00145
00149 void setSize( const SbVec2s& size );
00150
00154 SbVec2s getSize();
00161 virtual SbBool setFullScreen( const SbBool enable );
00162
00166 SbBool isFullScreen( void ) const;
00167
00173 void setFullScreenEnable( const SbBool enable );
00174
00179 SbBool isFullScreenEnable(void) const;
00180
00184 inline SbGlContextHelper::Display getDisplay();
00185
00192 void setTitle( const char* newTitle );
00193
00200 void setTitle( const SbString& newTitle );
00201
00208 void setTitle( const QString& newTitle );
00209
00213 const QString getTitle() const;
00214
00218 void setIconTitle( const QString& newIconTitle );
00219
00223 const QString getIconTitle() const;
00224
00229 static SoQtComponent* getComponent( QWidget* widget );
00230
00235 SbString getWidgetName() const;
00236
00241 SbString getClassName() const;
00242
00246 SbString helpFileName;
00247
00248 #ifdef _WIN32
00249
00253 UINT helpContextID;
00254 #endif
00255
00265 void setWindowCloseCallback( SoQtComponentCB* func, void* data = NULL )
00266 { m_windowCloseFunc = func; m_windowCloseData = data; }
00267
00268
00269 private:
00270
00271 virtual ~SoQtComponent();
00272
00273 void setFullScreenOn( SbBool enable ) { m_guiComponent->setFullScreen( enable ); };
00274
00275 static void finish();
00276
00277 SoGuiComponent* getGuiComponent() const;
00278
00279 Q_SIGNALS:
00280 #ifndef HIDDEN_FROM_DOC
00281 void visibilityChanged(SbBool visible);
00282 #endif // HIDDEN_FROM_DOC
00283
00284 private:
00285
00286 SoQtComponent( QWidget* parent = NULL,
00287 const char* name = NULL,
00288 SbBool buildInsideParent = TRUE,
00289 SbBool sync = TRUE );
00290
00291 SoQtComponent( QWidget* parent,
00292 const char* name,
00293 SbBool buildInsideParent,
00294 SbBool sync,
00295 SoGuiComponent* guiComponent );
00296
00297 void setBaseWidget( QWidget* w );
00298
00299 void setClassName( const char* n ) { m_guiComponent->setClassName( n ); }
00300
00301 virtual void afterRealizeHook();
00302
00303
00304 SbBool firstRealize;
00305
00306 virtual SbString getDefaultWidgetName() const;
00307 virtual SbString getDefaultTitle() const;
00308 virtual SbString getDefaultIconTitle() const;
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323 void registerWidget( QWidget* w );
00324 void unregisterWidget( QWidget* w );
00325
00326 #ifdef _WIN32
00327
00328 static HPALETTE _setupColorPalette( HDC );
00329 #endif //_WIN32
00330
00331 virtual bool eventFilter( QObject* object,QEvent *event );
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341 void openHelpCard( const char* cardName );
00342
00343 static void windowCloseActionCB( SoWidget widget, SoQtComponent* p, void* data );
00344
00345 private:
00346 #ifdef _WIN32
00347 const char* buildHelpPath( const char* filename );
00348 #endif
00349 void constructorCommon( QWidget* parent, const char* name, SbBool buildInsideParent, SbBool sync );
00350
00351
00352 SoGuiComponent* m_guiComponent;
00353
00354 SbBool createdShell;
00355 QWidget* parentWidget;
00356 QPointer<QWidget> _baseWidget;
00357
00358 SbVec2s size;
00359
00360
00361
00362 static SbDict* widgetDictionary;
00363
00364
00365 SbBool wasTopLevel;
00366
00367 QWidget* m_oldParentWidget;
00368 QRect m_oldGeometry;
00369 int m_widgetIndex;
00370
00371
00372 SoQtComponentCB* m_windowCloseFunc;
00373 void* m_windowCloseData;
00374 };
00375
00376
00377 SbGlContextHelper::Display
00378 SoQtComponent::getDisplay()
00379 {
00380 return SoQt::getDisplay();
00381 }
00382
00383 inline const QString
00384 SoQtComponent::getTitle() const
00385 {
00386 return QString::fromUtf16( m_guiComponent->getTitle().toUtf16() );
00387 }
00388
00389 inline const QString
00390 SoQtComponent::getIconTitle() const
00391 {
00392 return QString::fromUtf16( m_guiComponent->getIconTitle().toUtf16() );
00393 }
00394
00395 inline SbString
00396 SoQtComponent::getClassName() const
00397 {
00398 return m_guiComponent->getClassName();
00399 }
00400
00401 inline SbString
00402 SoQtComponent::getWidgetName() const
00403 {
00404 return m_guiComponent->getWidgetName();
00405 }
00406
00407 #endif // _SO_QT_COMPONENT_
00408
00409
00410