| 1 |
NAME SoXtResource "" "" { |
| 2 |
used to retrieve X resources for SoXtComponents and widgets |
| 3 |
} |
| 4 |
|
| 5 |
INCLUDE Xt/SoXtResource.h |
| 6 |
|
| 7 |
DESC { |
| 8 |
This class provides an easy to use interface for retrieving X resource |
| 9 |
values for widgets and components. Rather than use standard Xt calls to |
| 10 |
traverse up a widget hierarchy, this class performs its own traversal so |
| 11 |
that it may provide special care for widgets which are Inventor |
| 12 |
components. For instance, the Inventor Material Editor top level widget is |
| 13 |
a Motif form widget. Its class name is thus XmForm. \cSoXtResource\. knows |
| 14 |
that the editor is an Inventor component, though, so it uses the class name |
| 15 |
provided by the editor (in this case "SoXtMaterialEditor") when looking up |
| 16 |
resource values. |
| 17 |
|
| 18 |
\p |
| 19 |
EXAMPLE: |
| 20 |
\b\k\+ |
| 21 |
SoXtResource xr( materialEditor->getWidget() ); |
| 22 |
xr.getResource("tile1Color", "Tile1Color", color); |
| 23 |
xr.getResource("updateFrequency", "UpdateFrequency", freq); |
| 24 |
\.\- |
| 25 |
SoXtResource *xr; |
| 26 |
xr = SoXtResourceCreate( SoXtMtlEdGetWidget( materialEditor ) ); |
| 27 |
SoXtResourceGetCol(xr, "tile1Color", "Tile1Color", &color); |
| 28 |
SoXtResourceGetInt(xr, "updateFrequency", "UpdateFrequency", &freq); |
| 29 |
\.\.\. |
| 30 |
} |
| 31 |
|
| 32 |
METHOD "" SoXtResource(Widget w) {} |
| 33 |
METHOD "" ~SoXtResource() |
| 34 |
{ |
| 35 |
Constructor and destructor. The constructor takes the widget for which it |
| 36 |
will retrieve resource values. |
| 37 |
} |
| 38 |
|
| 39 |
METHOD getCol SbBool getResource(char *resName, char *resClass, SbColor &c) {} |
| 40 |
METHOD getInt SbBool getResource(char *resName, char *resClass, short &i) {} |
| 41 |
METHOD getUShort SbBool getResource(char *resName, char *resClass, unsigned short &u) {} |
| 42 |
METHOD getStr SbBool getResource(char *resName, char *resClass, char *&s) {} |
| 43 |
METHOD getBool SbBool getResource(char *resName, char *resClass, SbBool &b) {} |
| 44 |
METHOD getFloat SbBool getResource(char *resName, char *resClass, float &f) |
| 45 |
{ |
| 46 |
This returns the X resource value for the specified resource name and |
| 47 |
class. There is no need to specify the widget hierarchy; this is |
| 48 |
automatically computed in the constructor. |
| 49 |
} |
| 50 |
|
| 51 |
BEGIN C++ |
| 52 |
MISC NOTES { |
| 53 |
Components will typically look up their own resources during |
| 54 |
\mbuildWidget()\.. |
| 55 |
In order for a component to have its Inventor class name recognized by |
| 56 |
\cSoXtResource\., |
| 57 |
it must call \mSoXtComponent::registerWidget()\. |
| 58 |
in its \mbuildWidget()\. |
| 59 |
method. (This is done in every Inventor component.) |
| 60 |
} |
| 61 |
END |
| 62 |
|
| 63 |
ALSO { X Resources (Xrm), X Intrinsics (Xt), SoXt, SoXtComponent } |