00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _XawLayoutP_h
00027 #define _XawLayoutP_h
00028
00029 #if defined(LAYOUT)
00030 # include "Layout.h"
00031 #else
00032 # include <X11/Xaw3d/Layout.h>
00033 #endif
00034
00035 #include <X11/ConstrainP.h>
00036
00037 #ifdef MOTIF
00038 # include "Xm/ManagerP.h"
00039 #endif
00040
00041 #define GlueEqual(a,b) ((a).order == (b).order && (a).value == (b).value)
00042
00043 #define AddGlue(r,a,b) if (a.order == b.order) { \
00044 r.order = a.order; \
00045 r.value = a.value + b.value; \
00046 } else { \
00047 if (a.order > b.order) \
00048 r = a; \
00049 else \
00050 r = b; \
00051 }
00052
00053 #define MinGlue(r,a,b) if (a.order == b.order) { \
00054 r.order = a.order; \
00055 if (a.value > b.value) \
00056 r.value = b.value; \
00057 else \
00058 r.value = a.value; \
00059 } else { \
00060 if (a.order > b.order) \
00061 r = b; \
00062 else \
00063 r = a; \
00064 }
00065
00066 #define SubGlue(r,a,b) if (a.order == b.order) { \
00067 r.order = a.order; \
00068 r.value = a.value - b.value; \
00069 } else { \
00070 if (a.order > b.order) \
00071 r = a; \
00072 else { \
00073 r.order = b.order; \
00074 r.value = -b.value; \
00075 } \
00076 }
00077
00078 #define ZeroGlue(g) ((g).value = 0, (g).order = 0, (g).expr = 0)
00079 #define IsZeroGlue(g) ((g).value == 0)
00080
00081 #define QuarkToWidget(l,q) XtNameToWidget((Widget) l, \
00082 (char *) XrmQuarkToString(q));
00083
00084 typedef enum _BoxType { BoxBox, WidgetBox, GlueBox, VariableBox } BoxType;
00085
00086 typedef enum _LayoutDirection {
00087 LayoutHorizontal = 0, LayoutVertical = 1
00088 } LayoutDirection;
00089
00090 typedef enum _Operator {
00091 Plus, Minus, Times, Divide, Percent
00092 } Operator;
00093
00094 typedef enum _ExprType {
00095 Constant,
00096 Binary,
00097 Unary,
00098 Width,
00099 Height,
00100 Variable
00101 } ExprType;
00102
00103 typedef struct _Expr *ExprPtr;
00104
00105 typedef struct _Expr {
00106 ExprType type;
00107 union {
00108 double constant;
00109 struct {
00110 Operator op;
00111 ExprPtr left, right;
00112 } binary;
00113 struct {
00114 Operator op;
00115 ExprPtr down;
00116 } unary;
00117 XrmQuark width;
00118 XrmQuark height;
00119 XrmQuark variable;
00120 } u;
00121 } ExprRec;
00122
00123 typedef struct _Glue {
00124 int order;
00125 double value;
00126 ExprPtr expr;
00127 } GlueRec, *GluePtr;
00128
00129 typedef struct _BoxParams {
00130 GlueRec stretch[2];
00131 GlueRec shrink[2];
00132 } BoxParamsRec, *BoxParamsPtr;
00133
00134 typedef struct _Box *BoxPtr;
00135
00136 typedef BoxPtr LayoutPtr;
00137
00138 typedef struct _Box {
00139 BoxPtr nextSibling;
00140 BoxPtr parent;
00141 BoxParamsRec params;
00142 int size[2];
00143 int natural[2];
00144 BoxType type;
00145 union {
00146 struct {
00147 BoxPtr firstChild;
00148 LayoutDirection dir;
00149 } box;
00150 struct {
00151 XrmQuark quark;
00152 Widget widget;
00153 } widget;
00154 struct {
00155 ExprPtr expr;
00156 } glue;
00157 struct {
00158 XrmQuark quark;
00159 ExprPtr expr;
00160 } variable;
00161 } u;
00162 } LBoxRec;
00163
00164 typedef struct _SubInfo {
00165 int naturalSize[2];
00166 int naturalBw;
00167 } SubInfoRec, *SubInfoPtr;
00168
00169
00170 #define New(t) (t *) XtCalloc(1,sizeof (t))
00171 #define Dispose(p) XtFree((char *) p)
00172 #define Some(t,n) (t*) XtMalloc(sizeof(t) * n)
00173 #define More(p,t,n) ((p)? (t *) XtRealloc((char *) p, sizeof(t)*n):Some(t,n)
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 typedef struct _LayoutClassPart {
00184 int foo;
00185 } LayoutClassPart;
00186
00187
00188 typedef struct _LayoutClassRec {
00189 CoreClassPart core_class;
00190 CompositeClassPart composite_class;
00191 ConstraintClassPart constraint_class;
00192 #ifdef MOTIF
00193 XmManagerClassPart manager_class;
00194 #endif
00195 LayoutClassPart layout_class;
00196 } LayoutClassRec;
00197
00198 extern LayoutClassRec layoutClassRec;
00199
00200 typedef struct _LayoutConstraintsRec {
00201 #ifdef MOTIF
00202 XmManagerConstraintPart manager;
00203 #endif
00204 SubInfoRec layout;
00205 } LayoutConstraintsRec, *LayoutConstraints;
00206
00207 #define SubInfo(w) (&(((LayoutConstraints) (w)->core.constraints)->layout))
00208
00209
00210
00211 typedef struct {
00212
00213 LayoutPtr layout;
00214 Boolean debug;
00215 } LayoutPart;
00216
00217
00218
00219
00220
00221
00222
00223 typedef struct _LayoutRec {
00224 CorePart core;
00225 CompositePart composite;
00226 ConstraintPart constraint;
00227 #ifdef MOTIF
00228 XmManagerPart manager;
00229 #endif
00230 LayoutPart layout;
00231 } LayoutRec;
00232 #endif