1XmResolveAllPartOffsets(library call) XmResolveAllPartOffsets(library call)
2
3
4
6 XmResolveAllPartOffsets — A function that allows writing of upward-com‐
7 patible applications and widgets
8
10 #include <Xm/Xm.h>
11 void XmResolveAllPartOffsets(
12 WidgetClass widget_class,
13 XmOffsetPtr * offset,
14 XmOffsetPtr * constraint_offset);
15
17 Note:
18
19 This routine is obsolete and exists for compatibility with pre‐
20 vious releases. You should call XmeResolvePartOffsets instead.
21
22 The use of offset records requires two extra global variables per wid‐
23 get class. The variables consist of pointers to arrays of offsets into
24 the widget record and constraint record for each part of the widget
25 structure. The XmResolveAllPartOffsets function allocates the offset
26 records needed by an application to guarantee upward-compatible access
27 to widget instance and constraint records by applications and widgets.
28 These offset records are used by the widget to access all of the wid‐
29 get's variables. A widget needs to take the steps described in the
30 following paragraphs.
31
32 Instead of creating a resource list, the widget creates an offset
33 resource list. To accomplish this, use the XmPartResource structure
34 and the XmPartOffset macro. The XmPartResource data structure looks
35 just like a resource list, but instead of having one integer for its
36 offset, it has two shorts. This structure is put into the class record
37 as if it were a normal resource list. Instead of using XtOffset for the
38 offset, the widget uses XmPartOffset.
39
40 If the widget is a subclass of the Constraint class and it defines
41 additional constraint resources, create an offset resource list for the
42 constraint part as well. Instead of using XtOffset for the offset, the
43 widget uses XmConstraintPartOffset in the constraint resource list.
44
45 XmPartResource resources[] = {
46 { BarNxyz, BarCXyz, XmRBoolean, sizeof(Boolean),
47 XmPartOffset(Bar,xyz), XmRImmediate, (XtPointer)False } };
48 XmPartResource constraints[] = {
49 { BarNmaxWidth, BarNMaxWidth,
50 XmRDimension, sizeof(Dimension),
51 XmConstraintPartOffset(Bar,max_width),
52 XmRImmediate, (XtPointer)100 } };
53
54 Instead of putting the widget size in the class record, the widget puts
55 the widget part size in the same field. If the widget is a subclass of
56 the Constraint class, instead of putting the widget constraint record
57 size in the class record, the widget puts the widget constraint part
58 size in the same field.
59
60 Instead of putting XtVersion in the class record, the widget puts
61 XtVersionDontCheck in the class record.
62
63 Define a variable, of type XmOffsetPtr, to point to the offset record.
64 If the widget is a subclass of the Constraint class, define a variable
65 of type XmOffsetPtr to point to the constraint offset record. These
66 can be part of the widget's class record or separate global variables.
67
68 In class initialization, the widget calls XmResolveAllPartOffsets,
69 passing it pointers to the class record, the address of the offset
70 record, and the address of the constraint offset record. If the widget
71 not is a subclass of the Constraint class, it should pass NULL as the
72 address of the constraint offset record. This does several things:
73
74 · Adds the superclass (which, by definition, has already been ini‐
75 tialized) size field to the part size field
76
77 · If the widget is a subclass of the Constraint class, adds the
78 superclass constraint size field to the constraint size field
79
80 · Allocates an array based upon the number of superclasses
81
82 · If the widget is a subclass of the constraint class, allocates an
83 array for the constraint offset record
84
85 · Fills in the offsets of all the widget parts and constraint parts
86 with the appropriate values, determined by examining the size
87 fields of all superclass records
88
89 · Uses the part offset array to modify the offset entries in the
90 resource list to be real offsets, in place
91
92 The widget defines a constant that will be the index to its part struc‐
93 ture in the offsets array. The value should be 1 greater than the
94 index of the widget's superclass. Constants defined for all Xm widgets
95 can be found in XmP.h.
96
97 #define BarIndex (XmBulletinBIndex + 1)
98
99 Instead of accessing fields directly, the widget must always go through
100 the offset table. The XmField and XmConstraintField macros help you
101 access these fields. Because the XmPartOffset, XmConstraintPartOffset,
102 XmField, and XmConstraintField macros concatenate things, you must
103 ensure that there is no space after the part argument. For example,
104 the following macros do not work because of the space after the part
105 (Label) argument:
106
107 XmField(w, offset, Label, text, char *)
108 XmPartOffset(Label, text).
109
110 Therefore, you must not have any spaces after the part (Label) argu‐
111 ment, as illustrated here:
112
113 XmField(w, offset, Label, text, char *)
114
115 You can define macros for each field to make this easier. Assume an
116 integer field xyz:
117
118 #define BarXyz(w) (*(int *)(((char *) w) + \
119 offset[BarIndex] + XtOffset(BarPart,xyz)))
120
121 For constraint field max_width:
122
123 #define BarMaxWidth(w) \
124 XmConstraintField(w,constraint_offsets,Bar,max_width,Dimension)
125
126 The parameters for XmResolveAllPartOffsets are
127
128 widget_class
129 Specifies the widget class pointer for the created widget
130
131 offset Returns the offset record
132
133 constraint_offset
134 Returns the constraint offset record
135
137 XmResolvePartOffsets(3).
138
139
140
141 XmResolveAllPartOffsets(library call)