00001 /*======================================================================= 00002 * Copyright 1991-1996, Silicon Graphics, Inc. 00003 * ALL RIGHTS RESERVED 00004 * 00005 * UNPUBLISHED -- Rights reserved under the copyright laws of the United 00006 * States. Use of a copyright notice is precautionary only and does not 00007 * imply publication or disclosure. 00008 * 00009 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: 00010 * Use, duplication or disclosure by the Government is subject to restrictions 00011 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights 00012 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or 00013 * in similar or successor clauses in the FAR, or the DOD or NASA FAR 00014 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc., 00015 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 00016 * 00017 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY 00018 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION, 00019 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY 00020 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON 00021 * GRAPHICS, INC. 00022 **=======================================================================*/ 00023 /*======================================================================= 00024 ** Author : David Mott (MMM yyyy) 00025 ** Modified by : Alain Dumesny (MMM yyyy) 00026 **=======================================================================*/ 00027 /*======================================================================= 00028 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00029 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00030 *** *** 00031 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00032 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00033 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00034 *** *** 00035 *** RESTRICTED RIGHTS LEGEND *** 00036 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00037 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00038 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00039 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00040 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00041 *** *** 00042 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00043 *** BORDEAUX, FRANCE *** 00044 *** ALL RIGHTS RESERVED *** 00045 **=======================================================================*/ 00046 /*======================================================================= 00047 ** Modified by : VSG (MMM YYYY) 00048 **=======================================================================*/ 00049 00050 00051 #ifdef SOQT 00052 # include <Inventor/Qt/SoQtComponent.h> 00053 #elif defined _WIN32 00054 # include <Inventor/Win/SoWinComponent.h> 00055 #else // _WIN32 00056 00057 #ifndef _SO_XT_COMPONENT_H_ 00058 #define _SO_XT_COMPONENT_H_ 00059 00060 #include <X11/Intrinsic.h> 00061 #include <Inventor/SbLinear.h> 00062 #include <Inventor/SbString.h> 00063 #include <Inventor/Gui/SoGuiComponent.h> 00064 #include <Inventor/Xt/SoXtDef.h> 00065 00066 class SbDict; 00067 class SoXtComponent; 00068 class SoCallbackList; 00069 00070 typedef void SoXtComponentCB( void* data, SoXtComponent* v ); 00071 typedef void SoXtComponentVisibilityCB( void* data, SbBool b ); 00072 00144 class SoXtComponent 00145 { 00146 00147 public: 00148 00158 static void displayHelp( const char* filename, UINT contextID ); 00159 00163 virtual void show(); 00164 00168 virtual void hide(); 00169 00180 SbBool isVisible(); 00181 00187 SoWidget getWidget() const { return _baseWidget; } 00188 00194 SbBool isTopLevelShell() const { return m_guiComponent->isTopLevelShell(); } 00195 00200 SoWidget getShellWidget() const { return m_guiComponent->isTopLevelShell() ? parentWidget : NULL; } 00201 00205 SoWidget getParentWidget() const { return parentWidget; } 00206 00210 void setSize( const SbVec2s& size ); 00211 00215 SbVec2s getSize(); 00216 00220 SbBool setFullScreen( const SbBool enable ); 00221 00225 SbBool isFullScreen(void) const; 00226 00232 void setFullScreenEnable( const SbBool enable ); 00233 00238 SbBool isFullScreenEnable() const; 00239 00243 inline Display* getDisplay(); 00244 00253 SoNONUNICODE void setTitle( const char* newTitle ); 00254 00255 00262 void setTitle( const SbString& newTitle ); 00263 00267 SbString getTitle() const { 00268 return m_guiComponent->getTitle(); } 00269 00278 SoNONUNICODE void setIconTitle( const char* newIconTitle ); 00279 00286 void setIconTitle( const SbString& newIconTitle ); 00287 00291 SbString getIconTitle() const { 00292 return m_guiComponent->getIconTitle(); } 00293 00294 00304 void setWindowCloseCallback( SoXtComponentCB* func, void* data = NULL ) 00305 { windowCloseFunc = func; windowCloseData = data; } 00306 00311 static SoXtComponent* getComponent( SoWidget w ); 00312 00317 SbString getWidgetName() const { 00318 return m_guiComponent->getWidgetName(); } 00319 00324 SbString getClassName() const { 00325 return m_guiComponent->getClassName(); } 00326 00327 00328 private: 00329 00330 virtual ~SoXtComponent(); 00331 00332 // Deprecated. Replaced by getWidget(). 00333 SoWidget baseWidget() const { return getWidget(); } 00334 00335 virtual void posChanged( const SbVec2i32&, const SbVec2i32& ) {}; 00336 00337 SoGuiComponent* getGuiComponent() const; 00338 00339 private: 00340 // 00341 // If `parent` widget is suplied AND `buildInsideParent` is TRUE, this 00342 // component will build inside the given parent widget, else 00343 // it will create its own topLevelShell widget (component resides in 00344 // its own window). 00345 // The topLevelShell can either be created under the given 00346 // parent shell (`parent` != NULL) or under the main window. 00347 // 00348 // The name is used for looking up X resource values. If NULL, 00349 // then this component inherits resource values defined for its class. 00350 // 00351 // Calling setBaseWidget is needed for looking up Xt like 00352 // resources in the widget tree. It will use the class name of 00353 // the Inventor component (e.g. SoXtRenderArea) instead of 00354 // the class name of the Motif widget this component employs 00355 // (e.g. XmForm). 00356 // 00357 // Thus apps are able to do this in their app-defaults file: 00358 // 00359 // *SoXtRenderArea*BackgroundColor: salmon 00360 // 00361 SoXtComponent( SoWidget parent = NULL, 00362 const char* name = NULL, 00363 SbBool buildInsideParent = TRUE, 00364 SbBool sync = TRUE ); 00365 00366 SoXtComponent( SoWidget parent, 00367 const char* name, 00368 SbBool buildInsideParent, 00369 SbBool sync, 00370 SoGuiComponent* guiComponent ); 00371 00372 // Subclasses need to call this method passing the top most 00373 // widget after it has been created. 00374 void setBaseWidget( SoWidget w ); 00375 00376 // Subclasses need to set the class name in the constructor 00377 // before the widget is built. 00378 void setClassName( const SbString &n ) { m_guiComponent->setClassName( n ); } 00379 00380 // this routine is called whenever the top level shell widget receives 00381 // a close action (WM_DELETE_WINDOW message) from the window manager. 00382 // Instead of destroying the widget (default shell behavior) this 00383 // routine is used, which by default calls exit(0) if it is the main 00384 // window else calls hide() on the component. 00385 // 00386 virtual void windowCloseAction(); 00387 00388 // Support for doing things right after the widget is realized 00389 // for the first time. 00390 // The base class will set the window and icon title for shell widgets. 00391 virtual void afterRealizeHook(); 00392 SbBool firstRealize; 00393 00394 // 00395 // Subclasses should redefine these routines to return the appropriate 00396 // default information. Those are used when creating the widget to set 00397 // the name (used for resources), window title and window icon 00398 // name. Those default values are only used if the user didn't 00399 // explicitly specify them. 00400 // 00401 virtual SbString getDefaultWidgetName() const; 00402 virtual SbString getDefaultTitle() const; 00403 virtual SbString getDefaultIconTitle() const; 00404 00405 // 00406 // Register widget - should be called by subclasses after 00407 // they have created their top most widget (which is passed here), 00408 // and before they build any child widgets. Calling this method 00409 // ensures that the widgets name and class will be used when 00410 // calls are made to get X resource values for this widget. 00411 // 00412 // *** NOTE *** 00413 // ALL subclasses should register their top most widget within the 00414 // component, whether they retrieve resources or not, so that children 00415 // widgets can get X resources properly. 00416 // Unregister the widget when the widget is destroyed. 00417 // 00418 void registerWidget( SoWidget w ); 00419 void unregisterWidget( SoWidget w ); 00420 00421 // subclasses can add a callback to be called whenever the component 00422 // becomes visible or become hidden (like when it is iconified). 00423 // Sublcasses should use this to attach or detach any sensors they 00424 // have, or stop any ongoing anymation. 00425 void addVisibilityChangeCallback( SoXtComponentVisibilityCB* func, void* userData = NULL ); 00426 void removeVisibilityChangeCallback( SoXtComponentVisibilityCB* func, void* userData = NULL ); 00427 00428 // 00429 // This method can be used by subclasses to open a component help 00430 // card. The name of the file should be supplied withought a path 00431 // name. By default the file will be searched using: 00432 // 1) current working directory 00433 // 2) SO_HELP_DIR environment variable 00434 // 3) /usr/share/help/Inventor 00435 // 4) else bring a no help card found dialog 00436 // 00437 void openHelpCard( const char* cardName ); 00438 00439 // This method is used to get label from resources for Localisation. 00440 static SbString getlabel( unsigned int whatisit );// const; 00441 00442 00443 00444 private: 00445 00446 void constructorCommon( SoWidget parent, const char* name, SbBool buildInsideParent, SbBool sync ); 00447 00448 // Call a web browser to open the passed URL 00449 SbBool callWebBrowser( const char* url ) const; 00450 00451 // widgetDestroyed is called when the widget is destroyed. 00452 // There is no way to reconstruct the widget tree, so calling 00453 // this simply generates an error. The component should be 00454 // deleted to dispose of the widget. 00455 virtual void widgetDestroyed(); 00456 00457 SbBool createdShell; // TRUE if we created that toplevel shell 00458 SoWidget parentWidget; // topLevel shell if in its own window 00459 SoWidget _baseWidget; // returned by getWidget() 00460 SbVec2s size; // size of the '_baseWidget' and 'shell' (if toplevel) 00461 00462 // visibiltity stuff 00463 SbBool visibleState; 00464 SbBool ShellMapped, widgetMapped; 00465 SoCallbackList* visibiltyCBList; 00466 void checkForVisibilityChange(); 00467 static void widgetStructureNotifyCB( SoWidget w, SoXtComponent* p, XEvent* xe, Boolean* b ); 00468 static void shellStructureNotifyCB( SoWidget w, SoXtComponent* p, XEvent* xe, Boolean* b ); 00469 static void widgetDestroyedCB( SoWidget w, XtPointer clientData, XtPointer p ); 00470 00471 // window close action data 00472 SoXtComponentCB* windowCloseFunc; 00473 void* windowCloseData; 00474 static void windowCloseActionCB( SoWidget w, SoXtComponent* v, void* data ); 00475 00476 // The widget dictionary maps widgets to SoXtComponents. It's used 00477 // by getComponent(), and kept up to date by registerWidget(). 00478 static SbDict* widgetDictionary; 00479 00480 // For fullscreen mode. 00481 Dimension posX, posY, width, height; 00482 int m_decorationHints; 00483 int m_functionHints; 00484 00485 SoGuiComponent* m_guiComponent; 00486 00487 }; 00488 00489 // Inline routines 00490 Display* 00491 SoXtComponent::getDisplay() 00492 { 00493 return (_baseWidget != NULL ? XtDisplay(_baseWidget) : NULL); 00494 } 00495 00496 #endif // _SO_XT_COMPONENT_H_ 00497 00498 #endif // _WIN32 00499 00500 00501