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-2018 BY FEI S.A.S, *** 00043 *** MERIGNAC, 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 00146 class SoXtComponent 00147 { 00148 00149 public: 00150 00160 static void displayHelp( const char* filename, UINT contextID ); 00161 00165 virtual void show(); 00166 00170 virtual void hide(); 00171 00182 SbBool isVisible(); 00183 00189 SoWidget getWidget() const { return _baseWidget; } 00190 00196 SbBool isTopLevelShell() const { return m_guiComponent->isTopLevelShell(); } 00197 00202 SoWidget getShellWidget() const { return m_guiComponent->isTopLevelShell() ? parentWidget : NULL; } 00203 00207 SoWidget getParentWidget() const { return parentWidget; } 00208 00212 void setSize( const SbVec2s& size ); 00213 00217 SbVec2s getSize(); 00218 00222 SbBool setFullScreen( const SbBool enable ); 00223 00227 SbBool isFullScreen(void) const; 00228 00234 void setFullScreenEnable( const SbBool enable ); 00235 00240 SbBool isFullScreenEnable() const; 00241 00245 inline Display* getDisplay(); 00246 00255 SoNONUNICODE void setTitle( const char* newTitle ); 00256 00257 00264 void setTitle( const SbString& newTitle ); 00265 00269 SbString getTitle() const { 00270 return m_guiComponent->getTitle(); } 00271 00280 SoNONUNICODE void setIconTitle( const char* newIconTitle ); 00281 00288 void setIconTitle( const SbString& newIconTitle ); 00289 00293 SbString getIconTitle() const { 00294 return m_guiComponent->getIconTitle(); } 00295 00296 00306 void setWindowCloseCallback( SoXtComponentCB* func, void* data = NULL ) 00307 { windowCloseFunc = func; windowCloseData = data; } 00308 00313 static SoXtComponent* getComponent( SoWidget w ); 00314 00319 SbString getWidgetName() const { 00320 return m_guiComponent->getWidgetName(); } 00321 00326 SbString getClassName() const { 00327 return m_guiComponent->getClassName(); } 00328 00329 00330 private: 00331 00332 virtual ~SoXtComponent(); 00333 00334 // Deprecated. Replaced by getWidget(). 00335 SoWidget baseWidget() const { return getWidget(); } 00336 00337 virtual void posChanged( const SbVec2i32&, const SbVec2i32& ) {}; 00338 00339 SoGuiComponent* getGuiComponent() const; 00340 00341 private: 00342 // 00343 // If `parent` widget is suplied AND `buildInsideParent` is TRUE, this 00344 // component will build inside the given parent widget, else 00345 // it will create its own topLevelShell widget (component resides in 00346 // its own window). 00347 // The topLevelShell can either be created under the given 00348 // parent shell (`parent` != NULL) or under the main window. 00349 // 00350 // The name is used for looking up X resource values. If NULL, 00351 // then this component inherits resource values defined for its class. 00352 // 00353 // Calling setBaseWidget is needed for looking up Xt like 00354 // resources in the widget tree. It will use the class name of 00355 // the Inventor component (e.g. SoXtRenderArea) instead of 00356 // the class name of the Motif widget this component employs 00357 // (e.g. XmForm). 00358 // 00359 // Thus apps are able to do this in their app-defaults file: 00360 // 00361 // *SoXtRenderArea*BackgroundColor: salmon 00362 // 00363 SoXtComponent( SoWidget parent = NULL, 00364 const char* name = NULL, 00365 SbBool buildInsideParent = TRUE, 00366 SbBool sync = TRUE ); 00367 00368 SoXtComponent( SoWidget parent, 00369 const char* name, 00370 SbBool buildInsideParent, 00371 SbBool sync, 00372 SoGuiComponent* guiComponent ); 00373 00374 // Subclasses need to call this method passing the top most 00375 // widget after it has been created. 00376 void setBaseWidget( SoWidget w ); 00377 00378 // Subclasses need to set the class name in the constructor 00379 // before the widget is built. 00380 void setClassName( const SbString &n ) { m_guiComponent->setClassName( n ); } 00381 00382 // this routine is called whenever the top level shell widget receives 00383 // a close action (WM_DELETE_WINDOW message) from the window manager. 00384 // Instead of destroying the widget (default shell behavior) this 00385 // routine is used, which by default calls exit(0) if it is the main 00386 // window else calls hide() on the component. 00387 // 00388 virtual void windowCloseAction(); 00389 00390 // Support for doing things right after the widget is realized 00391 // for the first time. 00392 // The base class will set the window and icon title for shell widgets. 00393 virtual void afterRealizeHook(); 00394 SbBool firstRealize; 00395 00396 // 00397 // Subclasses should redefine these routines to return the appropriate 00398 // default information. Those are used when creating the widget to set 00399 // the name (used for resources), window title and window icon 00400 // name. Those default values are only used if the user didn't 00401 // explicitly specify them. 00402 // 00403 virtual SbString getDefaultWidgetName() const; 00404 virtual SbString getDefaultTitle() const; 00405 virtual SbString getDefaultIconTitle() const; 00406 00407 // 00408 // Register widget - should be called by subclasses after 00409 // they have created their top most widget (which is passed here), 00410 // and before they build any child widgets. Calling this method 00411 // ensures that the widgets name and class will be used when 00412 // calls are made to get X resource values for this widget. 00413 // 00414 // *** NOTE *** 00415 // ALL subclasses should register their top most widget within the 00416 // component, whether they retrieve resources or not, so that children 00417 // widgets can get X resources properly. 00418 // Unregister the widget when the widget is destroyed. 00419 // 00420 void registerWidget( SoWidget w ); 00421 void unregisterWidget( SoWidget w ); 00422 00423 // subclasses can add a callback to be called whenever the component 00424 // becomes visible or become hidden (like when it is iconified). 00425 // Sublcasses should use this to attach or detach any sensors they 00426 // have, or stop any ongoing anymation. 00427 void addVisibilityChangeCallback( SoXtComponentVisibilityCB* func, void* userData = NULL ); 00428 void removeVisibilityChangeCallback( SoXtComponentVisibilityCB* func, void* userData = NULL ); 00429 00430 // 00431 // This method can be used by subclasses to open a component help 00432 // card. The name of the file should be supplied withought a path 00433 // name. By default the file will be searched using: 00434 // 1) current working directory 00435 // 2) SO_HELP_DIR environment variable 00436 // 3) /usr/share/help/Inventor 00437 // 4) else bring a no help card found dialog 00438 // 00439 void openHelpCard( const char* cardName ); 00440 00441 // This method is used to get label from resources for Localisation. 00442 static SbString getlabel( unsigned int whatisit );// const; 00443 00444 00445 00446 private: 00447 00448 void constructorCommon( SoWidget parent, const char* name, SbBool buildInsideParent, SbBool sync ); 00449 00450 // Call a web browser to open the passed URL 00451 SbBool callWebBrowser( const char* url ) const; 00452 00453 // widgetDestroyed is called when the widget is destroyed. 00454 // There is no way to reconstruct the widget tree, so calling 00455 // this simply generates an error. The component should be 00456 // deleted to dispose of the widget. 00457 virtual void widgetDestroyed(); 00458 00459 SbBool createdShell; // TRUE if we created that toplevel shell 00460 SoWidget parentWidget; // topLevel shell if in its own window 00461 SoWidget _baseWidget; // returned by getWidget() 00462 SbVec2s size; // size of the '_baseWidget' and 'shell' (if toplevel) 00463 00464 // visibiltity stuff 00465 SbBool visibleState; 00466 SbBool ShellMapped, widgetMapped; 00467 SoCallbackList* visibiltyCBList; 00468 void checkForVisibilityChange(); 00469 static void widgetStructureNotifyCB( SoWidget w, SoXtComponent* p, XEvent* xe, Boolean* b ); 00470 static void shellStructureNotifyCB( SoWidget w, SoXtComponent* p, XEvent* xe, Boolean* b ); 00471 static void widgetDestroyedCB( SoWidget w, XtPointer clientData, XtPointer p ); 00472 00473 // window close action data 00474 SoXtComponentCB* windowCloseFunc; 00475 void* windowCloseData; 00476 static void windowCloseActionCB( SoWidget w, SoXtComponent* v, void* data ); 00477 00478 // The widget dictionary maps widgets to SoXtComponents. It's used 00479 // by getComponent(), and kept up to date by registerWidget(). 00480 static SbDict* widgetDictionary; 00481 00482 // For fullscreen mode. 00483 Dimension posX, posY, width, height; 00484 int m_decorationHints; 00485 int m_functionHints; 00486 00487 SoGuiComponent* m_guiComponent; 00488 00489 }; 00490 00491 // Inline routines 00492 Display* 00493 SoXtComponent::getDisplay() 00494 { 00495 return (_baseWidget != NULL ? XtDisplay(_baseWidget) : NULL); 00496 } 00497 00498 #endif // _SO_XT_COMPONENT_H_ 00499 00500 #endif // _WIN32 00501 00502 00503