LayoutP.h

Go to the documentation of this file.
00001 /*
00002  * $XConsortium: LayoutP.h,v 1.2 92/01/22 18:03:08 keith Exp $
00003  *
00004  * Copyright 1991 Massachusetts Institute of Technology
00005  *
00006  * Permission to use, copy, modify, distribute, and sell this software and its
00007  * documentation for any purpose is hereby granted without fee, provided that
00008  * the above copyright notice appear in all copies and that both that
00009  * copyright notice and this permission notice appear in supporting
00010  * documentation, and that the name of M.I.T. not be used in advertising or
00011  * publicity pertaining to distribution of the software without specific,
00012  * written prior permission.  M.I.T. makes no representations about the
00013  * suitability of this software for any purpose.  It is provided "as is"
00014  * without express or implied warranty.
00015  *
00016  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
00017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
00018  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00019  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
00020  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
00021  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00022  *
00023  * Author:  Keith Packard, MIT X Consortium
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; /* this conflicted with Box's BoxRec, besides, it's not used anywhere */
00163 
00164 typedef struct _SubInfo {
00165     int     naturalSize[2];
00166     int     naturalBw;
00167 } SubInfoRec, *SubInfoPtr;
00168 
00169 /* #define New(t) (t *) malloc(sizeof (t)) */
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  * Layout Widget Private Data
00178  *
00179  *********************************************************************/
00180 
00181 /* New fields for the Layout widget class record */
00182 
00183 typedef struct _LayoutClassPart {
00184     int foo;                    /* keep compiler happy. */
00185 } LayoutClassPart;
00186 
00187 /* Full Class record declaration */
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 /* New Fields for the Layout widget record */
00210 
00211 typedef struct {
00212     /* resources */
00213     LayoutPtr   layout;
00214     Boolean     debug;
00215 } LayoutPart;
00216 
00217 /**************************************************************************
00218  *
00219  * Full instance record declaration
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

Generated on Sun Mar 4 15:03:55 2007 for Scilab [trunk] by  doxygen 1.5.1