Scrollbar.c File Reference

#include <X11/IntrinsicP.h>
#include <X11/StringDefs.h>
#include <X11/Xaw3d/XawInit.h>
#include <X11/Xaw3d/ScrollbarP.h>
#include <X11/Xmu/Drawing.h>

Include dependency graph for Scrollbar.c:

Go to the source code of this file.

Data Structures

struct  EventData

Defines

#define Offset(field)   XtOffsetOf(ScrollbarRec, field)
#define NoButton   -1
#define PICKLENGTH(widget, x, y)   ((widget->scrollbar.orientation == XtorientHorizontal) ? x : y)
#define MIN(x, y)   ((x) < (y) ? (x) : (y))
#define MAX(x, y)   ((x) > (y) ? (x) : (y))
#define MARGIN(sbw)   (sbw)->threeD.shadow_width
#define Check(field)   if (newEvent->field != oldEvent->field) return False;

Functions

static void ClassInitialize ()
static void Initialize ()
static void Destroy ()
static void Realize ()
static void Resize ()
static void Redisplay ()
static Boolean SetValues ()
static void StartScroll ()
static void MoveThumb ()
static void NotifyThumb ()
static void NotifyScroll ()
static void EndScroll ()
static void FillArea (ScrollbarWidget sbw, Position top, Position bottom, int fill)
static void _ShadowSurroundedBox (Widget gw, XEvent *event, Region region, Dimension xtl, Dimension ytl, Dimension xbr, Dimension ybr, Boolean out)
static void PaintThumb (ScrollbarWidget sbw, XEvent *event)
static void Destroy (Widget w)
static void CreateGC (Widget w)
static void SetDimensions (ScrollbarWidget sbw)
static void Initialize (Widget request, Widget new, ArgList args, Cardinal *num_args)
static void Realize (Widget w, Mask *valueMask, XSetWindowAttributes *attributes)
static Boolean SetValues (Widget current, Widget request, Widget desired, ArgList args, Cardinal *num_args)
static void Resize (Widget w)
static void Redisplay (Widget w, XEvent *event, Region region)
static Boolean CompareEvents (XEvent *oldEvent, XEvent *newEvent)
static Bool PeekNotifyEvent (Display *dpy, XEvent *event, char *args)
static Boolean LookAhead (Widget w, XEvent *event)
static void ExtractPosition (XEvent *event, Position *x, Position *y)
static void StartScroll (Widget w, XEvent *event, String *params, Cardinal *num_params)
static int InRange (int num, int small, int big)
static float FloatInRange (float num, float small, float big)
static void NotifyScroll (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void EndScroll (Widget w, XEvent *event, String *params, Cardinal *num_params)
static float FractionLoc (ScrollbarWidget sbw, int x, int y)
static void MoveThumb (Widget w, XEvent *event, String *params, Cardinal *num_params)
static void NotifyThumb (Widget w, XEvent *event, String *params, Cardinal *num_params)
void XawScrollbarSetThumb (Widget w, float top, float shown)

Variables

static char defaultTranslations []
static float floatZero = 0.0
static XtResource resources []
static XtActionsRec actions []
ScrollbarClassRec scrollbarClassRec
WidgetClass scrollbarWidgetClass = (WidgetClass)&scrollbarClassRec


Define Documentation

#define Check ( field   )     if (newEvent->field != oldEvent->field) return False;

Referenced by Check(), CompareEvents(), GetBMATRIX(), GetCOLUMN(), GetIMATRIX(), GetMATRIX(), GetPOLYNOM(), GetROW(), GetSPARSE(), GetSTRING(), GetSTRINGMAT(), GetVECTOR(), and WriteArgCheck().

#define MARGIN ( sbw   )     (sbw)->threeD.shadow_width

Definition at line 240 of file Scrollbar.c.

Referenced by FillArea(), FractionLoc(), and PaintThumb().

#define MAX ( x,
y   )     ((x) > (y) ? (x) : (y))

Definition at line 227 of file Scrollbar.c.

#define MIN ( x,
y   )     ((x) < (y) ? (x) : (y))

Definition at line 226 of file Scrollbar.c.

Referenced by intdgesvd(), PaintThumb(), Xaw3dComputeTopShadowRGB(), and XawSme3dComputeTopShadowRGB().

#define NoButton   -1

Definition at line 223 of file Scrollbar.c.

#define Offset ( field   )     XtOffsetOf(ScrollbarRec, field)

Definition at line 95 of file Scrollbar.c.

#define PICKLENGTH ( widget,
x,
y   )     ((widget->scrollbar.orientation == XtorientHorizontal) ? x : y)

Definition at line 224 of file Scrollbar.c.

Referenced by FractionLoc(), and NotifyScroll().


Function Documentation

static void _ShadowSurroundedBox ( Widget  gw,
XEvent *  event,
Region  region,
Dimension  xtl,
Dimension  ytl,
Dimension  xbr,
Dimension  ybr,
Boolean  out 
) [static]

Definition at line 303 of file Scrollbar.c.

References bot, ThreeDPart::bot_shadow_GC, CoordModeOrigin, dpy, out(), pt, s, ThreeDPart::shadow_width, _ThreeDRec::threeD, top, and ThreeDPart::top_shadow_GC.

Referenced by PaintThumb().

