Back to index

plt-scheme  4.2.1
xwCommon.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 <stdio.h>
00007 #include <ctype.h>
00008 #include <X11/Xmu/Converters.h>
00009 #include <X11/Xmu/CharSet.h>
00010 #include <X11/Shell.h>
00011 #include <X11/keysym.h>
00012 #include "wxAllocColor.h"
00013 #include "wxAllocColor.c"
00014 #include "wxgl.h"
00015 #include <./xwCommonP.h>
00016 #define focus_detail(detail) (detail ==NotifyAncestor ?"NotifyAncestor":detail ==NotifyVirtual ?"NotifyVirtual":detail ==NotifyInferior ?"NotifyInferior":detail ==NotifyNonlinear ?"NotifyNonlinear":detail ==NotifyNonlinearVirtual ?"NotifyNonlinearVirtual":detail ==NotifyPointer ?"NotifyPointer":detail ==NotifyPointerRoot ?"NotifyPointerRoot":detail ==NotifyDetailNone ?"NotifyDetailNone":"???")
00017 
00018 
00019 static void focusIn(
00020 #if NeedFunctionPrototypes
00021 Widget,XEvent*,String*,Cardinal*
00022 #endif
00023 );
00024 static void focusOut(
00025 #if NeedFunctionPrototypes
00026 Widget,XEvent*,String*,Cardinal*
00027 #endif
00028 );
00029 static void checkTraverse(
00030 #if NeedFunctionPrototypes
00031 Widget,XEvent*,String*,Cardinal*
00032 #endif
00033 );
00034 static void traverseDown(
00035 #if NeedFunctionPrototypes
00036 Widget,XEvent*,String*,Cardinal*
00037 #endif
00038 );
00039 static void traverseUp(
00040 #if NeedFunctionPrototypes
00041 Widget,XEvent*,String*,Cardinal*
00042 #endif
00043 );
00044 static void traverseLeft(
00045 #if NeedFunctionPrototypes
00046 Widget,XEvent*,String*,Cardinal*
00047 #endif
00048 );
00049 static void traverseRight(
00050 #if NeedFunctionPrototypes
00051 Widget,XEvent*,String*,Cardinal*
00052 #endif
00053 );
00054 static void traverseNext(
00055 #if NeedFunctionPrototypes
00056 Widget,XEvent*,String*,Cardinal*
00057 #endif
00058 );
00059 static void traversePrev(
00060 #if NeedFunctionPrototypes
00061 Widget,XEvent*,String*,Cardinal*
00062 #endif
00063 );
00064 static void traverseNextTop(
00065 #if NeedFunctionPrototypes
00066 Widget,XEvent*,String*,Cardinal*
00067 #endif
00068 );
00069 static void traverseHome(
00070 #if NeedFunctionPrototypes
00071 Widget,XEvent*,String*,Cardinal*
00072 #endif
00073 );
00074 static void traverseCurrent(
00075 #if NeedFunctionPrototypes
00076 Widget,XEvent*,String*,Cardinal*
00077 #endif
00078 );
00079 
00080 static XtActionsRec actionsList[] = {
00081 {"focusIn", focusIn},
00082 {"focusOut", focusOut},
00083 {"checkTraverse", checkTraverse},
00084 {"traverseDown", traverseDown},
00085 {"traverseUp", traverseUp},
00086 {"traverseLeft", traverseLeft},
00087 {"traverseRight", traverseRight},
00088 {"traverseNext", traverseNext},
00089 {"traversePrev", traversePrev},
00090 {"traverseNextTop", traverseNextTop},
00091 {"traverseHome", traverseHome},
00092 {"traverseCurrent", traverseCurrent},
00093 };
00094 static void _resolve_inheritance(
00095 #if NeedFunctionPrototypes
00096 WidgetClass
00097 #endif
00098 );
00099 static void realize(
00100 #if NeedFunctionPrototypes
00101 Widget,XtValueMask *,XSetWindowAttributes *
00102 #endif
00103 );
00104 static void class_initialize(
00105 #if NeedFunctionPrototypes
00106 void
00107 #endif
00108 );
00109 static void initialize(
00110 #if NeedFunctionPrototypes
00111 Widget ,Widget,ArgList ,Cardinal *
00112 #endif
00113 );
00114 static Boolean  set_values(
00115 #if NeedFunctionPrototypes
00116 Widget ,Widget ,Widget,ArgList ,Cardinal *
00117 #endif
00118 );
00119 static void compute_inside(
00120 #if NeedFunctionPrototypes
00121 Widget,Position *,Position *,int *,int *
00122 #endif
00123 );
00124 static Dimension  total_frame_width(
00125 #if NeedFunctionPrototypes
00126 Widget
00127 #endif
00128 );
00129 static void expose(
00130 #if NeedFunctionPrototypes
00131 Widget,XEvent *,Region 
00132 #endif
00133 );
00134 static void _expose(
00135 #if NeedFunctionPrototypes
00136 Widget,XEvent *,Region 
00137 #endif
00138 );
00139 static void destroy(
00140 #if NeedFunctionPrototypes
00141 Widget
00142 #endif
00143 );
00144 static void highlight_border(
00145 #if NeedFunctionPrototypes
00146 Widget
00147 #endif
00148 );
00149 static void unhighlight_border(
00150 #if NeedFunctionPrototypes
00151 Widget
00152 #endif
00153 );
00154 static Boolean  accept_focus(
00155 #if NeedFunctionPrototypes
00156 Widget,Time *
00157 #endif
00158 );
00159 static void hilite_callbacks(
00160 #if NeedFunctionPrototypes
00161 Widget
00162 #endif
00163 );
00164 static Boolean  would_accept_focus(
00165 #if NeedFunctionPrototypes
00166 Widget
00167 #endif
00168 );
00169 static void traverse(
00170 #if NeedFunctionPrototypes
00171 Widget,TraversalDirection ,Widget ,Time *
00172 #endif
00173 );
00174 static Boolean  lighter_color(
00175 #if NeedFunctionPrototypes
00176 Widget,Pixel ,Pixel *
00177 #endif
00178 );
00179 static Boolean  darker_color(
00180 #if NeedFunctionPrototypes
00181 Widget,Pixel ,Pixel *
00182 #endif
00183 );
00184 static Boolean  set_color(
00185 #if NeedFunctionPrototypes
00186 Widget,Pixel ,Pixel *
00187 #endif
00188 );
00189 #define done(type, value) do {\
00190         if (to->addr != NULL) {\
00191             if (to->size < sizeof(type)) {\
00192                 to->size = sizeof(type);\
00193                 return False;\
00194             }\
00195             *(type*)(to->addr) = (value);\
00196         } else {\
00197             static type static_val;\
00198             static_val = (value);\
00199             to->addr = (XtPointer)&static_val;\
00200         }\
00201         to->size = sizeof(type);\
00202         return True;\
00203     }while (0 )
00204 
00205 
00206 static Boolean  cvtStringToAlignment(
00207 #if NeedFunctionPrototypes
00208 Display *,XrmValuePtr ,Cardinal *,XrmValuePtr ,XrmValuePtr ,XtPointer *
00209 #endif
00210 );
00211 static Boolean  cvtAlignmentToString(
00212 #if NeedFunctionPrototypes
00213 Display *,XrmValuePtr ,Cardinal *,XrmValuePtr ,XrmValuePtr ,XtPointer *
00214 #endif
00215 );
00216 static char  extraTranslations[] = "<Key>: checkTraverse()";;
00217 static char  extraTranslationsSmall[] = "\
00218         <FocusIn>: focusIn()\n\
00219         <FocusOut>: focusOut()";;
00220 static Boolean  traverse_to_direction(
00221 #if NeedFunctionPrototypes
00222 Widget,TraversalDirection ,int ,int ,Widget *,int *
00223 #endif
00224 );
00225 static void traverse_to_next(
00226 #if NeedFunctionPrototypes
00227 Widget,Widget ,Time *
00228 #endif
00229 );
00230 static void traverse_to_prev(
00231 #if NeedFunctionPrototypes
00232 Widget,Widget ,Time *
00233 #endif
00234 );
00235 static void traverse_to_next_top(
00236 #if NeedFunctionPrototypes
00237 Widget,Widget ,Time *
00238 #endif
00239 );
00240 /*ARGSUSED*/
00241 #if NeedFunctionPrototypes
00242 static Boolean  cvtStringToAlignment(Display * display,XrmValuePtr  args,Cardinal * num_args,XrmValuePtr  from,XrmValuePtr  to,XtPointer * converter_data)
00243 #else
00244 static Boolean  cvtStringToAlignment(display,args,num_args,from,to,converter_data)Display * display;XrmValuePtr  args;Cardinal * num_args;XrmValuePtr  from;XrmValuePtr  to;XtPointer * converter_data;
00245 #endif
00246 {
00247     Alignment a = 0;
00248     char c, *t, *s = (char*) from->addr;
00249 
00250     if (*num_args != 0)
00251         XtAppErrorMsg(XtDisplayToApplicationContext(display),
00252                       "cvtStringToAlignment", "wrongParameters",
00253                       "XtToolkitError",
00254                       "String to Alignment conversion needs no arguments",
00255                       (String*) NULL, (Cardinal*) NULL);
00256 
00257     while (*s) {
00258         for (; isspace(*s); s++) ;
00259         for (t = s; *t && ! isspace(*t); t++) ;
00260         c = *t;
00261         *t = '\0';
00262         if (XmuCompareISOLatin1(s, "top") == 0) a |= XfwfTop;
00263         else if (XmuCompareISOLatin1(s, "bottom") == 0) a |= XfwfBottom;
00264         else if (XmuCompareISOLatin1(s, "center") == 0) ; /* skip */
00265         else if (XmuCompareISOLatin1(s, "left") == 0) a |= XfwfLeft;
00266         else if (XmuCompareISOLatin1(s, "right") == 0) a |= XfwfRight;
00267         else {
00268             XtDisplayStringConversionWarning(display, (char*) from->addr, 
00269                                              "Alignment");
00270             break;
00271         }
00272         *t = c;
00273         s = t;
00274     }
00275     done(Alignment, a);
00276 }
00277 /*ARGSUSED*/
00278 #if NeedFunctionPrototypes
00279 static Boolean  cvtAlignmentToString(Display * display,XrmValuePtr  args,Cardinal * num_args,XrmValuePtr  from,XrmValuePtr  to,XtPointer * converter_data)
00280 #else
00281 static Boolean  cvtAlignmentToString(display,args,num_args,from,to,converter_data)Display * display;XrmValuePtr  args;Cardinal * num_args;XrmValuePtr  from;XrmValuePtr  to;XtPointer * converter_data;
00282 #endif
00283 {
00284     Alignment *a = (Alignment*) from->addr;
00285 
00286     if (*num_args != 0)
00287         XtAppErrorMsg(XtDisplayToApplicationContext(display),
00288                       "cvtAlignmentToString", "wrongParameters",
00289                       "XtToolkitError",
00290                       "Alignment to String conversion needs no arguments",
00291                       (String*) NULL, (Cardinal*) NULL);
00292     switch (*a) {
00293     case XfwfCenter: done(String, "center");
00294     case XfwfBottom: done(String, "bottom");
00295     case XfwfTop: done(String, "top");
00296     case XfwfLeft: done(String, "left");
00297     case XfwfRight: done(String, "right");
00298     case XfwfBottom + XfwfLeft: done(String, "bottom left");
00299     case XfwfBottom + XfwfRight: done(String, "bottom right");
00300     case XfwfTop + XfwfLeft: done(String, "top left");
00301     case XfwfTop + XfwfRight: done(String, "top right");
00302     default: done(String, "unknown");
00303     }
00304 }
00305 /*ARGSUSED*/
00306 #if NeedFunctionPrototypes
00307 static Boolean  traverse_to_direction(Widget self,TraversalDirection  dir,int  x,int  y,Widget * found,int * distance)
00308 #else
00309 static Boolean  traverse_to_direction(self,dir,x,y,found,distance)Widget self;TraversalDirection  dir;int  x;int  y;Widget * found;int * distance;
00310 #endif
00311 {
00312     int i;
00313     Position rx, ry;
00314     int dist;
00315     Boolean found_child = False;
00316 
00317     if (! ((XfwfCommonWidget)self)->xfwfCommon.traversalOn) return False;
00318     /*
00319      * First recurse to all descendants
00320      */
00321     for (i = 0; i < ((XfwfCommonWidget)self)->composite.num_children; i++)
00322         if (XtIsSubclass(((XfwfCommonWidget)self)->composite.children[i], xfwfCommonWidgetClass)
00323             && traverse_to_direction(((XfwfCommonWidget)self)->composite.children[i], dir, x, y, found, distance))
00324             found_child = True;
00325     if (found_child) return True;
00326     /*
00327      * No child found, now check own position and distance
00328      */
00329     switch (dir) {
00330     case TraverseHome: rx = 0; ry = 0; break;
00331     case TraverseLeft: rx = ((XfwfCommonWidget)self)->core.width; ry = ((XfwfCommonWidget)self)->core.height/2; break;
00332     case TraverseDown: rx = ((XfwfCommonWidget)self)->core.width/2; ry = 0; break;
00333     case TraverseRight: rx = 0; ry = ((XfwfCommonWidget)self)->core.height/2; break;
00334     case TraverseUp: rx = ((XfwfCommonWidget)self)->core.width/2; ry = ((XfwfCommonWidget)self)->core.height; break;
00335     default: break;
00336     }
00337     XtTranslateCoords(self, rx, ry, &rx, &ry);
00338     if ((dir == TraverseUp && ry > y)
00339         || (dir == TraverseLeft && rx > x)
00340         || (dir == TraverseDown && ry < y)
00341         || (dir == TraverseRight && rx < x)) return False;
00342     dist = (rx - x)*(rx - x) + (ry - y)*(ry - y);
00343     if (dist >= *distance) return False;
00344     /*
00345      * We are the best so far, but do we want the focus?
00346      */
00347     if (! ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.would_accept_focus(self)) return False;
00348     *distance = dist;
00349     *found = self;
00350     return True;
00351 }
00352 /*ARGSUSED*/
00353 #if NeedFunctionPrototypes
00354 static void traverse_to_next(Widget self,Widget  current,Time * time)
00355 #else
00356 static void traverse_to_next(self,current,time)Widget self;Widget  current;Time * time;
00357 #endif
00358 {
00359     int i = 0;
00360     Widget parent = XtParent(self);
00361 
00362     while (i < ((XfwfCommonWidget)self)->composite.num_children && ((XfwfCommonWidget)self)->composite.children[i] != current) i++;
00363     for (i++; i < ((XfwfCommonWidget)self)->composite.num_children; i++)
00364         if (XtCallAcceptFocus(((XfwfCommonWidget)self)->composite.children[i], time)) return;
00365     if (XtIsSubclass(parent, xfwfCommonWidgetClass))
00366         ((XfwfCommonWidgetClass)parent->core.widget_class)->xfwfCommon_class.traverse(parent, TraverseNext, self, time);
00367 }
00368 /*ARGSUSED*/
00369 #if NeedFunctionPrototypes
00370 static void traverse_to_prev(Widget self,Widget  current,Time * time)
00371 #else
00372 static void traverse_to_prev(self,current,time)Widget self;Widget  current;Time * time;
00373 #endif
00374 {
00375     int i = 0;
00376     Widget parent = XtParent(self);
00377 
00378     while (i < ((XfwfCommonWidget)self)->composite.num_children && ((XfwfCommonWidget)self)->composite.children[i] != current) i++;
00379     for (i--; i >= 0; i--)
00380         if (XtCallAcceptFocus(((XfwfCommonWidget)self)->composite.children[i], time)) return;
00381     if (XtIsSubclass(parent, xfwfCommonWidgetClass))
00382         ((XfwfCommonWidgetClass)parent->core.widget_class)->xfwfCommon_class.traverse(parent, TraversePrev, self, time);
00383 }
00384 /*ARGSUSED*/
00385 #if NeedFunctionPrototypes
00386 static void traverse_to_next_top(Widget self,Widget  current,Time * time)
00387 #else
00388 static void traverse_to_next_top(self,current,time)Widget self;Widget  current;Time * time;
00389 #endif
00390 {
00391     Widget parent = XtParent(self);
00392 
00393     if (XtIsSubclass(parent, xfwfCommonWidgetClass))
00394         ((XfwfCommonWidgetClass)parent->core.widget_class)->xfwfCommon_class.traverse(parent, TraverseNextTop, current, time);
00395     else
00396         XtCallCallbackList(self, ((XfwfCommonWidget)self)->xfwfCommon.nextTop, NULL);
00397 }
00398 
00399 static XtResource resources[] = {
00400 {XtNtraversalOn,XtCTraversalOn,XtRBoolean,sizeof(((XfwfCommonRec*)NULL)->xfwfCommon.traversalOn),XtOffsetOf(XfwfCommonRec,xfwfCommon.traversalOn),XtRImmediate,(XtPointer)True },
00401 {XtNtraversalTranslationDone,XtCTraversalTranslationDone,XtRBoolean,sizeof(((XfwfCommonRec*)NULL)->xfwfCommon.traversalTranslationDone),XtOffsetOf(XfwfCommonRec,xfwfCommon.traversalTranslationDone),XtRImmediate,(XtPointer)False },
00402 {XtNhighlightThickness,XtCHighlightThickness,XtRDimension,sizeof(((XfwfCommonRec*)NULL)->xfwfCommon.highlightThickness),XtOffsetOf(XfwfCommonRec,xfwfCommon.highlightThickness),XtRImmediate,(XtPointer)2 },
00403 {XtNhighlightColor,XtCHighlightColor,XtRPixel,sizeof(((XfwfCommonRec*)NULL)->xfwfCommon.highlightColor),XtOffsetOf(XfwfCommonRec,xfwfCommon.highlightColor),XtRString,(XtPointer)XtDefaultForeground },
00404 {XtNhighlightPixmap,XtCHighlightPixmap,XtRPixmap,sizeof(((XfwfCommonRec*)NULL)->xfwfCommon.highlightPixmap),XtOffsetOf(XfwfCommonRec,xfwfCommon.highlightPixmap),XtRImmediate,(XtPointer)None },
00405 {XtNnextTop,XtCNextTop,XtRCallback,sizeof(((XfwfCommonRec*)NULL)->xfwfCommon.nextTop),XtOffsetOf(XfwfCommonRec,xfwfCommon.nextTop),XtRImmediate,(XtPointer)NULL },
00406 {XtNuserData,XtCUserData,XtRPointer,sizeof(((XfwfCommonRec*)NULL)->xfwfCommon.userData),XtOffsetOf(XfwfCommonRec,xfwfCommon.userData),XtRImmediate,(XtPointer)NULL },
00407 {XtNuseExposeCallback,XtCUseExposeCallback,XtRBoolean,sizeof(((XfwfCommonRec*)NULL)->xfwfCommon.useExposeCallback),XtOffsetOf(XfwfCommonRec,xfwfCommon.useExposeCallback),XtRImmediate,(XtPointer)False },
00408 {XtNexposeCallback,XtCExposeCallback,XtRCallback,sizeof(((XfwfCommonRec*)NULL)->xfwfCommon.exposeCallback),XtOffsetOf(XfwfCommonRec,xfwfCommon.exposeCallback),XtRImmediate,(XtPointer)NULL },
00409 {XtNfocusHiliteChange,XtCFocusHiliteChange,XtRCallback,sizeof(((XfwfCommonRec*)NULL)->xfwfCommon.focusHiliteChange),XtOffsetOf(XfwfCommonRec,xfwfCommon.focusHiliteChange),XtRImmediate,(XtPointer)NULL },
00410 {XtNonDestroy,XtCOnDestroy,XtRCallback,sizeof(((XfwfCommonRec*)NULL)->xfwfCommon.onDestroy),XtOffsetOf(XfwfCommonRec,xfwfCommon.onDestroy),XtRImmediate,(XtPointer)NULL },
00411 };
00412 
00413 XfwfCommonClassRec xfwfCommonClassRec = {
00414 { /* core_class part */
00415 /* superclass        */  (WidgetClass) &compositeClassRec,
00416 /* class_name        */  "XfwfCommon",
00417 /* widget_size       */  sizeof(XfwfCommonRec),
00418 /* class_initialize  */  class_initialize,
00419 /* class_part_initialize*/  _resolve_inheritance,
00420 /* class_inited      */  FALSE,
00421 /* initialize        */  initialize,
00422 /* initialize_hook   */  NULL,
00423 /* realize           */  realize,
00424 /* actions           */  actionsList,
00425 /* num_actions       */  12,
00426 /* resources         */  resources,
00427 /* num_resources     */  11,
00428 /* xrm_class         */  NULLQUARK,
00429 /* compres_motion    */  True ,
00430 /* compress_exposure        */  XtExposeCompressMaximal ,
00431 /* compress_enterleave      */  True ,
00432 /* visible_interest  */  False ,
00433 /* destroy           */  destroy,
00434 /* resize            */  XtInheritResize,
00435 /* expose            */  expose,
00436 /* set_values        */  set_values,
00437 /* set_values_hook   */  NULL,
00438 /* set_values_almost        */  XtInheritSetValuesAlmost,
00439 /* get_values+hook   */  NULL,
00440 /* accept_focus      */  accept_focus,
00441 /* version           */  XtVersion,
00442 /* callback_private  */  NULL,
00443 /* tm_table          */  NULL,
00444 /* query_geometry    */  XtInheritQueryGeometry,
00445 /* display_acceleator       */  XtInheritDisplayAccelerator,
00446 /* extension         */  NULL 
00447 },
00448 { /* composite_class part */
00449 XtInheritGeometryManager,
00450 XtInheritChangeManaged,
00451 XtInheritInsertChild,
00452 XtInheritDeleteChild,
00453 NULL
00454 },
00455 { /* XfwfCommon_class part */
00456 compute_inside,
00457 total_frame_width,
00458 _expose,
00459 highlight_border,
00460 unhighlight_border,
00461 hilite_callbacks,
00462 would_accept_focus,
00463 traverse,
00464 lighter_color,
00465 darker_color,
00466 set_color,
00467 /* traversal_trans */  NULL ,
00468 /* traversal_trans_small */  NULL ,
00469 /* travMode */  1 ,
00470 },
00471 };
00472 WidgetClass xfwfCommonWidgetClass = (WidgetClass) &xfwfCommonClassRec;
00473 /*ARGSUSED*/
00474 static void focusIn(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00475 {
00476     Time time = CurrentTime;
00477 
00478     if (event->type != FocusIn)
00479         XtError("focusIn action may only be bound to FocusIn events");
00480     if (! ((XfwfCommonWidget)self)->xfwfCommon.traversalOn)
00481         return;
00482 
00483     if (event->xfocus.detail == NotifyAncestor
00484         || event->xfocus.detail == NotifyInferior
00485         || event->xfocus.detail == NotifyNonlinear) {
00486         if (!((XfwfCommonWidget)self)->xfwfCommon.traversal_focus)
00487          ((XfwfCommonWidgetClass)self->core.widget_class)->core_class.accept_focus(self, &time);
00488     } else if (event->xfocus.detail != NotifyPointer) {
00489       if (((XfwfCommonWidget)self)->xfwfCommon.traversal_focus) {
00490         ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.unhighlight_border(self);
00491         ((XfwfCommonWidget)self)->xfwfCommon.traversal_focus = False;
00492         ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.hilite_callbacks(self);
00493       }
00494    }
00495 }
00496 
00497 /*ARGSUSED*/
00498 static void focusOut(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00499 {
00500     if (event->type != FocusOut)
00501         XtError("focusOut action may only be bound to FocusOut events");
00502     if (((XfwfCommonWidget)self)->xfwfCommon.traversal_focus) {
00503       if (event->xfocus.detail == NotifyAncestor
00504         || event->xfocus.detail == NotifyInferior
00505         || event->xfocus.detail == NotifyNonlinear) {
00506           ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.unhighlight_border(self);
00507           ((XfwfCommonWidget)self)->xfwfCommon.traversal_focus = False;
00508           ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.hilite_callbacks(self);
00509        }
00510     }
00511 }
00512 
00513 /*ARGSUSED*/
00514 static void checkTraverse(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00515 {
00516   static KeyCode up, down, left, right, next, prior, tab, enter, home;
00517   char *action;
00518 
00519   if (!up) {
00520     Display *d = XtDisplay(self);
00521     up = XKeysymToKeycode(d, XK_Up);
00522     down = XKeysymToKeycode(d, XK_Down);
00523     left = XKeysymToKeycode(d, XK_Left);
00524     right = XKeysymToKeycode(d, XK_Right);
00525     next = XKeysymToKeycode(d, XK_Next);
00526     prior = XKeysymToKeycode(d, XK_Prior);
00527     enter = XKeysymToKeycode(d, XK_KP_Enter);
00528     home = XKeysymToKeycode(d, XK_Home);
00529     tab = XKeysymToKeycode(d, XK_Tab);
00530   }
00531 
00532   if (event->xkey.keycode == up)
00533     action = "traverseUp";
00534   else if (event->xkey.keycode == down)
00535     action = "traverseDown";
00536   else if (event->xkey.keycode == left)
00537     action = "traverseLeft";
00538   else if (event->xkey.keycode == right)
00539     action = "traverseRight";
00540   else if (event->xkey.keycode == next)
00541     action = "traverseNext";
00542   else if (event->xkey.keycode == prior)
00543     action = "traversePrev";
00544   else if (event->xkey.keycode == enter)
00545     action = "traverseNextTop";
00546   else if (event->xkey.keycode == home)
00547     action = "traverseHome";
00548   else if (event->xkey.keycode == tab) {
00549     if (event->xkey.state & ShiftMask)
00550       action = "traversePrev";
00551     else
00552       action = "traverseNext";
00553   } else
00554     action = NULL;
00555 
00556   if (action)
00557     XtCallActionProc(self, action, event, NULL, 0);
00558   else if (((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.travMode == 2)
00559     ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.travMode = 0;
00560 }
00561 
00562 /*ARGSUSED*/
00563 static void traverseDown(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00564 {
00565     ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traverse(self, TraverseDown, self, &event->xkey.time);
00566 }
00567 
00568 /*ARGSUSED*/
00569 static void traverseUp(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00570 {
00571     ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traverse(self, TraverseUp, self, &event->xkey.time);
00572 }
00573 
00574 /*ARGSUSED*/
00575 static void traverseLeft(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00576 {
00577     ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traverse(self, TraverseLeft, self, &event->xkey.time);
00578 }
00579 
00580 /*ARGSUSED*/
00581 static void traverseRight(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00582 {
00583     ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traverse(self, TraverseRight, self, &event->xkey.time);
00584 }
00585 
00586 /*ARGSUSED*/
00587 static void traverseNext(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00588 {
00589     ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traverse(self, TraverseNext, self, &event->xkey.time);
00590 }
00591 
00592 /*ARGSUSED*/
00593 static void traversePrev(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00594 {
00595     ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traverse(self, TraversePrev, self, &event->xkey.time);
00596 }
00597 
00598 /*ARGSUSED*/
00599 static void traverseNextTop(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00600 {
00601     ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traverse(self, TraverseNextTop, self, &event->xkey.time);
00602 }
00603 
00604 /*ARGSUSED*/
00605 static void traverseHome(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00606 {
00607     ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traverse(self, TraverseHome, self, &event->xkey.time);
00608 }
00609 
00610 /*ARGSUSED*/
00611 static void traverseCurrent(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00612 {
00613     Time time = CurrentTime;
00614 
00615     if (((XfwfCommonWidget)self)->xfwfCommon.traversalOn) (void) ((XfwfCommonWidgetClass)self->core.widget_class)->core_class.accept_focus(self, &time);
00616 }
00617 
00618 static void _resolve_inheritance(class)
00619 WidgetClass class;
00620 {
00621   XfwfCommonWidgetClass c = (XfwfCommonWidgetClass) class;
00622   XfwfCommonWidgetClass super;
00623   static CompositeClassExtensionRec extension_rec = {
00624     NULL, NULLQUARK, XtCompositeExtensionVersion,
00625     sizeof(CompositeClassExtensionRec), True};
00626   CompositeClassExtensionRec *ext;
00627   ext = (XtPointer)XtMalloc(sizeof(*ext));
00628   *ext = extension_rec;
00629   ext->next_extension = c->composite_class.extension;
00630   c->composite_class.extension = ext;
00631   if (class == xfwfCommonWidgetClass) return;
00632   super = (XfwfCommonWidgetClass)class->core_class.superclass;
00633   if (c->xfwfCommon_class.compute_inside == XtInherit_compute_inside)
00634     c->xfwfCommon_class.compute_inside = super->xfwfCommon_class.compute_inside;
00635   if (c->xfwfCommon_class.total_frame_width == XtInherit_total_frame_width)
00636     c->xfwfCommon_class.total_frame_width = super->xfwfCommon_class.total_frame_width;
00637   if (c->xfwfCommon_class._expose == XtInherit__expose)
00638     c->xfwfCommon_class._expose = super->xfwfCommon_class._expose;
00639   if (c->xfwfCommon_class.highlight_border == XtInherit_highlight_border)
00640     c->xfwfCommon_class.highlight_border = super->xfwfCommon_class.highlight_border;
00641   if (c->xfwfCommon_class.unhighlight_border == XtInherit_unhighlight_border)
00642     c->xfwfCommon_class.unhighlight_border = super->xfwfCommon_class.unhighlight_border;
00643   if (c->xfwfCommon_class.hilite_callbacks == XtInherit_hilite_callbacks)
00644     c->xfwfCommon_class.hilite_callbacks = super->xfwfCommon_class.hilite_callbacks;
00645   if (c->xfwfCommon_class.would_accept_focus == XtInherit_would_accept_focus)
00646     c->xfwfCommon_class.would_accept_focus = super->xfwfCommon_class.would_accept_focus;
00647   if (c->xfwfCommon_class.traverse == XtInherit_traverse)
00648     c->xfwfCommon_class.traverse = super->xfwfCommon_class.traverse;
00649   if (c->xfwfCommon_class.lighter_color == XtInherit_lighter_color)
00650     c->xfwfCommon_class.lighter_color = super->xfwfCommon_class.lighter_color;
00651   if (c->xfwfCommon_class.darker_color == XtInherit_darker_color)
00652     c->xfwfCommon_class.darker_color = super->xfwfCommon_class.darker_color;
00653   if (c->xfwfCommon_class.set_color == XtInherit_set_color)
00654     c->xfwfCommon_class.set_color = super->xfwfCommon_class.set_color;
00655 }
00656 /*ARGSUSED*/
00657 #if NeedFunctionPrototypes
00658 static void realize(Widget self,XtValueMask * mask,XSetWindowAttributes * attributes)
00659 #else
00660 static void realize(self,mask,attributes)Widget self;XtValueMask * mask;XSetWindowAttributes * attributes;
00661 #endif
00662 {
00663   if (wx_common_use_visual) {
00664     Display *dpy;
00665     int scrn;
00666     dpy = XtDisplay(self);
00667     scrn = XScreenNumberOfScreen(XtScreen(self));
00668     attributes->colormap = XCreateColormap(dpy, 
00669                                       RootWindow(dpy, scrn),
00670                                       wx_common_use_visual, AllocNone);
00671     *mask = *mask | CWColormap;
00672     XtCreateWindow(self, InputOutput, wx_common_use_visual, *mask, attributes);
00673   } else {
00674     compositeClassRec.core_class.realize(self, mask, attributes);
00675   }
00676 }
00677 /*ARGSUSED*/
00678 #if NeedFunctionPrototypes
00679 static void class_initialize(void)
00680 #else
00681 static void class_initialize()
00682 #endif
00683 {
00684     extern void XawInitializeWidgetSet(void);
00685 
00686     XtSetTypeConverter(XtRString, "Alignment", cvtStringToAlignment,
00687                        NULL, 0, XtCacheNone, NULL);
00688     XtSetTypeConverter("Alignment", XtRString, cvtAlignmentToString,
00689                        NULL, 0, XtCacheNone, NULL);
00690     /* XawInitializeWidgetSet(); */ /* unnecessary for fvwm with >>Style "*" Lenience<< */
00691 }
00692 /*ARGSUSED*/
00693 #if NeedFunctionPrototypes
00694 static void initialize(Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00695 #else
00696 static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00697 #endif
00698 {
00699     Dimension frame;
00700 
00701     if (((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traversal_trans == NULL)
00702         ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traversal_trans = XtParseTranslationTable(extraTranslations);
00703     if (((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traversal_trans_small == NULL)
00704         ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traversal_trans_small = XtParseTranslationTable(extraTranslationsSmall);
00705     if (((XfwfCommonWidget)self)->xfwfCommon.traversalOn) {
00706        XtAugmentTranslations(self, ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traversal_trans_small);
00707         ((XfwfCommonWidgetClass)self->core.widget_class)->core_class.visible_interest = True;
00708     }
00709     ((XfwfCommonWidget)self)->xfwfCommon.traversal_focus = False;
00710     ((XfwfCommonWidget)self)->xfwfCommon.bordergc = NULL;
00711     frame = ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.total_frame_width(self);
00712     if (((XfwfCommonWidget)self)->core.width < 2 * frame) ((XfwfCommonWidget)self)->core.width = 2 * frame;
00713     if (((XfwfCommonWidget)self)->core.height < 2 * frame) ((XfwfCommonWidget)self)->core.height = 2 * frame;
00714     if (((XfwfCommonWidget)self)->core.width == 0) ((XfwfCommonWidget)self)->core.width = 2;
00715     if (((XfwfCommonWidget)self)->core.height == 0) ((XfwfCommonWidget)self)->core.height = 2;
00716     /* create_bordergc($); - Now done on demand */
00717 }
00718 /*ARGSUSED*/
00719 #if NeedFunctionPrototypes
00720 static Boolean  set_values(Widget  old,Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00721 #else
00722 static Boolean  set_values(old,request,self,args,num_args)Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00723 #endif
00724 {
00725     Boolean need_redraw = False;
00726     Widget parent = XtParent(self);
00727     Time time = CurrentTime;
00728 
00729     if (((XfwfCommonWidget)self)->xfwfCommon.traversalOn != ((XfwfCommonWidget)old)->xfwfCommon.traversalOn && ((XfwfCommonWidget)self)->xfwfCommon.traversalOn) {      
00730        XtAugmentTranslations(self, ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traversal_trans_small);
00731         ((XfwfCommonWidgetClass)self->core.widget_class)->core_class.visible_interest = True;
00732     }
00733     if ((((XfwfCommonWidget)self)->core.sensitive != ((XfwfCommonWidget)old)->core.sensitive
00734     ||  ((XfwfCommonWidget)self)->core.ancestor_sensitive != ((XfwfCommonWidget)old)->core.ancestor_sensitive
00735     ||  ((XfwfCommonWidget)self)->xfwfCommon.traversalOn != ((XfwfCommonWidget)old)->xfwfCommon.traversalOn)
00736     &&  ((XfwfCommonWidget)self)->xfwfCommon.traversal_focus) {
00737         if (XtIsSubclass(parent, xfwfCommonWidgetClass)) {
00738            if (((XfwfCommonWidget)self)->core.sensitive == FALSE) {
00739               ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.unhighlight_border(self);
00740               ((XfwfCommonWidget)self)->xfwfCommon.traversal_focus = False;
00741                ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.hilite_callbacks(self);
00742            }
00743             ((XfwfCommonWidgetClass)parent->core.widget_class)->xfwfCommon_class.traverse(parent, TraverseHome, self, &time);
00744        }
00745     }
00746     if (((XfwfCommonWidget)self)->xfwfCommon.highlightThickness != ((XfwfCommonWidget)old)->xfwfCommon.highlightThickness)
00747         need_redraw = True;
00748     if (((XfwfCommonWidget)self)->xfwfCommon.highlightPixmap != ((XfwfCommonWidget)old)->xfwfCommon.highlightPixmap) {
00749         if (((XfwfCommonWidget)self)->xfwfCommon.bordergc) create_bordergc(self);
00750         need_redraw = True;
00751     } else if (((XfwfCommonWidget)self)->xfwfCommon.highlightColor != ((XfwfCommonWidget)old)->xfwfCommon.highlightColor) {
00752         ((XfwfCommonWidget)self)->xfwfCommon.highlightPixmap = None;
00753         if (((XfwfCommonWidget)self)->xfwfCommon.bordergc) create_bordergc(self);
00754         need_redraw = True;
00755     }
00756     return need_redraw;
00757 }
00758 /*ARGSUSED*/
00759 #if NeedFunctionPrototypes
00760 static void compute_inside(Widget self,Position * x,Position * y,int * w,int * h)
00761 #else
00762 static void compute_inside(self,x,y,w,h)Widget self;Position * x;Position * y;int * w;int * h;
00763 #endif
00764 {
00765     *x = ((XfwfCommonWidget)self)->xfwfCommon.highlightThickness;
00766     *y = ((XfwfCommonWidget)self)->xfwfCommon.highlightThickness;
00767     *w = ((XfwfCommonWidget)self)->core.width - 2 * ((XfwfCommonWidget)self)->xfwfCommon.highlightThickness;
00768     *h = ((XfwfCommonWidget)self)->core.height - 2 * ((XfwfCommonWidget)self)->xfwfCommon.highlightThickness;
00769 }
00770 /*ARGSUSED*/
00771 #if NeedFunctionPrototypes
00772 static Dimension  total_frame_width(Widget self)
00773 #else
00774 static Dimension  total_frame_width(self)Widget self;
00775 #endif
00776 {
00777     return ((XfwfCommonWidget)self)->xfwfCommon.highlightThickness;
00778 }
00779 /*ARGSUSED*/
00780 #if NeedFunctionPrototypes
00781 static void expose(Widget self,XEvent * event,Region  region)
00782 #else
00783 static void expose(self,event,region)Widget self;XEvent * event;Region  region;
00784 #endif
00785 {
00786     if (((XfwfCommonWidget)self)->xfwfCommon.useExposeCallback) {
00787        XfwfExposeInfo einfo;
00788        einfo.region = region;
00789        einfo.event  = event;
00790        XtCallCallbacks(self, XtNexposeCallback, (XtPointer)&einfo);
00791     } else {
00792        ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class._expose(self, event, region);
00793     }
00794 }
00795 /*ARGSUSED*/
00796 #if NeedFunctionPrototypes
00797 static void _expose(Widget self,XEvent * event,Region  region)
00798 #else
00799 static void _expose(self,event,region)Widget self;XEvent * event;Region  region;
00800 #endif
00801 {
00802     if (! XtIsRealized(self)) return;
00803     if (((XfwfCommonWidget)self)->xfwfCommon.traversal_focus) {
00804       if (!((XfwfCommonWidget)self)->xfwfCommon.bordergc) create_bordergc(self);
00805       if (region != NULL) XSetRegion(XtDisplay(self), ((XfwfCommonWidget)self)->xfwfCommon.bordergc, region);
00806       ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.highlight_border(self);
00807       if (region != NULL) XSetClipMask(XtDisplay(self), ((XfwfCommonWidget)self)->xfwfCommon.bordergc, None);
00808     }
00809 }
00810 /*ARGSUSED*/
00811 #if NeedFunctionPrototypes
00812 static void destroy(Widget self)
00813 #else
00814 static void destroy(self)Widget self;
00815 #endif
00816 {
00817 #if 0
00818     Widget parent = XtParent(self);
00819     Time time = CurrentTime;
00820 
00821     /* For MrEd: no focus delegation. If the widget is being destroyed,
00822        it can't still have the efefctive focus. (Either the widget is hidden
00823        or its parent is hidden.) */
00824     if (((XfwfCommonWidget)self)->xfwfCommon.traversal_focus) {
00825         ((XfwfCommonWidget)self)->core.sensitive = False;
00826         if (XtIsSubclass(parent, xfwfCommonWidgetClass))
00827             ((XfwfCommonWidgetClass)parent->core.widget_class)->xfwfCommon_class.traverse(parent, TraverseHome, self, &time);
00828     }
00829 #endif
00830 
00831     XtCallCallbackList(self, ((XfwfCommonWidget)self)->xfwfCommon.onDestroy, NULL);
00832     if (((XfwfCommonWidget)self)->xfwfCommon.bordergc) XtReleaseGC(self, ((XfwfCommonWidget)self)->xfwfCommon.bordergc); ((XfwfCommonWidget)self)->xfwfCommon.bordergc = NULL;
00833 }
00834 /*ARGSUSED*/
00835 #if NeedFunctionPrototypes
00836 static void highlight_border(Widget self)
00837 #else
00838 static void highlight_border(self)Widget self;
00839 #endif
00840 {
00841     XRectangle rect[4];
00842     int t;
00843 
00844     /* There's another function like this in xwEnforcer, for some reason */
00845 
00846     if (((XfwfCommonWidget)self)->xfwfCommon.highlightThickness == 0) return;
00847 
00848     t = 1 /* $highlightThickness */; 
00849 
00850     rect[0].x = 1;
00851     rect[0].y = 0;
00852     rect[0].width = ((XfwfCommonWidget)self)->core.width - 2;
00853     rect[0].height = t;
00854 
00855     rect[1].x = 0;
00856     rect[1].y = 1;
00857     rect[1].width = t;
00858     rect[1].height = ((XfwfCommonWidget)self)->core.height - 2;
00859 
00860     rect[2].x = ((XfwfCommonWidget)self)->core.width - t;
00861     rect[2].y = 1;
00862     rect[2].width = t;
00863     rect[2].height = ((XfwfCommonWidget)self)->core.height - 2;
00864 
00865     rect[3].x = 1;
00866     rect[3].y = ((XfwfCommonWidget)self)->core.height - t;
00867     rect[3].width = ((XfwfCommonWidget)self)->core.width - 2;
00868     rect[3].height = t;
00869 
00870     if (!((XfwfCommonWidget)self)->xfwfCommon.bordergc) create_bordergc(self);
00871     XFillRectangles(XtDisplay(self), XtWindow(self), ((XfwfCommonWidget)self)->xfwfCommon.bordergc, &rect[0], 4);
00872 }
00873 /*ARGSUSED*/
00874 #if NeedFunctionPrototypes
00875 static void unhighlight_border(Widget self)
00876 #else
00877 static void unhighlight_border(self)Widget self;
00878 #endif
00879 {
00880     if (((XfwfCommonWidget)self)->xfwfCommon.highlightThickness == 0) return;
00881 
00882     XClearArea(XtDisplay(self), XtWindow(self), 
00883                0, 0, ((XfwfCommonWidget)self)->core.width, ((XfwfCommonWidget)self)->xfwfCommon.highlightThickness, False);
00884     XClearArea(XtDisplay(self), XtWindow(self),
00885                0, 0, ((XfwfCommonWidget)self)->xfwfCommon.highlightThickness, ((XfwfCommonWidget)self)->core.height, False);
00886     XClearArea(XtDisplay(self), XtWindow(self),
00887                ((XfwfCommonWidget)self)->core.width - ((XfwfCommonWidget)self)->xfwfCommon.highlightThickness, 0, 
00888                ((XfwfCommonWidget)self)->xfwfCommon.highlightThickness, ((XfwfCommonWidget)self)->core.height, False);
00889     XClearArea(XtDisplay(self), XtWindow(self),
00890                0, ((XfwfCommonWidget)self)->core.height - ((XfwfCommonWidget)self)->xfwfCommon.highlightThickness,
00891                ((XfwfCommonWidget)self)->core.width, ((XfwfCommonWidget)self)->xfwfCommon.highlightThickness, False);
00892 }
00893 /*ARGSUSED*/
00894 #if NeedFunctionPrototypes
00895 static Boolean  accept_focus(Widget self,Time * time)
00896 #else
00897 static Boolean  accept_focus(self,time)Widget self;Time * time;
00898 #endif
00899 {
00900     int i;
00901 
00902     if (! XtIsRealized(self) || ! ((XfwfCommonWidget)self)->core.sensitive || ! ((XfwfCommonWidget)self)->xfwfCommon.traversalOn
00903         /* || ! $visible */ || ! ((XfwfCommonWidget)self)->core.ancestor_sensitive || ! ((XfwfCommonWidget)self)->core.managed
00904         || ! ((XfwfCommonWidget)self)->core.mapped_when_managed || ((XfwfCommonWidget)self)->core.being_destroyed) return False;
00905     for (i = 0; i < ((XfwfCommonWidget)self)->composite.num_children; i++)
00906         if (XtCallAcceptFocus(((XfwfCommonWidget)self)->composite.children[i], time)) return True;
00907     if (! ((XfwfCommonWidget)self)->xfwfCommon.traversal_focus) {
00908       int ok;
00909 #if 0
00910       XSetInputFocus(XtDisplay(self), XtWindow(self), RevertToParent, *time);
00911       ok = 1;
00912 #else
00913       Widget parent;
00914       parent = self;
00915       while (parent 
00916             && !XtIsTopLevelShell(parent) 
00917             && !XtIsTransientShell(parent))
00918        parent = XtParent(parent);
00919       
00920       if (parent) {
00921        XtSetKeyboardFocus(parent, self);
00922        ok = 1;
00923       } else 
00924        ok = 0;
00925 
00926       if (!((XfwfCommonWidget)self)->xfwfCommon.traversalTranslationDone) {
00927         XtAugmentTranslations(self, ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.traversal_trans);
00928        ((XfwfCommonWidget)self)->xfwfCommon.traversalTranslationDone = True;
00929       }
00930 #endif
00931       if (ok) {
00932         ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.highlight_border(self);
00933        ((XfwfCommonWidget)self)->xfwfCommon.traversal_focus = True;
00934        ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.hilite_callbacks(self);
00935       }
00936 
00937       return ok ? True : False;
00938     }
00939     return True;
00940 }
00941 /*ARGSUSED*/
00942 #if NeedFunctionPrototypes
00943 static void hilite_callbacks(Widget self)
00944 #else
00945 static void hilite_callbacks(self)Widget self;
00946 #endif
00947 {
00948   XtPointer on = (XtPointer)(long)((XfwfCommonWidget)self)->xfwfCommon.traversal_focus;
00949 
00950   while (self && XtIsSubclass(self, xfwfCommonWidgetClass) && !((XfwfCommonWidget)self)->xfwfCommon.focusHiliteChange)
00951     self = XtParent(self);
00952 
00953   if (self && XtIsSubclass(self, xfwfCommonWidgetClass))
00954     XtCallCallbackList(self, ((XfwfCommonWidget)self)->xfwfCommon.focusHiliteChange, on);
00955 }
00956 /*ARGSUSED*/
00957 #if NeedFunctionPrototypes
00958 static Boolean  would_accept_focus(Widget self)
00959 #else
00960 static Boolean  would_accept_focus(self)Widget self;
00961 #endif
00962 {
00963     int i;
00964     Widget child;
00965 
00966     if (! XtIsRealized(self) || ! ((XfwfCommonWidget)self)->core.sensitive || ! ((XfwfCommonWidget)self)->core.ancestor_sensitive || ! ((XfwfCommonWidget)self)->core.visible || ! ((XfwfCommonWidget)self)->xfwfCommon.traversalOn)
00967         return False;
00968     else {
00969         for (i = 0; i < ((XfwfCommonWidget)self)->composite.num_children; i++) {
00970             child = ((XfwfCommonWidget)self)->composite.children[i];
00971             if (XtIsSubclass(child, xfwfCommonWidgetClass)
00972                 && ((XfwfCommonWidgetClass)child->core.widget_class)->xfwfCommon_class.would_accept_focus(child))
00973                 return False;
00974         }
00975         return True;
00976     }
00977 }
00978 #define LARGE_NUMBER 2000000000 
00979 
00980 
00981 /*ARGSUSED*/
00982 #if NeedFunctionPrototypes
00983 static void traverse(Widget self,TraversalDirection  dir,Widget  current,Time * time)
00984 #else
00985 static void traverse(self,dir,current,time)Widget self;TraversalDirection  dir;Widget  current;Time * time;
00986 #endif
00987 {
00988     Widget w, parent = XtParent(self);
00989     Position x, y;
00990     int distance = LARGE_NUMBER;
00991 
00992     if (dir == TraverseNextTop)
00993         traverse_to_next_top(self, current, time);
00994     else if (dir == TraverseNext)
00995         traverse_to_next(self, current, time);
00996     else if (dir == TraversePrev)
00997         traverse_to_prev(self, current, time);
00998     else if (XtIsSubclass(parent, xfwfCommonWidgetClass))
00999         ((XfwfCommonWidgetClass)parent->core.widget_class)->xfwfCommon_class.traverse(parent, dir, current, time);
01000     else {
01001         switch (dir) {
01002         case TraverseHome: x = 0; y = 0; break;
01003         case TraverseLeft: x = 0; y = ((XfwfCommonWidget)current)->core.height/2; break;
01004         case TraverseDown: x = ((XfwfCommonWidget)current)->core.width/2; y = ((XfwfCommonWidget)current)->core.height; break;
01005         case TraverseRight: x = ((XfwfCommonWidget)current)->core.width; y = ((XfwfCommonWidget)current)->core.height/2; break;
01006         case TraverseUp: x = ((XfwfCommonWidget)current)->core.width/2; y = 0; break;
01007        default: break;
01008         }
01009         if (dir != TraverseHome) XtTranslateCoords(current, x, y, &x, &y);
01010         if (traverse_to_direction(self, dir, x, y, &w, &distance))
01011             XtCallAcceptFocus(w, time);
01012     }
01013 }
01014 /*ARGSUSED*/
01015 #if NeedFunctionPrototypes
01016 static Boolean  lighter_color(Widget self,Pixel  base,Pixel * result)
01017 #else
01018 static Boolean  lighter_color(self,base,result)Widget self;Pixel  base;Pixel * result;
01019 #endif
01020 {
01021   return get_scaled_color(self, 1.35, base, result);
01022 }
01023 /*ARGSUSED*/
01024 #if NeedFunctionPrototypes
01025 static Boolean  darker_color(Widget self,Pixel  base,Pixel * result)
01026 #else
01027 static Boolean  darker_color(self,base,result)Widget self;Pixel  base;Pixel * result;
01028 #endif
01029 {
01030   return get_scaled_color(self, 0.6, base, result);
01031 }
01032 /*ARGSUSED*/
01033 #if NeedFunctionPrototypes
01034 static Boolean  set_color(Widget self,Pixel  base,Pixel * result)
01035 #else
01036 static Boolean  set_color(self,base,result)Widget self;Pixel  base;Pixel * result;
01037 #endif
01038 {
01039   return get_scaled_color(self, 0.85, base, result);
01040 }
01041 /*ARGSUSED*/
01042 #if NeedFunctionPrototypes
01043 void XfwfCallComputeInside(Widget self,Position * x,Position * y,int * w,int * h)
01044 #else
01045 void XfwfCallComputeInside(self,x,y,w,h)Widget self;Position * x;Position * y;int * w;int * h;
01046 #endif
01047 {
01048     if (XtIsSubclass(self, xfwfCommonWidgetClass) && ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside) {
01049        int ww, hh;
01050         ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, x, y, &ww, &hh);
01051        *w = max(0, ww);
01052        *h = max(0, hh);
01053     } else 
01054         XtWarning
01055             ("XfwfCallComputeInside only applies to subclasses of Common");
01056 }
01057 /*ARGSUSED*/
01058 #if NeedFunctionPrototypes
01059 Dimension  XfwfCallFrameWidth(Widget self)
01060 #else
01061 Dimension  XfwfCallFrameWidth(self)Widget self;
01062 #endif
01063 {
01064     if (XtIsSubclass(self, xfwfCommonWidgetClass) && ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.total_frame_width)
01065         return ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class.total_frame_width(self);
01066     else 
01067         XtWarning
01068             ("XfwfCallFrameWidth only applies to subclasses of Common");
01069     return 0;
01070 }
01071 /*ARGSUSED*/
01072 #if NeedFunctionPrototypes
01073 Boolean  XfwfChooseColor(Widget self,double  factor,Pixel  base,Pixel * result)
01074 #else
01075 Boolean  XfwfChooseColor(self,factor,base,result)Widget self;double  factor;Pixel  base;Pixel * result;
01076 #endif
01077 {
01078     Colormap colormap;
01079     XColor color, dummy;
01080     static XColor gray75;
01081 
01082     if (XtIsRealized(self))
01083        colormap = ((XfwfCommonWidget)self)->core.colormap;
01084     else
01085        colormap = wx_default_colormap;
01086     color.pixel = base;
01087 
01088     XQueryColor(XtDisplay(self), colormap, &color);
01089     color.red = min(65535, factor * color.red);
01090     color.green = min(65535, factor * color.green);
01091     color.blue = min(65535, factor * color.blue);
01092     if (!wxAllocColor(XtDisplay(self), colormap, &color))
01093        return False;
01094     if (base == color.pixel) {
01095       if (!gray75.pixel)
01096        if (!XAllocNamedColor(XtDisplay(self), colormap, "gray75", &gray75, &dummy)) {
01097          return False;
01098         }
01099       color.red = gray75.red;
01100       color.green = gray75.green;
01101       color.blue = gray75.blue;
01102       color.pixel = gray75.pixel;
01103      }
01104     *result = color.pixel;
01105     return True;
01106 }
01107 /*ARGSUSED*/
01108 #if NeedFunctionPrototypes
01109 void XfwfCallExpose(Widget self,XEvent * event,Region  region)
01110 #else
01111 void XfwfCallExpose(self,event,region)Widget self;XEvent * event;Region  region;
01112 #endif
01113 {
01114     if (XtIsSubclass(self, xfwfCommonWidgetClass) && ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class._expose)
01115         ((XfwfCommonWidgetClass)self->core.widget_class)->xfwfCommon_class._expose(self, event, region);
01116 }
01117 /*ARGSUSED*/
01118 #if NeedFunctionPrototypes
01119 void create_bordergc(Widget self)
01120 #else
01121 void create_bordergc(self)Widget self;
01122 #endif
01123 {
01124     XtGCMask mask;
01125     XGCValues values;
01126 
01127     if (((XfwfCommonWidget)self)->xfwfCommon.bordergc) XtReleaseGC(self, ((XfwfCommonWidget)self)->xfwfCommon.bordergc);
01128     if (((XfwfCommonWidget)self)->xfwfCommon.highlightPixmap != None) {
01129         mask = GCFillStyle | GCTile;
01130         values.fill_style = FillTiled;
01131         values.tile = ((XfwfCommonWidget)self)->xfwfCommon.highlightPixmap;
01132     } else {
01133        Pixel res;
01134         mask = GCFillStyle | GCForeground;
01135         values.fill_style = FillSolid;
01136        lighter_color(self, ((XfwfCommonWidget)self)->xfwfCommon.highlightColor, &res);
01137         values.foreground = res;
01138     }
01139     ((XfwfCommonWidget)self)->xfwfCommon.bordergc = XtGetGC(self, mask, &values);
01140 }
01141 /*ARGSUSED*/
01142 #if NeedFunctionPrototypes
01143 Boolean  get_scaled_color(Widget self,float  scale,Pixel  base,Pixel * result)
01144 #else
01145 Boolean  get_scaled_color(self,scale,base,result)Widget self;float  scale;Pixel  base;Pixel * result;
01146 #endif
01147 {
01148   /* These two must be mutually prime: */
01149 #define CACHE_SIZE 29
01150 #define CACHE_STEP 10
01151   static struct {
01152     int set;
01153     float scale;
01154     Pixel in, out;
01155   } cache[CACHE_SIZE];
01156   static int reset = 0;
01157   int i;
01158 
01159   for (i = 0; i < CACHE_SIZE; i++) {
01160     if (cache[i].set 
01161        && (cache[i].scale == scale)
01162        && (cache[i].in == base)) {
01163       *result = cache[i].out;
01164       return TRUE;
01165     }
01166   }
01167 
01168   if (!XfwfChooseColor(self, scale, base, result))
01169     return FALSE;
01170   
01171   cache[reset].scale = scale;
01172   cache[reset].in = base;
01173   cache[reset].out = *result;
01174   cache[reset].set = 1;
01175 
01176   if (!cache[reset].set) {
01177     cache[reset].set = 1;
01178     reset++;
01179   } else
01180     reset += CACHE_STEP;
01181 
01182   reset = (reset % CACHE_SIZE);
01183 
01184   return TRUE;
01185 }
01186 /*ARGSUSED*/
01187 #if NeedFunctionPrototypes
01188 Boolean  has_focus_now(Widget self)
01189 #else
01190 Boolean  has_focus_now(self)Widget self;
01191 #endif
01192 {
01193   return ((XfwfCommonWidget)self)->xfwfCommon.traversal_focus;
01194 }