Back to index

plt-scheme  4.2.1
xwFrame.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 <string.h>
00007 #include <stdio.h>
00008 #include <X11/Xmu/Converters.h>
00009 #include <X11/Xmu/CharSet.h>
00010 #include "xwGray.h"
00011 #include <./xwFrameP.h>
00012 static void set_shadow(
00013 #if NeedFunctionPrototypes
00014 Widget,XEvent*,String*,Cardinal*
00015 #endif
00016 );
00017 
00018 static XtActionsRec actionsList[] = {
00019 {"set_shadow", set_shadow},
00020 };
00021 static void _resolve_inheritance(
00022 #if NeedFunctionPrototypes
00023 WidgetClass
00024 #endif
00025 );
00026 static void class_initialize(
00027 #if NeedFunctionPrototypes
00028 void
00029 #endif
00030 );
00031 static void initialize(
00032 #if NeedFunctionPrototypes
00033 Widget ,Widget,ArgList ,Cardinal *
00034 #endif
00035 );
00036 static void realize(
00037 #if NeedFunctionPrototypes
00038 Widget,XtValueMask *,XSetWindowAttributes *
00039 #endif
00040 );
00041 static void destroy(
00042 #if NeedFunctionPrototypes
00043 Widget
00044 #endif
00045 );
00046 static Boolean  set_values(
00047 #if NeedFunctionPrototypes
00048 Widget ,Widget ,Widget,ArgList ,Cardinal *
00049 #endif
00050 );
00051 static void _expose(
00052 #if NeedFunctionPrototypes
00053 Widget,XEvent *,Region 
00054 #endif
00055 );
00056 static void compute_inside(
00057 #if NeedFunctionPrototypes
00058 Widget,Position *,Position *,int *,int *
00059 #endif
00060 );
00061 static Dimension  total_frame_width(
00062 #if NeedFunctionPrototypes
00063 Widget
00064 #endif
00065 );
00066 static XtGeometryResult  query_geometry(
00067 #if NeedFunctionPrototypes
00068 Widget,XtWidgetGeometry *,XtWidgetGeometry *
00069 #endif
00070 );
00071 static XtGeometryResult  geometry_manager(
00072 #if NeedFunctionPrototypes
00073 Widget ,XtWidgetGeometry *,XtWidgetGeometry *
00074 #endif
00075 );
00076 static void resize(
00077 #if NeedFunctionPrototypes
00078 Widget
00079 #endif
00080 );
00081 static void change_managed(
00082 #if NeedFunctionPrototypes
00083 Widget
00084 #endif
00085 );
00086 #define done(type, value) do {\
00087       if (to->addr != NULL) {\
00088           if (to->size < sizeof(type)) {\
00089               to->size = sizeof(type);\
00090               return False;\
00091           }\
00092           *(type*)(to->addr) = (value);\
00093       } else {\
00094           static type static_val;\
00095           static_val = (value);\
00096           to->addr = (XtPointer)&static_val;\
00097       }\
00098       to->size = sizeof(type);\
00099       return True;\
00100   }while (0 )
00101 
00102 
00103 static void create_darkgc(
00104 #if NeedFunctionPrototypes
00105 Widget
00106 #endif
00107 );
00108 static void create_lightgc(
00109 #if NeedFunctionPrototypes
00110 Widget
00111 #endif
00112 );
00113 static void create_fggc(
00114 #if NeedFunctionPrototypes
00115 Widget
00116 #endif
00117 );
00118 static void compute_topcolor(
00119 #if NeedFunctionPrototypes
00120 Widget,int ,XrmValue *
00121 #endif
00122 );
00123 static void compute_bottomcolor(
00124 #if NeedFunctionPrototypes
00125 Widget,int ,XrmValue *
00126 #endif
00127 );
00128 /*ARGSUSED*/
00129 #if NeedFunctionPrototypes
00130 static void create_darkgc(Widget self)
00131 #else
00132 static void create_darkgc(self)Widget self;
00133 #endif
00134 {
00135     XtGCMask mask=0;
00136     XGCValues values;
00137 
00138     if (((XfwfFrameWidget)self)->xfwfFrame.darkgc != NULL) XtReleaseGC(self, ((XfwfFrameWidget)self)->xfwfFrame.darkgc);
00139     switch (((XfwfFrameWidget)self)->xfwfFrame.shadowScheme) {
00140     case XfwfColor:
00141         mask = GCForeground;
00142         values.foreground = ((XfwfFrameWidget)self)->xfwfFrame.bottomShadowColor;
00143         break;
00144     case XfwfStipple:
00145         mask = GCFillStyle | GCStipple | GCForeground | GCBackground;
00146         values.fill_style = FillOpaqueStippled;
00147         values.stipple = ((XfwfFrameWidget)self)->xfwfFrame.bottomShadowStipple ? ((XfwfFrameWidget)self)->xfwfFrame.bottomShadowStipple : GetGray(self);
00148         values.foreground = BlackPixelOfScreen(XtScreen(self));
00149         values.background = ((XfwfFrameWidget)self)->core.background_pixel;
00150         break;
00151     case XfwfBlack:
00152        mask = GCForeground;
00153        values.foreground = BlackPixelOfScreen(XtScreen(self));
00154        break;
00155     case XfwfAuto:
00156         if (DefaultDepthOfScreen(XtScreen(self)) > 4
00157             && ((XfwfFrameWidgetClass)self->core.widget_class)->xfwfCommon_class.darker_color(self, ((XfwfFrameWidget)self)->core.background_pixel, &values.foreground)) {
00158             mask = GCForeground;
00159         } else {
00160             mask = GCFillStyle | GCBackground | GCForeground | GCStipple;
00161             values.fill_style = FillOpaqueStippled;
00162             /* values.background = $background_pixel; */
00163             values.background = WhitePixelOfScreen(XtScreen(self));
00164             values.foreground = BlackPixelOfScreen(XtScreen(self));
00165             values.stipple = GetDarkGray(self);
00166         }
00167         break;
00168     }
00169     ((XfwfFrameWidget)self)->xfwfFrame.darkgc = XtGetGC(self, mask, &values);
00170 }
00171 /*ARGSUSED*/
00172 #if NeedFunctionPrototypes
00173 static void create_lightgc(Widget self)
00174 #else
00175 static void create_lightgc(self)Widget self;
00176 #endif
00177 {
00178     XtGCMask mask=0;
00179     XGCValues values;
00180 
00181     if (((XfwfFrameWidget)self)->xfwfFrame.lightgc != NULL) XtReleaseGC(self, ((XfwfFrameWidget)self)->xfwfFrame.lightgc);
00182     switch (((XfwfFrameWidget)self)->xfwfFrame.shadowScheme) {
00183     case XfwfColor:
00184         mask = GCForeground;
00185         values.foreground = ((XfwfFrameWidget)self)->xfwfFrame.topShadowColor;
00186         break;
00187     case XfwfStipple:
00188         mask = GCFillStyle | GCStipple | GCForeground | GCBackground;
00189         values.fill_style = FillOpaqueStippled;
00190         values.background = ((XfwfFrameWidget)self)->core.background_pixel;
00191         values.stipple = ((XfwfFrameWidget)self)->xfwfFrame.topShadowStipple ? ((XfwfFrameWidget)self)->xfwfFrame.topShadowStipple : GetGray(self);
00192         values.foreground = WhitePixelOfScreen(XtScreen(self));
00193         break;
00194     case XfwfBlack:
00195        mask = GCForeground;
00196        values.foreground = BlackPixelOfScreen(XtScreen(self));
00197        break;
00198     case XfwfAuto:
00199        {
00200          int ok;
00201          if (DefaultDepthOfScreen(XtScreen(self)) > 4) {
00202            ok = ((XfwfFrameWidgetClass)self->core.widget_class)->xfwfCommon_class.lighter_color(self, ((XfwfFrameWidget)self)->core.background_pixel, &values.foreground);
00203          } else
00204            ok = 0;
00205            
00206          if (ok) {
00207             mask = GCForeground;
00208          } else {
00209             mask = GCFillStyle | GCBackground | GCForeground | GCStipple;
00210             values.fill_style = FillOpaqueStippled;
00211             /* values.background = $background_pixel; */
00212             values.background = WhitePixelOfScreen(XtScreen(self));
00213             values.foreground = BlackPixelOfScreen(XtScreen(self));
00214             values.stipple = GetLightGray(self);
00215          }
00216         }
00217         break;
00218     }
00219     ((XfwfFrameWidget)self)->xfwfFrame.lightgc = XtGetGC(self, mask, &values);
00220 }
00221 /*ARGSUSED*/
00222 #if NeedFunctionPrototypes
00223 static void create_fggc(Widget self)
00224 #else
00225 static void create_fggc(self)Widget self;
00226 #endif
00227 {
00228     XtGCMask mask=0;
00229     XGCValues values;
00230 
00231     if (((XfwfFrameWidget)self)->xfwfFrame.fggc != NULL) XtReleaseGC(self, ((XfwfFrameWidget)self)->xfwfFrame.fggc);
00232     mask = GCForeground;
00233     ((XfwfFrameWidgetClass)self->core.widget_class)->xfwfCommon_class.set_color(self, ((XfwfFrameWidget)self)->core.background_pixel, &values.foreground);
00234     ((XfwfFrameWidget)self)->xfwfFrame.fggc = XtGetGC(self, mask, &values);
00235 }
00236 /*ARGSUSED*/
00237 #if NeedFunctionPrototypes
00238 static void compute_topcolor(Widget self,int  offset,XrmValue * value)
00239 #else
00240 static void compute_topcolor(self,offset,value)Widget self;int  offset;XrmValue * value;
00241 #endif
00242 {
00243     static Pixel color;
00244 #if 1
00245     ((XfwfFrameWidgetClass)self->core.widget_class)->xfwfCommon_class.lighter_color(self, ((XfwfFrameWidget)self)->core.background_pixel, &color);
00246 #else
00247     (void) choose_color(self, 1.35, ((XfwfFrameWidget)self)->core.background_pixel, &color);
00248 #endif
00249     value->addr = (XtPointer) &color;
00250 }
00251 /*ARGSUSED*/
00252 #if NeedFunctionPrototypes
00253 static void compute_bottomcolor(Widget self,int  offset,XrmValue * value)
00254 #else
00255 static void compute_bottomcolor(self,offset,value)Widget self;int  offset;XrmValue * value;
00256 #endif
00257 {
00258     static Pixel color;
00259 #if 1
00260     ((XfwfFrameWidgetClass)self->core.widget_class)->xfwfCommon_class.darker_color(self, ((XfwfFrameWidget)self)->core.background_pixel, &color);
00261 #else
00262     (void) choose_color(self, 0.6, ((XfwfFrameWidget)self)->core.background_pixel, &color);
00263 #endif
00264     value->addr = (XtPointer) &color;
00265 }
00266 
00267 static XtResource resources[] = {
00268 {XtNcursor,XtCCursor,XtRCursor,sizeof(((XfwfFrameRec*)NULL)->xfwfFrame.cursor),XtOffsetOf(XfwfFrameRec,xfwfFrame.cursor),XtRImmediate,(XtPointer)None },
00269 {XtNframeType,XtCFrameType,XtRFrameType,sizeof(((XfwfFrameRec*)NULL)->xfwfFrame.frameType),XtOffsetOf(XfwfFrameRec,xfwfFrame.frameType),XtRImmediate,(XtPointer)XfwfRaised },
00270 {XtNframeWidth,XtCFrameWidth,XtRDimension,sizeof(((XfwfFrameRec*)NULL)->xfwfFrame.frameWidth),XtOffsetOf(XfwfFrameRec,xfwfFrame.frameWidth),XtRImmediate,(XtPointer)0 },
00271 {XtNouterOffset,XtCOuterOffset,XtRDimension,sizeof(((XfwfFrameRec*)NULL)->xfwfFrame.outerOffset),XtOffsetOf(XfwfFrameRec,xfwfFrame.outerOffset),XtRImmediate,(XtPointer)0 },
00272 {XtNinnerOffset,XtCInnerOffset,XtRDimension,sizeof(((XfwfFrameRec*)NULL)->xfwfFrame.innerOffset),XtOffsetOf(XfwfFrameRec,xfwfFrame.innerOffset),XtRImmediate,(XtPointer)0 },
00273 {XtNshadowScheme,XtCShadowScheme,XtRShadowScheme,sizeof(((XfwfFrameRec*)NULL)->xfwfFrame.shadowScheme),XtOffsetOf(XfwfFrameRec,xfwfFrame.shadowScheme),XtRImmediate,(XtPointer)XfwfAuto },
00274 {XtNtopShadowColor,XtCTopShadowColor,XtRPixel,sizeof(((XfwfFrameRec*)NULL)->xfwfFrame.topShadowColor),XtOffsetOf(XfwfFrameRec,xfwfFrame.topShadowColor),XtRCallProc,(XtPointer)compute_topcolor },
00275 {XtNbottomShadowColor,XtCBottomShadowColor,XtRPixel,sizeof(((XfwfFrameRec*)NULL)->xfwfFrame.bottomShadowColor),XtOffsetOf(XfwfFrameRec,xfwfFrame.bottomShadowColor),XtRCallProc,(XtPointer)compute_bottomcolor },
00276 {XtNtopShadowStipple,XtCTopShadowStipple,XtRBitmap,sizeof(((XfwfFrameRec*)NULL)->xfwfFrame.topShadowStipple),XtOffsetOf(XfwfFrameRec,xfwfFrame.topShadowStipple),XtRImmediate,(XtPointer)NULL },
00277 {XtNbottomShadowStipple,XtCBottomShadowStipple,XtRBitmap,sizeof(((XfwfFrameRec*)NULL)->xfwfFrame.bottomShadowStipple),XtOffsetOf(XfwfFrameRec,xfwfFrame.bottomShadowStipple),XtRImmediate,(XtPointer)NULL },
00278 {XtNborderWidth,XtCBorderWidth,XtRDimension,sizeof(((XfwfFrameRec*)NULL)->core.border_width),XtOffsetOf(XfwfFrameRec,core.border_width),XtRImmediate,(XtPointer)0 },
00279 };
00280 
00281 XfwfFrameClassRec xfwfFrameClassRec = {
00282 { /* core_class part */
00283 /* superclass        */  (WidgetClass) &xfwfCommonClassRec,
00284 /* class_name        */  "XfwfFrame",
00285 /* widget_size       */  sizeof(XfwfFrameRec),
00286 /* class_initialize  */  class_initialize,
00287 /* class_part_initialize*/  _resolve_inheritance,
00288 /* class_inited      */  FALSE,
00289 /* initialize        */  initialize,
00290 /* initialize_hook   */  NULL,
00291 /* realize           */  realize,
00292 /* actions           */  actionsList,
00293 /* num_actions       */  1,
00294 /* resources         */  resources,
00295 /* num_resources     */  11,
00296 /* xrm_class         */  NULLQUARK,
00297 /* compres_motion    */  True ,
00298 /* compress_exposure        */  XtExposeCompressMaximal ,
00299 /* compress_enterleave      */  True ,
00300 /* visible_interest  */  False ,
00301 /* destroy           */  destroy,
00302 /* resize            */  resize,
00303 /* expose            */  XtInheritExpose,
00304 /* set_values        */  set_values,
00305 /* set_values_hook   */  NULL,
00306 /* set_values_almost        */  XtInheritSetValuesAlmost,
00307 /* get_values+hook   */  NULL,
00308 /* accept_focus      */  XtInheritAcceptFocus,
00309 /* version           */  XtVersion,
00310 /* callback_private  */  NULL,
00311 /* tm_table          */  NULL,
00312 /* query_geometry    */  query_geometry,
00313 /* display_acceleator       */  XtInheritDisplayAccelerator,
00314 /* extension         */  NULL 
00315 },
00316 { /* composite_class part */
00317 geometry_manager,
00318 change_managed,
00319 XtInheritInsertChild,
00320 XtInheritDeleteChild,
00321 NULL
00322 },
00323 { /* XfwfCommon_class part */
00324 compute_inside,
00325 total_frame_width,
00326 _expose,
00327 XtInherit_highlight_border,
00328 XtInherit_unhighlight_border,
00329 XtInherit_hilite_callbacks,
00330 XtInherit_would_accept_focus,
00331 XtInherit_traverse,
00332 XtInherit_lighter_color,
00333 XtInherit_darker_color,
00334 XtInherit_set_color,
00335 /* traversal_trans */  NULL ,
00336 /* traversal_trans_small */  NULL ,
00337 /* travMode */  1 ,
00338 },
00339 { /* XfwfFrame_class part */
00340  /* dummy */  0
00341 },
00342 };
00343 WidgetClass xfwfFrameWidgetClass = (WidgetClass) &xfwfFrameClassRec;
00344 /*ARGSUSED*/
00345 static void set_shadow(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00346 {
00347     Position x, y;
00348     int w, h;
00349     FrameType f = XfwfSunken;
00350 
00351     if (*num_params == 0) f = ((XfwfFrameWidget)self)->xfwfFrame.old_frame_type;  /* Reset to old style */
00352     else if (strcmp("raised", params[0]) == 0) f = XfwfRaised;
00353     else if (strcmp("sunken", params[0]) == 0) f = XfwfSunken;
00354     else if (strcmp("chiseled", params[0]) == 0) f = XfwfChiseled;
00355     else if (strcmp("ledged", params[0]) == 0) f = XfwfLedged;
00356     else XtWarning("Unknown frame type in set_shadow action");
00357 
00358     if (((XfwfFrameWidget)self)->xfwfFrame.frameType != f) {
00359         ((XfwfFrameWidget)self)->xfwfFrame.frameType = f;
00360         xfwfCommonClassRec.xfwfCommon_class.compute_inside(self, &x, &y, &w, &h);
00361        w -= 2*((XfwfFrameWidget)self)->xfwfFrame.outerOffset;
00362        h -= 2*((XfwfFrameWidget)self)->xfwfFrame.outerOffset;
00363         XfwfDrawFrame(self, x + ((XfwfFrameWidget)self)->xfwfFrame.outerOffset, y + ((XfwfFrameWidget)self)->xfwfFrame.outerOffset,
00364                       max(w, 0), max(h, 0),
00365                       ((XfwfFrameWidget)self)->xfwfFrame.frameType, ((XfwfFrameWidget)self)->xfwfFrame.frameWidth, ((XfwfFrameWidget)self)->xfwfFrame.lightgc, ((XfwfFrameWidget)self)->xfwfFrame.darkgc, ((XfwfFrameWidget)self)->xfwfFrame.fggc);
00366     }
00367 }
00368 
00369 static void _resolve_inheritance(class)
00370 WidgetClass class;
00371 {
00372   XfwfFrameWidgetClass c = (XfwfFrameWidgetClass) class;
00373   XfwfFrameWidgetClass super;
00374   static CompositeClassExtensionRec extension_rec = {
00375     NULL, NULLQUARK, XtCompositeExtensionVersion,
00376     sizeof(CompositeClassExtensionRec), True};
00377   CompositeClassExtensionRec *ext;
00378   ext = (XtPointer)XtMalloc(sizeof(*ext));
00379   *ext = extension_rec;
00380   ext->next_extension = c->composite_class.extension;
00381   c->composite_class.extension = ext;
00382   if (class == xfwfFrameWidgetClass) return;
00383   super = (XfwfFrameWidgetClass)class->core_class.superclass;
00384 }
00385 /*ARGSUSED*/
00386 #if NeedFunctionPrototypes
00387 static void class_initialize(void)
00388 #else
00389 static void class_initialize()
00390 #endif
00391 {
00392     static XtConvertArgRec screenArg[] = {
00393     {XtBaseOffset, (XtPointer)XtOffset(Widget, core.screen), sizeof(Screen*)}};
00394 
00395     XtSetTypeConverter(XtRString, XtRFrameType, cvtStringToFrameType,
00396                        NULL, 0, XtCacheNone, NULL);
00397     XtSetTypeConverter(XtRFrameType, XtRString, cvtFrameTypeToString,
00398                        NULL, 0, XtCacheNone, NULL);
00399 
00400     XtAddConverter(XtRString, XtRBitmap, XmuCvtStringToBitmap,
00401                        screenArg, XtNumber(screenArg));
00402 
00403     XtSetTypeConverter(XtRString, XtRShadowScheme, cvtStringToShadowScheme,
00404                        NULL, 0, XtCacheNone, NULL);
00405     XtSetTypeConverter(XtRShadowScheme, XtRString, cvtShadowSchemeToString,
00406                        NULL, 0, XtCacheNone, NULL);
00407 }
00408 /*ARGSUSED*/
00409 #if NeedFunctionPrototypes
00410 static void initialize(Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00411 #else
00412 static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00413 #endif
00414 {
00415     Dimension frame;
00416 
00417     ((XfwfFrameWidget)self)->xfwfFrame.lightgc = NULL;
00418     ((XfwfFrameWidget)self)->xfwfFrame.darkgc = NULL;
00419     ((XfwfFrameWidget)self)->xfwfFrame.fggc = NULL;
00420     ((XfwfFrameWidget)self)->xfwfFrame.old_frame_type = ((XfwfFrameWidget)self)->xfwfFrame.frameType;
00421     /* Make sure the width and height are at least as large as the frame */
00422     frame = ((XfwfFrameWidgetClass)self->core.widget_class)->xfwfCommon_class.total_frame_width(self);
00423     if (((XfwfFrameWidget)self)->core.width < 2 * frame) ((XfwfFrameWidget)self)->core.width = 2 * frame;
00424     if (((XfwfFrameWidget)self)->core.height < 2 * frame) ((XfwfFrameWidget)self)->core.height = 2 * frame;
00425 }
00426 /*ARGSUSED*/
00427 #if NeedFunctionPrototypes
00428 static void realize(Widget self,XtValueMask * mask,XSetWindowAttributes * attributes)
00429 #else
00430 static void realize(self,mask,attributes)Widget self;XtValueMask * mask;XSetWindowAttributes * attributes;
00431 #endif
00432 {
00433     *mask |= CWCursor;
00434     attributes->cursor = ((XfwfFrameWidget)self)->xfwfFrame.cursor;
00435     xfwfCommonClassRec.core_class.realize(self, mask, attributes);
00436 
00437     ((XfwfFrameWidget)self)->xfwfFrame.gray = (Pixmap)NULL;
00438     ((XfwfFrameWidget)self)->xfwfFrame.lightGray = (Pixmap)NULL;
00439     ((XfwfFrameWidget)self)->xfwfFrame.darkGray = (Pixmap)NULL;
00440 
00441     create_lightgc(self);
00442     create_darkgc(self);
00443     create_fggc(self);
00444 }
00445 /*ARGSUSED*/
00446 #if NeedFunctionPrototypes
00447 static void destroy(Widget self)
00448 #else
00449 static void destroy(self)Widget self;
00450 #endif
00451 {
00452   if (((XfwfFrameWidget)self)->xfwfFrame.darkgc) XtReleaseGC(self, ((XfwfFrameWidget)self)->xfwfFrame.darkgc); ((XfwfFrameWidget)self)->xfwfFrame.darkgc = NULL;
00453   if (((XfwfFrameWidget)self)->xfwfFrame.lightgc) XtReleaseGC(self, ((XfwfFrameWidget)self)->xfwfFrame.lightgc); ((XfwfFrameWidget)self)->xfwfFrame.lightgc = NULL;
00454   if (((XfwfFrameWidget)self)->xfwfFrame.fggc) XtReleaseGC(self, ((XfwfFrameWidget)self)->xfwfFrame.fggc); ((XfwfFrameWidget)self)->xfwfFrame.fggc = NULL;
00455 }
00456 /*ARGSUSED*/
00457 #if NeedFunctionPrototypes
00458 static Boolean  set_values(Widget  old,Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00459 #else
00460 static Boolean  set_values(old,request,self,args,num_args)Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00461 #endif
00462 {
00463     Boolean need_redisplay = False;
00464 
00465     if (((XfwfFrameWidget)self)->xfwfFrame.cursor != ((XfwfFrameWidget)old)->xfwfFrame.cursor && XtIsRealized(self))
00466         XDefineCursor(XtDisplay(self), XtWindow(self), ((XfwfFrameWidget)self)->xfwfFrame.cursor);
00467 
00468     if (((XfwfFrameWidget)self)->xfwfFrame.frameType == XfwfChiseled || ((XfwfFrameWidget)self)->xfwfFrame.frameType == XfwfLedged)
00469         ((XfwfFrameWidget)self)->xfwfFrame.frameWidth = 2 * ((int) (((XfwfFrameWidget)self)->xfwfFrame.frameWidth / 2));
00470 
00471     if (((XfwfFrameWidget)self)->xfwfFrame.shadowScheme     != ((XfwfFrameWidget)old)->xfwfFrame.shadowScheme
00472     ||  ((XfwfFrameWidget)self)->core.background_pixel != ((XfwfFrameWidget)old)->core.background_pixel) {
00473         create_darkgc(self);
00474         create_lightgc(self);
00475         create_fggc(self);
00476         need_redisplay = True;
00477     } else if (((XfwfFrameWidget)self)->xfwfFrame.shadowScheme == XfwfColor) {
00478         if (((XfwfFrameWidget)self)->xfwfFrame.topShadowColor != ((XfwfFrameWidget)old)->xfwfFrame.topShadowColor) {
00479             create_lightgc(self);
00480             need_redisplay = True;
00481         }
00482         if (((XfwfFrameWidget)self)->xfwfFrame.bottomShadowColor != ((XfwfFrameWidget)old)->xfwfFrame.bottomShadowColor) {
00483             create_darkgc(self);
00484             need_redisplay = True;
00485         }
00486     } else if (((XfwfFrameWidget)self)->xfwfFrame.shadowScheme == XfwfStipple) {
00487         if (((XfwfFrameWidget)self)->xfwfFrame.topShadowStipple != ((XfwfFrameWidget)old)->xfwfFrame.topShadowStipple) {
00488             create_lightgc(self);
00489             need_redisplay = True;
00490         }
00491         if (((XfwfFrameWidget)self)->xfwfFrame.bottomShadowStipple != ((XfwfFrameWidget)old)->xfwfFrame.bottomShadowStipple) {
00492             create_darkgc(self);
00493             need_redisplay = True;
00494         }
00495     }
00496 
00497     if (((XfwfFrameWidget)self)->xfwfFrame.outerOffset != ((XfwfFrameWidget)old)->xfwfFrame.outerOffset)
00498         need_redisplay = True;
00499 
00500     if (((XfwfFrameWidget)self)->xfwfFrame.innerOffset != ((XfwfFrameWidget)old)->xfwfFrame.innerOffset)
00501         need_redisplay = True;
00502 
00503     if (((XfwfFrameWidget)self)->xfwfFrame.frameType != ((XfwfFrameWidget)old)->xfwfFrame.frameType) {
00504         ((XfwfFrameWidget)self)->xfwfFrame.old_frame_type = ((XfwfFrameWidget)self)->xfwfFrame.frameType;
00505         need_redisplay = True;
00506     }
00507 
00508     if (((XfwfFrameWidget)self)->xfwfFrame.frameWidth != ((XfwfFrameWidget)old)->xfwfFrame.frameWidth)
00509         need_redisplay = True;
00510     else if (((XfwfFrameWidget)self)->xfwfFrame.frameWidth == 0)
00511         need_redisplay = False;
00512 
00513     return need_redisplay;
00514 }
00515 /*ARGSUSED*/
00516 #if NeedFunctionPrototypes
00517 static void _expose(Widget self,XEvent * event,Region  region)
00518 #else
00519 static void _expose(self,event,region)Widget self;XEvent * event;Region  region;
00520 #endif
00521 {
00522     Position x, y;
00523     int w, h;
00524 
00525     if (! XtIsRealized(self)) return;
00526     if (region != NULL) {
00527         XSetRegion(XtDisplay(self), ((XfwfFrameWidget)self)->xfwfFrame.lightgc, region);
00528         XSetRegion(XtDisplay(self), ((XfwfFrameWidget)self)->xfwfFrame.darkgc, region);
00529         XSetRegion(XtDisplay(self), ((XfwfFrameWidget)self)->xfwfFrame.fggc, region);
00530     }
00531     ((XfwfFrameWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &w, &h);
00532     w += 2*((XfwfFrameWidget)self)->xfwfFrame.innerOffset + 2*((XfwfFrameWidget)self)->xfwfFrame.frameWidth;
00533     h += 2*((XfwfFrameWidget)self)->xfwfFrame.innerOffset + 2*((XfwfFrameWidget)self)->xfwfFrame.frameWidth;
00534     XfwfDrawFrame(self, 
00535                 x - ((XfwfFrameWidget)self)->xfwfFrame.frameWidth - ((XfwfFrameWidget)self)->xfwfFrame.innerOffset,
00536                 y - ((XfwfFrameWidget)self)->xfwfFrame.frameWidth - ((XfwfFrameWidget)self)->xfwfFrame.innerOffset,
00537                 max(w, 0),
00538                 max(h, 0),
00539                 ((XfwfFrameWidget)self)->xfwfFrame.frameType, ((XfwfFrameWidget)self)->xfwfFrame.frameWidth, ((XfwfFrameWidget)self)->xfwfFrame.lightgc, ((XfwfFrameWidget)self)->xfwfFrame.darkgc, ((XfwfFrameWidget)self)->xfwfFrame.fggc);
00540     if (region != NULL) {
00541         XSetClipMask(XtDisplay(self), ((XfwfFrameWidget)self)->xfwfFrame.lightgc, None);
00542         XSetClipMask(XtDisplay(self), ((XfwfFrameWidget)self)->xfwfFrame.darkgc, None);
00543         XSetClipMask(XtDisplay(self), ((XfwfFrameWidget)self)->xfwfFrame.fggc, None);
00544     }
00545     xfwfCommonClassRec.xfwfCommon_class._expose(self, event, region);
00546 }
00547 /*ARGSUSED*/
00548 #if NeedFunctionPrototypes
00549 static void compute_inside(Widget self,Position * x,Position * y,int * w,int * h)
00550 #else
00551 static void compute_inside(self,x,y,w,h)Widget self;Position * x;Position * y;int * w;int * h;
00552 #endif
00553 {
00554     xfwfCommonClassRec.xfwfCommon_class.compute_inside(self, x, y, w, h);
00555     *x += ((XfwfFrameWidget)self)->xfwfFrame.outerOffset + ((XfwfFrameWidget)self)->xfwfFrame.frameWidth + ((XfwfFrameWidget)self)->xfwfFrame.innerOffset;
00556     *y += ((XfwfFrameWidget)self)->xfwfFrame.outerOffset + ((XfwfFrameWidget)self)->xfwfFrame.frameWidth + ((XfwfFrameWidget)self)->xfwfFrame.innerOffset;
00557     *w -= 2 * (((XfwfFrameWidget)self)->xfwfFrame.outerOffset + ((XfwfFrameWidget)self)->xfwfFrame.frameWidth + ((XfwfFrameWidget)self)->xfwfFrame.innerOffset);
00558     *h -= 2 * (((XfwfFrameWidget)self)->xfwfFrame.outerOffset + ((XfwfFrameWidget)self)->xfwfFrame.frameWidth + ((XfwfFrameWidget)self)->xfwfFrame.innerOffset);
00559 }
00560 /*ARGSUSED*/
00561 #if NeedFunctionPrototypes
00562 static Dimension  total_frame_width(Widget self)
00563 #else
00564 static Dimension  total_frame_width(self)Widget self;
00565 #endif
00566 {
00567     return xfwfCommonClassRec.xfwfCommon_class.total_frame_width(self) + ((XfwfFrameWidget)self)->xfwfFrame.outerOffset + ((XfwfFrameWidget)self)->xfwfFrame.frameWidth + ((XfwfFrameWidget)self)->xfwfFrame.innerOffset ;
00568 }
00569 /*ARGSUSED*/
00570 #if NeedFunctionPrototypes
00571 static XtGeometryResult  query_geometry(Widget self,XtWidgetGeometry * request,XtWidgetGeometry * reply)
00572 #else
00573 static XtGeometryResult  query_geometry(self,request,reply)Widget self;XtWidgetGeometry * request;XtWidgetGeometry * reply;
00574 #endif
00575 {
00576     XtWidgetGeometry request2, reply2;
00577     XtGeometryResult result;
00578     Dimension h;
00579 
00580     if (((XfwfFrameWidget)self)->composite.num_children == 0) return XtGeometryYes;
00581 
00582     /* We're only interested in size and stacking order */
00583     reply->request_mode =
00584         (CWWidth | CWHeight | CWStackMode) & request->request_mode;
00585 
00586     /* If nothing of interest is left, we can return immediately */
00587     if (reply->request_mode == 0)
00588         return XtGeometryYes;
00589 
00590     /* Prepare a request to the child */
00591     h = 2 * (((XfwfFrameWidget)self)->xfwfFrame.outerOffset + ((XfwfFrameWidget)self)->xfwfFrame.frameWidth + ((XfwfFrameWidget)self)->xfwfFrame.innerOffset);
00592     request2.request_mode = reply->request_mode;
00593     request2.width = request->width - h;
00594     request2.height = request->height - h;
00595     request2.sibling = request->sibling;
00596     request2.stack_mode = request->stack_mode;
00597 
00598     result = XtQueryGeometry(((XfwfFrameWidget)self)->composite.children[0], &request2, &reply2);
00599 
00600     /* If the child accepted its proposal, we accept ours */
00601     if (result == XtGeometryYes) return XtGeometryYes;
00602 
00603     /* If the child doesn't want any change, we don't want any, either */
00604     if (result == XtGeometryNo) return XtGeometryNo;
00605 
00606     /* Otherwise, ignore everything but size and stacking order */
00607     reply->request_mode &= reply2.request_mode;
00608     if (reply->request_mode == 0) return XtGeometryYes;
00609 
00610     reply->width = reply2.width + h;
00611     reply->height = reply2.height + h;
00612     reply->sibling = reply2.sibling;
00613     reply->stack_mode = reply2.stack_mode;
00614     return XtGeometryAlmost;
00615 }
00616 /*ARGSUSED*/
00617 #if NeedFunctionPrototypes
00618 static XtGeometryResult  geometry_manager(Widget  child,XtWidgetGeometry * request,XtWidgetGeometry * reply)
00619 #else
00620 static XtGeometryResult  geometry_manager(child,request,reply)Widget  child;XtWidgetGeometry * request;XtWidgetGeometry * reply;
00621 #endif
00622 { Widget self = XtParent(child); {
00623     XtWidgetGeometry request2, reply2;
00624     XtGeometryResult result;
00625     Position x, y;
00626     int w, h, extraw, extrah;
00627 
00628     ((XfwfFrameWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &w, &h);
00629     if (! (request->request_mode & (CWWidth|CWHeight))) return XtGeometryYes;
00630     extraw = ((XfwfFrameWidget)self)->core.width - w;
00631     extrah = ((XfwfFrameWidget)self)->core.height - h;
00632     request2.request_mode = request->request_mode & (CWWidth|CWHeight);
00633     request2.width = request->width + extraw;
00634     request2.height = request->height + extrah;
00635     result = XtMakeGeometryRequest(self, &request2, &reply2);
00636     if (result == XtGeometryNo) return XtGeometryNo;
00637     if (result == XtGeometryYes) return XtGeometryYes;
00638     reply->request_mode = reply2.request_mode & (CWWidth|CWHeight);
00639     reply->width = reply2.width - extraw;
00640     reply->height = reply2.height - extrah;
00641     return XtGeometryAlmost;
00642 }
00643 }
00644 /*ARGSUSED*/
00645 #if NeedFunctionPrototypes
00646 static void resize(Widget self)
00647 #else
00648 static void resize(self)Widget self;
00649 #endif
00650 {
00651     Position x, y;
00652     int w, h;
00653     Widget child;
00654 
00655     if (((XfwfFrameWidget)self)->composite.num_children == 0) return;
00656     ((XfwfFrameWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &w, &h);
00657     child = ((XfwfFrameWidget)self)->composite.children[0];
00658     w -= 2 * ((XfwfFrameWidget)child)->core.border_width;
00659     h -= 2 * ((XfwfFrameWidget)child)->core.border_width;
00660     XtConfigureWidget(child, x, y, max(1, w), max(1, h), ((XfwfFrameWidget)child)->core.border_width);
00661 }
00662 /*ARGSUSED*/
00663 #if NeedFunctionPrototypes
00664 static void change_managed(Widget self)
00665 #else
00666 static void change_managed(self)Widget self;
00667 #endif
00668 {
00669     XtWidgetGeometry request2, reply2;
00670     XtGeometryResult result;
00671     Widget child;
00672     Position x, y;
00673     int w, h;
00674 
00675     if (((XfwfFrameWidget)self)->composite.num_children == 0) return;
00676     ((XfwfFrameWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &w, &h);
00677     child = ((XfwfFrameWidget)self)->composite.children[0];
00678     request2.request_mode = CWWidth | CWHeight;
00679     request2.width = ((XfwfFrameWidget)child)->core.width + ((XfwfFrameWidget)self)->core.width - w;
00680     request2.height = ((XfwfFrameWidget)child)->core.height + ((XfwfFrameWidget)self)->core.height - h;
00681     result = XtMakeGeometryRequest(self, &request2, &reply2);
00682     ((XfwfFrameWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &x, &y, &w, &h);
00683     w -= 2 * ((XfwfFrameWidget)child)->core.border_width;
00684     h -= 2 * ((XfwfFrameWidget)child)->core.border_width;
00685     XtConfigureWidget(child, x, y, max(1, w), max(1, h), ((XfwfFrameWidget)child)->core.border_width);
00686 }
00687 /*ARGSUSED*/
00688 #if NeedFunctionPrototypes
00689 void XfwfDrawFrame(Widget self,int  x,int  y,int  w,int  h,FrameType  tp,int  t,GC  lightgc,GC  darkgc,GC  fggc)
00690 #else
00691 void XfwfDrawFrame(self,x,y,w,h,tp,t,lightgc,darkgc,fggc)Widget self;int  x;int  y;int  w;int  h;FrameType  tp;int  t;GC  lightgc;GC  darkgc;GC  fggc;
00692 #endif
00693 {
00694     XPoint tlPoints[7], brPoints[7];
00695 
00696     if (t == 0) return;
00697     switch (tp) {
00698     case XfwfPlain:
00699        XDrawRectangle(XtDisplay(self), XtWindow(self), darkgc, x+1, y+1, w-1, h-1);
00700        break;
00701     case XfwfRaised:
00702     case XfwfSunken:
00703         tlPoints[0].x = x;              tlPoints[0].y = y;
00704         tlPoints[1].x = x + w;          tlPoints[1].y = y;
00705         tlPoints[2].x = x + w - t;      tlPoints[2].y = y + t;
00706         tlPoints[3].x = x + t;          tlPoints[3].y = y + t;
00707         tlPoints[4].x = x + t;          tlPoints[4].y = y + h - t;
00708         tlPoints[5].x = x;              tlPoints[5].y = y + h;
00709         tlPoints[6].x = x;              tlPoints[6].y = y;
00710         brPoints[0].x = x + w;          brPoints[0].y = y + h;
00711         brPoints[1].x = x;              brPoints[1].y = y + h;
00712         brPoints[2].x = x + t;          brPoints[2].y = y + h - t;
00713         brPoints[3].x = x + w - t;      brPoints[3].y = y + h - t;
00714         brPoints[4].x = x + w - t;      brPoints[4].y = y + t;
00715         brPoints[5].x = x + w;          brPoints[5].y = y;
00716         brPoints[6].x = x + w;          brPoints[6].y = y + h;
00717         if (tp == XfwfSunken) {
00718             XFillPolygon(XtDisplay(self), XtWindow(self),
00719                          darkgc, tlPoints, 7, Nonconvex, CoordModeOrigin);
00720             XFillPolygon(XtDisplay(self), XtWindow(self),
00721                          lightgc, brPoints, 7, Nonconvex, CoordModeOrigin);
00722         } else {
00723             XFillPolygon(XtDisplay(self), XtWindow(self),
00724                          lightgc, tlPoints, 7, Nonconvex, CoordModeOrigin);
00725             XFillPolygon(XtDisplay(self), XtWindow(self),
00726                          darkgc, brPoints, 7, Nonconvex, CoordModeOrigin);
00727         }
00728        if (fggc)
00729          XDrawRectangle(XtDisplay(self), XtWindow(self), fggc, x, y, w-1, h-1);
00730         break;
00731     case XfwfLedged:
00732         XfwfDrawFrame(self, x, y, w, h, XfwfRaised, t/2, lightgc, darkgc, NULL);
00733         XfwfDrawFrame(self, x+t/2, y+t/2, w-2*(int)(t/2), h-2*(int)(t/2),
00734                   XfwfSunken, t/2, lightgc, darkgc, NULL);
00735         break;
00736     case XfwfChiseled:
00737         XfwfDrawFrame(self, x, y, w, h, XfwfSunken, t/2, lightgc, darkgc, NULL);
00738         XfwfDrawFrame(self, x+t/2, y+t/2, w-2*(int)(t/2), h-2*(int)(t/2),
00739                   XfwfRaised, t/2, lightgc, darkgc, NULL);
00740         break;
00741     case XfwfNothing:
00742         break;
00743     }
00744 
00745 }
00746 /*ARGSUSED*/
00747 #if NeedFunctionPrototypes
00748 Boolean  cvtStringToFrameType(Display * display,XrmValuePtr  args,Cardinal * num_args,XrmValuePtr  from,XrmValuePtr  to,XtPointer * converter_data)
00749 #else
00750 Boolean  cvtStringToFrameType(display,args,num_args,from,to,converter_data)Display * display;XrmValuePtr  args;Cardinal * num_args;XrmValuePtr  from;XrmValuePtr  to;XtPointer * converter_data;
00751 #endif
00752 {
00753     String s = (String) from->addr;
00754 
00755     if (*num_args != 0)
00756         XtAppErrorMsg(XtDisplayToApplicationContext(display),
00757                       "cvtStringToFrameType", "wrongParameters",
00758                       "XtToolkitError",
00759                       "String to frame type conversion needs no arguments",
00760                       (String*) NULL, (Cardinal*) NULL);
00761 
00762     if (XmuCompareISOLatin1(s, "raised") == 0) done(FrameType, XfwfRaised);
00763     if (XmuCompareISOLatin1(s, "sunken") == 0) done(FrameType, XfwfSunken);
00764     if (XmuCompareISOLatin1(s, "chiseled") == 0) done(FrameType, XfwfChiseled);
00765     if (XmuCompareISOLatin1(s, "ledged") == 0) done(FrameType, XfwfLedged);
00766     XtDisplayStringConversionWarning(display, s, XtRFrameType);
00767     done(FrameType, XfwfRaised);
00768 }
00769 /*ARGSUSED*/
00770 #if NeedFunctionPrototypes
00771 Boolean  cvtFrameTypeToString(Display * display,XrmValuePtr  args,Cardinal * num_args,XrmValuePtr  from,XrmValuePtr  to,XtPointer * converter_data)
00772 #else
00773 Boolean  cvtFrameTypeToString(display,args,num_args,from,to,converter_data)Display * display;XrmValuePtr  args;Cardinal * num_args;XrmValuePtr  from;XrmValuePtr  to;XtPointer * converter_data;
00774 #endif
00775 {
00776     if (*num_args != 0)
00777         XtAppErrorMsg(XtDisplayToApplicationContext(display),
00778                       "cvtFrameTypeToString", "wrongParameters",
00779                       "XtToolkitError",
00780                       "Fframe type to String conversion needs no arguments",
00781                       (String*) NULL, (Cardinal*) NULL);
00782     switch (*(FrameType*)from->addr) {
00783     case XfwfRaised: done(String, "raised");
00784     case XfwfSunken: done(String, "sunken");
00785     case XfwfChiseled: done(String, "chiseled");
00786     case XfwfLedged: done(String, "ledged");
00787     default: XtError("Illegal FrameType");
00788     }
00789     return FALSE;
00790 }
00791 /*ARGSUSED*/
00792 #if NeedFunctionPrototypes
00793 Boolean  cvtStringToShadowScheme(Display * display,XrmValuePtr  args,Cardinal * num_args,XrmValuePtr  from,XrmValuePtr  to,XtPointer * converter_data)
00794 #else
00795 Boolean  cvtStringToShadowScheme(display,args,num_args,from,to,converter_data)Display * display;XrmValuePtr  args;Cardinal * num_args;XrmValuePtr  from;XrmValuePtr  to;XtPointer * converter_data;
00796 #endif
00797 {
00798     String s = (String) from->addr;
00799 
00800     if (*num_args != 0)
00801         XtAppErrorMsg(XtDisplayToApplicationContext(display),
00802                       "cvtStringToShadowScheme", "wrongParameters",
00803                       "XtToolkitError",
00804                       "String to shadow scheme conversion needs no arguments",
00805                       (String*) NULL, (Cardinal*) NULL);
00806 
00807     if (XmuCompareISOLatin1(s, "auto")==0) done(ShadowScheme, XfwfAuto);
00808     if (XmuCompareISOLatin1(s, "color")==0) done(ShadowScheme, XfwfColor);
00809     if (XmuCompareISOLatin1(s, "stipple")==0) done(ShadowScheme, XfwfStipple);
00810     XtDisplayStringConversionWarning(display, s, XtRShadowScheme);
00811     done(ShadowScheme, XfwfAuto);
00812 }
00813 /*ARGSUSED*/
00814 #if NeedFunctionPrototypes
00815 Boolean  cvtShadowSchemeToString(Display * display,XrmValuePtr  args,Cardinal * num_args,XrmValuePtr  from,XrmValuePtr  to,XtPointer * converter_data)
00816 #else
00817 Boolean  cvtShadowSchemeToString(display,args,num_args,from,to,converter_data)Display * display;XrmValuePtr  args;Cardinal * num_args;XrmValuePtr  from;XrmValuePtr  to;XtPointer * converter_data;
00818 #endif
00819 {
00820     if (*num_args != 0)
00821         XtAppErrorMsg(XtDisplayToApplicationContext(display),
00822                       "cvtShadowSchemeToString", "wrongParameters",
00823                       "XtToolkitError",
00824                       "Shadow scheme to String conversion needs no arguments",
00825                       (String*) NULL, (Cardinal*) NULL);
00826 
00827     switch (*(ShadowScheme*)from->addr) {
00828     case XfwfAuto: done(String, "auto");
00829     case XfwfColor: done(String, "color");
00830     case XfwfStipple: done(String, "stipple");
00831     case XfwfPlain: done(String, "plain");
00832     default: XtError("Illegal ShadowScheme");
00833     }
00834     return FALSE;
00835 }
00836 /*ARGSUSED*/
00837 #if NeedFunctionPrototypes
00838 Pixmap  GetGray(Widget self)
00839 #else
00840 Pixmap  GetGray(self)Widget self;
00841 #endif
00842 {
00843   if (!((XfwfFrameWidget)self)->xfwfFrame.gray) {
00844     ((XfwfFrameWidget)self)->xfwfFrame.gray = XCreateBitmapFromData(XtDisplay(self), XtWindow(self),
00845         wx_gray_bits, wx_gray_width, wx_gray_height);
00846   }
00847   return ((XfwfFrameWidget)self)->xfwfFrame.gray;
00848 }
00849 /*ARGSUSED*/
00850 #if NeedFunctionPrototypes
00851 Pixmap  GetLightGray(Widget self)
00852 #else
00853 Pixmap  GetLightGray(self)Widget self;
00854 #endif
00855 {
00856   if (!((XfwfFrameWidget)self)->xfwfFrame.lightGray) {
00857     static char light_bits[] = { 0x02, 0x04, 0x01};
00858 
00859     ((XfwfFrameWidget)self)->xfwfFrame.lightGray = XCreateBitmapFromData(XtDisplay(self), XtWindow(self),
00860         light_bits, 3, 3);
00861   }
00862   return ((XfwfFrameWidget)self)->xfwfFrame.lightGray;
00863 }
00864 /*ARGSUSED*/
00865 #if NeedFunctionPrototypes
00866 Pixmap  GetDarkGray(Widget self)
00867 #else
00868 Pixmap  GetDarkGray(self)Widget self;
00869 #endif
00870 {
00871   if (!((XfwfFrameWidget)self)->xfwfFrame.darkGray) {
00872     static char dark_bits[] = { 0x05, 0x03, 0x06};
00873 
00874     ((XfwfFrameWidget)self)->xfwfFrame.darkGray = XCreateBitmapFromData(XtDisplay(self), XtWindow(self),
00875         dark_bits, 3, 3);
00876   }
00877   return ((XfwfFrameWidget)self)->xfwfFrame.darkGray;
00878 }