00309 {
00310     XPoint       pt[6];
00311     ThreeDWidget tdw = (ThreeDWidget) gw;
00312     Dimension    s   = tdw->threeD.shadow_width;
00313 
00314     /* 
00315      *  no point to do anything if the shadow_width is 0 or the
00316      *  widget has not been realized.
00317      */ 
00318     if((s > 0) && XtIsRealized (gw)){
00319 
00320         Dimension       xms = xtl - s;
00321         Dimension       yms = ytl - s;
00322         Dimension       xps = xbr + s;
00323         Dimension       yps = ybr + s;
00324         Display         *dpy = XtDisplay (gw);
00325         Window          win = XtWindow (gw);
00326         GC              top, bot;
00327 
00328         if (out) {
00329             top = tdw->threeD.top_shadow_GC;
00330             bot = tdw->threeD.bot_shadow_GC;
00331         } else {
00332             top = tdw->threeD.bot_shadow_GC;
00333             bot = tdw->threeD.top_shadow_GC;
00334         }
00335         /* Draw shadows. Points are numbered as follows:
00336          *
00337          *   1_________________________________ 2
00338          *   |                               / /|
00339          *   |                              / / |
00340          *   |   4_________________________/ /  |
00341          *   |   |                         3|   |
00342 
00343          *   |   |                          |   |
00344          *   |   |                          |   |
00345          *   |   |                          |   |
00346          *   |   |5_________________________|   |
00347          *   |  / /                         4   |
00348          *   | / /                              |
00349          *   |/ /_______________________________|
00350          *   3                                  1
00351          */
00352 
00353         /* points common to top and bottom shadow */
00354         pt[0].x = xms;  pt[0].y = yps;
00355         pt[2].x = xps;  pt[2].y = yms;
00356         pt[3].x = xbr;  pt[3].y = ytl;
00357         pt[5].x = xtl;  pt[5].y = ybr;
00358 
00359         /* top-left shadow */
00360         if ((region == NULL) ||
00361             (XRectInRegion (region, xms, yms, xps, ytl) != RectangleOut) ||
00362             (XRectInRegion (region, xms, yms, xtl, yps) != RectangleOut)) {
00363 
00364             pt[1].x = xms;      pt[1].y = yms;
00365             pt[4].x = xtl;      pt[4].y = ytl;
00366             XFillPolygon (dpy, win, top, pt, 6,Complex,CoordModeOrigin);
00367         }
00368 
00369         /* bottom-right shadow */
00370         if ((region == NULL) ||
00371             (XRectInRegion (region, xms, ybr, xps, yps) != RectangleOut) ||
00372             (XRectInRegion (region, xbr, yms, xps, yps) != RectangleOut)) {
00373 
00374             /* swap points from top left to bottom right */
00375             pt[1].x = xps;      pt[1].y = yps;
00376             pt[4].x = xbr;      pt[4].y = ybr;
00377             XFillPolygon (dpy, win, bot, pt,6, Complex,CoordModeOrigin);
00378         }
00379     }
00380 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void ClassInitialize (  )  [static]

Definition at line 229 of file Scrollbar.c.

References XawInitializeWidgetSet(), and XmuCvtStringToOrientation().

00230 {
00231     XawInitializeWidgetSet();
00232     XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
00233                     (XtConvertArgList)NULL, (Cardinal)0 );
00234 }

Here is the call graph for this function:

static Boolean CompareEvents ( XEvent *  oldEvent,
XEvent *  newEvent 
) [static]

Definition at line 774 of file Scrollbar.c.

References Check.

Referenced by LookAhead(), and PeekNotifyEvent().

00776 {
00777 #define Check(field) if (newEvent->field != oldEvent->field) return False;
00778 
00779     Check(xany.display);
00780     Check(xany.type);
00781     Check(xany.window);
00782 
00783     switch (newEvent->type) {
00784     case MotionNotify:
00785         Check(xmotion.state); 
00786         break;
00787     case ButtonPress:
00788     case ButtonRelease:
00789         Check(xbutton.state);
00790         Check(xbutton.button); 
00791         break;
00792     case KeyPress:
00793     case KeyRelease:
00794         Check(xkey.state);
00795         Check(xkey.keycode); 
00796         break;
00797     case EnterNotify:
00798     case LeaveNotify:
00799         Check(xcrossing.mode);
00800         Check(xcrossing.detail);
00801         Check(xcrossing.state); 
00802         break;
00803     }
00804 #undef Check
00805 
00806     return True;
00807 }

Here is the caller graph for this function:

static void CreateGC ( Widget  w  )  [static]

Definition at line 576 of file Scrollbar.c.

References _ScrollbarRec::core, depth, ScrollbarPart::foreground, ScrollbarPart::gc, height, root, _ScrollbarRec::scrollbar, ScrollbarPart::thumb, width, x, XmuCreateStippledPixmap(), and y.

Referenced by Initialize(), and SetValues().

