Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SoXtComponent.h
1/*=======================================================================
2 * Copyright 1991-1996, Silicon Graphics, Inc.
3 * ALL RIGHTS RESERVED
4 *
5 * UNPUBLISHED -- Rights reserved under the copyright laws of the United
6 * States. Use of a copyright notice is precautionary only and does not
7 * imply publication or disclosure.
8 *
9 * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:
10 * Use, duplication or disclosure by the Government is subject to restrictions
11 * as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights
12 * in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or
13 * in similar or successor clauses in the FAR, or the DOD or NASA FAR
14 * Supplement. Contractor/manufacturer is Silicon Graphics, Inc.,
15 * 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311.
16 *
17 * THE CONTENT OF THIS WORK CONTAINS CONFIDENTIAL AND PROPRIETARY
18 * INFORMATION OF SILICON GRAPHICS, INC. ANY DUPLICATION, MODIFICATION,
19 * DISTRIBUTION, OR DISCLOSURE IN ANY FORM, IN WHOLE, OR IN PART, IS STRICTLY
20 * PROHIBITED WITHOUT THE PRIOR EXPRESS WRITTEN PERMISSION OF SILICON
21 * GRAPHICS, INC.
22**=======================================================================*/
23/*=======================================================================
24** Author : David Mott (MMM yyyy)
25** Modified by : Alain Dumesny (MMM yyyy)
26**=======================================================================*/
27/*=======================================================================
28 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
29 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
30 *** ***
31 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
32 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
33 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
34 *** ***
35 *** RESTRICTED RIGHTS LEGEND ***
36 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
37 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
38 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
39 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
40 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
41 *** ***
42 *** COPYRIGHT (C) 1996-2024 BY FEI S.A.S, ***
43 *** BORDEAUX, FRANCE ***
44 *** ALL RIGHTS RESERVED ***
45**=======================================================================*/
46/*=======================================================================
47** Modified by : VSG (MMM YYYY)
48**=======================================================================*/
49
50
51#ifdef SOQT
52# include <Inventor/Qt/SoQtComponent.h>
53#elif defined _WIN32
54# include <Inventor/Win/SoWinComponent.h>
55#else // _WIN32
56
57#ifndef _SO_XT_COMPONENT_H_
58#define _SO_XT_COMPONENT_H_
59
60#include <X11/Intrinsic.h>
61#include <Inventor/SbLinear.h>
62#include <Inventor/SbString.h>
63#include <Inventor/Gui/SoGuiComponent.h>
64#include <Inventor/Xt/SoXtDef.h>
65
66class SbDict;
67class SoXtComponent;
68class SoCallbackList;
69
71typedef void SoXtComponentCB( void* data, SoXtComponent* v );
72typedef void SoXtComponentVisibilityCB( void* data, SbBool b );
73
146{
147
148 public:
149
159 static void displayHelp( const char* filename, UINT contextID );
160
164 virtual void show();
165
169 virtual void hide();
170
182
188 SoWidget getWidget() const { return _baseWidget; }
189
195 SbBool isTopLevelShell() const { return m_guiComponent->isTopLevelShell(); }
196
201 SoWidget getShellWidget() const { return m_guiComponent->isTopLevelShell() ? parentWidget : NULL; }
202
206 SoWidget getParentWidget() const { return parentWidget; }
207
211 void setSize( const SbVec2s& size );
212
217
221 SbBool setFullScreen( const SbBool enable );
222
226 SbBool isFullScreen(void) const;
227
233 void setFullScreenEnable( const SbBool enable );
234
240
244 inline Display* getDisplay();
245
254 SoNONUNICODE void setTitle( const char* newTitle );
255
256
263 void setTitle( const SbString& newTitle );
264
269 return m_guiComponent->getTitle(); }
270
279 SoNONUNICODE void setIconTitle( const char* newIconTitle );
280
287 void setIconTitle( const SbString& newIconTitle );
288
293 return m_guiComponent->getIconTitle(); }
294
295
305 void setWindowCloseCallback( SoXtComponentCB* func, void* data = NULL )
306 { windowCloseFunc = func; windowCloseData = data; }
307
312 static SoXtComponent* getComponent( SoWidget w );
313
319 return m_guiComponent->getWidgetName(); }
320
326 return m_guiComponent->getClassName(); }
327
328
329 private:
330
331 virtual ~SoXtComponent();
332
333 // Deprecated. Replaced by getWidget().
334 SoWidget baseWidget() const { return getWidget(); }
335
336 virtual void posChanged( const SbVec2i32&, const SbVec2i32& ) {};
337
338 SoGuiComponent* getGuiComponent() const;
339
340 private:
341 //
342 // If `parent` widget is suplied AND `buildInsideParent` is TRUE, this
343 // component will build inside the given parent widget, else
344 // it will create its own topLevelShell widget (component resides in
345 // its own window).
346 // The topLevelShell can either be created under the given
347 // parent shell (`parent` != NULL) or under the main window.
348 //
349 // The name is used for looking up X resource values. If NULL,
350 // then this component inherits resource values defined for its class.
351 //
352 // Calling setBaseWidget is needed for looking up Xt like
353 // resources in the widget tree. It will use the class name of
354 // the Inventor component (e.g. SoXtRenderArea) instead of
355 // the class name of the Motif widget this component employs
356 // (e.g. XmForm).
357 //
358 // Thus apps are able to do this in their app-defaults file:
359 //
360 // *SoXtRenderArea*BackgroundColor: salmon
361 //
362 SoXtComponent( SoWidget parent = NULL,
363 const char* name = NULL,
364 SbBool buildInsideParent = TRUE,
365 SbBool sync = TRUE );
366
367 SoXtComponent( SoWidget parent,
368 const char* name,
369 SbBool buildInsideParent,
370 SbBool sync,
371 SoGuiComponent* guiComponent );
372
373 // Subclasses need to call this method passing the top most
374 // widget after it has been created.
375 void setBaseWidget( SoWidget w );
376
377 // Subclasses need to set the class name in the constructor
378 // before the widget is built.
379 void setClassName( const SbString &n ) { m_guiComponent->setClassName( n ); }
380
381 // this routine is called whenever the top level shell widget receives
382 // a close action (WM_DELETE_WINDOW message) from the window manager.
383 // Instead of destroying the widget (default shell behavior) this
384 // routine is used, which by default calls exit(0) if it is the main
385 // window else calls hide() on the component.
386 //
387 virtual void windowCloseAction();
388
389 // Support for doing things right after the widget is realized
390 // for the first time.
391 // The base class will set the window and icon title for shell widgets.
392 virtual void afterRealizeHook();
393 SbBool firstRealize;
394
395 //
396 // Subclasses should redefine these routines to return the appropriate
397 // default information. Those are used when creating the widget to set
398 // the name (used for resources), window title and window icon
399 // name. Those default values are only used if the user didn't
400 // explicitly specify them.
401 //
402 virtual SbString getDefaultWidgetName() const;
403 virtual SbString getDefaultTitle() const;
404 virtual SbString getDefaultIconTitle() const;
405
406 //
407 // Register widget - should be called by subclasses after
408 // they have created their top most widget (which is passed here),
409 // and before they build any child widgets. Calling this method
410 // ensures that the widgets name and class will be used when
411 // calls are made to get X resource values for this widget.
412 //
413 // *** NOTE ***
414 // ALL subclasses should register their top most widget within the
415 // component, whether they retrieve resources or not, so that children
416 // widgets can get X resources properly.
417 // Unregister the widget when the widget is destroyed.
418 //
419 void registerWidget( SoWidget w );
420 void unregisterWidget( SoWidget w );
421
422 // subclasses can add a callback to be called whenever the component
423 // becomes visible or become hidden (like when it is iconified).
424 // Sublcasses should use this to attach or detach any sensors they
425 // have, or stop any ongoing anymation.
426 void addVisibilityChangeCallback( SoXtComponentVisibilityCB* func, void* userData = NULL );
427 void removeVisibilityChangeCallback( SoXtComponentVisibilityCB* func, void* userData = NULL );
428
429 //
430 // This method can be used by subclasses to open a component help
431 // card. The name of the file should be supplied withought a path
432 // name. By default the file will be searched using:
433 // 1) current working directory
434 // 2) SO_HELP_DIR environment variable
435 // 3) /usr/share/help/Inventor
436 // 4) else bring a no help card found dialog
437 //
438 void openHelpCard( const char* cardName );
439
440 // This method is used to get label from resources for Localisation.
441 static SbString getlabel( unsigned int whatisit );// const;
442
443
444
445 private:
446
447 void constructorCommon( SoWidget parent, const char* name, SbBool buildInsideParent, SbBool sync );
448
449 // Call a web browser to open the passed URL
450 SbBool callWebBrowser( const char* url ) const;
451
452 // widgetDestroyed is called when the widget is destroyed.
453 // There is no way to reconstruct the widget tree, so calling
454 // this simply generates an error. The component should be
455 // deleted to dispose of the widget.
456 virtual void widgetDestroyed();
457
458 SbBool createdShell; // TRUE if we created that toplevel shell
459 SoWidget parentWidget; // topLevel shell if in its own window
460 SoWidget _baseWidget; // returned by getWidget()
461 SbVec2s size; // size of the '_baseWidget' and 'shell' (if toplevel)
462
463 // visibiltity stuff
464 SbBool visibleState;
465 SbBool ShellMapped, widgetMapped;
466 SoCallbackList* visibiltyCBList;
467 void checkForVisibilityChange();
468 static void widgetStructureNotifyCB( SoWidget w, SoXtComponent* p, XEvent* xe, Boolean* b );
469 static void shellStructureNotifyCB( SoWidget w, SoXtComponent* p, XEvent* xe, Boolean* b );
470 static void widgetDestroyedCB( SoWidget w, XtPointer clientData, XtPointer p );
471
472 // window close action data
473 SoXtComponentCB* windowCloseFunc;
474 void* windowCloseData;
475 static void windowCloseActionCB( SoWidget w, SoXtComponent* v, void* data );
476
477 // The widget dictionary maps widgets to SoXtComponents. It's used
478 // by getComponent(), and kept up to date by registerWidget().
479 static SbDict* widgetDictionary;
480
481 // For fullscreen mode.
482 Dimension posX, posY, width, height;
483 int m_decorationHints;
484 int m_functionHints;
485
486 SoGuiComponent* m_guiComponent;
487
488};
489
490// Inline routines
491Display*
493{
494 return (_baseWidget != NULL ? XtDisplay(_baseWidget) : NULL);
495}
496
497#endif // _SO_XT_COMPONENT_H_
498
499#endif // _WIN32
500
501
Class for smart character strings.
Definition SbString.h:202
2D vector class.
Definition SbVec.h:517
2D vector class.
Definition SbVec.h:700
Manages a list of callbacks and associated data.
Abstract base class for all Open Inventor components.
SbBool isFullScreen(void) const
Queries if the viewer is in fullscreen mode.
SbVec2s getSize()
Convenience routine on the widget.
void setSize(const SbVec2s &size)
Convenience routine on the widget.
SoWidget getShellWidget() const
Returns the shell widget (NULL if the shell hasn't been created by this component).
void setWindowCloseCallback(SoXtComponentCB *func, void *data=NULL)
Sets which callback to call when the user closes this component (double click in the upper left corne...
void SoXtComponentCB(void *data, SoXtComponent *v)
virtual void show()
This shows the component.
static SoXtComponent * getComponent(SoWidget w)
This returns the SoXtComponent for this widget.
void setFullScreenEnable(const SbBool enable)
Enables/disables fullscreen mode.
SbString getClassName() const
Returns the class name.
SbString getWidgetName() const
Returns the widget name.
SoNONUNICODE void setIconTitle(const char *newIconTitle)
Sets icon title.
SbString getTitle() const
Gets window title.
Display * getDisplay()
Returns the X display associated with this components widget.
static void displayHelp(const char *filename, UINT contextID)
Static method to display the specified topic of the specified help file.
SbBool isVisible()
Returns TRUE if this component is mapped onto the screen.
SoWidget getWidget() const
This returns the base widget for this component.
SbBool isFullScreenEnable() const
Queries if it is possible to put the viewer in fullscreen mode.
SoWidget getParentWidget() const
Returns the parent widget, be it a shell or not.
SoNONUNICODE void setTitle(const char *newTitle)
Sets window title.
SbBool isTopLevelShell() const
Returns TRUE if this component is a top level shell component (has its own window).
SbString getIconTitle() const
Gets icon title.
SbBool setFullScreen(const SbBool enable)
Switches the viewer into (or out of) fullscreen mode.
void setIconTitle(const SbString &newIconTitle)
Sets icon title.
virtual void hide()
This hides the component.
void setTitle(const SbString &newTitle)
Sets window title.
int SbBool
Boolean type.
Definition SbBase.h:87
union _XEvent XEvent
Definition SoQtDef.h:126
char Boolean
Definition SoQtDef.h:124
void * XtPointer
Definition SoQtDef.h:122