SOXTRESOURCE(3iv)

πŸ’– SoXtResource β€” the manual page, but make it cute

okay bestie, welcome to SoXtResource(3IV) β€” yes that's the manual name, and yes it's giving "3IV" the whole time, we love a consistent section number πŸ’…


🌸 NAME 🌸

SoXtResource β€” the little helper that goes and gets your X resources for SoXtComponents and widgets πŸŽ€


πŸ¦‹ INHERITS FROM πŸ¦‹

SoXtResource


✨ SYNOPSIS ✨

#include <Inventor/Xt/SoXtResource.h>

Methods from class SoXtResource:

                     SoXtResource(Widget w)
                     ~SoXtResource()
 SbBool              getResource(char *resName, char *resClass, SbColor &c)
 SbBool              getResource(char *resName, char *resClass, short &i)
 SbBool              getResource(char *resName, char *resClass, unsigned
                          short &u)
 SbBool              getResource(char *resName, char *resClass, char *&s)
 SbBool              getResource(char *resName, char *resClass, SbBool &b)
 SbBool              getResource(char *resName, char *resClass, float &f)

πŸ’œ DESCRIPTION πŸ’œ

so basically this class is your low-effort, high-reward way to grab X resource values for widgets and components. ✨ Instead of doing the whole standard Xt thing where you climb up a widget hierarchy with Xt calls, this class does its own traversal β€” and it does that on purpose, because it wants to give special care to widgets that are Inventor components. 🫢

like, real example: the Inventor Material Editor top level widget is a Motif form widget, so its class name is XmForm. But SoXtResource knows the editor is an Inventor component, so it uses the class name that the editor itself provides (in this case "SoXtMaterialEditor") when it goes looking up resource values. no cap, it just knows. πŸ‘‘

EXAMPLE:

SoXtResource xr( materialEditor->getWidget() );
xr.getResource("tile1Color", "Tile1Color", color);
xr.getResource("updateFrequency", "UpdateFrequency", freq);

🌈 METHODS 🌈

                     SoXtResource(Widget w)
                     ~SoXtResource()

Constructor and destructor, the classic duo. πŸ’– The constructor takes the widget it's gonna retrieve resource values for.

 SbBool              getResource(char *resName, char *resClass, SbColor &c)
 SbBool              getResource(char *resName, char *resClass, short &i)
 SbBool              getResource(char *resName, char *resClass, unsigned
                          short &u)
 SbBool              getResource(char *resName, char *resClass, char *&s)
 SbBool              getResource(char *resName, char *resClass, SbBool &b)
 SbBool              getResource(char *resName, char *resClass, float &f)

This hands you back the X resource value for the resource name and class you asked for. And the best part?? you do NOT need to specify the widget hierarchy β€” that gets computed automatically in the constructor. obsessed. 😌✨


πŸŽ€ NOTES πŸŽ€

Components will typically look up their own resources during buildWidget(). 🧚 And here's the important bit, bestie: for a component to have its Inventor class name recognized by SoXtResource, it must call SoXtComponent::registerWidget() in its buildWidget() method. (This is done in every Inventor component.) So don't skip it, fr fr. πŸ’€


⭐ SEE ALSO ⭐

  • X Resources (Xrm)
  • X Intrinsics (Xt)
  • SoXt
  • SoXtComponent

okay that's the whole page, you ate it, go forth and resource your widgets πŸ«ΆπŸ’…

and that's a wrap on SoXtResource(3IV) β€” from the SoXtResource(3IV) manual, page footer and all, no date attached, just vibes and version numbers. πŸŒˆπŸ‘‘