00578 {
00579     ScrollbarWidget sbw = (ScrollbarWidget) w;
00580     XGCValues gcValues;
00581     XtGCMask mask;
00582     unsigned int depth = 1;
00583 
00584     if (sbw->scrollbar.thumb == XtUnspecifiedPixmap) {
00585         sbw->scrollbar.thumb = XmuCreateStippledPixmap (XtScreen(w), 
00586                                         (Pixel) 1, (Pixel) 0, depth);
00587     } else if (sbw->scrollbar.thumb != None) {
00588         Window root;
00589         int x, y;
00590         unsigned int width, height, bw;
00591         if (XGetGeometry (XtDisplay(w), sbw->scrollbar.thumb, &root, &x, &y,
00592                          &width, &height, &bw, &depth) == 0) {
00593             XtAppError (XtWidgetToApplicationContext (w),
00594                "Scrollbar Widget: Could not get geometry of thumb pixmap.");
00595         }
00596     }
00597 
00598     gcValues.foreground = sbw->scrollbar.foreground;
00599     gcValues.background = sbw->core.background_pixel;
00600     mask = GCForeground | GCBackground;
00601 
00602     if (sbw->scrollbar.thumb != None) {
00603         if (depth == 1) {
00604             gcValues.fill_style = FillOpaqueStippled;
00605             gcValues.stipple = sbw->scrollbar.thumb;
00606             mask |= GCFillStyle | GCStipple;
00607         }
00608         else {
00609             gcValues.fill_style = FillTiled;
00610             gcValues.tile = sbw->scrollbar.thumb;
00611             mask |= GCFillStyle | GCTile;
00612         }
00613     }
00614     /* the creation should be non-caching, because */
00615     /* we now set and clear clip masks on the gc returned */
00616     sbw->scrollbar.gc = XtGetGC (w, mask, &gcValues);
00617 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void Destroy ( Widget  w  )  [static]

Definition at line 559 of file Scrollbar.c.

References ScrollbarPart::gc, and _ScrollbarRec::scrollbar.

00561 {
00562     ScrollbarWidget sbw = (ScrollbarWidget) w;
00563 #ifdef ARROW_SCROLLBAR
00564     if(sbw->scrollbar.timer_id != (XtIntervalId) 0)
00565         XtRemoveTimeOut (sbw->scrollbar.timer_id);
00566 #endif
00567     XtReleaseGC (w, sbw->scrollbar.gc);
00568 }

static void Destroy (  )  [static]

static void EndScroll ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
) [static]

Definition at line 1089 of file Scrollbar.c.

References ScrollbarPart::direction, ScrollbarPart::inactiveCursor, _ScrollbarRec::scrollbar, and XtNcursor.

01094 {
01095     ScrollbarWidget sbw = (ScrollbarWidget) w;
01096 
01097 #ifdef ARROW_SCROLLBAR
01098     sbw->scrollbar.scroll_mode = 0;
01099     /* no need to remove any autoscroll timeout; it will no-op */
01100     /* because the scroll_mode is 0 */
01101     /* but be sure to remove timeout in destroy proc */
01102 #else
01103     XtVaSetValues (w, XtNcursor, sbw->scrollbar.inactiveCursor, NULL);
01104     XFlush (XtDisplay (w));
01105     sbw->scrollbar.direction = 0;
01106 #endif
01107 }

static void EndScroll (  )  [static]

static void ExtractPosition ( XEvent *  event,
Position *  x,
Position *  y 
) [static]

Definition at line 844 of file Scrollbar.c.

Referenced by MoveThumb(), and NotifyScroll().

00847 {
00848     switch( event->type ) {
00849     case MotionNotify:
00850         *x = event->xmotion.x;   
00851         *y = event->xmotion.y;    
00852         break;
00853     case ButtonPress:
00854     case ButtonRelease:
00855         *x = event->xbutton.x;   
00856         *y = event->xbutton.y;   
00857         break;
00858     case KeyPress:
00859     case KeyRelease:
00860         *x = event->xkey.x;      
00861         *y = event->xkey.y;       
00862         break;
00863     case EnterNotify:
00864     case LeaveNotify:
00865         *x = event->xcrossing.x; 
00866         *y = event->xcrossing.y; 
00867         break;
00868     default:
00869         *x = 0; *y = 0;
00870     }
00871 }

Here is the caller graph for this function:

static void FillArea ( ScrollbarWidget  sbw,
Position  top,
Position  bottom,
int  fill 
) [static]

Definition at line 249 of file Scrollbar.c.

References FALSE, lw, MARGIN, and XtorientHorizontal.

Referenced by PaintThumb().

00253 {
00254     int tlen = bottom - top;    /* length of thumb in pixels */
00255     int sw, margin, floor;
00256     int lx, ly, lw, lh;
00257 
00258     if (bottom <= 0 || bottom <= top) 
00259         return;
00260     if ((sw = sbw->threeD.shadow_width) < 0) 
00261         sw = 0;
00262     margin = MARGIN (sbw);
00263     floor = sbw->scrollbar.length - margin;
00264 
00265     if (sbw->scrollbar.orientation == XtorientHorizontal) {
00266         lx = ((top < margin) ? margin : top);
00267         ly = sw;
00268         lw = ((bottom > floor) ? floor - top : tlen);
00269 /* CHECKIT      lw = (((top + tlen) > floor) ? floor - top : tlen); */
00270         lh = sbw->core.height - 2 * sw;
00271     } else {
00272         lx = sw;
00273         ly = ((top < margin) ? margin : top);
00274         lw = sbw->core.width - 2 * sw;
00275 /* CHECKIT      lh = (((top + tlen) > floor) ? floor - top : tlen); */
00276         lh = ((bottom > floor) ? floor - top : tlen);
00277     }
00278     if (lh <= 0 || lw <= 0) return;
00279     if (fill) {
00280         XFillRectangle(XtDisplay((Widget) sbw), XtWindow((Widget) sbw), 
00281                         sbw->scrollbar.gc, 
00282                         lx, ly, (unsigned int) lw, (unsigned int) lh);
00283     } else {
00284         XClearArea (XtDisplay((Widget) sbw), XtWindow((Widget) sbw), 
00285                         lx, ly, (unsigned int) lw, (unsigned int) lh, 
00286                         FALSE);
00287     }
00288 }

Here is the caller graph for this function:

static float FloatInRange ( float  num,
float  small,
float  big 
) [static]

Definition at line 981 of file Scrollbar.c.

