XMRESOLVEALLPARTOFFSETS(3)
β¨ XmResolveAllPartOffsets π
okay bestie, so we're looking at XmResolveAllPartOffsets, and it lives in the library call section of the manual. It's a function that lets you write upward-compatible applications and widgets β yes, the iconic kind that don't break the second somebody adds a field. π«Ά
πΈ SYNOPSIS πΈ
#include <Xm/Xm.h>
void XmResolveAllPartOffsets(
WidgetClass widget_class,
XmOffsetPtr * offset,
XmOffsetPtr * constraint_offset);
π DESCRIPTION π
Note: this routine is obsolete, bestie. It's still here for compatibility with previous releases only. You should be calling XmeResolvePartOffsets instead. Not me telling you twice. π
So here's the tea about offset records: using them means you need two extra global variables per widget class. Those variables are just pointers to arrays of offsets into the widget record and the constraint record, for each part of the widget structure. What XmResolveAllPartOffsets does is allocate those offset records so an application can guarantee upward-compatible access to widget instance and constraint records β for both applications and widgets. The widget uses these offset records to get at all of its own variables. And a widget has to take the following steps, periodt.
- Instead of making a resource list, the widget makes an offset resource list. To do that, use the
XmPartResourcestructure and theXmPartOffsetmacro. TheXmPartResourcedata structure looks exactly like a resource list, except instead of one integer for its offset, it has two shorts. You put this structure into the class record as if it were a normal resource list. And instead of usingXtOffsetfor the offset, the widget usesXmPartOffset. - If the widget is a subclass of the
Constraintclass and it defines additional constraint resources, make an offset resource list for the constraint part too. And instead of usingXtOffsetfor the offset, the widget usesXmConstraintPartOffsetin the constraint resource list.
XmPartResource resources[] = {
{ BarNxyz, BarCXyz, XmRBoolean, sizeof(Boolean),
XmPartOffset(Bar,xyz), XmRImmediate, (XtPointer)False } };
XmPartResource constraints[] = {
{ BarNmaxWidth, BarNMaxWidth,
XmRDimension, sizeof(Dimension),
XmConstraintPartOffset(Bar,max_width),
XmRImmediate, (XtPointer)100 } };
- Instead of putting the widget size in the class record, the widget puts the widget part size in that same field. And if the widget is a subclass of the
Constraintclass, instead of putting the widget constraint record size in the class record, the widget puts the widget constraint part size in that same field. π - Instead of putting
XtVersionin the class record, the widget putsXtVersionDontCheckin the class record. - Define a variable of type
XmOffsetPtrto point to the offset record. If the widget is a subclass of theConstraintclass, also define a variable of typeXmOffsetPtrto point to the constraint offset record. These can live in the widget's class record or be separate global variables β your call, bestie. - In class initialization, the widget calls
XmResolveAllPartOffsets, handing it pointers to the class record, the address of the offset record, and the address of the constraint offset record. If the widget is not a subclass of theConstraintclass, it should passNULLas the address of the constraint offset record.
And this call does several things, no cap:
- Adds the superclass (which, by definition, has already been initialized) size field to the part size field
- If the widget is a subclass of the
Constraintclass, adds the superclass constraint size field to the constraint size field - Allocates an array based upon the number of superclasses
- If the widget is a subclass of the constraint class, allocates an array for the constraint offset record
- Fills in the offsets of all the widget parts and constraint parts with the appropriate values, determined by examining the size fields of all superclass records
- Uses the part offset array to modify the offset entries in the resource list to be real offsets, in place
The widget also defines a constant that will be the index to its part structure in the offsets array. That value should be 1 greater than the index of the widget's superclass. Constants defined for all Xm widgets can be found in XmP.h. π
#define BarIndex (XmBulletinBIndex + 1)
Instead of accessing fields directly, the widget must always go through the offset table. The XmField and XmConstraintField macros are your besties for accessing these fields. But here's the catch β because the XmPartOffset, XmConstraintPartOffset, XmField, and XmConstraintField macros concatenate things, you must make sure there is no space after the part argument. For example, the following macros do not work because of the space after the part (Label) argument:
XmField(w, offset, Label, text, char *)
XmPartOffset(Label, text).
So you must not have any spaces after the part (Label) argument, as illustrated here:
XmField(w, offset, Label, text, char *)
You can define macros for each field to make this easier, though. Assume an integer field xyz:
#define BarXyz(w) (*(int *)(((char *) w) + \
offset[BarIndex] + XtOffset(BarPart,xyz)))
And for constraint field max_width:
#define BarMaxWidth(w) \
XmConstraintField(w,constraint_offsets,Bar,max_width,Dimension)
π¦ The Parameters π¦
The parameters for XmResolveAllPartOffsets are:
widget_classβ Specifies the widget class pointer for the created widgetoffsetβ Returns the offset recordconstraint_offsetβ Returns the constraint offset record
π RELATED INFORMATION π
and that's the whole page, bestie! π this one's straight out of the XmResolveAllPartOffsets(library call) pages β no date stamp on it, so don't come for me about timestamps. go slay your offset records, mwah πβ¨
π¦ where this page comes from
- alpine 3.24: motif-doc 2.5.2-r0 Β· LGPL-2.1-or-later
- arch rolling: openmotif 2.3.8-4 Β· LGPL-2.1-or-later
- centos-stream 9: motif-devel 2.3.4-32.el9 Β· LGPLv2+
- centos-stream 9: motif-devel 2.3.4-32.el9 Β· LGPLv2+
- epel 10: motif-devel 2.3.8-2.el10_2 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-1.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-1.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-2.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 43: motif-devel 2.3.8-2.fc43 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: motif-devel 2.3.8-3.fc44 Β· LicenseRef-Callaway-LGPLv2+
- fedora 44: motif-devel 2.3.8-3.fc44 Β· LicenseRef-Callaway-LGPLv2+
- nixos 26.05: motif 2.3.8
- nixpkgs unstable: motif 2.3.8
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: motif-devel 2.3.8-bp160.1.1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms