Back to index

plt-scheme  4.2.1
xwSlider2.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 "xwGray.h"
00007 #include <stdio.h>
00008 #include <./xwSlider2P.h>
00009 static void start(
00010 #if NeedFunctionPrototypes
00011 Widget,XEvent*,String*,Cardinal*
00012 #endif
00013 );
00014 static void finish(
00015 #if NeedFunctionPrototypes
00016 Widget,XEvent*,String*,Cardinal*
00017 #endif
00018 );
00019 static void drag(
00020 #if NeedFunctionPrototypes
00021 Widget,XEvent*,String*,Cardinal*
00022 #endif
00023 );
00024 
00025 static XtActionsRec actionsList[] = {
00026 {"start", start},
00027 {"finish", finish},
00028 {"drag", drag},
00029 };
00030 
00031 static char defaultTranslations[] = "\
00032 <Btn1Down>: start() \n\
00033 <Btn1Motion>: drag() \n\
00034 <Btn1Up>: finish() \n\
00035 <Btn2Down>: start() \n\
00036 <Btn2Motion>: drag() \n\
00037 <Btn2Up>: finish() \n\
00038 ";
00039 static void _resolve_inheritance(
00040 #if NeedFunctionPrototypes
00041 WidgetClass
00042 #endif
00043 );
00044 static void compute_thumb(
00045 #if NeedFunctionPrototypes
00046 Widget,Position *,Position *,Dimension *,Dimension *
00047 #endif
00048 );
00049 static void compute_inside(
00050 #if NeedFunctionPrototypes
00051 Widget,Position *,Position *,int *,int *
00052 #endif
00053 );
00054 static void _expose(
00055 #if NeedFunctionPrototypes
00056 Widget,XEvent *,Region 
00057 #endif
00058 );
00059 static void initialize(
00060 #if NeedFunctionPrototypes
00061 Widget ,Widget,ArgList ,Cardinal *
00062 #endif
00063 );
00064 static void destroy(
00065 #if NeedFunctionPrototypes
00066 Widget
00067 #endif
00068 );
00069 static void move_thumb(
00070 #if NeedFunctionPrototypes
00071 Widget,int ,int ,int ,int ,int ,int 
00072 #endif
00073 );
00074 static void compute_info(
00075 #if NeedFunctionPrototypes
00076 Widget,Position *,Position *,Dimension *,Dimension *,float *,float *,float *,float *
00077 #endif
00078 );
00079 static Boolean  set_values(
00080 #if NeedFunctionPrototypes
00081 Widget ,Widget ,Widget,ArgList ,Cardinal *
00082 #endif
00083 );
00084 static void scroll_response(
00085 #if NeedFunctionPrototypes
00086 Widget ,XtPointer ,XtPointer 
00087 #endif
00088 );
00089 static void create_gc(
00090 #if NeedFunctionPrototypes
00091 Widget
00092 #endif
00093 );
00094 static void create_thumbgc(
00095 #if NeedFunctionPrototypes
00096 Widget
00097 #endif
00098 );
00099 static void create_fggc(
00100 #if NeedFunctionPrototypes
00101 Widget
00102 #endif
00103 );
00104 static void create_thumblightgc(
00105 #if NeedFunctionPrototypes
00106 Widget
00107 #endif
00108 );
00109 static void create_thumbdarkgc(
00110 #if NeedFunctionPrototypes
00111 Widget
00112 #endif
00113 );
00114 /*ARGSUSED*/
00115 #if NeedFunctionPrototypes
00116 static void create_gc(Widget self)
00117 #else
00118 static void create_gc(self)Widget self;
00119 #endif
00120 {
00121     XtGCMask mask;
00122     XGCValues values;
00123 
00124     if (((XfwfSlider2Widget)self)->xfwfLabel.gc != NULL) XtReleaseGC(self, ((XfwfSlider2Widget)self)->xfwfLabel.gc);
00125     values.background = ((XfwfSlider2Widget)self)->xfwfSlider2.thumbColor;
00126     values.foreground = ((XfwfSlider2Widget)self)->xfwfLabel.foreground;
00127     mask = GCBackground | GCForeground;
00128     ((XfwfSlider2Widget)self)->xfwfLabel.gc = XtGetGC(self, mask, &values);
00129 }
00130 /*ARGSUSED*/
00131 #if NeedFunctionPrototypes
00132 static void create_thumbgc(Widget self)
00133 #else
00134 static void create_thumbgc(self)Widget self;
00135 #endif
00136 {
00137     XtGCMask mask;
00138     XGCValues values;
00139 
00140     if (((XfwfSlider2Widget)self)->xfwfSlider2.thumbgc != NULL) XtReleaseGC(self, ((XfwfSlider2Widget)self)->xfwfSlider2.thumbgc);
00141     if (((XfwfSlider2Widget)self)->xfwfSlider2.thumbPixmap != 0) {
00142        mask = GCTile | GCFillStyle;
00143        values.tile = ((XfwfSlider2Widget)self)->xfwfSlider2.thumbPixmap;
00144        values.fill_style = FillTiled;
00145     } else {
00146        mask = GCForeground;
00147        values.foreground = ((XfwfSlider2Widget)self)->xfwfSlider2.thumbColor;
00148     }
00149     ((XfwfSlider2Widget)self)->xfwfSlider2.thumbgc = XtGetGC(self, mask, &values);
00150 }
00151 /*ARGSUSED*/
00152 #if NeedFunctionPrototypes
00153 static void create_fggc(Widget self)
00154 #else
00155 static void create_fggc(self)Widget self;
00156 #endif
00157 {
00158     XtGCMask mask;
00159     XGCValues values;
00160 
00161     if (((XfwfSlider2Widget)self)->xfwfFrame.fggc != NULL) XtReleaseGC(self, ((XfwfSlider2Widget)self)->xfwfFrame.fggc);
00162     mask = GCForeground;
00163     ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfCommon_class.set_color(self, ((XfwfSlider2Widget)self)->core.background_pixel, &values.foreground);
00164     ((XfwfSlider2Widget)self)->xfwfFrame.fggc = XtGetGC(self, mask, &values);
00165 }
00166 /*ARGSUSED*/
00167 #if NeedFunctionPrototypes
00168 static void create_thumblightgc(Widget self)
00169 #else
00170 static void create_thumblightgc(self)Widget self;
00171 #endif
00172 {
00173     XtGCMask mask=0;
00174     XGCValues values;
00175 
00176     if (((XfwfSlider2Widget)self)->xfwfSlider2.thumblightgc != NULL) XtReleaseGC(self, ((XfwfSlider2Widget)self)->xfwfSlider2.thumblightgc);
00177     switch (((XfwfSlider2Widget)self)->xfwfFrame.shadowScheme) {
00178     case XfwfColor:
00179        mask = GCForeground;
00180        values.foreground = ((XfwfSlider2Widget)self)->xfwfFrame.topShadowColor;
00181        break;
00182     case XfwfStipple:
00183        mask = GCFillStyle | GCStipple | GCForeground | GCBackground;
00184        values.fill_style = FillOpaqueStippled;
00185        values.background = ((XfwfSlider2Widget)self)->xfwfSlider2.thumbColor;
00186        values.stipple = ((XfwfSlider2Widget)self)->xfwfFrame.topShadowStipple;
00187        values.foreground = WhitePixelOfScreen(XtScreen(self));
00188        break;
00189     case XfwfBlack:
00190     case XfwfAuto:
00191        if (DefaultDepthOfScreen(XtScreen(self)) > 4
00192            && ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfCommon_class.lighter_color(self, ((XfwfSlider2Widget)self)->xfwfSlider2.thumbColor, &values.foreground)) {
00193            mask = GCForeground;
00194        } else {
00195            mask = GCFillStyle | GCBackground | GCForeground | GCStipple;
00196            values.fill_style = FillOpaqueStippled;
00197            /* values.background = $thumbColor; */
00198            values.background = BlackPixelOfScreen(XtScreen(self));
00199            values.foreground = WhitePixelOfScreen(XtScreen(self));
00200            values.stipple =
00201               XCreateBitmapFromData(XtDisplay(self),
00202                                   RootWindowOfScreen(XtScreen(self)),
00203                                   wx_gray_bits, wx_gray_width, wx_gray_height);
00204        }
00205        break;
00206     }
00207     ((XfwfSlider2Widget)self)->xfwfSlider2.thumblightgc = XtGetGC(self, mask, &values);
00208 }
00209 /*ARGSUSED*/
00210 #if NeedFunctionPrototypes
00211 static void create_thumbdarkgc(Widget self)
00212 #else
00213 static void create_thumbdarkgc(self)Widget self;
00214 #endif
00215 {
00216     XtGCMask mask=0;
00217     XGCValues values;
00218 
00219     if (((XfwfSlider2Widget)self)->xfwfSlider2.thumbdarkgc != NULL) XtReleaseGC(self, ((XfwfSlider2Widget)self)->xfwfSlider2.thumbdarkgc);
00220     switch (((XfwfSlider2Widget)self)->xfwfFrame.shadowScheme) {
00221     case XfwfColor:
00222        mask = GCForeground;
00223        values.foreground = ((XfwfSlider2Widget)self)->xfwfFrame.bottomShadowColor;
00224        break;
00225     case XfwfStipple:
00226        mask = GCFillStyle | GCStipple | GCForeground | GCBackground;
00227        values.fill_style = FillOpaqueStippled;
00228        values.stipple = ((XfwfSlider2Widget)self)->xfwfFrame.bottomShadowStipple;
00229        values.foreground = BlackPixelOfScreen(XtScreen(self));
00230        values.background = ((XfwfSlider2Widget)self)->xfwfSlider2.thumbColor;
00231        break;
00232     case XfwfBlack:
00233     case XfwfAuto:
00234        if (DefaultDepthOfScreen(XtScreen(self)) > 4
00235            && ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfCommon_class.darker_color(self, ((XfwfSlider2Widget)self)->xfwfSlider2.thumbColor, &values.foreground)) {
00236            mask = GCForeground;
00237        } else {
00238            mask = GCFillStyle | GCBackground | GCForeground | GCStipple;
00239            values.fill_style = FillOpaqueStippled;
00240            /* values.background = $thumbColor; */
00241            values.background = BlackPixelOfScreen(XtScreen(self));
00242            values.foreground = WhitePixelOfScreen(XtScreen(self));
00243            values.stipple =
00244               XCreateBitmapFromData(XtDisplay(self),
00245                                   RootWindowOfScreen(XtScreen(self)),
00246                                   wx_gray_bits, wx_gray_width, wx_gray_height);
00247        }
00248        break;
00249     }
00250     ((XfwfSlider2Widget)self)->xfwfSlider2.thumbdarkgc = XtGetGC(self, mask, &values);
00251 }
00252 
00253 static XtResource resources[] = {
00254 {XtNthumbColor,XtCThumbColor,XtRPixel,sizeof(((XfwfSlider2Rec*)NULL)->xfwfSlider2.thumbColor),XtOffsetOf(XfwfSlider2Rec,xfwfSlider2.thumbColor),XtRString,(XtPointer)XtDefaultBackground },
00255 {XtNthumbPixmap,XtCThumbPixmap,XtRPixmap,sizeof(((XfwfSlider2Rec*)NULL)->xfwfSlider2.thumbPixmap),XtOffsetOf(XfwfSlider2Rec,xfwfSlider2.thumbPixmap),XtRImmediate,(XtPointer)NULL },
00256 {XtNminsize,XtCMinsize,XtRDimension,sizeof(((XfwfSlider2Rec*)NULL)->xfwfSlider2.minsize),XtOffsetOf(XfwfSlider2Rec,xfwfSlider2.minsize),XtRImmediate,(XtPointer)20 },
00257 {XtNthumbFrameWidth,XtCThumbFrameWidth,XtRDimension,sizeof(((XfwfSlider2Rec*)NULL)->xfwfSlider2.thumbFrameWidth),XtOffsetOf(XfwfSlider2Rec,xfwfSlider2.thumbFrameWidth),XtRImmediate,(XtPointer)2 },
00258 {XtNthumbFrameType,XtCThumbFrameType,XtRFrameType,sizeof(((XfwfSlider2Rec*)NULL)->xfwfSlider2.thumbFrameType),XtOffsetOf(XfwfSlider2Rec,xfwfSlider2.thumbFrameType),XtRImmediate,(XtPointer)XfwfRaised },
00259 {XtNscrollCallback,XtCScrollCallback,XtRCallback,sizeof(((XfwfSlider2Rec*)NULL)->xfwfSlider2.scrollCallback),XtOffsetOf(XfwfSlider2Rec,xfwfSlider2.scrollCallback),XtRImmediate,(XtPointer)NULL },
00260 {XtNscrollResponse,XtCScrollResponse,XtRXTCallbackProc,sizeof(((XfwfSlider2Rec*)NULL)->xfwfSlider2.scrollResponse),XtOffsetOf(XfwfSlider2Rec,xfwfSlider2.scrollResponse),XtRImmediate,(XtPointer)scroll_response },
00261 {XtNframeWidth,XtCFrameWidth,XtRDimension,sizeof(((XfwfSlider2Rec*)NULL)->xfwfFrame.frameWidth),XtOffsetOf(XfwfSlider2Rec,xfwfFrame.frameWidth),XtRImmediate,(XtPointer)2 },
00262 {XtNframeType,XtCFrameType,XtRFrameType,sizeof(((XfwfSlider2Rec*)NULL)->xfwfFrame.frameType),XtOffsetOf(XfwfSlider2Rec,xfwfFrame.frameType),XtRImmediate,(XtPointer)XfwfSunken },
00263 };
00264 
00265 XfwfSlider2ClassRec xfwfSlider2ClassRec = {
00266 { /* core_class part */
00267 /* superclass        */  (WidgetClass) &xfwfLabelClassRec,
00268 /* class_name        */  "XfwfSlider2",
00269 /* widget_size       */  sizeof(XfwfSlider2Rec),
00270 /* class_initialize  */  NULL,
00271 /* class_part_initialize*/  _resolve_inheritance,
00272 /* class_inited      */  FALSE,
00273 /* initialize        */  initialize,
00274 /* initialize_hook   */  NULL,
00275 /* realize           */  XtInheritRealize,
00276 /* actions           */  actionsList,
00277 /* num_actions       */  3,
00278 /* resources         */  resources,
00279 /* num_resources     */  9,
00280 /* xrm_class         */  NULLQUARK,
00281 /* compres_motion    */  True ,
00282 /* compress_exposure        */  XtExposeCompressMultiple |XtExposeGraphicsExpose ,
00283 /* compress_enterleave      */  True ,
00284 /* visible_interest  */  False ,
00285 /* destroy           */  destroy,
00286 /* resize            */  XtInheritResize,
00287 /* expose            */  XtInheritExpose,
00288 /* set_values        */  set_values,
00289 /* set_values_hook   */  NULL,
00290 /* set_values_almost        */  XtInheritSetValuesAlmost,
00291 /* get_values+hook   */  NULL,
00292 /* accept_focus      */  XtInheritAcceptFocus,
00293 /* version           */  XtVersion,
00294 /* callback_private  */  NULL,
00295 /* tm_table          */  defaultTranslations,
00296 /* query_geometry    */  XtInheritQueryGeometry,
00297 /* display_acceleator       */  XtInheritDisplayAccelerator,
00298 /* extension         */  NULL 
00299 },
00300 { /* composite_class part */
00301 XtInheritGeometryManager,
00302 XtInheritChangeManaged,
00303 XtInheritInsertChild,
00304 XtInheritDeleteChild,
00305 NULL
00306 },
00307 { /* XfwfCommon_class part */
00308 compute_inside,
00309 XtInherit_total_frame_width,
00310 _expose,
00311 XtInherit_highlight_border,
00312 XtInherit_unhighlight_border,
00313 XtInherit_hilite_callbacks,
00314 XtInherit_would_accept_focus,
00315 XtInherit_traverse,
00316 XtInherit_lighter_color,
00317 XtInherit_darker_color,
00318 XtInherit_set_color,
00319 /* traversal_trans */  NULL ,
00320 /* traversal_trans_small */  NULL ,
00321 /* travMode */  1 ,
00322 },
00323 { /* XfwfFrame_class part */
00324  /* dummy */  0
00325 },
00326 { /* XfwfBoard_class part */
00327 XtInherit_set_abs_location,
00328 },
00329 { /* XfwfLabel_class part */
00330 XtInherit_set_label,
00331 },
00332 { /* XfwfSlider2_class part */
00333 compute_thumb,
00334 move_thumb,
00335 compute_info,
00336 scroll_response,
00337 },
00338 };
00339 WidgetClass xfwfSlider2WidgetClass = (WidgetClass) &xfwfSlider2ClassRec;
00340 /*ARGSUSED*/
00341 static void start(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00342 {
00343     Dimension w, h;
00344     Position x, y;
00345     XfwfScrollInfo info;
00346     Boolean outside = False;
00347 
00348     if (event->type != ButtonPress && event->type != ButtonRelease
00349        && event->type != MotionNotify)
00350        XtError("The start action must be bound to a mouse event");
00351     ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.compute_thumb(self, &x, &y, &w, &h);
00352     if (event->xbutton.button == Button2) {
00353       /* Pretend mouse was clicked on the middle of the thumb... */
00354       ((XfwfSlider2Widget)self)->xfwfSlider2.drag_in_progress = True;
00355       ((XfwfSlider2Widget)self)->xfwfSlider2.m_delta_x = - (w / 2);
00356       ((XfwfSlider2Widget)self)->xfwfSlider2.m_delta_y = - (h / 2);
00357       /* and dragged to here: */
00358       drag(self,event,params,num_params);
00359     } else {
00360       if (event->xbutton.x < x) {                /* Left of thumb */
00361        info.reason = XfwfSPageLeft;
00362        info.flags = XFWF_HPOS;                   /* Suggest a value: */
00363        info.hpos = max(0.0, ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x - ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_wd);
00364        outside = True;
00365        XtCallCallbackList(self, ((XfwfSlider2Widget)self)->xfwfSlider2.scrollCallback, &info);
00366       }
00367       if (event->xbutton.x >= x + w) {           /* Right of thumb */
00368        info.reason = XfwfSPageRight;
00369        info.flags = XFWF_HPOS;                   /* Suggest a value: */
00370        info.hpos = min(1.0, ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x + ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_wd);
00371        outside = True;
00372        XtCallCallbackList(self, ((XfwfSlider2Widget)self)->xfwfSlider2.scrollCallback, &info);
00373       }
00374       if (event->xbutton.y < y) {                /* Above thumb */
00375        info.reason = XfwfSPageUp;
00376        info.flags = XFWF_VPOS;                   /* Suggest a value: */
00377        info.vpos = max(0.0, ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y - ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_ht);
00378        outside = True;
00379        XtCallCallbackList(self, ((XfwfSlider2Widget)self)->xfwfSlider2.scrollCallback, &info);
00380       }
00381       if (event->xbutton.y >= y + h) {           /* Below thumb */
00382        info.reason = XfwfSPageDown;
00383        info.flags = XFWF_VPOS;                   /* Suggest a value: */
00384        info.vpos = min(1.0, ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y + ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_ht);
00385        outside = True;
00386        XtCallCallbackList(self, ((XfwfSlider2Widget)self)->xfwfSlider2.scrollCallback, &info);
00387       }
00388 
00389       if (! outside) {                           /* Inside the thumb */
00390        ((XfwfSlider2Widget)self)->xfwfSlider2.drag_in_progress = True;
00391        ((XfwfSlider2Widget)self)->xfwfSlider2.m_delta_x = x - event->xbutton.x;
00392        ((XfwfSlider2Widget)self)->xfwfSlider2.m_delta_y = y - event->xbutton.y;
00393       }
00394     }
00395 }
00396 
00397 /*ARGSUSED*/
00398 static void finish(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00399 {
00400     XfwfScrollInfo info;
00401 
00402     if (((XfwfSlider2Widget)self)->xfwfSlider2.drag_in_progress) {
00403        ((XfwfSlider2Widget)self)->xfwfSlider2.drag_in_progress = False;
00404        info.reason = XfwfSMove;
00405        info.flags = XFWF_VPOS | XFWF_HPOS;
00406        info.hpos = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x;
00407        info.vpos = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y;
00408        XtCallCallbackList(self, ((XfwfSlider2Widget)self)->xfwfSlider2.scrollCallback, &info);
00409     }
00410 }
00411 
00412 /*ARGSUSED*/
00413 static void drag(self,event,params,num_params)Widget self;XEvent*event;String*params;Cardinal*num_params;
00414 {
00415     XfwfScrollInfo info;
00416     Dimension wd, ht;
00417     Position oldx, oldy, newx, newy;
00418     float dum1, dum2;
00419 
00420     if (! ((XfwfSlider2Widget)self)->xfwfSlider2.drag_in_progress) return;
00421     if (event->type != ButtonPress && event->type != ButtonRelease
00422        && event->type != MotionNotify)
00423        XtError("The drag action must be bound to a mouse event");
00424     ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.compute_thumb(self, &oldx, &oldy, &wd, &ht);
00425     newx = event->xbutton.x + ((XfwfSlider2Widget)self)->xfwfSlider2.m_delta_x;
00426     newy = event->xbutton.y + ((XfwfSlider2Widget)self)->xfwfSlider2.m_delta_y;
00427     ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.compute_info(self, &newx, &newy, &wd, &ht, &((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x, &((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y,&dum1,&dum2);
00428     ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.move_thumb(self, oldx, oldy, wd, ht, newx, newy);
00429     info.reason = XfwfSDrag;
00430     info.flags = XFWF_VPOS | XFWF_HPOS;
00431     info.hpos = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x;
00432     info.vpos = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y;
00433     XtCallCallbackList(self, ((XfwfSlider2Widget)self)->xfwfSlider2.scrollCallback, &info);
00434 }
00435 
00436 static void _resolve_inheritance(class)
00437 WidgetClass class;
00438 {
00439   XfwfSlider2WidgetClass c = (XfwfSlider2WidgetClass) class;
00440   XfwfSlider2WidgetClass super;
00441   static CompositeClassExtensionRec extension_rec = {
00442     NULL, NULLQUARK, XtCompositeExtensionVersion,
00443     sizeof(CompositeClassExtensionRec), True};
00444   CompositeClassExtensionRec *ext;
00445   ext = (XtPointer)XtMalloc(sizeof(*ext));
00446   *ext = extension_rec;
00447   ext->next_extension = c->composite_class.extension;
00448   c->composite_class.extension = ext;
00449   if (class == xfwfSlider2WidgetClass) return;
00450   super = (XfwfSlider2WidgetClass)class->core_class.superclass;
00451   if (c->xfwfSlider2_class.compute_thumb == XtInherit_compute_thumb)
00452     c->xfwfSlider2_class.compute_thumb = super->xfwfSlider2_class.compute_thumb;
00453   if (c->xfwfSlider2_class.move_thumb == XtInherit_move_thumb)
00454     c->xfwfSlider2_class.move_thumb = super->xfwfSlider2_class.move_thumb;
00455   if (c->xfwfSlider2_class.compute_info == XtInherit_compute_info)
00456     c->xfwfSlider2_class.compute_info = super->xfwfSlider2_class.compute_info;
00457   if (c->xfwfSlider2_class.scroll_response == XtInherit_scroll_response)
00458     c->xfwfSlider2_class.scroll_response = super->xfwfSlider2_class.scroll_response;
00459 }
00460 /*ARGSUSED*/
00461 #if NeedFunctionPrototypes
00462 static void compute_thumb(Widget self,Position * x,Position * y,Dimension * width,Dimension * height)
00463 #else
00464 static void compute_thumb(self,x,y,width,height)Widget self;Position * x;Position * y;Dimension * width;Dimension * height;
00465 #endif
00466 {
00467     Position fx, fy;
00468     int fw, fh;
00469 
00470     xfwfLabelClassRec.xfwfCommon_class.compute_inside(self, &fx, &fy, &fw, &fh);
00471     fw = max(0, fw);
00472     fh = max(0, fh);
00473     *width = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_wd * fw + 0.5;
00474     *height = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_ht * fh + 0.5;
00475     if (*width < ((XfwfSlider2Widget)self)->xfwfSlider2.minsize) *width = min(fw, ((XfwfSlider2Widget)self)->xfwfSlider2.minsize);
00476     if (*height < ((XfwfSlider2Widget)self)->xfwfSlider2.minsize) *height = min(fh, ((XfwfSlider2Widget)self)->xfwfSlider2.minsize);
00477     *x = fx + ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x * (fw - *width) + 0.5;
00478     *y = fy + ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y * (fh - *height) + 0.5;
00479 }
00480 /*ARGSUSED*/
00481 #if NeedFunctionPrototypes
00482 static void compute_inside(Widget self,Position * x,Position * y,int * w,int * h)
00483 #else
00484 static void compute_inside(self,x,y,w,h)Widget self;Position * x;Position * y;int * w;int * h;
00485 #endif
00486 {
00487     Dimension ww, hh;
00488 
00489     ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.compute_thumb(self, x, y, &ww, &hh);
00490     *x += ((XfwfSlider2Widget)self)->xfwfSlider2.thumbFrameWidth;
00491     *y += ((XfwfSlider2Widget)self)->xfwfSlider2.thumbFrameWidth;
00492     *w = (int)ww - 2 * ((XfwfSlider2Widget)self)->xfwfSlider2.thumbFrameWidth;
00493     *h = (int)hh - 2 * ((XfwfSlider2Widget)self)->xfwfSlider2.thumbFrameWidth;
00494 }
00495 /*ARGSUSED*/
00496 #if NeedFunctionPrototypes
00497 static void _expose(Widget self,XEvent * event,Region  region)
00498 #else
00499 static void _expose(self,event,region)Widget self;XEvent * event;Region  region;
00500 #endif
00501 {
00502     Position x, y;
00503     Dimension wd, ht, d;
00504 
00505     if (! XtIsRealized(self)) return;
00506     if (region != NULL) {
00507        XSetRegion(XtDisplay(self), ((XfwfSlider2Widget)self)->xfwfFrame.fggc, region);
00508        XSetRegion(XtDisplay(self), ((XfwfSlider2Widget)self)->xfwfSlider2.thumbgc, region);
00509        XSetRegion(XtDisplay(self), ((XfwfSlider2Widget)self)->xfwfSlider2.thumbdarkgc, region);
00510        XSetRegion(XtDisplay(self), ((XfwfSlider2Widget)self)->xfwfSlider2.thumblightgc, region);
00511     }
00512     ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.compute_thumb(self, &x, &y, &wd, &ht);
00513     d = ((XfwfSlider2Widget)self)->xfwfSlider2.thumbFrameWidth;
00514     if ((wd > 2 * d) && (ht > 2 * d)) {
00515       XFillRectangle(XtDisplay(self), XtWindow(self), ((XfwfSlider2Widget)self)->xfwfSlider2.thumbgc, x + d, y + d, wd - 2 * d, ht - 2 * d);
00516       XfwfDrawFrame(self, x, y, wd, ht, ((XfwfSlider2Widget)self)->xfwfSlider2.thumbFrameType, d,
00517                    ((XfwfSlider2Widget)self)->xfwfSlider2.thumblightgc, ((XfwfSlider2Widget)self)->xfwfSlider2.thumbdarkgc, NULL);
00518     }
00519     if (region != NULL) {
00520        XSetClipMask(XtDisplay(self), ((XfwfSlider2Widget)self)->xfwfFrame.fggc, None);
00521        XSetClipMask(XtDisplay(self), ((XfwfSlider2Widget)self)->xfwfSlider2.thumbgc, None);
00522        XSetClipMask(XtDisplay(self), ((XfwfSlider2Widget)self)->xfwfSlider2.thumbdarkgc, None);
00523        XSetClipMask(XtDisplay(self), ((XfwfSlider2Widget)self)->xfwfSlider2.thumblightgc, None);
00524     }
00525     xfwfLabelClassRec.xfwfCommon_class._expose(self, event, region);
00526 }
00527 /*ARGSUSED*/
00528 #if NeedFunctionPrototypes
00529 static void initialize(Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00530 #else
00531 static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00532 #endif
00533 {
00534     ((XfwfSlider2Widget)self)->xfwfLabel.text_bg = ((XfwfSlider2Widget)self)->xfwfSlider2.thumbColor;
00535     ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y = 0.0;
00536     ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_wd = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_ht = 1.0;
00537     ((XfwfSlider2Widget)self)->xfwfSlider2.drag_in_progress = False;
00538     create_fggc(self);
00539     create_thumbgc(self);
00540     create_gc(self);
00541     ((XfwfSlider2Widget)self)->xfwfSlider2.thumblightgc = NULL; create_thumblightgc(self);
00542     ((XfwfSlider2Widget)self)->xfwfSlider2.thumbdarkgc = NULL; create_thumbdarkgc(self);
00543 }
00544 /*ARGSUSED*/
00545 #if NeedFunctionPrototypes
00546 static void destroy(Widget self)
00547 #else
00548 static void destroy(self)Widget self;
00549 #endif
00550 {
00551   if (((XfwfSlider2Widget)self)->xfwfLabel.gc) XtReleaseGC(self, ((XfwfSlider2Widget)self)->xfwfLabel.gc); ((XfwfSlider2Widget)self)->xfwfLabel.gc = NULL;
00552   if (((XfwfSlider2Widget)self)->xfwfSlider2.thumblightgc) XtReleaseGC(self, ((XfwfSlider2Widget)self)->xfwfSlider2.thumblightgc); ((XfwfSlider2Widget)self)->xfwfSlider2.thumblightgc = NULL;
00553   if (((XfwfSlider2Widget)self)->xfwfSlider2.thumbdarkgc) XtReleaseGC(self, ((XfwfSlider2Widget)self)->xfwfSlider2.thumbdarkgc); ((XfwfSlider2Widget)self)->xfwfSlider2.thumbdarkgc = NULL;
00554   if (((XfwfSlider2Widget)self)->xfwfSlider2.thumbgc) XtReleaseGC(self, ((XfwfSlider2Widget)self)->xfwfSlider2.thumbdarkgc); ((XfwfSlider2Widget)self)->xfwfSlider2.thumbgc = NULL;
00555   if (((XfwfSlider2Widget)self)->xfwfFrame.fggc) XtReleaseGC(self, ((XfwfSlider2Widget)self)->xfwfFrame.fggc); ((XfwfSlider2Widget)self)->xfwfFrame.fggc = NULL;
00556 }
00557 /*ARGSUSED*/
00558 #if NeedFunctionPrototypes
00559 static void move_thumb(Widget self,int  oldx,int  oldy,int  wd,int  ht,int  newx,int  newy)
00560 #else
00561 static void move_thumb(self,oldx,oldy,wd,ht,newx,newy)Widget self;int  oldx;int  oldy;int  wd;int  ht;int  newx;int  newy;
00562 #endif
00563 {
00564     int h, ah;
00565 
00566     XCopyArea(XtDisplay(self), XtWindow(self), XtWindow(self),
00567              ((XfwfSlider2Widget)self)->xfwfLabel.gc,
00568              oldx, oldy, wd, ht, newx, newy);
00569     /* First check if the old and new areas do not overlap */
00570     if (newx + wd <= oldx || oldx + wd <= newx
00571        || newy + ht <= oldy || oldy + ht <= newy) {
00572        XClearArea(XtDisplay(self), XtWindow(self), oldx, oldy, wd, ht, False);
00573        return;
00574     } else {                              /* They do overlap */
00575        h = oldy - newy;
00576        if (h > 0)
00577            XClearArea(XtDisplay(self), XtWindow(self), oldx, newy + ht, wd,h,False);
00578        else if (h < 0)
00579            XClearArea(XtDisplay(self), XtWindow(self), oldx, oldy, wd, -h, False);
00580        ah = (h < 0) ? -h : h;
00581        if (newx < oldx)
00582            XClearArea(XtDisplay(self), XtWindow(self), newx + wd,
00583                      max(oldy, newy), oldx - newx, ht - ah, False);
00584        else if (oldx < newx)
00585            XClearArea(XtDisplay(self), XtWindow(self), oldx, max(oldy, newy),
00586                      newx - oldx, ht - ah, False);
00587     }
00588 }
00589 /*ARGSUSED*/
00590 #if NeedFunctionPrototypes
00591 static void compute_info(Widget self,Position * x,Position * y,Dimension * w,Dimension * h,float * thumb_x,float * thumb_y,float * thumb_wd,float * thumb_ht)
00592 #else
00593 static void compute_info(self,x,y,w,h,thumb_x,thumb_y,thumb_wd,thumb_ht)Widget self;Position * x;Position * y;Dimension * w;Dimension * h;float * thumb_x;float * thumb_y;float * thumb_wd;float * thumb_ht;
00594 #endif
00595 {
00596     int fw, fh;
00597     Position fx, fy;
00598 
00599     xfwfLabelClassRec.xfwfCommon_class.compute_inside(self, &fx, &fy, &fw, &fh);
00600     fw = max(0, fw);
00601     fh = max(0, fh);
00602     *w = min(fw, max(((XfwfSlider2Widget)self)->xfwfSlider2.minsize, *w));
00603     *h = min(fh, max(((XfwfSlider2Widget)self)->xfwfSlider2.minsize, *h));
00604     *x = min(fx + fw - *w, max(fx, *x));
00605     *y = min(fy + fh - *h, max(fy, *y));
00606     *thumb_wd = ((float) *w)/fw;
00607     *thumb_ht = ((float) *h)/fh;
00608     *thumb_x = (*w == fw) ? 0.0 : ((float) (*x - fx))/(fw - *w);
00609     *thumb_y = (*h == fh) ? 0.0 : ((float) (*y - fy))/(fh - *h);
00610 }
00611 /*ARGSUSED*/
00612 #if NeedFunctionPrototypes
00613 static Boolean  set_values(Widget  old,Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00614 #else
00615 static Boolean  set_values(old,request,self,args,num_args)Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00616 #endif
00617 {
00618     Boolean need_redisplay = False;
00619     Position x, y;
00620     Dimension w, h;
00621 
00622     if (((XfwfSlider2Widget)self)->xfwfSlider2.thumbPixmap != ((XfwfSlider2Widget)old)->xfwfSlider2.thumbPixmap) {
00623        create_fggc(self);
00624        create_thumbgc(self);
00625        create_thumblightgc(self);
00626        create_thumbdarkgc(self);
00627        need_redisplay = True;
00628     } else if (((XfwfSlider2Widget)self)->xfwfSlider2.thumbColor != ((XfwfSlider2Widget)old)->xfwfSlider2.thumbColor) {
00629        ((XfwfSlider2Widget)self)->xfwfSlider2.thumbPixmap = 0;
00630        create_fggc(self);
00631        create_thumbgc(self);
00632        create_thumblightgc(self);
00633        create_thumbdarkgc(self);
00634        need_redisplay = True;
00635     }
00636     if (((XfwfSlider2Widget)self)->xfwfSlider2.thumbFrameWidth != ((XfwfSlider2Widget)old)->xfwfSlider2.thumbFrameWidth)
00637        need_redisplay = True;
00638     if (((XfwfSlider2Widget)self)->xfwfSlider2.thumbFrameType != ((XfwfSlider2Widget)old)->xfwfSlider2.thumbFrameType)
00639        need_redisplay = True;
00640     if (((XfwfSlider2Widget)self)->xfwfSlider2.minsize != ((XfwfSlider2Widget)old)->xfwfSlider2.minsize) {
00641        compute_thumb(old, &x, &y, &w, &h);
00642        if (w < ((XfwfSlider2Widget)self)->xfwfSlider2.minsize || h < ((XfwfSlider2Widget)self)->xfwfSlider2.minsize) need_redisplay = True;
00643     }
00644     if (((XfwfSlider2Widget)self)->xfwfSlider2.scrollResponse != ((XfwfSlider2Widget)old)->xfwfSlider2.scrollResponse) {
00645        ((XfwfSlider2Widget)self)->xfwfSlider2.scrollResponse = ((XfwfSlider2Widget)old)->xfwfSlider2.scrollResponse;
00646        XtWarning("scrollResponse resource may only be queried, not set");
00647     }
00648 
00649     return need_redisplay;
00650 }
00651 #define range(x) (0.0 <=(x )&&(x )<=1.0 )
00652 
00653 
00654 /*ARGSUSED*/
00655 #if NeedFunctionPrototypes
00656 static void scroll_response(Widget  wdg,XtPointer  client_data,XtPointer  call_data)
00657 #else
00658 static void scroll_response(wdg,client_data,call_data)Widget  wdg;XtPointer  client_data;XtPointer  call_data;
00659 #endif
00660 {
00661     Widget self = (Widget) client_data;
00662     XfwfScrollInfo *inf = (XfwfScrollInfo *)call_data;
00663     XfwfScrollInfo new_info;
00664     float x, y, w, h;
00665     Position newx, newy, oldx, oldy;
00666     Dimension newwd, newht, oldwd, oldht, wd, ht;
00667     XEvent event;
00668     XRectangle rect;
00669     Region clip;
00670     Display *dpy = XtDisplay(self);
00671 
00672     x = (inf->flags&XFWF_HPOS) && range(inf->hpos) ? inf->hpos : ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x;
00673     y = (inf->flags&XFWF_VPOS) && range(inf->vpos) ? inf->vpos : ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y;
00674     w = (inf->flags&XFWF_HSIZE) && range(inf->hsize) ? inf->hsize : ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_wd;
00675     h = (inf->flags&XFWF_VSIZE) && range(inf->vsize) ? inf->vsize : ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_ht;
00676 
00677     if (((XfwfSlider2Widget)self)->xfwfSlider2.thumb_wd != w || ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_ht != h) {       /* Size changed */
00678        if (XtIsRealized(self))
00679            ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.compute_thumb(self, &oldx, &oldy, &oldwd, &oldht);
00680        ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_wd = w;
00681        ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_ht = h;
00682        ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x = x;
00683        ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y = y;
00684        if (XtIsRealized(self)) {
00685            ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.compute_thumb(self, &newx, &newy, &newwd, &newht);
00686            if ((oldwd > newwd) || (oldht > newht))
00687              XClearArea(dpy, XtWindow(self), oldx, oldy, oldwd, oldht, False);
00688            event.xexpose.x = rect.x = newx;
00689            event.xexpose.y = rect.y = newy;
00690            event.xexpose.width = rect.width = newwd;
00691            event.xexpose.height = rect.height = newht;
00692            clip = XCreateRegion();
00693            XUnionRectWithRegion(&rect, clip, clip);
00694            ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfCommon_class._expose(self, &event, clip);
00695            XDestroyRegion(clip);
00696        }
00697     } else if (((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x != x || ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y != y) { /* Only position changed */
00698        if (XtIsRealized(self))
00699            ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.compute_thumb(self, &oldx, &oldy, &wd, &ht);
00700        ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x = x;
00701        ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y = y;
00702        if (XtIsRealized(self)) {
00703            ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.compute_thumb(self, &newx, &newy, &wd, &ht);
00704            ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.move_thumb(self, oldx, oldy, wd, ht, newx, newy);
00705        }
00706     }
00707 
00708     if (inf->reason != XfwfSNotify) {
00709        new_info = *inf;
00710        new_info.reason = XfwfSNotify;
00711        XtCallCallbackList(self, ((XfwfSlider2Widget)self)->xfwfSlider2.scrollCallback, &new_info);
00712     }
00713 }
00714 /*ARGSUSED*/
00715 #if NeedFunctionPrototypes
00716 void XfwfGetThumb(Widget self,XfwfScrollInfo * info)
00717 #else
00718 void XfwfGetThumb(self,info)Widget self;XfwfScrollInfo * info;
00719 #endif
00720 {
00721     if (! XtIsSubclass(self, xfwfSlider2WidgetClass))
00722        XtError("XfwfGetThumb called with incorrect widget type");
00723     info->reason = XfwfSNotify;
00724     info->flags = XFWF_VPOS | XFWF_VSIZE | XFWF_HPOS | XFWF_HSIZE;
00725     info->vpos = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_y;
00726     info->vsize = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_ht;
00727     info->hpos = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_x;
00728     info->hsize = ((XfwfSlider2Widget)self)->xfwfSlider2.thumb_wd;
00729 }
00730 /*ARGSUSED*/
00731 #if NeedFunctionPrototypes
00732 void XfwfMoveThumb(Widget self,double  x,double  y)
00733 #else
00734 void XfwfMoveThumb(self,x,y)Widget self;double  x;double  y;
00735 #endif
00736 {
00737     XfwfScrollInfo info;
00738 
00739     if (! XtIsSubclass(self, xfwfSlider2WidgetClass))
00740        XtError("XfwfMoveThumb called with incorrect widget type");
00741     if (x < 0.0 || x > 1.0 || y < 0.0 || y > 1.0)
00742        XtError("XfwfMoveThumb called with incorrect arguments");
00743     info.flags = XFWF_VPOS | XFWF_HPOS;
00744     info.reason = XfwfSNotify;
00745     info.vpos = y;
00746     info.hpos = x;
00747     ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.scroll_response(NULL, self, &info);
00748 }
00749 /*ARGSUSED*/
00750 #if NeedFunctionPrototypes
00751 void XfwfResizeThumb(Widget self,double  wd,double  ht)
00752 #else
00753 void XfwfResizeThumb(self,wd,ht)Widget self;double  wd;double  ht;
00754 #endif
00755 {
00756     XfwfScrollInfo info;
00757 
00758     if (! XtIsSubclass(self, xfwfSlider2WidgetClass))
00759        XtError("XfwfResizeThumb called with incorrect widget type");
00760     if (wd < 0.0 || wd > 1.0 || ht < 0.0 || ht > 1.0)
00761        XtError("XfwfResizeThumb called with incorrect arguments");
00762 
00763     info.reason = XfwfSNotify;
00764     info.flags = XFWF_VSIZE | XFWF_HSIZE;
00765     info.vsize = ht;
00766     info.hsize = wd;
00767     ((XfwfSlider2WidgetClass)self->core.widget_class)->xfwfSlider2_class.scroll_response(NULL, self, &info);
00768 }