Referenced by FractionLoc(), and MoveThumb().

00983 {
00984     return (num < small) ? small : ((num > big) ? big : num);
00985 }

Here is the caller graph for this function:

static float FractionLoc ( ScrollbarWidget  sbw,
int  x,
int  y 
) [static]

Definition at line 1109 of file Scrollbar.c.

References FloatInRange(), height, MARGIN, PICKLENGTH, result, and width.

Referenced by MoveThumb().

01112 {
01113     float   result;
01114     int margin;
01115     float   height, width;
01116 
01117     margin = MARGIN (sbw);
01118     x -= margin;
01119     y -= margin;
01120     height = sbw->core.height - 2 * margin;
01121     width = sbw->core.width - 2 * margin;
01122     result = PICKLENGTH (sbw, x / width, y / height);
01123     return FloatInRange(result, 0.0, 1.0);
01124 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void Initialize ( Widget  request,
Widget  new,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 632 of file Scrollbar.c.

References _ScrollbarRec::core, CreateGC(), ScrollbarPart::length, ScrollbarPart::min_thumb, ScrollbarPart::orientation, _ScrollbarRec::scrollbar, SetDimensions(), ScrollbarPart::shownLength, ScrollbarPart::thickness, ScrollbarPart::topLoc, XtorientHorizontal, and XtorientVertical.

00637 {
00638     ScrollbarWidget sbw = (ScrollbarWidget) new;
00639 
00640     CreateGC (new);
00641 
00642     if (sbw->core.width == 0)
00643         sbw->core.width = (sbw->scrollbar.orientation == XtorientVertical)
00644             ? sbw->scrollbar.thickness : sbw->scrollbar.length;
00645 
00646     if (sbw->core.height == 0)
00647         sbw->core.height = (sbw->scrollbar.orientation == XtorientHorizontal)
00648             ? sbw->scrollbar.thickness : sbw->scrollbar.length;
00649 
00650     SetDimensions (sbw);
00651 #ifdef ARROW_SCROLLBAR
00652     sbw->scrollbar.scroll_mode = 0;
00653     sbw->scrollbar.timer_id = (XtIntervalId)0;
00654 #endif
00655     sbw->scrollbar.topLoc = 0;
00656     sbw->scrollbar.shownLength = sbw->scrollbar.min_thumb;
00657 }

Here is the call graph for this function:

static void Initialize (  )  [static]

Definition at line 26 of file javasci_globals.c.

00027 {
00028   static char env[1024];
00029   static char initstr[]="exec(\"SCI/etc/scilab.start\",-1);quit;";
00030   static int iflag=-1, stacksize = 1000000, ierr=0;
00031 
00032   #ifdef _MSC_VER
00033     static char JavaSciInterf[]="javasci";
00034     static char nw[]="-nw";
00035     static char nb[]="-nb";
00036   #endif
00037 
00038   
00039   char *p1 = (char*)getenv ("SCI");
00040   
00041   
00042   #ifdef _MSC_VER
00043   /* Supprime le mode windows et la baniere */
00044     add_sci_argv(JavaSciInterf);
00045     add_sci_argv(nb);
00046   #endif
00047   
00048   #ifdef _MSC_VER 
00049     if ( p1== NULL )
00050     {
00051                 /* Detection Scilab path */
00052                 char modname[MAX_PATH+1];
00053                 if (!GetModuleFileName (GetModuleHandle("javasci.dll"), modname, MAX_PATH))
00054                 {
00055                         MessageBox(NULL,"javasci.dll not found","Warning",MB_ICONWARNING);
00056                 }
00057                 else
00058                 {
00059                         char *p;
00060                         if ((p = strrchr (modname, '\\')) == NULL) exit(1); /* remove \javasci.dll from modname */
00061                         else
00062                         {
00063                                 *p='\0';
00064                                 if ((p = strrchr (modname, '\\')) == NULL) exit(1); /* remove \bin from modname */
00065                                 else
00066                                 {
00067                                         *p='\0';
00068                                         set_sci_env(modname);
00069                                 }
00070                         }
00071                 }
00072     }
00073     else 
00074         {
00075                 char *pathSCI=(char*)MALLOC((strlen(p1)+1)*sizeof(char));
00076                 sprintf(pathSCI,"%s",p1);
00077                 set_sci_env(pathSCI);
00078                 if (pathSCI) {FREE(pathSCI);pathSCI=NULL;}
00079         }
00080   #else
00081    if (p1==NULL)
00082    {
00083         fprintf(stderr,"Please define SCI environment variable\n");
00084         sprintf (env, "%s=%s", "SCI",SCI);
00085         setSCIpath(SCI);
00086         putenv (env);
00087    }
00088   #endif
00089   /* set TMPDIR */
00090   C2F(settmpdir)();
00091   /* Scilab Initialization */
00092   C2F(inisci)(&iflag,&stacksize,&ierr);
00093   if ( ierr > 0 ) 
00094     {
00095       fprintf(stderr,"Scilab initialization failed !\n");
00096       exit(1);
00097     }
00098 
00099 
00100   /* Initialisation fenetre graphique */
00101   #ifdef _MSC_VER
00102     InitWindowGraphDll();
00103   #endif
00104 
00105   /* pour initialisation de la primitive scilab : fromjava() */
00106   SetFromJavaToON();
00107 
00108   /* Chargement de Scilab.start */
00109   C2F(scirun)(initstr,(int)strlen(initstr));
00110  
00111 }

static int InRange ( int  num,
int  small,
int  big 
) [static]

Definition at line 970 of file Scrollbar.c.

Referenced by NotifyScroll().

00972 {
00973     return (num < small) ? small : ((num > big) ? big : num);
00974 }

Here is the caller graph for this function:

static Boolean LookAhead ( Widget  w,
XEvent *  event 
) [static]

Definition at line 826 of file Scrollbar.c.

References CompareEvents(), EventData::count, EventData::oldEvent, and PeekNotifyEvent().

Referenced by MoveThumb(), NotifyScroll(), and NotifyThumb().

00829 {
00830     XEvent newEvent;
00831     struct EventData eventData;
00832 
00833     if (QLength (XtDisplay (w)) == 0) return False;
00834 
00835     eventData.count = 0;
00836     eventData.oldEvent = event;
00837 
00838     XPeekIfEvent (XtDisplay (w), &newEvent, PeekNotifyEvent, (char*)&eventData);
00839 
00840     return CompareEvents (event, &newEvent);
00841 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void MoveThumb ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
) [static]

Definition at line 1127 of file Scrollbar.c.

References ScrollbarPart::direction, ExtractPosition(), FloatInRange(), FractionLoc(), LookAhead(), PaintThumb(), ScrollbarPart::pick_top, ScrollbarPart::picked, _ScrollbarRec::scrollbar, ScrollbarPart::shown, and ScrollbarPart::top.

01132 {
01133     ScrollbarWidget sbw = (ScrollbarWidget) w;
01134     Position x, y;
01135     float loc, t, s;
01136 
01137 #ifndef ARROW_SCROLLBAR
01138     if (sbw->scrollbar.direction == 0) return; /* if no StartScroll */
01139 #endif
01140 
01141     if (LookAhead (w, event)) return;
01142 
01143     if (!event->xmotion.same_screen) return;
01144 
01145     ExtractPosition (event, &x, &y);
01146     loc = FractionLoc (sbw, x, y);
01147     t = sbw->scrollbar.top;
01148     s = sbw->scrollbar.shown;
01149 #ifdef ARROW_SCROLLBAR
01150     if (sbw->scrollbar.scroll_mode != 2 )
01151       /* initialize picked position */
01152       sbw->scrollbar.picked = (FloatInRange( loc, t, t + s ) - t);
01153 #else
01154     sbw->scrollbar.picked = 0.5 * s;
01155 #endif
01156     if (sbw->scrollbar.pick_top)
01157       sbw->scrollbar.top = loc;
01158     else {
01159       sbw->scrollbar.top = loc - sbw->scrollbar.picked;
01160       if (sbw->scrollbar.top < 0.0) sbw->scrollbar.top = 0.0;
01161     }
01162 
01163     if (sbw->scrollbar.top + sbw->scrollbar.shown > 1.0)
01164       sbw->scrollbar.top = 1.0 - sbw->scrollbar.shown;
01165 #ifdef ARROW_SCROLLBAR
01166     sbw->scrollbar.scroll_mode = 2; /* indicate continuous scroll */
01167 #endif
01168     PaintThumb (sbw, event);
01169     XFlush (XtDisplay (w));     /* re-draw it before Notifying */
01170 }

Here is the call graph for this function:

static void MoveThumb (  )  [static]

static void NotifyScroll ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
) [static]

Definition at line 1038 of file Scrollbar.c.

References ScrollbarPart::direction, ExtractPosition(), InRange(), LookAhead(), PICKLENGTH, _ScrollbarRec::scrollbar, and style.

01041                                         : Proportional|FullLength */
01042     Cardinal *num_params;       /* we only support 1 */
01043 {
01044     ScrollbarWidget sbw = (ScrollbarWidget) w;
01045     int call_data;
01046     char style;
01047     Position x, y;
01048 
01049     if (sbw->scrollbar.direction == 0) return; /* if no StartScroll */
01050     if (LookAhead (w, event)) return;
01051     if (*num_params > 0) 
01052         style = *params[0];
01053     else
01054         style = 'P';
01055 
01056     switch (style) {
01057     case 'P':    /* Proportional */
01058     case 'p':
01059         ExtractPosition (event, &x, &y);
01060         call_data = 
01061             InRange (PICKLENGTH (sbw, x, y), 0, (int) sbw->scrollbar.length); 
01062         break;
01063 
01064     case 'F':    /* FullLength */
01065     case 'f':    
01066         call_data = sbw->scrollbar.length; 
01067         break;
01068     }
01069     switch (sbw->scrollbar.direction) {
01070     case 'B':
01071     case 'b':    
01072         call_data = -call_data;
01073         /* fall through */
01074 
01075     case 'F':
01076     case 'f':    
01077         XtCallCallbacks (w, XtNscrollProc, (XtPointer)call_data);
01078         break;
01079 
01080     case 'C':
01081     case 'c':
01082         /* NotifyThumb has already called the thumbProc(s) */
01083         break;
01084     }
01085 }

Here is the call graph for this function:

static void NotifyScroll (  )  [static]

static void NotifyThumb ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
) [static]

