Back to index

plt-scheme  4.2.1
xwRowCol.c
Go to the documentation of this file.
00001 /* Generated by wbuild
00002  * (generator version 3.2)
00003  */
00004 #include <X11/IntrinsicP.h>
00005 #include <X11/StringDefs.h>
00006 #include <./xwRowColP.h>
00007 static void _resolve_inheritance(
00008 #if NeedFunctionPrototypes
00009 WidgetClass
00010 #endif
00011 );
00012 #line 88 "XWidgets/xwRowCol.w"
00013 static void change_managed(
00014 #if NeedFunctionPrototypes
00015 Widget
00016 #endif
00017 );
00018 #line 95 "XWidgets/xwRowCol.w"
00019 static void insert_child(
00020 #if NeedFunctionPrototypes
00021 Widget 
00022 #endif
00023 );
00024 #line 119 "XWidgets/xwRowCol.w"
00025 static void layout(
00026 #if NeedFunctionPrototypes
00027 Widget,int ,Boolean 
00028 #endif
00029 );
00030 #line 200 "XWidgets/xwRowCol.w"
00031 static XtGeometryResult  geometry_manager(
00032 #if NeedFunctionPrototypes
00033 Widget ,XtWidgetGeometry *,XtWidgetGeometry *
00034 #endif
00035 );
00036 #line 225 "XWidgets/xwRowCol.w"
00037 static void resize(
00038 #if NeedFunctionPrototypes
00039 Widget
00040 #endif
00041 );
00042 #line 234 "XWidgets/xwRowCol.w"
00043 static void initialize(
00044 #if NeedFunctionPrototypes
00045 Widget ,Widget,ArgList ,Cardinal *
00046 #endif
00047 );
00048 #line 244 "XWidgets/xwRowCol.w"
00049 static Boolean  set_values(
00050 #if NeedFunctionPrototypes
00051 Widget ,Widget ,Widget,ArgList ,Cardinal *
00052 #endif
00053 );
00054 #line 266 "XWidgets/xwRowCol.w"
00055 static void align_child(
00056 #if NeedFunctionPrototypes
00057 Widget,int ,int ,int ,int ,Alignment 
00058 #endif
00059 );
00060 #line 266 "XWidgets/xwRowCol.w"
00061 /*ARGSUSED*/
00062 #if NeedFunctionPrototypes
00063 #line 266 "XWidgets/xwRowCol.w"
00064 static void align_child(Widget self,int  cx,int  cy,int  width,int  height,Alignment  alignment)
00065 #else
00066 #line 266 "XWidgets/xwRowCol.w"
00067 static void align_child(self,cx,cy,width,height,alignment)Widget self;int  cx;int  cy;int  width;int  height;Alignment  alignment;
00068 #endif
00069 #line 267 "XWidgets/xwRowCol.w"
00070 {
00071     Position x, y;
00072 
00073     if (alignment & XfwfLeft) x = cx;
00074     else if (alignment & XfwfRight) x = cx + width - ((XfwfRowColWidget)self)->core.width;
00075     else x = cx + (width - ((XfwfRowColWidget)self)->core.width) / 2;
00076     if (alignment & XfwfTop) y = cy;
00077     else if (alignment & XfwfBottom) y = cy + height - ((XfwfRowColWidget)self)->core.height;
00078     else y = cy + (height - ((XfwfRowColWidget)self)->core.height) / 2;
00079     XtMoveWidget(self, x, y);
00080 }
00081 
00082 static XtResource resources[] = {
00083 #line 32 "XWidgets/xwRowCol.w"
00084 {XtNstoreByRow,XtCStoreByRow,XtRBoolean,sizeof(((XfwfRowColRec*)NULL)->xfwfRowCol.storeByRow),XtOffsetOf(XfwfRowColRec,xfwfRowCol.storeByRow),XtRImmediate,(XtPointer)True },
00085 #line 42 "XWidgets/xwRowCol.w"
00086 {XtNrows,XtCRows,XtRInt,sizeof(((XfwfRowColRec*)NULL)->xfwfRowCol.rows),XtOffsetOf(XfwfRowColRec,xfwfRowCol.rows),XtRImmediate,(XtPointer)0 },
00087 #line 43 "XWidgets/xwRowCol.w"
00088 {XtNcolumns,XtCColumns,XtRInt,sizeof(((XfwfRowColRec*)NULL)->xfwfRowCol.columns),XtOffsetOf(XfwfRowColRec,xfwfRowCol.columns),XtRImmediate,(XtPointer)0 },
00089 #line 52 "XWidgets/xwRowCol.w"
00090 {XtNalignment,XtCAlignment,XtRAlignment,sizeof(((XfwfRowColRec*)NULL)->xfwfRowCol.alignment),XtOffsetOf(XfwfRowColRec,xfwfRowCol.alignment),XtRImmediate,(XtPointer)XfwfTopLeft },
00091 #line 64 "XWidgets/xwRowCol.w"
00092 {XtNshrinkToFit,XtCShrinkToFit,XtRBoolean,sizeof(((XfwfRowColRec*)NULL)->xfwfRowCol.shrinkToFit),XtOffsetOf(XfwfRowColRec,xfwfRowCol.shrinkToFit),XtRImmediate,(XtPointer)False },
00093 #line 70 "XWidgets/xwRowCol.w"
00094 {XtNframeType,XtCFrameType,XtRFrameType,sizeof(((XfwfRowColRec*)NULL)->xfwfFrame.frameType),XtOffsetOf(XfwfRowColRec,xfwfFrame.frameType),XtRImmediate,(XtPointer)XfwfSunken },
00095 #line 71 "XWidgets/xwRowCol.w"
00096 {XtNframeWidth,XtCFrameWidth,XtRDimension,sizeof(((XfwfRowColRec*)NULL)->xfwfFrame.frameWidth),XtOffsetOf(XfwfRowColRec,xfwfFrame.frameWidth),XtRImmediate,(XtPointer)2 },
00097 };
00098 
00099 XfwfRowColClassRec xfwfRowColClassRec = {
00100 { /* core_class part */
00101 /* superclass        */  (WidgetClass) &xfwfBoardClassRec,
00102 /* class_name        */  "XfwfRowCol",
00103 /* widget_size       */  sizeof(XfwfRowColRec),
00104 /* class_initialize  */  NULL,
00105 /* class_part_initialize*/  _resolve_inheritance,
00106 /* class_inited      */  FALSE,
00107 /* initialize        */  initialize,
00108 /* initialize_hook   */  NULL,
00109 /* realize           */  XtInheritRealize,
00110 /* actions           */  NULL,
00111 /* num_actions       */  0,
00112 /* resources         */  resources,
00113 /* num_resources     */  7,
00114 /* xrm_class         */  NULLQUARK,
00115 /* compres_motion    */  True ,
00116 /* compress_exposure        */  XtExposeCompressMultiple ,
00117 /* compress_enterleave      */  True ,
00118 /* visible_interest  */  False ,
00119 /* destroy           */  NULL,
00120 /* resize            */  resize,
00121 /* expose            */  XtInheritExpose,
00122 /* set_values        */  set_values,
00123 /* set_values_hook   */  NULL,
00124 /* set_values_almost        */  XtInheritSetValuesAlmost,
00125 /* get_values+hook   */  NULL,
00126 /* accept_focus      */  XtInheritAcceptFocus,
00127 /* version           */  XtVersion,
00128 /* callback_private  */  NULL,
00129 /* tm_table          */  NULL,
00130 /* query_geometry    */  XtInheritQueryGeometry,
00131 /* display_acceleator       */  XtInheritDisplayAccelerator,
00132 /* extension         */  NULL 
00133 },
00134 { /* composite_class part */
00135 geometry_manager,
00136 change_managed,
00137 insert_child,
00138 XtInheritDeleteChild,
00139 NULL
00140 },
00141 { /* XfwfCommon_class part */
00142 XtInherit_compute_inside,
00143 XtInherit_total_frame_width,
00144 XtInherit__expose,
00145 XtInherit_highlight_border,
00146 XtInherit_unhighlight_border,
00147 XtInherit_hilite_callbacks,
00148 XtInherit_would_accept_focus,
00149 XtInherit_traverse,
00150 XtInherit_lighter_color,
00151 XtInherit_darker_color,
00152 XtInherit_set_color,
00153 /* traversal_trans */  NULL ,
00154 /* traversal_trans_small */  NULL ,
00155 /* travMode */  1 ,
00156 },
00157 { /* XfwfFrame_class part */
00158  /* dummy */  0
00159 },
00160 { /* XfwfBoard_class part */
00161 XtInherit_set_abs_location,
00162 },
00163 { /* XfwfRowCol_class part */
00164 layout,
00165 },
00166 };
00167 WidgetClass xfwfRowColWidgetClass = (WidgetClass) &xfwfRowColClassRec;
00168 static void _resolve_inheritance(class)
00169 WidgetClass class;
00170 {
00171   XfwfRowColWidgetClass c = (XfwfRowColWidgetClass) class;
00172   XfwfRowColWidgetClass super;
00173   static CompositeClassExtensionRec extension_rec = {
00174     NULL, NULLQUARK, XtCompositeExtensionVersion,
00175     sizeof(CompositeClassExtensionRec), True};
00176   CompositeClassExtensionRec *ext;
00177   ext = (XtPointer)XtMalloc(sizeof(*ext));
00178   *ext = extension_rec;
00179   ext->next_extension = c->composite_class.extension;
00180   c->composite_class.extension = ext;
00181   if (class == xfwfRowColWidgetClass) return;
00182   super = (XfwfRowColWidgetClass)class->core_class.superclass;
00183   if (c->xfwfRowCol_class.layout == XtInherit_layout)
00184     c->xfwfRowCol_class.layout = super->xfwfRowCol_class.layout;
00185 }
00186 #line 88 "XWidgets/xwRowCol.w"
00187 /*ARGSUSED*/
00188 #if NeedFunctionPrototypes
00189 #line 88 "XWidgets/xwRowCol.w"
00190 static void change_managed(Widget self)
00191 #else
00192 #line 88 "XWidgets/xwRowCol.w"
00193 static void change_managed(self)Widget self;
00194 #endif
00195 #line 89 "XWidgets/xwRowCol.w"
00196 {
00197     ((XfwfRowColWidgetClass)self->core.widget_class)->xfwfRowCol_class.layout(self, ((XfwfRowColWidget)self)->xfwfRowCol.shrinkToFit, True);
00198 }
00199 #line 95 "XWidgets/xwRowCol.w"
00200 /*ARGSUSED*/
00201 #if NeedFunctionPrototypes
00202 #line 174 "XWidgets/xwRowCol.w"
00203 static void insert_child(Widget  child)
00204 #else
00205 #line 174 "XWidgets/xwRowCol.w"
00206 static void insert_child(child)Widget  child;
00207 #endif
00208 { Widget self = XtParent(child); {
00209     xfwfBoardClassRec.composite_class.insert_child(child);
00210     if (((XfwfRowColWidget)self)->xfwfRowCol.shrinkToFit)
00211        ((XfwfRowColWidgetClass)self->core.widget_class)->xfwfRowCol_class.layout(self, ((XfwfRowColWidget)self)->xfwfRowCol.shrinkToFit, False);
00212 }
00213 }
00214 #line 119 "XWidgets/xwRowCol.w"
00215 /*ARGSUSED*/
00216 #if NeedFunctionPrototypes
00217 #line 119 "XWidgets/xwRowCol.w"
00218 static void layout(Widget self,int  shrink,Boolean  align)
00219 #else
00220 #line 119 "XWidgets/xwRowCol.w"
00221 static void layout(self,shrink,align)Widget self;int  shrink;Boolean  align;
00222 #endif
00223 #line 120 "XWidgets/xwRowCol.w"
00224 {
00225     int nrows, ncols, i, nchild, n;
00226     Position left, top, x, y;
00227     int width, height, w, h;
00228     Widget child;
00229 
00230     nchild = 0;
00231     ((XfwfRowColWidget)self)->xfwfRowCol.max_width = 0;
00232     ((XfwfRowColWidget)self)->xfwfRowCol.max_height = 0;
00233     for (i = 0; i < ((XfwfRowColWidget)self)->composite.num_children; i++) {
00234         child = ((XfwfRowColWidget)self)->composite.children[i];
00235         if (align && ! XtIsManaged(child)) continue;
00236         nchild++;
00237         ((XfwfRowColWidget)self)->xfwfRowCol.max_width = max(((XfwfRowColWidget)self)->xfwfRowCol.max_width, ((XfwfRowColWidget)child)->core.width + 2*((XfwfRowColWidget)child)->core.border_width);
00238         ((XfwfRowColWidget)self)->xfwfRowCol.max_height = max(((XfwfRowColWidget)self)->xfwfRowCol.max_height, ((XfwfRowColWidget)child)->core.height + 2*((XfwfRowColWidget)child)->core.border_width);
00239     }
00240 
00241     ((XfwfRowColWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &left, &top, &width, &height);
00242     width = max(0, width);
00243 
00244     if (((XfwfRowColWidget)self)->xfwfRowCol.columns != 0) {
00245         ncols = ((XfwfRowColWidget)self)->xfwfRowCol.columns;
00246         nrows = (nchild + ncols - 1)/ncols;
00247     } else if (((XfwfRowColWidget)self)->xfwfRowCol.rows != 0) {
00248         nrows = ((XfwfRowColWidget)self)->xfwfRowCol.rows;
00249         ncols = (nchild + nrows - 1)/nrows;
00250     } else {
00251         ncols = ((XfwfRowColWidget)self)->xfwfRowCol.max_width != 0 ? width/((XfwfRowColWidget)self)->xfwfRowCol.max_width : 1;
00252         if (ncols == 0) ncols = 1;
00253         nrows = (nchild + ncols - 1)/ncols;
00254     }
00255 
00256     x = left;
00257     y = top;
00258     n = 0;
00259     if (((XfwfRowColWidget)self)->xfwfRowCol.storeByRow) {
00260         for (i = 0; i < ((XfwfRowColWidget)self)->composite.num_children; i++) {
00261             child = ((XfwfRowColWidget)self)->composite.children[i];
00262             if (align && ! XtIsManaged(child)) continue;
00263            if (align)
00264               align_child(child, x, y, ((XfwfRowColWidget)self)->xfwfRowCol.max_width, ((XfwfRowColWidget)self)->xfwfRowCol.max_height, ((XfwfRowColWidget)self)->xfwfRowCol.alignment);
00265             n++;
00266             if (n == ncols) {
00267                 n = 0;
00268                 x = left;
00269                 y += ((XfwfRowColWidget)self)->xfwfRowCol.max_height;
00270             } else
00271                 x += ((XfwfRowColWidget)self)->xfwfRowCol.max_width;
00272         }
00273     } else {
00274         for (i = 0; i < ((XfwfRowColWidget)self)->composite.num_children; i++) {
00275             child = ((XfwfRowColWidget)self)->composite.children[i];
00276             if (align && ! XtIsManaged(child)) continue;
00277            if (align)
00278               align_child(child, x, y, ((XfwfRowColWidget)self)->xfwfRowCol.max_width, ((XfwfRowColWidget)self)->xfwfRowCol.max_height, ((XfwfRowColWidget)self)->xfwfRowCol.alignment);
00279             n++;
00280             if (n == nrows) {
00281                 n = 0;
00282                 y = top;
00283                 x += ((XfwfRowColWidget)self)->xfwfRowCol.max_width;
00284             } else
00285                 y += ((XfwfRowColWidget)self)->xfwfRowCol.max_height;
00286         }
00287     }
00288 
00289     if (shrink) {
00290       w = 2*left + ncols * ((XfwfRowColWidget)self)->xfwfRowCol.max_width;
00291       h = 2*top + nrows * ((XfwfRowColWidget)self)->xfwfRowCol.max_height;
00292       XtVaSetValues(self, XtNwidth, max(1, w), XtNheight, max(1, h), NULL);
00293     }
00294 }
00295 #line 200 "XWidgets/xwRowCol.w"
00296 /*ARGSUSED*/
00297 #if NeedFunctionPrototypes
00298 #line 167 "XWidgets/xwRowCol.w"
00299 static XtGeometryResult  geometry_manager(Widget  child,XtWidgetGeometry * request,XtWidgetGeometry * reply)
00300 #else
00301 #line 167 "XWidgets/xwRowCol.w"
00302 static XtGeometryResult  geometry_manager(child,request,reply)Widget  child;XtWidgetGeometry * request;XtWidgetGeometry * reply;
00303 #endif
00304 { Widget self = XtParent(child); {
00305     Dimension newwd, newht, newbd;
00306 
00307     if (request->request_mode & (CWX | CWY)) return XtGeometryNo;
00308     if (request->request_mode & XtCWQueryOnly) return XtGeometryYes;
00309 
00310     newwd = request->request_mode & CWWidth ? request->width : ((XfwfRowColWidget)child)->core.width;
00311     newht = request->request_mode & CWHeight ? request->height : ((XfwfRowColWidget)child)->core.height;
00312     newbd = request->request_mode & CWBorderWidth
00313         ? request->border_width : ((XfwfRowColWidget)child)->core.border_width;
00314 
00315     if (newwd == ((XfwfRowColWidget)child)->core.width && newht == ((XfwfRowColWidget)child)->core.height
00316         && newbd == ((XfwfRowColWidget)child)->core.border_width) return XtGeometryNo;
00317 
00318     XtResizeWidget(child, newwd, newht, newbd);
00319     ((XfwfRowColWidgetClass)self->core.widget_class)->xfwfRowCol_class.layout(self, ((XfwfRowColWidget)self)->xfwfRowCol.shrinkToFit, True);
00320     return XtGeometryDone;
00321 }
00322 }
00323 #line 225 "XWidgets/xwRowCol.w"
00324 /*ARGSUSED*/
00325 #if NeedFunctionPrototypes
00326 #line 225 "XWidgets/xwRowCol.w"
00327 static void resize(Widget self)
00328 #else
00329 #line 225 "XWidgets/xwRowCol.w"
00330 static void resize(self)Widget self;
00331 #endif
00332 #line 226 "XWidgets/xwRowCol.w"
00333 {
00334     if (((XfwfRowColWidget)self)->xfwfRowCol.rows == 0 && ((XfwfRowColWidget)self)->xfwfRowCol.columns == 0) ((XfwfRowColWidgetClass)self->core.widget_class)->xfwfRowCol_class.layout(self, False, True);
00335 }
00336 #line 234 "XWidgets/xwRowCol.w"
00337 /*ARGSUSED*/
00338 #if NeedFunctionPrototypes
00339 #line 234 "XWidgets/xwRowCol.w"
00340 static void initialize(Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00341 #else
00342 #line 234 "XWidgets/xwRowCol.w"
00343 static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00344 #endif
00345 #line 235 "XWidgets/xwRowCol.w"
00346 {
00347     ((XfwfRowColWidget)self)->xfwfRowCol.max_width = ((XfwfRowColWidget)self)->xfwfRowCol.max_height = 0;
00348 }
00349 #line 244 "XWidgets/xwRowCol.w"
00350 /*ARGSUSED*/
00351 #if NeedFunctionPrototypes
00352 #line 244 "XWidgets/xwRowCol.w"
00353 static Boolean  set_values(Widget  old,Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00354 #else
00355 #line 244 "XWidgets/xwRowCol.w"
00356 static Boolean  set_values(old,request,self,args,num_args)Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00357 #endif
00358 #line 245 "XWidgets/xwRowCol.w"
00359 {
00360     Boolean need_layout = False;
00361     Boolean need_redisplay = False;
00362 
00363     if (((XfwfRowColWidget)old)->xfwfRowCol.storeByRow != ((XfwfRowColWidget)self)->xfwfRowCol.storeByRow) need_layout = True;
00364     if (((XfwfRowColWidget)old)->xfwfRowCol.rows != ((XfwfRowColWidget)self)->xfwfRowCol.rows) need_layout = True;
00365     if (((XfwfRowColWidget)old)->xfwfRowCol.columns != ((XfwfRowColWidget)self)->xfwfRowCol.columns) need_layout = True;
00366     if (((XfwfRowColWidget)old)->xfwfRowCol.alignment != ((XfwfRowColWidget)self)->xfwfRowCol.alignment) need_layout = True;
00367     if (((XfwfRowColWidget)old)->xfwfRowCol.shrinkToFit != ((XfwfRowColWidget)self)->xfwfRowCol.shrinkToFit) need_layout = True;
00368     if (need_layout) {
00369         ((XfwfRowColWidgetClass)self->core.widget_class)->xfwfRowCol_class.layout(self, ((XfwfRowColWidget)self)->xfwfRowCol.shrinkToFit, True);
00370         need_redisplay = True;
00371     }
00372     return need_redisplay;
00373 }