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