Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SoWinComponent.h
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-2024 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
29#include <Inventor/Win/SoWinBeginStrict.h>
30#include <windows.h>
31#include <Inventor/Win/SoWin.h>
32#include <Inventor/Win/SoWinDef.h>
33#include <Inventor/Gui/SoGuiComponent.h>
34
35#include <Inventor/SbLinear.h>
36#include <Inventor/SbString.h>
37
38class SbDict;
39class SoWinComponent;
40class SoCallbackList;
41class SoWinComponentP;
42
44typedef void SoWinComponentCB( void* userData, SoWinComponent* comp );
45typedef void SoWinComponentVisibilityCB( void* userData, SbBool visibleFlag );
46
115{
116 friend class SoWinComponentP;
117
118 public:
119SoDEPRECATED SoNONUNICODE static void displayHelp(const char* filename, UINT contextID);
134 SoDEPRECATED static void displayHelp(const SbString& filename, UINT contextID);
147
154 virtual void show();
155
159 virtual void hide();
160
172
178 SoWidget getWidget() const { return _baseWidget; }
179
185 SbBool isTopLevelShell() const { return m_guiComponent->isTopLevelShell(); }
186
191 SoWidget getShellWidget() const { return m_guiComponent->isTopLevelShell() ? parentWidget : NULL; }
192
196 SoWidget getParentWidget() const { return parentWidget; }
197
201 void setSize( const SbVec2s& size );
202
207
211 SbBool setFullScreen( const SbBool enable );
212
217
223 void setFullScreenEnable( const SbBool enable );
224
230
234 UINT* getDisplay() { return NULL; }
235
244 SoNONUNICODE void setTitle( const char* newTitle );
245
253 void setTitle( const SbString& newTitle );
254
258 SbString getTitle() const { return m_guiComponent->getTitle(); }
259
264 SoNONUNICODE void setIconTitle( const char* newIconTitle );
265
269 void setIconTitle( const SbString& newIconTitle );
270
274 SbString getIconTitle() const { return m_guiComponent->getIconTitle(); }
275
295 void setWindowCloseCallback( SoWinComponentCB *func, void* data = NULL )
296 { windowCloseFunc = func; windowCloseData = data; }
297
302 static SoWinComponent* getComponent( SoWidget w );
303
308 SbString getWidgetName() const { return m_guiComponent->getWidgetName(); }
309
314 SbString getClassName() const { return m_guiComponent->getClassName(); }
315
321
327
333
336
337 private:
338
339 // Deprecated. Replaced by getWidget().
340 SoWidget baseWidget() const { return getWidget(); }
341
342 static void exitClass();
343
344 // Returns the current guiComponent
345 SoGuiComponent* getGuiComponent() const;
346
347 private:
348 //
349 // If `parent` widget is suplied AND `buildInsideParent` is TRUE, this
350 // component will build inside the given parent widget, else
351 // it will create its own topLevelShell widget (component resides in
352 // its own window).
353 // The topLevelShell can either be created under the given
354 // parent shell (`parent` != NULL) or under the main window.
355 //
356 // The name is used for looking up X resource values. If NULL,
357 // then this component inherits resource values defined for its class.
358 //
359 // Calling setBaseWidget is needed for looking up Xt like
360 // resources in the widget tree. It will use the class name of
361 // the Inventor component (e.g. SoWinRenderArea) instead of
362 // the class name of the Motif widget this component employs
363 // (e.g. XmForm).
364 //
365 // Thus apps are able to do this in their app-defaults file:
366 //
367 // *SoWinRenderArea*BackgroundColor: salmon
368 //
369 SoWinComponent( SoWidget parent = NULL,
370 const SbString& name = "",
371 SbBool buildInsideParent = TRUE,
372 SbBool sync = TRUE );
373
374 SoWinComponent( SoWidget parent,
375 const SbString& name,
376 SbBool buildInsideParent,
377 SbBool sync,
378 SoGuiComponent* guiComponent );
379
380 // Subclasses need to call this method passing the top most
381 // widget after it has been created.
382 void setBaseWidget( SoWidget w );
383
384 // Subclasses need to set the class name in the constructor
385 // before the widget is built.
386 void setClassName( const SbString& n ) { m_guiComponent->setClassName( n ); }
387
388 // this routine is called whenever the top level shell widget receives
389 // a close action (WM_DELETE_WINDOW message) from the window manager.
390 // Instead of destroying the widget (default shell behavior) this
391 // routine is used, which by default calls exit(0) if it is the main
392 // window else calls hide() on the component.
393 //
394 virtual void windowCloseAction();
395
396 // Support for doing things right after the widget is realized
397 // for the first time.
398 // The base class will set the window and icon title for shell widgets.
399 virtual void afterRealizeHook();
400 SbBool firstRealize;
401
402 //
403 // Subclasses should redefine these routines to return the appropriate
404 // default information. Those are used when creating the widget to set
405 // the name (used for resources), window title and window icon
406 // name. Those default values are only used if the user didn't
407 // explicitly specify them.
408 virtual SbString getDefaultWidgetName() const;
409 virtual SbString getDefaultTitle() const;
410 virtual SbString getDefaultIconTitle() const;
411
412 //
413 // Register widget - should be called by subclasses after
414 // they have created their top most widget (which is passed here),
415 // and before they build any child widgets. Calling this method
416 // ensures that the widgets name and class will be used when
417 // calls are made to get X resource values for this widget.
418 //
419 // *** NOTE ***
420 // ALL subclasses should register their top most widget within the
421 // component, whether they retrieve resources or not, so that children
422 // widgets can get X resources properly.
423 // Unregister the widget when the widget is destroyed.
424 //
425 void registerWidget( SoWidget w );
426 void unregisterWidget( SoWidget w );
427
428 // subclasses can add a callback to be called whenever the component
429 // becomes visible or become hidden (like when it is iconified).
430 // Sublcasses should use this to attach or detach any sensors they
431 // have, or stop any ongoing anymation.
432 void addVisibilityChangeCallback( SoWinComponentVisibilityCB* func,
433 void* userData = NULL );
434 void removeVisibilityChangeCallback( SoWinComponentVisibilityCB* func,
435 void* userData = NULL );
436
437 //
438 // This method can be used by subclasses to open a component help
439 // card. The name of the file should be supplied without a path
440 // name. By default the file will be searched using:
441 // 1) current working directory
442 // 2) SO_HELP_DIR environment variable
443 // 3) /usr/share/help/Inventor
444 // 4) else bring a no help card found dialog
445 //SoDEPRECATED void openHelpCard(const SbString& cardName);
447
453 static void openHelpPage( const SbString& helpPage );
454
455 // Used to factorize displayHelp and openHelpCard methods.SoDEPRECATED static void internalDisplayHelp(const SbString& path, UINT contextID, HWND hWndMain = NULL);
457
458 SoWidget buildFormWidget( SoWidget parent );
459
460 void setResize( SbBool nResize ) { m_nResizeBaseWidget = nResize; }
461 SbBool getResize() { return m_nResizeBaseWidget ; }
462
463 // Utility function to setup logical color palette for 8bit devices
464 static HPALETTE _setupColorPalette( HDC );
465
466 void unSubclassDialog( Hwnd hWnd );
467 void subclassDialog( Hwnd hWnd );
468 void drawDialogIcon( Hwnd hWnd );
469
470 static LRESULT CALLBACK dlgWndProc( Hwnd hwnd, UINT message,
471 WPARAM wParam, LPARAM lParam );
472 static Hwnd getMDIAncestor( Hwnd win );
473
474 // If parent of glxMgrWindow is MDI we need to call DefMDIChildProc
475 // in mgrWindowProc instead of DefWindowProc
476 SbBool m_nParentIsMDI;
477
478 HICON hDlgIcon;
479
480 char* windowName;
481 SbBool buildInside;
482
483 static void widgetStructureNotifyCB( SoWidget w, SoWinComponent* c, XEvent* e, Boolean* b );
484 static void windowCloseActionCB(SoWidget, SoWinComponent *, void *);
485 static int ChoosePixelFormatOIV( HDC hdc, int pixelType, int glModes, PIXELFORMATDESCRIPTOR* pfd );
486
487 private:
488
489 void constructorCommon( SoWidget parent, const SbString& name, SbBool buildInsideParent, SbBool sync );
490
491 // widgetDestroyed is called when the widget is destroyed.
492 // There is no way to reconstruct the widget tree, so calling
493 // this simply generates an error. The component should be
494 // deleted to dispose of the widget.
495 virtual void widgetDestroyed();
496
497 SbBool createdShell; // TRUE if we created that toplevel shell
498 SoWidget parentWidget; // topLevel shell if in its own window
499 SoWidget _baseWidget; // returned by getWidget()
500 SbVec2s size; // size of the '_baseWidget' and 'shell' (if toplevel)
501
502 // visibiltity stuff
503 SbBool visibleState;
504 SbBool ShellMapped, widgetMapped;
505 SoCallbackList *visibiltyCBList;
506 void checkForVisibilityChange();
507
508 // For fullscreen.
509 SbVec2s viewerPos;
510 SbVec2s viewerSize;
511 long style, extStyle;
512
513 static void shellStructureNotifyCB( SoWidget w, SoWinComponent* c, XEvent* e, Boolean* b );
514 static void widgetDestroyedCB( SoWidget w, XtPointer p1, XtPointer p2 );
515
516 // window close action data
517 SoWinComponentCB* windowCloseFunc;
518 void* windowCloseData;
519
520 // The widget dictionary maps widgets to SoWinComponents. It's used
521 // by getComponent(), and kept up to date by registerWidget().
522 static SbDict* widgetDictionary;
523
524 // If we subclass our parent, remember parent's original wndproc so we
525 // can pass messages along to it.
526 WNDPROC parentWndProc;
527 WNDPROC origDlgWndProc;
528
529 // if this is true, then SoWinComponent resizes the base widget when
530 // it receive WM_SIZE, otherwise no resize
531 SbBool m_nResizeBaseWidget;
532
533 static void OnWmSize( Hwnd hwnd, UINT message,
534 WPARAM wParam, LPARAM lParam );
535 static void OnWmPaint( Hwnd hwnd, UINT message,
536 WPARAM wParam, LPARAM lParam );
537 static void OnWmDestroy( Hwnd hwnd, UINT message,
538 WPARAM wParam, LPARAM lParam );
539
540 // Window proc for "subclassing" parent shell window (to track size changes)
541 static LRESULT CALLBACK componentWndProc( Hwnd hwnd, UINT message,
542 WPARAM wParam, LPARAM lParam );
543 static LRESULT CALLBACK formWindowProc( Hwnd hwnd, UINT message,
544 WPARAM wParam, LPARAM lParam );
545
546 //Implementation class for SoXxComponent
547 SoGuiComponent* m_guiComponent;
548};
549
550#include <Inventor/Win/SoWinEndStrict.h>
551
552#endif // _SO_WIN_COMPONENT_H_
553
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.
void SoWinComponentCB(void *userData, SoWinComponent *comp)
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
union _XEvent XEvent
Definition SoQtDef.h:126
char Boolean
Definition SoQtDef.h:124
void * XtPointer
Definition SoQtDef.h:122