Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
SoWinComponent.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24
25
26#ifndef _SO_WIN_COMPONENT_H_
27#define _SO_WIN_COMPONENT_H_
28
30#include <windows.h>
31#include <Inventor/Win/SoWin.h>
34
35#include <Inventor/SbLinear.h>
36#include <Inventor/SbString.h>
37
38class SbDict;
39class SoWinComponent;
40class SoCallbackList;
41class SoWinComponentP;
42
43typedef void SoWinComponentCB( void* userData, SoWinComponent* comp );
44typedef void SoWinComponentVisibilityCB( void* userData, SbBool visibleFlag );
45
114{
115 friend class SoWinComponentP;
116
117 public:
118SoDEPRECATED SoNONUNICODE static void displayHelp(const char* filename, UINT contextID);
133 SoDEPRECATED static void displayHelp(const SbString& filename, UINT contextID);
146
153 virtual void show();
154
158 virtual void hide();
159
171
177 SoWidget getWidget() const { return _baseWidget; }
178
184 SbBool isTopLevelShell() const { return m_guiComponent->isTopLevelShell(); }
185
190 SoWidget getShellWidget() const { return m_guiComponent->isTopLevelShell() ? parentWidget : NULL; }
191
195 SoWidget getParentWidget() const { return parentWidget; }
196
200 void setSize( const SbVec2s& size );
201
206
211
216
223
229
233 UINT* getDisplay() { return NULL; }
234
243 SoNONUNICODE void setTitle( const char* newTitle );
244
252 void setTitle( const SbString& newTitle );
253
257 SbString getTitle() const { return m_guiComponent->getTitle(); }
258
263 SoNONUNICODE void setIconTitle( const char* newIconTitle );
264
268 void setIconTitle( const SbString& newIconTitle );
269
273 SbString getIconTitle() const { return m_guiComponent->getIconTitle(); }
274
294 void setWindowCloseCallback( SoWinComponentCB *func, void* data = NULL )
295 { windowCloseFunc = func; windowCloseData = data; }
296
302
307 SbString getWidgetName() const { return m_guiComponent->getWidgetName(); }
308
313 SbString getClassName() const { return m_guiComponent->getClassName(); }
314
320
326
332
335
336 private:
337
338 // Deprecated. Replaced by getWidget().
339 SoWidget baseWidget() const { return getWidget(); }
340
341 static void exitClass();
342
343 // Returns the current guiComponent
344 SoGuiComponent* getGuiComponent() const;
345
346 private:
347 //
348 // If `parent` widget is suplied AND `buildInsideParent` is TRUE, this
349 // component will build inside the given parent widget, else
350 // it will create its own topLevelShell widget (component resides in
351 // its own window).
352 // The topLevelShell can either be created under the given
353 // parent shell (`parent` != NULL) or under the main window.
354 //
355 // The name is used for looking up X resource values. If NULL,
356 // then this component inherits resource values defined for its class.
357 //
358 // Calling setBaseWidget is needed for looking up Xt like
359 // resources in the widget tree. It will use the class name of
360 // the Inventor component (e.g. SoWinRenderArea) instead of
361 // the class name of the Motif widget this component employs
362 // (e.g. XmForm).
363 //
364 // Thus apps are able to do this in their app-defaults file:
365 //
366 // *SoWinRenderArea*BackgroundColor: salmon
367 //
368 SoWinComponent( SoWidget parent = NULL,
369 const SbString& name = "",
370 SbBool buildInsideParent = TRUE,
371 SbBool sync = TRUE );
372
373 SoWinComponent( SoWidget parent,
374 const SbString& name,
375 SbBool buildInsideParent,
376 SbBool sync,
377 SoGuiComponent* guiComponent );
378
379 // Subclasses need to call this method passing the top most
380 // widget after it has been created.
381 void setBaseWidget( SoWidget w );
382
383 // Subclasses need to set the class name in the constructor
384 // before the widget is built.
385 void setClassName( const SbString& n ) { m_guiComponent->setClassName( n ); }
386
387 // this routine is called whenever the top level shell widget receives
388 // a close action (WM_DELETE_WINDOW message) from the window manager.
389 // Instead of destroying the widget (default shell behavior) this
390 // routine is used, which by default calls exit(0) if it is the main
391 // window else calls hide() on the component.
392 //
393 virtual void windowCloseAction();
394
395 // Support for doing things right after the widget is realized
396 // for the first time.
397 // The base class will set the window and icon title for shell widgets.
398 virtual void afterRealizeHook();
399 SbBool firstRealize;
400
401 //
402 // Subclasses should redefine these routines to return the appropriate
403 // default information. Those are used when creating the widget to set
404 // the name (used for resources), window title and window icon
405 // name. Those default values are only used if the user didn't
406 // explicitly specify them.
407 virtual SbString getDefaultWidgetName() const;
408 virtual SbString getDefaultTitle() const;
409 virtual SbString getDefaultIconTitle() const;
410
411 //
412 // Register widget - should be called by subclasses after
413 // they have created their top most widget (which is passed here),
414 // and before they build any child widgets. Calling this method
415 // ensures that the widgets name and class will be used when
416 // calls are made to get X resource values for this widget.
417 //
418 // *** NOTE ***
419 // ALL subclasses should register their top most widget within the
420 // component, whether they retrieve resources or not, so that children
421 // widgets can get X resources properly.
422 // Unregister the widget when the widget is destroyed.
423 //
424 void registerWidget( SoWidget w );
425 void unregisterWidget( SoWidget w );
426
427 // subclasses can add a callback to be called whenever the component
428 // becomes visible or become hidden (like when it is iconified).
429 // Sublcasses should use this to attach or detach any sensors they
430 // have, or stop any ongoing anymation.
431 void addVisibilityChangeCallback( SoWinComponentVisibilityCB* func,
432 void* userData = NULL );
433 void removeVisibilityChangeCallback( SoWinComponentVisibilityCB* func,
434 void* userData = NULL );
435
436 //
437 // This method can be used by subclasses to open a component help
438 // card. The name of the file should be supplied without a path
439 // name. By default the file will be searched using:
440 // 1) current working directory
441 // 2) SO_HELP_DIR environment variable
442 // 3) /usr/share/help/Inventor
443 // 4) else bring a no help card found dialog
444 //SoDEPRECATED void openHelpCard(const SbString& cardName);
446
452 static void openHelpPage( const SbString& helpPage );
453
454 // Used to factorize displayHelp and openHelpCard methods.SoDEPRECATED static void internalDisplayHelp(const SbString& path, UINT contextID, HWND hWndMain = NULL);
456
457 SoWidget buildFormWidget( SoWidget parent );
458
459 void setResize( SbBool nResize ) { m_nResizeBaseWidget = nResize; }
460 SbBool getResize() { return m_nResizeBaseWidget ; }
461
462 // Utility function to setup logical color palette for 8bit devices
463 static HPALETTE _setupColorPalette( HDC );
464
465 void unSubclassDialog( Hwnd hWnd );
466 void subclassDialog( Hwnd hWnd );
467 void drawDialogIcon( Hwnd hWnd );
468
469 static LRESULT CALLBACK dlgWndProc( Hwnd hwnd, UINT message,
470 WPARAM wParam, LPARAM lParam );
471 static Hwnd getMDIAncestor( Hwnd win );
472
473 // If parent of glxMgrWindow is MDI we need to call DefMDIChildProc
474 // in mgrWindowProc instead of DefWindowProc
475 SbBool m_nParentIsMDI;
476
477 HICON hDlgIcon;
478
479 char* windowName;
480 SbBool buildInside;
481
482 static void widgetStructureNotifyCB( SoWidget w, SoWinComponent* c, XEvent* e, Boolean* b );
483 static void windowCloseActionCB(SoWidget, SoWinComponent *, void *);
484 static int ChoosePixelFormatOIV( HDC hdc, int pixelType, int glModes, PIXELFORMATDESCRIPTOR* pfd );
485
486 private:
487
488 void constructorCommon( SoWidget parent, const SbString& name, SbBool buildInsideParent, SbBool sync );
489
490 // widgetDestroyed is called when the widget is destroyed.
491 // There is no way to reconstruct the widget tree, so calling
492 // this simply generates an error. The component should be
493 // deleted to dispose of the widget.
494 virtual void widgetDestroyed();
495
496 SbBool createdShell; // TRUE if we created that toplevel shell
497 SoWidget parentWidget; // topLevel shell if in its own window
498 SoWidget _baseWidget; // returned by getWidget()
499 SbVec2s size; // size of the '_baseWidget' and 'shell' (if toplevel)
500
501 // visibiltity stuff
502 SbBool visibleState;
503 SbBool ShellMapped, widgetMapped;
504 SoCallbackList *visibiltyCBList;
505 void checkForVisibilityChange();
506
507 // For fullscreen.
508 SbVec2s viewerPos;
509 SbVec2s viewerSize;
510 long style, extStyle;
511
512 static void shellStructureNotifyCB( SoWidget w, SoWinComponent* c, XEvent* e, Boolean* b );
513 static void widgetDestroyedCB( SoWidget w, XtPointer p1, XtPointer p2 );
514
515 // window close action data
516 SoWinComponentCB* windowCloseFunc;
517 void* windowCloseData;
518
519 // The widget dictionary maps widgets to SoWinComponents. It's used
520 // by getComponent(), and kept up to date by registerWidget().
521 static SbDict* widgetDictionary;
522
523 // If we subclass our parent, remember parent's original wndproc so we
524 // can pass messages along to it.
525 WNDPROC parentWndProc;
526 WNDPROC origDlgWndProc;
527
528 // if this is true, then SoWinComponent resizes the base widget when
529 // it receive WM_SIZE, otherwise no resize
530 SbBool m_nResizeBaseWidget;
531
532 static void OnWmSize( Hwnd hwnd, UINT message,
533 WPARAM wParam, LPARAM lParam );
534 static void OnWmPaint( Hwnd hwnd, UINT message,
535 WPARAM wParam, LPARAM lParam );
536 static void OnWmDestroy( Hwnd hwnd, UINT message,
537 WPARAM wParam, LPARAM lParam );
538
539 // Window proc for "subclassing" parent shell window (to track size changes)
540 static LRESULT CALLBACK componentWndProc( Hwnd hwnd, UINT message,
541 WPARAM wParam, LPARAM lParam );
542 static LRESULT CALLBACK formWindowProc( Hwnd hwnd, UINT message,
543 WPARAM wParam, LPARAM lParam );
544
545 //Implementation class for SoXxComponent
546 SoGuiComponent* m_guiComponent;
547};
548
550
551#endif // _SO_WIN_COMPONENT_H_
552
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
union _XEvent XEvent
Definition SoQtDef.h:120
char Boolean
Definition SoQtDef.h:119
void * XtPointer
Definition SoQtDef.h:118
#define SoWidget
Definition SoQtDef.h:40
virtual void enable(QWidget *w, XtEventHandler f, XtPointer data, void *unused=NULL)
void SoWinComponentVisibilityCB(void *userData, SbBool visibleFlag)
void SoWinComponentCB(void *userData, SoWinComponent *comp)
#define Hwnd
Definition SoWinDef.h:83
#define PIXELFORMATDESCRIPTOR
Class for smart character strings.
Definition SbString.h:202
2D vector class.
Definition SbVec.h:700
Manages a list of callbacks and associated data.
<a href="IconLegend.html"><img src="extTGS.gif" alt="VSG extension" border="0"></a> Abstract base cl...
SbBool isTopLevelShell() const
Returns TRUE if this component is a top level shell component (has its own window).
UINT * getDisplay()
Included for portability only.
SoWidget getParentWidget() const
Returns the parent window handle, be it a shell or not.
SbBool isVisible()
Returns TRUE if this component is mapped onto the screen.
SbString getClassName() const
Returns the class name.
void setSize(const SbVec2s &size)
Convenience routine on the window handle.
SbString helpContextString
The TopicID of the help topic to open when the viewer Help button is pressed.
SbString getTitle() const
Gets window title.
void setTitle(const SbString &newTitle)
Sets window title.
SbVec2s getSize()
Convenience routine on the window handle.
SbString helpFileName
Name of help file to open when the viewer Help button is pressed.
SbBool setFullScreen(const SbBool enable)
Switches the viewer into (or out of) fullscreen mode.
virtual void show()
This shows the component.
virtual void hide()
This hides the component.
SoWidget getWidget() const
This returns the base window handle for this component.
static SoWinComponent * getComponent(SoWidget w)
Returns the SoWinComponent for this window handle.
SoNONUNICODE void setTitle(const char *newTitle)
Sets window title.
SoWidget getShellWidget() const
Returns the shell window handle (NULL if the shell hasn't been created by this component).
void setWindowCloseCallback(SoWinComponentCB *func, void *data=NULL)
Sets which callback to call when the user closes this component (double click in the upper left corne...
SbString getIconTitle() const
Included for portability only.
void setIconTitle(const SbString &newIconTitle)
Included for portability only.
UINT helpContextID
The context ID of the help topic to open when the viewer Help button is pressed.
void setFullScreenEnable(const SbBool enable)
Enables/disables fullscreen mode.
SbBool isFullScreen() const
Queries if the viewer is in fullscreen mode.
SoDEPRECATED static SoNONUNICODE void displayHelp(const char *filename, UINT contextID)
Static method to display the specified topic of the specified help file.
virtual ~SoWinComponent()
Destructor.
SbString getWidgetName() const
Returns the window handle name.
SoNONUNICODE void setIconTitle(const char *newIconTitle)
Included for portability only.
SbBool isFullScreenEnable(void) const
Queries if it is possible to put the viewer in fullscreen mode.
friend class SoWinComponentP
int SbBool
Boolean type.
Definition SbBase.h:87
size_t size() const
unsigned int UINT
Definition port.h:357
#define CALLBACK
Definition port.h:345
#define HDC
Definition port.h:351