1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
/*
* Copyright 1991 Massachusetts Institute of Technology
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. M.I.T. makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
* BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Author: Keith Packard, MIT X Consortium
*/
#ifndef _XawLayoutP_h
#define _XawLayoutP_h
#if defined(LAYOUT)
# include "Layout.h"
#else
# include <X11/Xaw3d/Layout.h>
#endif
#include <X11/ConstrainP.h>
#ifdef MOTIF
# include "Xm/ManagerP.h"
#endif
#define GlueEqual(a,b) ((a).order == (b).order && (a).value == (b).value)
#define AddGlue(r,a,b) if (a.order == b.order) { \
r.order = a.order; \
r.value = a.value + b.value; \
} else { \
if (a.order > b.order) \
r = a; \
else \
r = b; \
}
#define MinGlue(r,a,b) if (a.order == b.order) { \
r.order = a.order; \
if (a.value > b.value) \
r.value = b.value; \
else \
r.value = a.value; \
} else { \
if (a.order > b.order) \
r = b; \
else \
r = a; \
}
#define SubGlue(r,a,b) if (a.order == b.order) { \
r.order = a.order; \
r.value = a.value - b.value; \
} else { \
if (a.order > b.order) \
r = a; \
else { \
r.order = b.order; \
r.value = -b.value; \
} \
}
#define ZeroGlue(g) ((g).value = 0, (g).order = 0, (g).expr = 0)
#define IsZeroGlue(g) ((g).value == 0)
#define QuarkToWidget(l,q) XtNameToWidget((Widget) l, \
(char *) XrmQuarkToString(q));
typedef enum _BoxType { BoxBox, WidgetBox, GlueBox, VariableBox } BoxType;
typedef enum _LayoutDirection {
LayoutHorizontal = 0, LayoutVertical = 1
} LayoutDirection;
typedef enum _Operator {
Plus, Minus, Times, Divide, Percent
} Operator;
typedef enum _ExprType {
Constant,
Binary,
Unary,
Width,
Height,
Variable
} ExprType;
typedef struct _Expr *ExprPtr;
typedef struct _Expr {
ExprType type;
union {
double constant;
struct {
Operator op;
ExprPtr left, right;
} binary;
struct {
Operator op;
ExprPtr down;
} unary;
XrmQuark width;
XrmQuark height;
XrmQuark variable;
} u;
} ExprRec;
typedef struct _Glue {
int order;
double value;
ExprPtr expr;
} GlueRec, *GluePtr;
typedef struct _BoxParams {
GlueRec stretch[2];
GlueRec shrink[2];
} BoxParamsRec, *BoxParamsPtr;
typedef struct _Box *BoxPtr;
typedef BoxPtr LayoutPtr;
typedef struct _Box {
BoxPtr nextSibling;
BoxPtr parent;
BoxParamsRec params;
int size[2];
int natural[2];
BoxType type;
union {
struct {
BoxPtr firstChild;
LayoutDirection dir;
} box;
struct {
XrmQuark quark;
Widget widget;
} widget;
struct {
ExprPtr expr;
} glue;
struct {
XrmQuark quark;
ExprPtr expr;
} variable;
} u;
} LBoxRec; /* this conflicted with Box's BoxRec, besides, it's not used anywhere */
typedef struct _SubInfo {
int naturalSize[2];
int naturalBw;
} SubInfoRec, *SubInfoPtr;
/* #define New(t) (t *) malloc(sizeof (t)) */
#define New(t) (t *) XtCalloc(1,sizeof (t))
#define Dispose(p) XtFree((char *) p)
#define Some(t,n) (t*) XtMalloc(sizeof(t) * n)
#define More(p,t,n) ((p)? (t *) XtRealloc((char *) p, sizeof(t)*n):Some(t,n)
/*********************************************************************
*
* Layout Widget Private Data
*
*********************************************************************/
/* New fields for the Layout widget class record */
typedef struct _LayoutClassPart {
int foo; /* keep compiler happy. */
} LayoutClassPart;
/* Full Class record declaration */
typedef struct _LayoutClassRec {
CoreClassPart core_class;
CompositeClassPart composite_class;
ConstraintClassPart constraint_class;
#ifdef MOTIF
XmManagerClassPart manager_class;
#endif
LayoutClassPart layout_class;
} LayoutClassRec;
extern LayoutClassRec layoutClassRec;
typedef struct _LayoutConstraintsRec {
#ifdef MOTIF
XmManagerConstraintPart manager;
#endif
SubInfoRec layout;
} LayoutConstraintsRec, *LayoutConstraints;
#define SubInfo(w) (&(((LayoutConstraints) (w)->core.constraints)->layout))
/* New Fields for the Layout widget record */
typedef struct {
/* resources */
LayoutPtr layout;
Boolean debug;
} LayoutPart;
/**************************************************************************
*
* Full instance record declaration
*
**************************************************************************/
typedef struct _LayoutRec {
CorePart core;
CompositePart composite;
ConstraintPart constraint;
#ifdef MOTIF
XmManagerPart manager;
#endif
LayoutPart layout;
} LayoutRec;
#endif
|