Definition at line 1174 of file Scrollbar.c.

References ScrollbarPart::direction, LookAhead(), _ScrollbarRec::scrollbar, and ScrollbarPart::top.

01179 {
01180     register ScrollbarWidget sbw = (ScrollbarWidget) w;
01181     float top = sbw->scrollbar.top;
01182 
01183 #ifndef ARROW_SCROLLBAR
01184     if (sbw->scrollbar.direction == 0) return; /* if no StartScroll */
01185 #endif
01186 
01187     if (LookAhead (w, event)) return;
01188 
01189     /* thumbProc is not pretty, but is necessary for backwards
01190        compatibility on those architectures for which it work{s,ed};
01191        the intent is to pass a (truncated) float by value. */
01192 #ifdef ARROW_SCROLLBAR
01193     /* This corrects for rounding errors: If the thumb is moved to the end of
01194        the scrollable area sometimes the last line/column is not displayed.
01195        This can happen when the integer number of the top line or leftmost
01196        column to be be displayed is calculated from the float value
01197        sbw->scrollbar.top. The numerical error of this rounding problem is
01198        very small. We therefore add a small value which then forces the
01199        next line/column (the correct one) to be used. Since we can expect
01200        that the resolution of display screens will not be higher then
01201        10000 text lines/columns we add 1/10000 to the top position. The
01202        intermediate variable `top' is used to avoid erroneous summing up
01203        corrections (can this happen at all?). If the arrows are not displayed
01204        there is no problem since in this case there is always a constant
01205        integer number of pixels the thumb must be moved in order to scroll
01206        to the next line/column. */
01207     top += 0.0001;
01208 #endif
01209     XtCallCallbacks (w, XtNthumbProc, *(XtPointer*)&top);
01210     XtCallCallbacks (w, XtNjumpProc, (XtPointer)&top);
01211 }

