1SoXtComponent(3IV)() SoXtComponent(3IV)()
2
3
4
6 SoXtComponent — abstract base class for all Inventor Xt components
7
9 SoXtComponent
10
12 #include <Inventor/Xt/SoXtComponent.h>
13
14 typedef void SoXtComponentCB(void *userData, SoXtComponent *comp)
15
16 Methods from class SoXtComponent:
17
18 virtual void show()
19 virtual void hide()
20 SbBool isVisible()
21 Widget getWidget() const
22 SbBool isTopLevelShell() const
23 Widget getShellWidget() const
24 Widget getParentWidget() const
25 void setSize(const SbVec2s &size)
26 SbVec2s getSize()
27 Display * getDisplay()
28 void setTitle(const char *newTitle)
29 const char * getTitle() const
30 void setIconTitle(const char *newIconTitle)
31 const char * getIconTitle() const
32 void setWindowCloseCallback(SoXtComponentCB *func,
33 void *data = NULL)
34 static SoXtComponent * getComponent(Widget w)
35 const char * getWidgetName() const
36 const char * getClassName() const
37
38
40 Abstract base class from which all Inventor Xt components are derived.
41 This class provides a basic C++ protocol for building and displaying
42 Motif components. Components are used to encapsulate some function or
43 task into a reusable package in the form of a Motif widget that can be
44 used in any Inventor Xt program. See the Example section on how to
45 build and use SoXtComponents.
46
48 virtual void show()
49 virtual void hide()
50 This shows and hides the component. If this is a topLevelShell com‐
51 ponent, then show() will Realize and Map the window, otherwise it
52 will simply Manage the widget. hide() calls the appropriate unmap or
53 unmanage routines.
54
55 In addition, show() will also pop the component window to the top
56 and de-iconify if necessary, to make sure the component is visible
57 by the user.
58
59 SbBool isVisible()
60 Returns TRUE if this component is mapped onto the screen. For a com‐
61 ponent to be visible, it's widget and the shell containing this wid‐
62 get must be mapped (which is FALSE when the component is iconified).
63
64 Subclasses should call this routine before redrawing anything and in
65 any sensor trigger methods. Calling this will check the current vis‐
66 ibility (which is really cheap) and invoke the visibility changed
67 callbacks if the state changes (see addVisibilityChangeCallback()).
68
69 Widget getWidget() const
70 This returns the base widget for this component. If the component
71 created its own shell, this returns the topmost widget beneath the
72 shell. Call getShellWidget() to obtain the shell.
73
74 SbBool isTopLevelShell() const
75 Widget getShellWidget() const
76 Returns TRUE if this component is a top level shell component (has
77 its own window). Subclasses may use this to decide if they are
78 allowed to resize themselves. Also method to return the shell widget
79 (NULL if the shell hasn't been created by this component).
80
81 Widget getParentWidget() const
82 Return the parent widget, be it a shell or not
83
84 void setSize(const SbVec2s &size)
85 SbVec2s getSize()
86 Convenience routines on the widget — setSize calls XtSetValue
87
88 Display * getDisplay()
89 Returns the X display associated with this components widget.
90
91 void setTitle(const char *newTitle)
92 const char * getTitle() const
93 void setIconTitle(const char *newIconTitle)
94 const char * getIconTitle() const
95 The window and icon title can be set for topLevelShell components or
96 components which are directly under a shell widget (i.e. components
97 which have their own window).
98
99 void setWindowCloseCallback(SoXtComponentCB *func,
100 void *data = NULL)
101 Sets which callback to call when the user closes this component
102 (double click in the upper left corner) — by default hide() is
103 called on this component, unless a callback is set to something
104 other than NULL. A pointer to this class will be passed as the
105 callback data.
106
107 Note: this callback is supplied because the user may wish to delete
108 this component when it is closed.
109
110 static SoXtComponent * getComponent(Widget w)
111 This returns the SoXtComponent for this widget. If the widget is not
112 an Inventor component, then NULL is returned.
113
114 const char * getWidgetName() const
115 const char * getClassName() const
116 Routines which return the widget name and the class name. The widget
117 name is passed to the build method. The class name is predefined by
118 each component. These names are used when retrieving X resource val‐
119 ues for the component.
120
121
123 This example shows how an Inventor component can be built inside a pro‐
124 gram using the Xt widget set. The example uses the SoXtExaminerViewer
125 widget to view some simple geometry.
126 #include <Inventor/Xt/SoXt.h>
127 #include <Inventor/nodes/SoCone.h>
128 #include <Inventor/Xt/viewers/SoXtExaminerViewer.h>
129
130 void main(int, char **argv)
131 {
132 // Initialize Inventor and Xt, which must be done
133 // before any Inventor calls are made.
134 Widget myWindow = SoXt::init(argv[0]);
135
136 // create the viewer in the toplevel window
137 // and set some scene to display
138 SoXtExaminerViewer *myViewer = new SoXtExaminerViewer(myWindow);
139 myViewer->setSceneGraph( new SoCone() );
140
141 // manage and map window on screen
142 myViewer->show();
143 SoXt::show(myWindow); // calls XtRealizeWidget()
144
145 // Loop forever
146 SoXt::mainLoop();
147 }
148
149
151 SoXt, SoXtRenderArea, SoXtViewer, SoXtMaterialEditor
152
153
154
155
156 SoXtComponent(3IV)()