XtClass(3)

πŸ’– NAME πŸ’–

XtClass, XtSuperclass, XtIsSubclass, XtCheckSubclass, XtIsObject, XtIsRectObj, XtIsWidget, XtIsComposite, XtIsConstraint, XtIsShell, XtIsOverrideShell, XtIsWMShell, XtIsVendorShell, XtIsTransientShell, XtIsTopLevelShell, XtIsApplicationShell, XtIsSessionShell β€” bestie, this is the whole girl-gang of functions that obtain and verify a widget's class. That's it, that's the job, and they ate. πŸ’…

This is from the XT FUNCTIONS manual, section 3, in case you were wondering where we're at. ✨


🌸 SYNTAX 🌸

First you gotta pull in the header, no cap:

#include <X11/Intrinsic.h>

Then here's every single one of them, in order, exactly as written:

WidgetClass XtClass(Widget w);

WidgetClass XtSuperclass(Widget w);

Boolean XtIsSubclass(Widget w, WidgetClass widget_class);

void XtCheckSubclass(Widget widget, WidgetClass widget_class, String
       message);

Boolean XtIsObject(Widget w);

Boolean XtIsRectObj(Widget w);

Boolean XtIsWidget(Widget w);

Boolean XtIsComposite(Widget w);

Boolean XtIsConstraint(Widget w);

Boolean XtIsShell(Widget w);

Boolean XtIsOverrideShell(Widget w);

Boolean XtIsWMShell(Widget w);

Boolean XtIsVendorShell(Widget w);

Boolean XtIsTransientShell(Widget w);

Boolean XtIsTopLevelShell(Widget w);

Boolean XtIsApplicationShell(Widget w);

Boolean XtIsSessionShell(Widget w);

Look at that lineup. Seventeen functions. Main character energy from top to bottom. πŸ‘‘


πŸŽ€ ARGUMENTS πŸŽ€

  • w β€” Specifies the widget. (The one you're interrogating. Be nice to her. πŸ₯Ί)
  • widget_class β€” Specifies the widget class. (The vibe you're comparing against. πŸ’œ)
  • message β€” Specifies the message that is to be used. (The little note she'll scream at everyone if things go wrong. 😭)

✨ DESCRIPTION ✨

Okay so let's go one by one, because each of these has her own little thing going on:

  • XtClass returns a pointer to the widget's class structure. Straight to the point, no drama. πŸ¦‹
  • XtSuperclass returns a pointer to the widget's superclass class structure. So like, her mom. Her lineage. Her origin story. πŸ’«
  • XtIsSubclass returns True if the class of the specified widget is equal to or is a subclass of the specified class. And here's the tea: the widget's class can be any number of subclasses down the chain and does not need to be an immediate subclass of the specified class. Composite widgets that need to restrict the class of the items they contain can use XtIsSubclass to find out if a widget belongs to the desired class of objects. Obsessed with the flexibility ngl. 🌈
  • XtCheckSubclass is a macro, and she determines if the class of the specified widget is equal to or is a subclass of the specified widget class. Same deal: the widget can be any number of subclasses down the chain and need not be an immediate subclass of the specified widget class. BUT β€” and this is the part where it gets real β€” if the specified widget is not a subclass, XtCheckSubclass constructs an error message from the supplied message, the widget's actual class, and the expected class, and calls XtErrorMsg. πŸ’€ So yeah, she will absolutely read you in front of everyone. XtCheckSubclass should be used at the entry point of exported routines to ensure that the client has passed in a valid widget class for the exported operation. Gatekeeping? Maybe. Correct? Also yes. 🫢
🚨 Important caveat bestie, do not skip this one: XtCheckSubclass is only executed when the widget has been compiled with the compiler symbol DEBUG defined; otherwise, it is defined as the empty string and generates no code. So in a non-DEBUG build she literally vanishes. Poof. No check. No message. Just vibes. πŸ™ˆ
  • To test if a given widget belongs to a subclass of an Intrinsics-defined class, the Intrinsics defines macros or functions equivalent to XtIsSubclass for each of the built-in classes. Those procedures are: XtIsObject, XtIsRectObj, XtIsWidget, XtIsComposite, XtIsConstraint, XtIsShell, XtIsOverrideShell, XtIsWMShell, XtIsVendorShell, XtIsTransientShell, XtIsTopLevelShell, XtIsApplicationShell, and XtIsSessionShell. Thirteen little shortcuts so you don't have to spell out the whole class every time. Queen behavior. πŸ’–
  • The
ngl the original page literally just ends there β€” "The" and then nothing 😭 we are not making that up, that's genuinely how the manpage text stops. Left us on a cliffhanger fr fr.

πŸ‘‘ SEE ALSO πŸ‘‘


That's the whole page, bestie, every flag, every class, every warning, not a single crumb left behind. πŸ“

Kisses from X Version 11, libXt 1.3.1 β€” mwah, go check your subclass, stay in DEBUG mode, and slay. πŸ’…βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from