1XmResolvePartOffsets(library call)          XmResolvePartOffsets(library call)
2
3
4

NAME

6       XmResolvePartOffsets — A function that allows writing of upward-compat‐
7       ible applications and widgets
8

SYNOPSIS

10       #include <Xm/Xm.h>
11       void XmResolvePartOffsets(
12       WidgetClass widget_class,
13       XmOffsetPtr * offset);
14

DESCRIPTION

16       The use of offset records requires one extra global variable per widget
17       class.   The variable consists of a pointer to an array of offsets into
18       the widget record for each part of the  widget  structure.   The  XmRe‐
19       solvePartOffsets  function  allocates  the  offset records needed by an
20       application to guarantee upward-compatible access  to  widget  instance
21       records  by applications and widgets.  These offset records are used by
22       the widget to access all of the widget's variables.  A widget needs  to
23       take the steps described in the following paragraphs.
24
25       Instead  of  creating  a  resource  list,  the widget creates an offset
26       resource list.  To accomplish this, use  the  XmPartResource  structure
27       and  the  XmPartOffset  macro.  The XmPartResource data structure looks
28       just like a resource list, but instead of having one  integer  for  its
29       offset, it has two shorts.  This structure is put into the class record
30       as if it were a normal resource list. Instead of using XtOffset for the
31       offset, the widget uses XmPartOffset.
32
33       XmPartResource resources[] = {
34         { BarNxyz, BarCXyz, XmRBoolean,
35           sizeof(Boolean), XmPartOffset(Bar,xyz),
36           XmRImmediate, (XtPointer)False }
37       };
38
39       Instead of putting the widget size in the class record, the widget puts
40       the widget part size in the same field.
41
42       Instead of putting XtVersion in  the  class  record,  the  widget  puts
43       XtVersionDontCheck in the class record.
44
45       The  widget  defines  a  variable, of type XmOffsetPtr, to point to the
46       offset record.  This can be part of the widget's class record or a sep‐
47       arate global variable.
48
49       In class initialization, the widget calls XmResolvePartOffsets, passing
50       it a pointer to contain the address of the offset record and the  class
51       record.  This does several things:
52
53          ·  Adds  the superclass (which, by definition, has already been ini‐
54             tialized) size field to the part size field
55
56          ·  Allocates an array based upon the number of superclasses
57
58          ·  Fills in the offsets of all the widget parts with the appropriate
59             values, determined by examining the size fields of all superclass
60             records
61
62          ·  Uses the part offset array to modify the offset  entries  in  the
63             resource list to be real offsets, in place
64
65       The widget defines a constant that will be the index to its part struc‐
66       ture in the offsets array.  The value should  be  1  greater  than  the
67       index of the widget's superclass.  Constants defined for all Xm widgets
68       can be found in XmP.h.
69
70       #define BarIndex (XmBulletinBIndex + 1)
71
72       Instead of accessing fields directly, the widget must always go through
73       the  offset  table.   The  XmField macro helps you access these fields.
74       Because  the  XmPartOffset  and  XmField  macros   concatenate   things
75       together,  you  must ensure that there is no space after the part argu‐
76       ment.  For example, the following macros do not  work  because  of  the
77       space after the part (Label) argument:
78
79       XmField(w, offset, Label, text, char *)
80       XmPartOffset(Label, text)
81
82       Therefore,  you  must  not have any spaces after the part (Label) argu‐
83       ment, as illustrated here:
84
85       XmField(w, offset, Label, text, char *)
86
87       You can define macros for each field to make this  easier.   Assume  an
88       integer field xyz:
89
90       #define BarXyz(w) (*(int *)(((char *) w) + \
91               offset[BarIndex] + XtOffset(BarPart,xyz)))
92
93       The parameters for XmResolvePartOffsets are
94
95       widget_class
96                 Specifies the widget class pointer for the created widget
97
98       offset    Returns the offset record
99
101       XmResolveAllPartOffsets(3).
102
103
104
105                                            XmResolvePartOffsets(library call)
Impressum