Back to index

plt-scheme  4.2.1
xwScrollWin.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 <xwEnforcer.h>
00008 #include <xwBoard.h>
00009 #include <xwVScrollb.h>
00010 #include <xwHScrollb.h>
00011 #include <xwscroll.h>
00012 #include <./xwScrollWinP.h>
00013 static void _resolve_inheritance(
00014 #if NeedFunctionPrototypes
00015 WidgetClass
00016 #endif
00017 );
00018 static void initialize(
00019 #if NeedFunctionPrototypes
00020 Widget ,Widget,ArgList ,Cardinal *
00021 #endif
00022 );
00023 static Boolean  set_values(
00024 #if NeedFunctionPrototypes
00025 Widget ,Widget ,Widget,ArgList ,Cardinal *
00026 #endif
00027 );
00028 static void resize(
00029 #if NeedFunctionPrototypes
00030 Widget
00031 #endif
00032 );
00033 static void insert_child(
00034 #if NeedFunctionPrototypes
00035 Widget 
00036 #endif
00037 );
00038 static void compute_inside(
00039 #if NeedFunctionPrototypes
00040 Widget,Position *,Position *,int *,int *
00041 #endif
00042 );
00043 static void destroy(
00044 #if NeedFunctionPrototypes
00045 Widget
00046 #endif
00047 );
00048 static void scroll_response(
00049 #if NeedFunctionPrototypes
00050 Widget ,XtPointer ,XtPointer 
00051 #endif
00052 );
00053 static void compute_sizes(
00054 #if NeedFunctionPrototypes
00055 Widget
00056 #endif
00057 );
00058 static void copy_vScrollAmount(
00059 #if NeedFunctionPrototypes
00060 Widget,int ,XrmValue *
00061 #endif
00062 );
00063 static void scroll_callback(
00064 #if NeedFunctionPrototypes
00065 Widget ,XtPointer ,XtPointer 
00066 #endif
00067 );
00068 static void CW_killed(
00069 #if NeedFunctionPrototypes
00070 Widget ,XtPointer ,XtPointer 
00071 #endif
00072 );
00073 static void configure(
00074 #if NeedFunctionPrototypes
00075 Widget ,XtPointer ,XEvent *,Boolean *
00076 #endif
00077 );
00078 /*ARGSUSED*/
00079 #if NeedFunctionPrototypes
00080 static void compute_sizes(Widget self)
00081 #else
00082 static void compute_sizes(self)Widget self;
00083 #endif
00084 {
00085     int selfw, selfh, framew, frameh, vsheight, hswidth;
00086     Dimension help;
00087     Position selfx, selfy;
00088     int edgeX;
00089 
00090     xfwfBoardClassRec.xfwfCommon_class.compute_inside(self, &selfx, &selfy, &selfw, &selfh);
00091     if (! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar)
00092        vsheight = (int)selfh - 3 * ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth;
00093     else
00094        vsheight = (int)selfh - 2 * ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing;
00095     if (! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar)
00096        hswidth = (int)selfw - 3 * ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth;
00097     else
00098        hswidth = (int)selfw - 2 * ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing;
00099     edgeX = (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.edgeBars ? 1 + ((XfwfScrolledWindowWidget)self)->xfwfFrame.frameWidth : 0);
00100     XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, XtNhighlightThickness, &help, NULL);
00101     if (help > ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing) help = 0;
00102     help += ((XfwfScrolledWindowWidget)self)->xfwfFrame.frameWidth;
00103     XtConfigureWidget(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll,
00104                     selfx + selfw - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth + edgeX,
00105                     selfy + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - help,
00106                     ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth,
00107                     max(1, vsheight + 2*help + (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar ? 0 : edgeX)),
00108                     0);
00109     XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, XtNhighlightThickness, &help, NULL);
00110     if (help > ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing) help = 0;
00111     help += ((XfwfScrolledWindowWidget)self)->xfwfFrame.frameWidth;
00112     XtConfigureWidget(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll,
00113                     ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing /* - help */,
00114                     selfy + selfh - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth + edgeX,
00115                     max(1, hswidth + 2*help + (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar ? 0 : edgeX)),
00116                     ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth,
00117                     0);
00118     XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame, XtNhighlightThickness, &help, NULL);
00119     if (help > ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing) help = 0;
00120     framew = selfw - 2 * ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing + 2 * help;
00121     frameh = selfh - 2 * ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing + 2 * help;
00122     if (! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar) framew -= ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - edgeX;
00123     if (! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar) frameh -= ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - edgeX;
00124     XtConfigureWidget(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame,
00125                     selfx + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - help,
00126                     selfy + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing - help,
00127                     max(1, framew),
00128                     max(1, frameh),
00129                     0);
00130 }
00131 /*ARGSUSED*/
00132 #if NeedFunctionPrototypes
00133 static void copy_vScrollAmount(Widget self,int  offset,XrmValue * value)
00134 #else
00135 static void copy_vScrollAmount(self,offset,value)Widget self;int  offset;XrmValue * value;
00136 #endif
00137 {
00138     value->addr = (XtPointer) &((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vScrollAmount;
00139 }
00140 /*ARGSUSED*/
00141 #if NeedFunctionPrototypes
00142 static void scroll_callback(Widget  w,XtPointer  client_data,XtPointer  call_data)
00143 #else
00144 static void scroll_callback(w,client_data,call_data)Widget  w;XtPointer  client_data;XtPointer  call_data;
00145 #endif
00146 {
00147     Widget self = (Widget) client_data;
00148     XfwfScrollInfo *info = (XfwfScrollInfo *) call_data;
00149     XfwfScrollInfo new;
00150     Position boardx, boardy, gx, gy, minx = 0, miny = 0;
00151     int boardwd, boardht;
00152     Dimension gwd, ght;
00153 
00154     if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.autoAdjustScrollbars) {
00155       xfwfBoardClassRec.xfwfCommon_class.compute_inside(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, &boardx, &boardy, &boardwd, &boardht);
00156       boardwd = max(0, boardwd);
00157       boardht = max(0, boardht);
00158       XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, XtNx, &gx, XtNy, &gy, XtNwidth, &gwd,
00159                   XtNheight, &ght, NULL);
00160       minx = gwd <= boardwd ? 0 : boardwd - gwd;
00161       miny = ght <= boardht ? 0 : boardht - ght;
00162       switch (info->reason) {
00163       case XfwfSUp: gy = min(gy + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vScrollAmount, 0); break;
00164       case XfwfSDown: gy = max(gy - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vScrollAmount, miny); break;
00165       case XfwfSLeft: gx = min(gx + ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hScrollAmount, 0); break;
00166       case XfwfSRight: gx = max(gx - ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hScrollAmount, minx); break;
00167       case XfwfSPageUp: gy = min(gy + boardht, 0); break;
00168       case XfwfSPageDown: gy = max(gy - boardht, miny); break;
00169       case XfwfSPageLeft: gx = min(gx + boardwd, 0); break;
00170       case XfwfSPageRight: gx = max(gx - boardwd, minx); break;
00171       case XfwfSDrag:
00172        if (w == ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll) gy = info->vpos * miny;
00173        else gx = info->hpos * minx;
00174        break;
00175       case XfwfSMove: break;
00176       case XfwfSTop: gy = 0; break;
00177       case XfwfSBottom: gy = miny; break;
00178       case XfwfSLeftSide: gx = 0; break;
00179       case XfwfSRightSide: gx = minx; break;
00180       default: break;
00181       }
00182     
00183       if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.doScroll)
00184         XtVaSetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, XtNx, gx, XtNy, gy, NULL);
00185     }
00186 
00187     if (info->reason != XfwfSNotify) {
00188        new.reason = info->reason;
00189        if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.autoAdjustScrollbars) {
00190          new.flags  = XFWF_VPOS | XFWF_HPOS | XFWF_HSIZE | XFWF_VSIZE ;
00191          new.hpos   = minx == 0 ? 0.0 : gx/minx;
00192          new.vpos   = miny == 0 ? 0.0 : gy/miny;
00193          new.hsize  = gwd <= boardwd ? 1.0 : (float)boardwd/(float)gwd;
00194          new.vsize  = ght <= boardht ? 1.0 : (float)boardht/(float)ght;
00195          new.gx     = gx;
00196          new.gy     = gy;
00197        } else {
00198          if (info->reason == XfwfSDrag) {
00199            if (w == ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll)
00200              new.flags  = XFWF_VPOS;
00201            else
00202              new.flags  = XFWF_HPOS;
00203          } else
00204            new.flags  = 0;
00205        }
00206        XtCallCallbackList(self, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollCallback, &new);
00207     }
00208 }
00209 /*ARGSUSED*/
00210 #if NeedFunctionPrototypes
00211 static void CW_killed(Widget  w,XtPointer  client_data,XtPointer  call_data)
00212 #else
00213 static void CW_killed(w,client_data,call_data)Widget  w;XtPointer  client_data;XtPointer  call_data;
00214 #endif
00215 {
00216     Widget self = (Widget) client_data;
00217 
00218     /* don't propagate key events from frame to child widget anymore */
00219     XtVaSetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame, XtNpropagateTarget, NULL, NULL);
00220     XtRemoveEventHandler(w, StructureNotifyMask, False, configure, self);
00221     XtRemoveEventHandler(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, StructureNotifyMask, False, configure, self);
00222     ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW = NULL;
00223     XfwfSetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, 0.0, 1.0);
00224     XfwfSetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, 0.0, 1.0);
00225 }
00226 /*ARGSUSED*/
00227 #if NeedFunctionPrototypes
00228 static void configure(Widget  w,XtPointer  client_data,XEvent * event,Boolean * cont)
00229 #else
00230 static void configure(w,client_data,event,cont)Widget  w;XtPointer  client_data;XEvent * event;Boolean * cont;
00231 #endif
00232 {
00233     Widget self = (Widget) client_data;
00234     int boardwd, boardht;
00235     Dimension gwd, ght;
00236     Position boardx, boardy, gx, gy, minx, miny;
00237     float wd, ht, x, y;
00238 
00239     if (((XfwfScrolledWindowWidget)self)->core.being_destroyed) {
00240        /*
00241         * it may be possible that a configure event
00242         * occures during destruction
00243         */
00244        return;
00245     }
00246 
00247     /* -- There is nothing wrong, when the event is something else */
00248     /* -- than a ConfigureNotify. The if prevents correct setting of */
00249     /* -- scrollbars during the insert_child method */
00250     /* if (event != NULL && event->type != ConfigureNotify) return; */
00251     if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.autoAdjustScrollbars) {
00252       xfwfBoardClassRec.xfwfCommon_class.compute_inside(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, &boardx, &boardy, &boardwd, &boardht);
00253       boardwd = max(0, boardwd);
00254       boardht = max(0, boardht);
00255       XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, XtNx, &gx, XtNy, &gy, XtNwidth, &gwd,
00256                   XtNheight, &ght, NULL);
00257       minx = gwd <= boardwd ? 0 : boardwd - gwd;
00258       miny = ght <= boardht ? 0 : boardht - ght;
00259       if ((gx < minx) || (gy < miny)) {
00260        if (gx < minx) gx = minx;
00261        if (gy < miny) gy = miny;
00262        XtVaSetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, XtNx, gx, XtNy, gy, NULL);
00263       }
00264       wd = gwd <= boardwd ? 1.0 : (float) boardwd/gwd;
00265       ht = ght <= boardht ? 1.0 : (float) boardht/ght;
00266       x = gwd <= boardwd ? 0.0 : gx/(((float) boardwd) - gwd);
00267       y = ght <= boardht ? 0.0 : gy/(((float) boardht) - ght);
00268       if (x > 1.0) x = 1.0;
00269       if (y > 1.0) y = 1.0;
00270       XfwfSetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, x, wd);
00271       XfwfSetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, y, ht);
00272    }
00273 }
00274 
00275 static XtResource resources[] = {
00276 {XtNautoAdjustScrollbars,XtCAutoAdjustScrollbars,XtRBoolean,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.autoAdjustScrollbars),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.autoAdjustScrollbars),XtRImmediate,(XtPointer)TRUE },
00277 {XtNhighlightThickness,XtCHighlightThickness,XtRDimension,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfCommon.highlightThickness),XtOffsetOf(XfwfScrolledWindowRec,xfwfCommon.highlightThickness),XtRImmediate,(XtPointer)0 },
00278 {XtNtraverseToChild,XtCTraverseToChild,XtRBoolean,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.traverseToChild),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.traverseToChild),XtRImmediate,(XtPointer)TRUE },
00279 {XtNspacing,XtCSpacing,XtRDimension,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.spacing),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.spacing),XtRImmediate,(XtPointer)0 },
00280 {XtNedgeBars,XtCEdgeBars,XtRBoolean,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.edgeBars),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.edgeBars),XtRImmediate,(XtPointer)FALSE },
00281 {XtNscrollbarWidth,XtCScrollbarWidth,XtRDimension,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.scrollbarWidth),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.scrollbarWidth),XtRImmediate,(XtPointer)16 },
00282 {XtNshadowWidth,XtCShadowWidth,XtRDimension,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.shadowWidth),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.shadowWidth),XtRImmediate,(XtPointer)2 },
00283 {XtNhideHScrollbar,XtCHideHScrollbar,XtRBoolean,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.hideHScrollbar),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.hideHScrollbar),XtRImmediate,(XtPointer)False },
00284 {XtNhideVScrollbar,XtCHideVScrollbar,XtRBoolean,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.hideVScrollbar),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.hideVScrollbar),XtRImmediate,(XtPointer)False },
00285 {XtNvScrollAmount,XtCVScrollAmount,XtRInt,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.vScrollAmount),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.vScrollAmount),XtRImmediate,(XtPointer)20 },
00286 {XtNhScrollAmount,XtCHScrollAmount,XtRInt,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.hScrollAmount),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.hScrollAmount),XtRCallProc,(XtPointer)copy_vScrollAmount },
00287 {XtNinitialX,XtCInitialX,XtRPosition,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.initialX),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.initialX),XtRImmediate,(XtPointer)0 },
00288 {XtNinitialY,XtCInitialY,XtRPosition,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.initialY),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.initialY),XtRImmediate,(XtPointer)0 },
00289 {XtNdrawgrayScrollWin,XtCDrawgrayScrollWin,XtRBoolean,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.drawgrayScrollWin),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.drawgrayScrollWin),XtRImmediate,(XtPointer)FALSE },
00290 {XtNdoScroll,XtCDoScroll,XtRBoolean,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.doScroll),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.doScroll),XtRImmediate,(XtPointer)TRUE },
00291 {XtNscrollCallback,XtCScrollCallback,XtRCallback,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.scrollCallback),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.scrollCallback),XtRImmediate,(XtPointer)NULL },
00292 {XtNscrollResponse,XtCScrollResponse,XtRXTCallbackProc,sizeof(((XfwfScrolledWindowRec*)NULL)->xfwfScrolledWindow.scrollResponse),XtOffsetOf(XfwfScrolledWindowRec,xfwfScrolledWindow.scrollResponse),XtRImmediate,(XtPointer)scroll_response },
00293 };
00294 
00295 XfwfScrolledWindowClassRec xfwfScrolledWindowClassRec = {
00296 { /* core_class part */
00297 /* superclass        */  (WidgetClass) &xfwfBoardClassRec,
00298 /* class_name        */  "XfwfScrolledWindow",
00299 /* widget_size       */  sizeof(XfwfScrolledWindowRec),
00300 /* class_initialize  */  NULL,
00301 /* class_part_initialize*/  _resolve_inheritance,
00302 /* class_inited      */  FALSE,
00303 /* initialize        */  initialize,
00304 /* initialize_hook   */  NULL,
00305 /* realize           */  XtInheritRealize,
00306 /* actions           */  NULL,
00307 /* num_actions       */  0,
00308 /* resources         */  resources,
00309 /* num_resources     */  17,
00310 /* xrm_class         */  NULLQUARK,
00311 /* compres_motion    */  True ,
00312 /* compress_exposure        */  XtExposeCompressMaximal ,
00313 /* compress_enterleave      */  True ,
00314 /* visible_interest  */  False ,
00315 /* destroy           */  destroy,
00316 /* resize            */  resize,
00317 /* expose            */  XtInheritExpose,
00318 /* set_values        */  set_values,
00319 /* set_values_hook   */  NULL,
00320 /* set_values_almost        */  XtInheritSetValuesAlmost,
00321 /* get_values+hook   */  NULL,
00322 /* accept_focus      */  XtInheritAcceptFocus,
00323 /* version           */  XtVersion,
00324 /* callback_private  */  NULL,
00325 /* tm_table          */  NULL,
00326 /* query_geometry    */  XtInheritQueryGeometry,
00327 /* display_acceleator       */  XtInheritDisplayAccelerator,
00328 /* extension         */  NULL 
00329 },
00330 { /* composite_class part */
00331 XtInheritGeometryManager,
00332 XtInheritChangeManaged,
00333 insert_child,
00334 XtInheritDeleteChild,
00335 NULL
00336 },
00337 { /* XfwfCommon_class part */
00338 compute_inside,
00339 XtInherit_total_frame_width,
00340 XtInherit__expose,
00341 XtInherit_highlight_border,
00342 XtInherit_unhighlight_border,
00343 XtInherit_hilite_callbacks,
00344 XtInherit_would_accept_focus,
00345 XtInherit_traverse,
00346 XtInherit_lighter_color,
00347 XtInherit_darker_color,
00348 XtInherit_set_color,
00349 /* traversal_trans */  NULL ,
00350 /* traversal_trans_small */  NULL ,
00351 /* travMode */  1 ,
00352 },
00353 { /* XfwfFrame_class part */
00354  /* dummy */  0
00355 },
00356 { /* XfwfBoard_class part */
00357 XtInherit_set_abs_location,
00358 },
00359 { /* XfwfScrolledWindow_class part */
00360 scroll_response,
00361 },
00362 };
00363 WidgetClass xfwfScrolledWindowWidgetClass = (WidgetClass) &xfwfScrolledWindowClassRec;
00364 static void _resolve_inheritance(class)
00365 WidgetClass class;
00366 {
00367   XfwfScrolledWindowWidgetClass c = (XfwfScrolledWindowWidgetClass) class;
00368   XfwfScrolledWindowWidgetClass super;
00369   static CompositeClassExtensionRec extension_rec = {
00370     NULL, NULLQUARK, XtCompositeExtensionVersion,
00371     sizeof(CompositeClassExtensionRec), True};
00372   CompositeClassExtensionRec *ext;
00373   ext = (XtPointer)XtMalloc(sizeof(*ext));
00374   *ext = extension_rec;
00375   ext->next_extension = c->composite_class.extension;
00376   c->composite_class.extension = ext;
00377   if (class == xfwfScrolledWindowWidgetClass) return;
00378   super = (XfwfScrolledWindowWidgetClass)class->core_class.superclass;
00379   if (c->xfwfScrolledWindow_class.scroll_response == XtInherit_scroll_response)
00380     c->xfwfScrolledWindow_class.scroll_response = super->xfwfScrolledWindow_class.scroll_response;
00381 }
00382 /*ARGSUSED*/
00383 #if NeedFunctionPrototypes
00384 static void initialize(Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00385 #else
00386 static void initialize(request,self,args,num_args)Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00387 #endif
00388 {
00389     XtPointer bg;
00390 
00391     ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initializing = True;
00392     if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialX > 0) ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialX = 0;
00393     if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialY > 0) ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialY = 0;
00394     ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW = NULL; ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board = NULL;
00395     XtVaGetValues(self, XtNbackground, &bg, NULL),
00396     ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame = XtVaCreateManagedWidget
00397        ("_frame", xfwfEnforcerWidgetClass, self,
00398         XtNframeType, XfwfSunken, XtNframeWidth, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.shadowWidth,
00399         XtNborderWidth, 0, XtNhighlightThickness, 0,
00400         XtNtraversalOn, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.traverseToChild, 
00401         XtNbackground, bg,
00402          XtNtraversalTranslationDone, ((XfwfScrolledWindowWidget)self)->xfwfCommon.traversalTranslationDone, 
00403         NULL);
00404     ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board = XtVaCreateManagedWidget
00405        ("_board", xfwfBoardWidgetClass, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame, XtNframeWidth, 0,
00406         XtNborderWidth, 0, XtNhighlightThickness, 0,
00407         XtNbackground, bg,
00408         XtNtraversalOn, False, NULL);
00409     ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll = XtVaCreateWidget
00410        ("_vscroll", xfwfVScrollbarWidgetClass, self, XtNframeWidth,
00411         1, XtNframeType, XfwfSunken, XtNborderWidth, 0, 
00412          XtNhighlightColor, ((XfwfScrolledWindowWidget)self)->xfwfCommon.highlightColor,
00413         XtNhighlightThickness, 0, XtNbackground, bg, NULL);
00414     ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll = XtVaCreateWidget
00415        ("_hscroll", xfwfHScrollbarWidgetClass, self, XtNframeWidth,
00416         1, XtNframeType, XfwfSunken, XtNborderWidth, 0, 
00417          XtNhighlightColor, ((XfwfScrolledWindowWidget)self)->xfwfCommon.highlightColor,
00418         XtNhighlightThickness, 0, XtNbackground, bg, NULL);
00419     if (! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar) XtManageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll);
00420     if (! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar) XtManageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll);
00421     compute_sizes(self);
00422     XtAddCallback(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, XtNscrollCallback, scroll_callback, self);
00423     XtAddCallback(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, XtNscrollCallback, scroll_callback, self);
00424     XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, XtNscrollResponse, &((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll_resp, NULL);
00425     XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, XtNscrollResponse, &((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll_resp, NULL);
00426     ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initializing = False;
00427     if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollResponse != scroll_response) {
00428        ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollResponse = scroll_response;
00429        XtWarning("scrollResponse resource may only be queried, not set");
00430     }
00431 }
00432 /*ARGSUSED*/
00433 #if NeedFunctionPrototypes
00434 static Boolean  set_values(Widget  old,Widget  request,Widget self,ArgList  args,Cardinal * num_args)
00435 #else
00436 static Boolean  set_values(old,request,self,args,num_args)Widget  old;Widget  request;Widget self;ArgList  args;Cardinal * num_args;
00437 #endif
00438 {
00439     if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.traverseToChild && !((XfwfScrolledWindowWidget)old)->xfwfCommon.traversalTranslationDone && ((XfwfScrolledWindowWidget)self)->xfwfCommon.traversalTranslationDone) {
00440        XtVaSetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame, XtNtraversalTranslationDone, ((XfwfScrolledWindowWidget)self)->xfwfCommon.traversalTranslationDone, NULL);
00441     }
00442 
00443     if (((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideVScrollbar && ! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar) {
00444        XtManageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll);
00445     } else if (! ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideVScrollbar && ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar) {
00446        XtUnmanageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll);
00447     }
00448     if (((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideHScrollbar && ! ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar) {
00449        XtManageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll);
00450     } else if (! ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideHScrollbar && ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar) {
00451        XtUnmanageChild(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll);
00452     }
00453     if (((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.traverseToChild != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.traverseToChild) {
00454        XtVaSetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame, XtNtraversalOn, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.traverseToChild, NULL);
00455        XtVaSetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame, XtNpropagateTarget, (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.traverseToChild ? ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW : NULL), NULL);
00456     }
00457     if (((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.spacing != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.spacing
00458        || ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.scrollbarWidth != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollbarWidth
00459        || ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.shadowWidth != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.shadowWidth
00460        || ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideHScrollbar != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideHScrollbar
00461        || ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.hideVScrollbar != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hideVScrollbar)
00462        compute_sizes(self);
00463     if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollResponse != ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.scrollResponse) {
00464        ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollResponse = ((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.scrollResponse;
00465        XtWarning("scrollResponse resource may only be queried, not set");
00466     }
00467     if (((XfwfScrolledWindowWidget)old)->xfwfScrolledWindow.drawgrayScrollWin != ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.drawgrayScrollWin) {
00468       XtVaSetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, XtNdrawgrayScrollbar, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.drawgrayScrollWin, NULL);
00469       XtVaSetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, XtNdrawgrayScrollbar, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.drawgrayScrollWin, NULL);
00470     }
00471 
00472     return False;
00473 }
00474 /*ARGSUSED*/
00475 #if NeedFunctionPrototypes
00476 static void resize(Widget self)
00477 #else
00478 static void resize(self)Widget self;
00479 #endif
00480 {
00481     compute_sizes(self);
00482 }
00483 /*ARGSUSED*/
00484 #if NeedFunctionPrototypes
00485 static void insert_child(Widget  child)
00486 #else
00487 static void insert_child(child)Widget  child;
00488 #endif
00489 { Widget self = XtParent(child); {
00490     Position boardx, boardy, gx, gy;
00491     int boardwd, boardht;
00492     Dimension gwd, ght;
00493     Boolean dummy;
00494 
00495     if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initializing) {
00496        xfwfBoardClassRec.composite_class.insert_child(child);
00497     } else if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW == NULL) {
00498        ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW = child;
00499        ((XfwfScrolledWindowWidget)child)->core.parent = ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board;
00500        XtAddCallback(child, XtNdestroyCallback, CW_killed, self);
00501        xfwfBoardClassRec.composite_class.insert_child(child);
00502        XtAddEventHandler(child, StructureNotifyMask, False, configure, self);
00503        XtAddEventHandler(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, StructureNotifyMask, False, configure, self);
00504        xfwfBoardClassRec.xfwfCommon_class.compute_inside(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, &boardx, &boardy, &boardwd, &boardht);
00505         boardwd = max(0, boardwd);
00506         boardht = max(0, boardht);
00507        XtVaGetValues(child, XtNwidth, &gwd, XtNheight, &ght, NULL);
00508        gx = gwd <= boardwd ? 0 : max(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialX, boardwd - gwd);
00509        gy = ght <= boardht ? 0 : max(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.initialY, boardht - ght);
00510        XtVaSetValues(child, XtNx, gx, XtNy, gy, NULL);
00511        /* propagate key events from frame to child widget */
00512        if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.traverseToChild)
00513            XtVaSetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.frame, XtNpropagateTarget, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, NULL);
00514        XtVaSetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, XtNpropagateTarget, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, NULL);
00515        configure(self, self, NULL, &dummy);
00516     } else {
00517        char s[500];
00518        (void) sprintf(s, "Cannot add <%s>, %s <%s> already has a child\n",
00519                      XtName(child), "ScrolledWindow", XtName(self));
00520        XtWarning(s);
00521     }
00522 }
00523 }
00524 /*ARGSUSED*/
00525 #if NeedFunctionPrototypes
00526 static void compute_inside(Widget self,Position * x,Position * y,int * w,int * h)
00527 #else
00528 static void compute_inside(self,x,y,w,h)Widget self;Position * x;Position * y;int * w;int * h;
00529 #endif
00530 {
00531     xfwfBoardClassRec.xfwfCommon_class.compute_inside((((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board ? ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board : self), x, y, w, h);
00532 }
00533 /*ARGSUSED*/
00534 #if NeedFunctionPrototypes
00535 static void destroy(Widget self)
00536 #else
00537 static void destroy(self)Widget self;
00538 #endif
00539 {
00540     if (((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW != NULL) {
00541        XtRemoveEventHandler(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, StructureNotifyMask, False,
00542                           configure, self);
00543        XtRemoveEventHandler(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, StructureNotifyMask, False,
00544                           configure, self);
00545     }
00546 }
00547 /*ARGSUSED*/
00548 #if NeedFunctionPrototypes
00549 static void scroll_response(Widget  w,XtPointer  client_data,XtPointer  call_data)
00550 #else
00551 static void scroll_response(w,client_data,call_data)Widget  w;XtPointer  client_data;XtPointer  call_data;
00552 #endif
00553 {
00554     Widget self = (Widget) client_data;
00555     XfwfScrollInfo *info = (XfwfScrollInfo *) call_data;
00556     XfwfScrollInfo new;
00557     Position boardx, boardy, gx, gy, minx, miny;
00558     int boardwd, boardht;
00559     Dimension gwd, ght;
00560 
00561     xfwfBoardClassRec.xfwfCommon_class.compute_inside(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, &boardx, &boardy, &boardwd, &boardht);
00562     boardwd = max(0, boardwd);
00563     boardht = max(0, boardht);
00564     XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, XtNx, &gx, XtNy, &gy, XtNwidth, &gwd,
00565                 XtNheight, &ght, NULL);
00566     minx = gwd <= boardwd ? 0 : boardwd - gwd;
00567     miny = ght <= boardht ? 0 : boardht - ght;
00568 
00569     if (info->flags & XFWF_VPOS) gy = info->vpos * miny;
00570     if (info->flags & XFWF_HPOS) gx = info->hpos * minx;
00571 
00572     XtVaSetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.CW, XtNx, gx, XtNy, gy, NULL);
00573 
00574     if (info->reason != XfwfSNotify && ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.doScroll) {
00575        new.reason = XfwfSNotify;
00576        new.flags = info->flags & (XFWF_VPOS | XFWF_HPOS);
00577        new.hpos = info->hpos;
00578        new.vpos = info->vpos;
00579        XtCallCallbackList(self, ((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.scrollCallback, info);
00580     }
00581 }
00582 /*ARGSUSED*/
00583 #if NeedFunctionPrototypes
00584 void xws_set_scroll_direct(Widget self,long  hlen,long  hpage,long  hpos,long  vlen,long  vpage,long  vpos)
00585 #else
00586 void xws_set_scroll_direct(self,hlen,hpage,hpos,vlen,vpage,vpos)Widget self;long  hlen;long  hpage;long  hpos;long  vlen;long  vpage;long  vpos;
00587 #endif
00588 {
00589   if (!hpage) hpage = 1;
00590   XfwfSetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, !hlen ? 0 : (float)hpos / hlen, (float)hpage / (hlen + hpage));
00591   if (!vpage) vpage = 1;
00592   XfwfSetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, !vlen ? 0 : (float)vpos / vlen, (float)vpage / (vlen + vpage));
00593 }
00594 /*ARGSUSED*/
00595 #if NeedFunctionPrototypes
00596 void xws_get_scroll_pos(Widget self,double * x,double * y)
00597 #else
00598 void xws_get_scroll_pos(self,x,y)Widget self;double * x;double * y;
00599 #endif
00600 {
00601   XfwfGetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.hscroll, x, NULL);
00602   XfwfGetScrollbar(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.vscroll, NULL, y);
00603 }
00604 /*ARGSUSED*/
00605 #if NeedFunctionPrototypes
00606 void xws_get_scroll_area(Widget self,Dimension * x,Dimension * y)
00607 #else
00608 void xws_get_scroll_area(self,x,y)Widget self;Dimension * x;Dimension * y;
00609 #endif
00610 {
00611   XtVaGetValues(((XfwfScrolledWindowWidget)self)->xfwfScrolledWindow.board, XtNwidth, x, XtNheight, y, NULL);
00612 }
00613 /*ARGSUSED*/
00614 #if NeedFunctionPrototypes
00615 void ScrollWinViewableHeight(Widget self,int * boardht)
00616 #else
00617 void ScrollWinViewableHeight(self,boardht)Widget self;int * boardht;
00618 #endif
00619 {
00620   Position boardx, boardy;
00621   int boardwd;
00622        
00623   ((XfwfScrolledWindowWidgetClass)self->core.widget_class)->xfwfCommon_class.compute_inside(self, &boardx, &boardy, &boardwd, boardht);  
00624 }