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 SOWX 00054 # include <Inventor/Wx/SoWxComponent.h> 00055 #elif defined _WIN32 00056 # include <Inventor/Win/SoWinComponent.h> 00057 #else // _WIN32 00058 00059 #ifndef _SO_XT_COMPONENT_H_ 00060 #define _SO_XT_COMPONENT_H_ 00061 00062 #include <X11/Intrinsic.h> 00063 #include <Inventor/SbLinear.h> 00064 #include <Inventor/SbString.h> 00065 #include <Inventor/Gui/SoGuiComponent.h> 00066 #include <Inventor/Xt/SoXtDef.h> 00067 00068 class SbDict; 00069 class SoXtComponent; 00070 class SoCallbackList; 00071 00072 typedef void SoXtComponentCB( void* data, SoXtComponent* v ); 00073 typedef void SoXtComponentVisibilityCB( void* data, SbBool b ); 00074 00147 class SoXtComponent 00148 { 00149 00150 public: 00151 00161 static void displayHelp( const char* filename, UINT contextID ); 00162 00166 virtual void show(); 00167 00171 virtual void hide(); 00172 00183 SbBool isVisible(); 00184 00190 SoWidget getWidget() const { return _baseWidget; } 00191 00197 SbBool isTopLevelShell() const { return m_guiComponent->isTopLevelShell(); } 00198 00203 SoWidget getShellWidget() const { return m_guiComponent->isTopLevelShell() ? parentWidget : NULL; } 00204 00208 SoWidget getParentWidget() const { return parentWidget; } 00209 00213 void setSize( const SbVec2s& size ); 00214 00218 SbVec2s getSize(); 00219 00223 SbBool setFullScreen( const SbBool enable ); 00224 00228 SbBool isFullScreen(void) const; 00229 00235 void setFullScreenEnable( const SbBool enable ); 00236 00241 SbBool isFullScreenEnable() const; 00242 00246 SbBool isDirectViz(void) const; 00247 00251 void setDirectVizEnable(const SbBool enable); 00252 00257 SbBool isDirectVizEnable(void) const; 00258 00262 inline Display* getDisplay(); 00263 00272 SoNONUNICODE void setTitle( const char* newTitle ); 00273 00274 00281 void setTitle( const SbString& newTitle ); 00282 00286 SbString getTitle() const { 00287 return m_guiComponent->getTitle(); } 00288 00297 SoNONUNICODE void setIconTitle( const char* newIconTitle ); 00298 00305 void setIconTitle( const SbString& newIconTitle ); 00306 00310 SbString getIconTitle() const { 00311 return m_guiComponent->getIconTitle(); } 00312 00313 00323 void setWindowCloseCallback( SoXtComponentCB* func, void* data = NULL ) 00324 { windowCloseFunc = func; windowCloseData = data; } 00325 00330 static SoXtComponent* getComponent( SoWidget w ); 00331 00336 SbString getWidgetName() const { 00337 return m_guiComponent->getWidgetName(); } 00338 00343 SbString getClassName() const { 00344 return m_guiComponent->getClassName(); } 00345 00346 00347 private: 00348 00349 virtual ~SoXtComponent(); 00350 00351 // Deprecated. Replaced by getWidget(). 00352 SoWidget baseWidget() const { return getWidget(); } 00353 00354 virtual void posChanged( const SbVec2i32&, const SbVec2i32& ) {}; 00355 00356 SoGuiComponent* getGuiComponent() const; 00357 00358 private: 00359 // 00360 // If `parent` widget is suplied AND `buildInsideParent` is TRUE, this 00361 // component will build inside the given parent widget, else 00362 // it will create its own topLevelShell widget (component resides in 00363 // its own window). 00364 // The topLevelShell can either be created under the given 00365 // parent shell (`parent` != NULL) or under the main window. 00366 // 00367 // The name is used for looking up X resource values. If NULL, 00368 // then this component inherits resource values defined for its class. 00369 // 00370 // Calling setBaseWidget is needed for looking up Xt like 00371 // resources in the widget tree. It will use the class name of 00372 // the Inventor component (e.g. SoXtRenderArea) instead of 00373 // the class name of the Motif widget this component employs 00374 // (e.g. XmForm). 00375 // 00376 // Thus apps are able to do this in their app-defaults file: 00377 // 00378 // *SoXtRenderArea*BackgroundColor: salmon 00379 // 00380 SoXtComponent( SoWidget parent = NULL, 00381 const char* name = NULL, 00382 SbBool buildInsideParent = TRUE, 00383 SbBool sync = TRUE ); 00384 00385 SoXtComponent( SoWidget parent, 00386 const char* name, 00387 SbBool buildInsideParent, 00388 SbBool sync, 00389 SoGuiComponent* guiComponent ); 00390 00391 // Subclasses need to call this method passing the top most 00392 // widget after it has been created. 00393 void setBaseWidget( SoWidget w ); 00394 00395 // Subclasses need to set the class name in the constructor 00396 // before the widget is built. 00397 void setClassName( const SbString &n ) { m_guiComponent->setClassName( n ); } 00398 00399 // this routine is called whenever the top level shell widget receives 00400 // a close action (WM_DELETE_WINDOW message) from the window manager. 00401 // Instead of destroying the widget (default shell behavior) this 00402 // routine is used, which by default calls exit(0) if it is the main 00403 // window else calls hide() on the component. 00404 // 00405 virtual void windowCloseAction(); 00406 00407 // Support for doing things right after the widget is realized 00408 // for the first time. 00409 // The base class will set the window and icon title for shell widgets. 00410 virtual void afterRealizeHook(); 00411 SbBool firstRealize; 00412 00413 // 00414 // Subclasses should redefine these routines to return the appropriate 00415 // default information. Those are used when creating the widget to set 00416 // the name (used for resources), window title and window icon 00417 // name. Those default values are only used if the user didn't 00418 // explicitly specify them. 00419 // 00420 virtual SbString getDefaultWidgetName() const; 00421 virtual SbString getDefaultTitle() const; 00422 virtual SbString getDefaultIconTitle() const; 00423 00424 // 00425 // Register widget - should be called by subclasses after 00426 // they have created their top most widget (which is passed here), 00427 // and before they build any child widgets. Calling this method 00428 // ensures that the widgets name and class will be used when 00429 // calls are made to get X resource values for this widget. 00430 // 00431 // *** NOTE *** 00432 // ALL subclasses should register their top most widget within the 00433 // component, whether they retrieve resources or not, so that children 00434 // widgets can get X resources properly. 00435 // Unregister the widget when the widget is destroyed. 00436 // 00437 void registerWidget( SoWidget w ); 00438 void unregisterWidget( SoWidget w ); 00439 00440 // subclasses can add a callback to be called whenever the component 00441 // becomes visible or become hidden (like when it is iconified). 00442 // Sublcasses should use this to attach or detach any sensors they 00443 // have, or stop any ongoing anymation. 00444 void addVisibilityChangeCallback( SoXtComponentVisibilityCB* func, void* userData = NULL ); 00445 void removeVisibilityChangeCallback( SoXtComponentVisibilityCB* func, void* userData = NULL ); 00446 00447 // 00448 // This method can be used by subclasses to open a component help 00449 // card. The name of the file should be supplied withought a path 00450 // name. By default the file will be searched using: 00451 // 1) current working directory 00452 // 2) SO_HELP_DIR environment variable 00453 // 3) /usr/share/help/Inventor 00454 // 4) else bring a no help card found dialog 00455 // 00456 void openHelpCard( const char* cardName ); 00457 00458 // This method is used to get label from resources for Localisation. 00459 static SbString getlabel( unsigned int whatisit );// const; 00460 00461 00462 00463 private: 00464 00465 void constructorCommon( SoWidget parent, const char* name, SbBool buildInsideParent, SbBool sync ); 00466 00467 // Call a web browser to open the passed URL 00468 SbBool callWebBrowser( const char* url ) const; 00469 00470 // widgetDestroyed is called when the widget is destroyed. 00471 // There is no way to reconstruct the widget tree, so calling 00472 // this simply generates an error. The component should be 00473 // deleted to dispose of the widget. 00474 virtual void widgetDestroyed(); 00475 00476 SbBool createdShell; // TRUE if we created that toplevel shell 00477 SoWidget parentWidget; // topLevel shell if in its own window 00478 SoWidget _baseWidget; // returned by getWidget() 00479 SbVec2s size; // size of the '_baseWidget' and 'shell' (if toplevel) 00480 00481 // visibiltity stuff 00482 SbBool visibleState; 00483 SbBool ShellMapped, widgetMapped; 00484 SoCallbackList* visibiltyCBList; 00485 void checkForVisibilityChange(); 00486 static void widgetStructureNotifyCB( SoWidget w, SoXtComponent* p, XEvent* xe, Boolean* b ); 00487 static void shellStructureNotifyCB( SoWidget w, SoXtComponent* p, XEvent* xe, Boolean* b ); 00488 static void widgetDestroyedCB( SoWidget w, XtPointer clientData, XtPointer p ); 00489 00490 // window close action data 00491 SoXtComponentCB* windowCloseFunc; 00492 void* windowCloseData; 00493 static void windowCloseActionCB( SoWidget w, SoXtComponent* v, void* data ); 00494 00495 // The widget dictionary maps widgets to SoXtComponents. It's used 00496 // by getComponent(), and kept up to date by registerWidget(). 00497 static SbDict* widgetDictionary; 00498 00499 // For fullscreen mode. 00500 Dimension posX, posY, width, height; 00501 int m_decorationHints; 00502 int m_functionHints; 00503 00504 SoGuiComponent* m_guiComponent; 00505 00506 // For DirectViz mode 00507 SbBool m_directVizOn; 00508 SbBool m_directVizEnabled; 00509 }; 00510 00511 // Inline routines 00512 Display* 00513 SoXtComponent::getDisplay() 00514 { 00515 return (_baseWidget != NULL ? XtDisplay(_baseWidget) : NULL); 00516 } 00517 00518 #endif // _SO_XT_COMPONENT_H_ 00519 00520 #endif // _WIN32 00521 00522 00523