Here is the call graph for this function:

static void NotifyThumb (  )  [static]

static void PaintThumb ( ScrollbarWidget  sbw,
XEvent *  event 
) [static]

Definition at line 387 of file Scrollbar.c.

References _ShadowSurroundedBox(), FillArea(), int, MARGIN, MAX, MIN, s, TRUE, and XtorientHorizontal.

Referenced by MoveThumb(), Redisplay(), and XawScrollbarSetThumb().

00390 {
00391     Dimension s                   = sbw->threeD.shadow_width;
00392     Position  oldtop              = sbw->scrollbar.topLoc;
00393     Position  oldbot              = oldtop + sbw->scrollbar.shownLength;
00394     Dimension margin              = MARGIN (sbw);
00395     Dimension tzl                 = sbw->scrollbar.length - margin - margin;
00396     Position newtop, newbot;    
00397     Position  floor               = sbw->scrollbar.length - margin;
00398 
00399     newtop = margin + (int)(tzl * sbw->scrollbar.top);
00400     newbot = newtop + (int)(tzl * sbw->scrollbar.shown);
00401     if (sbw->scrollbar.shown < 1.) newbot++;
00402     if (newbot < newtop + (int)sbw->scrollbar.min_thumb +
00403                         2 * (int)sbw->threeD.shadow_width) 
00404       newbot = newtop + sbw->scrollbar.min_thumb +
00405                         2 * sbw->threeD.shadow_width;
00406     if ( newbot >= floor ) {
00407         newtop = floor-(newbot-newtop)+1;
00408         newbot = floor;
00409     }
00410 
00411     sbw->scrollbar.topLoc = newtop;
00412     sbw->scrollbar.shownLength = newbot - newtop;
00413     if (XtIsRealized ((Widget) sbw)) {
00414       /*  3D thumb wanted ?
00415        */
00416       if (s) 
00417           {
00418           if (newtop < oldtop) FillArea(sbw, oldtop, oldtop + s, 0);
00419           if (newtop > oldtop) FillArea(sbw, oldtop, MIN(newtop, oldbot), 0);
00420           if (newbot < oldbot) FillArea(sbw, MAX(newbot, oldtop), oldbot, 0);
00421           if (newbot > oldbot) FillArea(sbw, oldbot - s, oldbot, 0);
00422 
00423           if (sbw->scrollbar.orientation == XtorientHorizontal) 
00424               {
00425               _ShadowSurroundedBox(
00426                   sbw, event,
00427                   (Region)NULL,
00428                   newtop + s, 2 * s,
00429                   newbot - s, sbw->core.height - 2 * s, TRUE);
00430               }
00431           else 
00432               {
00433               _ShadowSurroundedBox(
00434                   sbw, event,
00435                   (Region)NULL,
00436                   2 * s, newtop + s,
00437                   sbw->core.width - 2 * s, newbot - s,
00438                   TRUE);
00439               }
00440           }
00441       else 
00442           {
00443           /* 
00444             Note to Mitch: FillArea is (now) correctly implemented to 
00445             not draw over shadows or the arrows. Therefore setting clipmasks 
00446             doesn't seem to be necessary.  Correct me if I'm wrong!
00447           */
00448           if (newtop < oldtop) FillArea(sbw, newtop, MIN(newbot, oldtop), 1);
00449           if (newtop > oldtop) FillArea(sbw, oldtop, MIN(newtop, oldbot), 0);
00450           if (newbot < oldbot) FillArea(sbw, MAX(newbot, oldtop), oldbot, 0);
00451           if (newbot > oldbot) FillArea(sbw, MAX(newtop, oldbot), newbot, 1);
00452           }
00453     }
00454 }

Here is the call graph for this function:

Here is the caller graph for this function:

static Bool PeekNotifyEvent ( Display *  dpy,
XEvent *  event,
char *  args 
) [static]

Definition at line 814 of file Scrollbar.c.

References CompareEvents(), EventData::count, and EventData::oldEvent.

Referenced by LookAhead().

00818 {
00819     struct EventData *eventData = (struct EventData*)args;
00820 
00821     return ((++eventData->count == QLength(dpy)) /* since PeekIf blocks */
00822             || CompareEvents(event, eventData->oldEvent));
00823 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void Realize ( Widget  w,
Mask *  valueMask,
XSetWindowAttributes *  attributes 
) [static]

Definition at line 659 of file Scrollbar.c.

References SimplePart::cursor_name, ScrollbarPart::horCursor, ScrollbarPart::inactiveCursor, ScrollbarPart::orientation, _ScrollbarRec::scrollbar, _ScrollbarRec::simple, ScrollbarPart::verCursor, XtNcursor, XtNcursorName, and XtorientVertical.

00663 {
00664     ScrollbarWidget sbw = (ScrollbarWidget) w;
00665 #ifdef ARROW_SCROLLBAR
00666     if(sbw->simple.cursor_name == NULL)
00667         XtVaSetValues(w, XtNcursorName, "crosshair", NULL);
00668     /* dont set the cursor of the window to anything */
00669     *valueMask &= ~CWCursor;
00670 #else
00671     sbw->scrollbar.inactiveCursor =
00672       (sbw->scrollbar.orientation == XtorientVertical)
00673         ? sbw->scrollbar.verCursor
00674         : sbw->scrollbar.horCursor;
00675 
00676     XtVaSetValues (w, XtNcursor, sbw->scrollbar.inactiveCursor, NULL);
00677 #endif
00678     /* 
00679      * The Simple widget actually stuffs the value in the valuemask. 
00680      */
00681     
00682     (*scrollbarWidgetClass->core_class.superclass->core_class.realize)
00683         (w, valueMask, attributes);
00684 }

static void Realize (  )  [static]

static void Redisplay ( Widget  w,
XEvent *  event,
Region  region 
) [static]

Definition at line 737 of file Scrollbar.c.

References _ScrollbarRec::core, FALSE, height, ScrollbarPart::length, ScrollbarPart::orientation, PaintThumb(), _ScrollbarRec::scrollbar, ThreeDClassPart::shadowdraw, ScrollbarPart::shownLength, _ScrollbarClassRec::threeD_class, ScrollbarPart::topLoc, width, x, XtorientHorizontal, and y.

00741 {
00742     ScrollbarWidget sbw = (ScrollbarWidget) w;
00743     ScrollbarWidgetClass swclass = (ScrollbarWidgetClass) XtClass (w);
00744     int x, y;
00745     unsigned int width, height;
00746 
00747     (*swclass->threeD_class.shadowdraw) (w, event, region, FALSE);
00748 
00749     if (sbw->scrollbar.orientation == XtorientHorizontal) {
00750         x = sbw->scrollbar.topLoc;
00751         y = 1;
00752         width = sbw->scrollbar.shownLength;
00753         height = sbw->core.height - 2;
00754     } else {
00755         x = 1;
00756         y = sbw->scrollbar.topLoc;
00757         width = sbw->core.width - 2;
00758         height = sbw->scrollbar.shownLength;
00759     }
00760     if (region == NULL ||
00761         XRectInRegion (region, x, y, width, height) != RectangleOut) {
00762         /* Forces entire thumb to be painted. */
00763         sbw->scrollbar.topLoc = -(sbw->scrollbar.length + 1);
00764         PaintThumb (sbw, event); 
00765     }
00766 #ifdef ARROW_SCROLLBAR
00767     /* we'd like to be region aware here!!!! */
00768     PaintArrows (sbw);
00769 #endif
00770 
00771 }

Here is the call graph for this function:

static void Redisplay (  )  [static]

static void Resize ( Widget  w  )  [static]

Definition at line 726 of file Scrollbar.c.

References Redisplay(), SetDimensions(), and w.

00728 {
00729     /* ForgetGravity has taken care of background, but thumb may
00730      * have to move as a result of the new size. */
00731     SetDimensions ((ScrollbarWidget) w);
00732     Redisplay (w, (XEvent*) NULL, (Region)NULL);
00733 }

Here is the call graph for this function:

static void Resize (  )  [static]

static void SetDimensions ( ScrollbarWidget  sbw  )  [static]

Definition at line 619 of file Scrollbar.c.

References XtorientVertical.

Referenced by Initialize(), and Resize().

00621 {
00622     if (sbw->scrollbar.orientation == XtorientVertical) {
00623         sbw->scrollbar.length = sbw->core.height;
00624         sbw->scrollbar.thickness = sbw->core.width;
00625     } else {
00626         sbw->scrollbar.length = sbw->core.width;
00627         sbw->scrollbar.thickness = sbw->core.height;
00628     }
00629 }

Here is the caller graph for this function:

static Boolean SetValues ( Widget  current,
Widget  request,
Widget  desired,
ArgList  args,
Cardinal *  num_args 
) [static]

Definition at line 687 of file Scrollbar.c.

References _ScrollbarRec::core, CreateGC(), FALSE, ScrollbarPart::foreground, ScrollbarPart::gc, _ScrollbarRec::scrollbar, ScrollbarPart::shown, ScrollbarPart::thumb, ScrollbarPart::top, and TRUE.

00693 {
00694     ScrollbarWidget sbw = (ScrollbarWidget) current;
00695     ScrollbarWidget dsbw = (ScrollbarWidget) desired;
00696     Boolean redraw = FALSE;
00697 
00698 /*
00699  * If these values are outside the acceptable range ignore them...
00700  */
00701 
00702     if (dsbw->scrollbar.top < 0.0 || dsbw->scrollbar.top > 1.0)
00703         dsbw->scrollbar.top = sbw->scrollbar.top;
00704 
00705     if (dsbw->scrollbar.shown < 0.0 || dsbw->scrollbar.shown > 1.0)
00706         dsbw->scrollbar.shown = sbw->scrollbar.shown;
00707 
00708 /*
00709  * Change colors and stuff...
00710  */
00711     if (XtIsRealized (desired)) {
00712         if (sbw->scrollbar.foreground != dsbw->scrollbar.foreground ||
00713             sbw->core.background_pixel != dsbw->core.background_pixel ||
00714             sbw->scrollbar.thumb != dsbw->scrollbar.thumb) {
00715             XtReleaseGC (desired, sbw->scrollbar.gc);
00716             CreateGC (desired);
00717             redraw = TRUE;
00718         }
00719         if (sbw->scrollbar.top != dsbw->scrollbar.top ||
00720             sbw->scrollbar.shown != dsbw->scrollbar.shown)
00721             redraw = TRUE;
00722     }
00723     return redraw;
00724 }

Here is the call graph for this function:

static Boolean SetValues (  )  [static]

static void StartScroll ( Widget  w,
XEvent *  event,
String *  params,
Cardinal *  num_params 
) [static]

Definition at line 919 of file Scrollbar.c.

References ScrollbarPart::direction, ScrollbarPart::downCursor, ScrollbarPart::leftCursor, ScrollbarPart::orientation, ScrollbarPart::rightCursor, _ScrollbarRec::scrollbar, ScrollbarPart::upCursor, XtNcursor, and XtorientVertical.

00922                                             : Back|Forward|Smooth */
00923     Cardinal *num_params;       /* we only support 1 */
00924 {
00925     ScrollbarWidget sbw = (ScrollbarWidget) w;
00926     Cursor cursor;
00927     char direction;
00928 
00929     if (sbw->scrollbar.direction != 0) return; /* if we're already scrolling */
00930     if (*num_params > 0) 
00931         direction = *params[0];
00932     else
00933         direction = 'C';
00934 
00935     sbw->scrollbar.direction = direction;
00936 
00937     switch (direction) {
00938     case 'B':
00939     case 'b':   
00940         cursor = (sbw->scrollbar.orientation == XtorientVertical)
00941                         ? sbw->scrollbar.downCursor
00942                         : sbw->scrollbar.rightCursor; 
00943         break;
00944     case 'F':
00945     case 'f':
00946         cursor = (sbw->scrollbar.orientation == XtorientVertical)
00947                         ? sbw->scrollbar.upCursor
00948                         : sbw->scrollbar.leftCursor; 
00949         break;
00950     case 'C':
00951     case 'c':
00952         cursor = (sbw->scrollbar.orientation == XtorientVertical)
00953                         ? sbw->scrollbar.rightCursor
00954                         : sbw->scrollbar.upCursor; 
00955         break;
00956     default:    
00957         return; /* invalid invocation */
00958     }
00959     XtVaSetValues (w, XtNcursor, cursor, NULL);
00960     XFlush (XtDisplay (w));
00961 }

static void StartScroll (  )  [static]

void XawScrollbarSetThumb ( Widget  w,
float  top,
float  shown 
)

Definition at line 1231 of file Scrollbar.c.

References ScrollbarPart::direction, PaintThumb(), _ScrollbarRec::scrollbar, ScrollbarPart::shown, and ScrollbarPart::top.

Referenced by _XawTextSetScrollBars(), CheckVBarScrolling(), ScrollBarDrawThumb(), and SetBar().

01235 {
01236     ScrollbarWidget sbw = (ScrollbarWidget) w;
01237 
01238 #ifdef WIERD
01239     fprintf(stderr,"< XawScrollbarSetThumb w=%p, top=%f, shown=%f\n", 
01240             w,top,shown);
01241 #endif
01242 
01243 #ifdef ARROW_SCROLLBAR
01244     if (sbw->scrollbar.scroll_mode == (char) 2) return; /* if still thumbing */
01245 #else
01246     if (sbw->scrollbar.direction == 'c') return; /* if still thumbing */
01247 #endif
01248 
01249     sbw->scrollbar.top = (top > 1.0) ? 1.0 :
01250                                 (top >= 0.0) ? top : sbw->scrollbar.top;
01251 
01252     sbw->scrollbar.shown = (shown > 1.0) ? 1.0 :
01253                                 (shown >= 0.0) ? shown : sbw->scrollbar.shown;
01254 
01255     PaintThumb (sbw);
01256 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

XtActionsRec actions[] [static]

Initial value:

 {



    {"StartScroll",     StartScroll},

    {"MoveThumb",       MoveThumb},
    {"NotifyThumb",     NotifyThumb},
    {"NotifyScroll",    NotifyScroll},
    {"EndScroll",       EndScroll}
}

Definition at line 160 of file Scrollbar.c.

char defaultTranslations[] [static]

Initial value:

    "<Btn1Down>:   StartScroll(Forward) \n\
     <Btn2Down>:   StartScroll(Continuous) MoveThumb() NotifyThumb() \n\
     <Btn3Down>:   StartScroll(Backward) \n\
     <Btn2Motion>: MoveThumb() NotifyThumb() \n\
     <BtnUp>:      NotifyScroll(Proportional) EndScroll()"

Definition at line 80 of file Scrollbar.c.

float floatZero = 0.0 [static]

Definition at line 93 of file Scrollbar.c.

XtResource resources[] [static]

Definition at line 97 of file Scrollbar.c.

ScrollbarClassRec scrollbarClassRec

Definition at line 173 of file Scrollbar.c.

WidgetClass scrollbarWidgetClass = (WidgetClass)&scrollbarClassRec

Definition at line 221 of file Scrollbar.c.


Generated on Sun Mar 4 16:01:45 2007 for Scilab [trunk] by  doxygen 1.5.1