rust/cargo-c: update to 0.10.7+cargo-0.84.0
[oi-userland.git] / components / x11 / libXaw4 / src / Xaw3_1Scrollbar.c
blob3f78a2ff9ba19ec04b50bd3f36dac75b915e525d
1 #ifndef lint
2 static char Xrcsid[] =
3 "$XConsortium: Scrollbar.c,v 1.58 89/12/15 11:36:58 kit Exp $";
4 #endif /* lint */
6 /***********************************************************
7 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
8 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
10 All Rights Reserved
12 Permission to use, copy, modify, and distribute this software and its
13 documentation for any purpose and without fee is hereby granted,
14 provided that the above copyright notice appear in all copies and that
15 both that copyright notice and this permission notice appear in
16 supporting documentation, and that the names of Digital or MIT not be
17 used in advertising or publicity pertaining to distribution of the
18 software without specific, written prior permission.
20 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
21 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
22 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
23 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
24 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
26 SOFTWARE.
28 ******************************************************************/
30 /* ScrollBar.c */
31 /* created by weissman, Mon Jul 7 13:20:03 1986 */
32 /* converted by swick, Thu Aug 27 1987 */
34 #include <X11/IntrinsicP.h>
35 #include <X11/StringDefs.h>
37 #include <./Xaw3_1XawInit.h>
38 #include <./Xaw3_1ScrollbarP.h>
40 #include <X11/Xmu/Drawing.h> /* for XmuCreateStippledPixmap */
42 /* Private definitions. */
44 static char defaultTranslations[] =
45 "<Btn1Down>: StartScroll(Forward) \n\
46 <Btn2Down>: StartScroll(Continuous) MoveThumb() NotifyThumb() \n\
47 <Btn3Down>: StartScroll(Backward) \n\
48 <Btn2Motion>: MoveThumb() NotifyThumb() \n\
49 <BtnUp>: NotifyScroll(Proportional) EndScroll()";
51 #ifdef bogusScrollKeys
52 /* examples */
53 "<KeyPress>f: StartScroll(Forward) NotifyScroll(FullLength) EndScroll()"
54 "<KeyPress>b: StartScroll(Backward) NotifyScroll(FullLength) EndScroll()"
55 #endif
57 static float floatZero = 0.0;
59 #define Offset(field) XtOffset(ScrollbarWidget, field)
61 static XtResource resources[] = {
62 {XtNlength, XtCLength, XtRDimension, sizeof(Dimension),
63 Offset(scrollbar.length), XtRImmediate, (caddr_t) 1},
64 {XtNthickness, XtCThickness, XtRDimension, sizeof(Dimension),
65 Offset(scrollbar.thickness), XtRImmediate, (caddr_t) 14},
66 {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation),
67 Offset(scrollbar.orientation), XtRImmediate, (caddr_t) XtorientVertical},
68 {XtNscrollProc, XtCCallback, XtRCallback, sizeof(caddr_t),
69 Offset(scrollbar.scrollProc), XtRCallback, NULL},
70 {XtNthumbProc, XtCCallback, XtRCallback, sizeof(caddr_t),
71 Offset(scrollbar.thumbProc), XtRCallback, NULL},
72 {XtNjumpProc, XtCCallback, XtRCallback, sizeof(caddr_t),
73 Offset(scrollbar.jumpProc), XtRCallback, NULL},
74 {XtNthumb, XtCThumb, XtRPixmap, sizeof(Pixmap),
75 Offset(scrollbar.thumb), XtRImmediate, (XtPointer) XtUnspecifiedPixmap},
76 {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
77 Offset(scrollbar.foreground), XtRString, XtDefaultForeground},
78 {XtNshown, XtCShown, XtRFloat, sizeof(float),
79 Offset(scrollbar.shown), XtRFloat, (caddr_t)&floatZero},
80 {XtNtopOfThumb, XtCTopOfThumb, XtRFloat, sizeof(float),
81 Offset(scrollbar.top), XtRFloat, (caddr_t)&floatZero},
82 {XtNscrollVCursor, XtCCursor, XtRCursor, sizeof(Cursor),
83 Offset(scrollbar.verCursor), XtRString, "sb_v_double_arrow"},
84 {XtNscrollHCursor, XtCCursor, XtRCursor, sizeof(Cursor),
85 Offset(scrollbar.horCursor), XtRString, "sb_h_double_arrow"},
86 {XtNscrollUCursor, XtCCursor, XtRCursor, sizeof(Cursor),
87 Offset(scrollbar.upCursor), XtRString, "sb_up_arrow"},
88 {XtNscrollDCursor, XtCCursor, XtRCursor, sizeof(Cursor),
89 Offset(scrollbar.downCursor), XtRString, "sb_down_arrow"},
90 {XtNscrollLCursor, XtCCursor, XtRCursor, sizeof(Cursor),
91 Offset(scrollbar.leftCursor), XtRString, "sb_left_arrow"},
92 {XtNscrollRCursor, XtCCursor, XtRCursor, sizeof(Cursor),
93 Offset(scrollbar.rightCursor), XtRString, "sb_right_arrow"},
94 {XtNminimumThumb, XtCMinimumThumb, XtRDimension, sizeof(Dimension),
95 Offset(scrollbar.min_thumb), XtRImmediate, (caddr_t) 7},
98 static void ClassInitialize();
99 static void Initialize();
100 static void Destroy();
101 static void Realize();
102 static void Resize();
103 static void Redisplay();
104 static Boolean SetValues();
106 static void StartScroll();
107 static void MoveThumb();
108 static void NotifyThumb();
109 static void NotifyScroll();
110 static void EndScroll();
112 static XtActionsRec actions[] = {
113 {"StartScroll", StartScroll},
114 {"MoveThumb", MoveThumb},
115 {"NotifyThumb", NotifyThumb},
116 {"NotifyScroll", NotifyScroll},
117 {"EndScroll", EndScroll},
118 {NULL,NULL}
122 ScrollbarClassRec scrollbarClassRec = {
123 /* core fields */
124 /* superclass */ (WidgetClass) &widgetClassRec,
125 /* class_name */ "Scrollbar",
126 /* size */ sizeof(ScrollbarRec),
127 /* class_initialize */ ClassInitialize,
128 /* class_part_init */ NULL,
129 /* class_inited */ FALSE,
130 /* initialize */ Initialize,
131 /* initialize_hook */ NULL,
132 /* realize */ Realize,
133 /* actions */ actions,
134 /* num_actions */ XtNumber(actions),
135 /* resources */ resources,
136 /* num_resources */ XtNumber(resources),
137 /* xrm_class */ NULLQUARK,
138 /* compress_motion */ TRUE,
139 /* compress_exposure*/ TRUE,
140 /* compress_enterleave*/ TRUE,
141 /* visible_interest */ FALSE,
142 /* destroy */ Destroy,
143 /* resize */ Resize,
144 /* expose */ Redisplay,
145 /* set_values */ SetValues,
146 /* set_values_hook */ NULL,
147 /* set_values_almost */ XtInheritSetValuesAlmost,
148 /* get_values_hook */ NULL,
149 /* accept_focus */ NULL,
150 /* version */ XtVersion,
151 /* callback_private */ NULL,
152 /* tm_table */ defaultTranslations,
153 /* query_geometry */ XtInheritQueryGeometry,
154 /* display_accelerator*/ XtInheritDisplayAccelerator,
155 /* extension */ NULL
158 WidgetClass scrollbarWidgetClass = (WidgetClass)&scrollbarClassRec;
160 #define NoButton -1
161 #define PICKLENGTH(widget, x, y) \
162 ((widget->scrollbar.orientation == XtorientHorizontal) ? x : y)
163 #define MIN(x,y) ((x) < (y) ? (x) : (y))
164 #define MAX(x,y) ((x) > (y) ? (x) : (y))
166 static void ClassInitialize()
168 static XtConvertArgRec screenConvertArg[] = {
169 {XtWidgetBaseOffset, (caddr_t) XtOffset(Widget, core.screen),
170 sizeof(Screen *)}
173 XawInitializeWidgetSet();
174 XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation,
175 NULL, (Cardinal)0 );
176 XtAddConverter( XtRString, XtRPixmap, XmuCvtStringToBitmap,
177 screenConvertArg, XtNumber(screenConvertArg));
181 * Make sure the first number is within the range specified by the other
182 * two numbers.
185 static int InRange(num, small, big)
186 int num, small, big;
188 return (num < small) ? small : ((num > big) ? big : num);
192 * Same as above, but for floating numbers.
195 static float FloatInRange(num, small, big)
196 float num, small, big;
198 return (num < small) ? small : ((num > big) ? big : num);
202 /* Fill the area specified by top and bottom with the given pattern. */
203 static float FractionLoc(w, x, y)
204 ScrollbarWidget w;
205 int x, y;
207 float result;
209 result = PICKLENGTH(w, (float) x/w->core.width,
210 (float) y/w->core.height);
211 return FloatInRange(result, 0.0, 1.0);
215 static void FillArea(w, top, bottom, thumb)
216 ScrollbarWidget w;
217 Position top, bottom;
218 int thumb;
220 Dimension length = bottom-top;
222 if (bottom < 0) return;
224 switch(thumb) {
225 /* Fill the new Thumb location */
226 case 1:
227 if (w->scrollbar.orientation == XtorientHorizontal)
228 XFillRectangle(XtDisplay(w), XtWindow(w),
229 w->scrollbar.gc, top, 1, length,
230 w->core.height-2);
232 else XFillRectangle(XtDisplay(w), XtWindow(w), w->scrollbar.gc,
233 1, top, w->core.width-2, length);
235 break;
236 /* Clear the old Thumb location */
237 case 0:
238 if (w->scrollbar.orientation == XtorientHorizontal)
239 XClearArea(XtDisplay(w), XtWindow(w), top, 1,
240 length, w->core.height-2, FALSE);
242 else XClearArea(XtDisplay(w), XtWindow(w), 1,
243 top, w->core.width-2, length, FALSE);
249 /* Paint the thumb in the area specified by w->top and
250 w->shown. The old area is erased. The painting and
251 erasing is done cleverly so that no flickering will occur. */
253 static void PaintThumb( w )
254 ScrollbarWidget w;
256 Position oldtop, oldbot, newtop, newbot;
258 oldtop = w->scrollbar.topLoc;
259 oldbot = oldtop + w->scrollbar.shownLength;
260 newtop = w->scrollbar.length * w->scrollbar.top;
261 newbot = newtop + (int)(w->scrollbar.length * w->scrollbar.shown);
262 if (newbot < newtop + w->scrollbar.min_thumb)
263 newbot = newtop + w->scrollbar.min_thumb;
264 w->scrollbar.topLoc = newtop;
265 w->scrollbar.shownLength = newbot - newtop;
267 if (XtIsRealized((Widget)w)) {
268 if (newtop < oldtop) FillArea(w, newtop, MIN(newbot, oldtop), 1);
269 if (newtop > oldtop) FillArea(w, oldtop, MIN(newtop, oldbot), 0);
270 if (newbot < oldbot) FillArea(w, MAX(newbot, oldtop), oldbot, 0);
271 if (newbot > oldbot) FillArea(w, MAX(newtop, oldbot), newbot, 1);
276 static void SetDimensions(w)
277 ScrollbarWidget w;
279 if (w->scrollbar.orientation == XtorientVertical) {
280 w->scrollbar.length = w->core.height;
281 w->scrollbar.thickness = w->core.width;
283 else {
284 w->scrollbar.length = w->core.width;
285 w->scrollbar.thickness = w->core.height;
289 /* Function Name: Destroy
290 * Description: Called as the scrollbar is going away...
291 * Arguments: w - the scrollbar.
292 * Returns: nonw
295 static void
296 Destroy(w)
297 Widget w;
299 ScrollbarWidget sbw = (ScrollbarWidget) w;
301 XtReleaseGC(w, sbw->scrollbar.gc);
304 /* Function Name: CreateGC
305 * Description: Creates the GC.
306 * Arguments: w - the scrollbar widget.
307 * Returns: none.
310 static void
311 CreateGC(w)
312 Widget w;
314 ScrollbarWidget sbw = (ScrollbarWidget) w;
315 XGCValues gcValues;
316 XtGCMask mask;
317 unsigned int depth = 1;
319 if (sbw->scrollbar.thumb == XtUnspecifiedPixmap) {
320 sbw->scrollbar.thumb = XmuCreateStippledPixmap (XtScreen(w),
321 (Pixel) 1, (Pixel) 0,
322 depth);
324 else if (sbw->scrollbar.thumb != None) {
325 Window root;
326 int x, y;
327 unsigned int width, height, bw;
328 if (XGetGeometry(XtDisplay(w), sbw->scrollbar.thumb, &root, &x, &y,
329 &width, &height, &bw, &depth) == 0) {
330 XtAppError(XtWidgetToApplicationContext(w),
331 "Scrollbar Widget: Could not get geometry of thumb pixmap.");
335 gcValues.foreground = sbw->scrollbar.foreground;
336 gcValues.background = sbw->core.background_pixel;
337 mask = GCForeground | GCBackground;
339 if (sbw->scrollbar.thumb != None) {
340 if (depth == 1) {
341 gcValues.fill_style = FillOpaqueStippled;
342 gcValues.stipple = sbw->scrollbar.thumb;
343 mask |= GCFillStyle | GCStipple;
345 else {
346 gcValues.fill_style = FillTiled;
347 gcValues.tile = sbw->scrollbar.thumb;
348 mask |= GCFillStyle | GCTile;
351 sbw->scrollbar.gc = XtGetGC( w, mask, &gcValues);
354 /* ARGSUSED */
355 static void Initialize( request, new )
356 Widget request; /* what the client asked for */
357 Widget new; /* what we're going to give him */
359 ScrollbarWidget w = (ScrollbarWidget) new;
361 CreateGC(new);
363 if (w->core.width == 0)
364 w->core.width = (w->scrollbar.orientation == XtorientVertical)
365 ? w->scrollbar.thickness : w->scrollbar.length;
367 if (w->core.height == 0)
368 w->core.height = (w->scrollbar.orientation == XtorientHorizontal)
369 ? w->scrollbar.thickness : w->scrollbar.length;
371 SetDimensions( w );
372 w->scrollbar.direction = 0;
373 w->scrollbar.topLoc = 0;
374 w->scrollbar.shownLength = w->scrollbar.min_thumb;
377 static void Realize( gw, valueMask, attributes )
378 Widget gw;
379 Mask *valueMask;
380 XSetWindowAttributes *attributes;
382 ScrollbarWidget w = (ScrollbarWidget) gw;
384 w->scrollbar.inactiveCursor =
385 (w->scrollbar.orientation == XtorientVertical)
386 ? w->scrollbar.verCursor
387 : w->scrollbar.horCursor;
389 attributes->cursor = w->scrollbar.inactiveCursor;
390 *valueMask |= CWCursor;
392 XtCreateWindow( gw, InputOutput, (Visual *)CopyFromParent,
393 *valueMask, attributes );
396 /* ARGSUSED */
397 static Boolean
398 SetValues( current, request, desired )
399 Widget current, /* what I am */
400 request, /* what he wants me to be */
401 desired; /* what I will become */
403 ScrollbarWidget w = (ScrollbarWidget) current;
404 ScrollbarWidget dw = (ScrollbarWidget) desired;
405 Boolean redraw = FALSE;
408 * If these values are outside the acceptable range ignore them...
411 if (dw->scrollbar.top < 0.0 || dw->scrollbar.top > 1.0)
412 dw->scrollbar.top = w->scrollbar.top;
414 if (dw->scrollbar.shown < 0.0 || dw->scrollbar.shown > 1.0)
415 dw->scrollbar.shown = w->scrollbar.shown;
418 * Change colors and stuff...
421 if ( XtIsRealized (desired) ) {
422 if ( (w->scrollbar.foreground != dw->scrollbar.foreground) ||
423 (w->core.background_pixel != dw->core.background_pixel) ||
424 (w->scrollbar.thumb != dw->scrollbar.thumb) )
426 XtReleaseGC((Widget)w, w->scrollbar.gc);
427 CreateGC( (Widget) dw);
428 redraw = TRUE;
430 if (w->scrollbar.top != dw->scrollbar.top ||
431 w->scrollbar.shown != dw->scrollbar.shown)
432 redraw = TRUE;
435 return( redraw );
438 static void Resize( gw )
439 Widget gw;
441 /* ForgetGravity has taken care of background, but thumb may
442 * have to move as a result of the new size. */
443 SetDimensions( (ScrollbarWidget)gw );
444 Redisplay( gw, (XEvent*)NULL, (Region)NULL );
448 /* ARGSUSED */
449 static void Redisplay( gw, event, region )
450 Widget gw;
451 XEvent *event;
452 Region region;
454 ScrollbarWidget w = (ScrollbarWidget) gw;
455 int x, y;
456 unsigned int width, height;
458 if (w->scrollbar.orientation == XtorientHorizontal) {
459 x = w->scrollbar.topLoc;
460 y = 1;
461 width = w->scrollbar.shownLength;
462 height = w->core.height - 2;
463 } else {
464 x = 1;
465 y = w->scrollbar.topLoc;
466 width = w->core.width - 2;
467 height = w->scrollbar.shownLength;
470 if ( (region == NULL) ||
471 (XRectInRegion(region, x, y, width, height) != RectangleOut) ) {
472 /* Forces entire thumb to be painted. */
473 w->scrollbar.topLoc = -(w->scrollbar.length + 1);
474 PaintThumb( w );
479 /* ARGSUSED */
480 static void StartScroll( gw, event, params, num_params )
481 Widget gw;
482 XEvent *event;
483 String *params; /* direction: Back|Forward|Smooth */
484 Cardinal *num_params; /* we only support 1 */
486 ScrollbarWidget w = (ScrollbarWidget) gw;
487 Cursor cursor;
488 char direction;
490 if (w->scrollbar.direction != 0) return; /* if we're already scrolling */
491 if (*num_params > 0) direction = *params[0];
492 else direction = 'C';
494 w->scrollbar.direction = direction;
496 switch( direction ) {
497 case 'B':
498 case 'b': cursor = (w->scrollbar.orientation == XtorientVertical)
499 ? w->scrollbar.downCursor
500 : w->scrollbar.rightCursor; break;
502 case 'F':
503 case 'f': cursor = (w->scrollbar.orientation == XtorientVertical)
504 ? w->scrollbar.upCursor
505 : w->scrollbar.leftCursor; break;
507 case 'C':
508 case 'c': cursor = (w->scrollbar.orientation == XtorientVertical)
509 ? w->scrollbar.rightCursor
510 : w->scrollbar.upCursor; break;
512 default: return; /* invalid invocation */
515 XDefineCursor(XtDisplay(w), XtWindow(w), cursor);
517 XFlush(XtDisplay(w));
521 static Boolean CompareEvents( oldEvent, newEvent )
522 XEvent *oldEvent, *newEvent;
524 #define Check(field) if (newEvent->field != oldEvent->field) return False;
526 Check(xany.display);
527 Check(xany.type);
528 Check(xany.window);
530 switch( newEvent->type ) {
531 case MotionNotify:
532 Check(xmotion.state); break;
533 case ButtonPress:
534 case ButtonRelease:
535 Check(xbutton.state);
536 Check(xbutton.button); break;
537 case KeyPress:
538 case KeyRelease:
539 Check(xkey.state);
540 Check(xkey.keycode); break;
541 case EnterNotify:
542 case LeaveNotify:
543 Check(xcrossing.mode);
544 Check(xcrossing.detail);
545 Check(xcrossing.state); break;
547 #undef Check
549 return True;
552 struct EventData {
553 XEvent *oldEvent;
554 int count;
557 static Bool PeekNotifyEvent( dpy, event, args )
558 Display *dpy;
559 XEvent *event;
560 char *args;
562 struct EventData *eventData = (struct EventData*)args;
564 return ((++eventData->count == QLength(dpy)) /* since PeekIf blocks */
565 || CompareEvents(event, eventData->oldEvent));
569 static Boolean LookAhead( w, event )
570 Widget w;
571 XEvent *event;
573 XEvent newEvent;
574 struct EventData eventData;
576 if (QLength(XtDisplay(w)) == 0) return False;
578 eventData.count = 0;
579 eventData.oldEvent = event;
581 XPeekIfEvent(XtDisplay(w), &newEvent, PeekNotifyEvent, (char*)&eventData);
583 if (CompareEvents(event, &newEvent))
584 return True;
585 else
586 return False;
590 static void ExtractPosition( event, x, y )
591 XEvent *event;
592 Position *x, *y; /* RETURN */
594 switch( event->type ) {
595 case MotionNotify:
596 *x = event->xmotion.x; *y = event->xmotion.y; break;
597 case ButtonPress:
598 case ButtonRelease:
599 *x = event->xbutton.x; *y = event->xbutton.y; break;
600 case KeyPress:
601 case KeyRelease:
602 *x = event->xkey.x; *y = event->xkey.y; break;
603 case EnterNotify:
604 case LeaveNotify:
605 *x = event->xcrossing.x; *y = event->xcrossing.y; break;
606 default:
607 *x = 0; *y = 0;
611 static void NotifyScroll( gw, event, params, num_params )
612 Widget gw;
613 XEvent *event;
614 String *params; /* style: Proportional|FullLength */
615 Cardinal *num_params; /* we only support 1 */
617 ScrollbarWidget w = (ScrollbarWidget) gw;
618 int call_data;
619 char style;
620 Position x, y;
622 if (w->scrollbar.direction == 0) return; /* if no StartScroll */
624 if (LookAhead(gw, event)) return;
626 if (*num_params > 0) style = *params[0];
627 else style = 'P';
629 switch( style ) {
630 case 'P': /* Proportional */
631 case 'p': ExtractPosition( event, &x, &y );
632 call_data = InRange( PICKLENGTH( w, x, y ),
634 (int) w->scrollbar.length); break;
636 case 'F': /* FullLength */
637 case 'f': call_data = w->scrollbar.length; break;
640 switch( w->scrollbar.direction ) {
641 case 'B':
642 case 'b': call_data = -call_data;
643 /* fall through */
644 case 'F':
645 case 'f': XtCallCallbacks( gw, XtNscrollProc, (caddr_t)call_data );
646 break;
648 case 'C':
649 case 'c': /* NotifyThumb has already called the thumbProc(s) */
650 break;
654 /* ARGSUSED */
655 static void EndScroll(gw, event, params, num_params )
656 Widget gw;
657 XEvent *event; /* unused */
658 String *params; /* unused */
659 Cardinal *num_params; /* unused */
661 ScrollbarWidget w = (ScrollbarWidget) gw;
663 XDefineCursor(XtDisplay(w), XtWindow(w), w->scrollbar.inactiveCursor);
664 XFlush(XtDisplay(w));
666 w->scrollbar.direction = 0;
670 /* ARGSUSED */
671 static void MoveThumb( gw, event, params, num_params )
672 Widget gw;
673 XEvent *event;
674 String *params; /* unused */
675 Cardinal *num_params; /* unused */
677 ScrollbarWidget w = (ScrollbarWidget) gw;
678 Position x, y;
680 if (w->scrollbar.direction == 0) return; /* if no StartScroll */
682 if (LookAhead(gw, event)) return;
684 ExtractPosition( event, &x, &y );
685 w->scrollbar.top = FractionLoc(w, x, y);
686 PaintThumb(w);
687 XFlush(XtDisplay(w)); /* re-draw it before Notifying */
691 /* ARGSUSED */
692 static void NotifyThumb( gw, event, params, num_params )
693 Widget gw;
694 XEvent *event;
695 String *params; /* unused */
696 Cardinal *num_params; /* unused */
698 register ScrollbarWidget w = (ScrollbarWidget) gw;
700 if (w->scrollbar.direction == 0) return; /* if no StartScroll */
702 if (LookAhead(gw, event)) return;
704 XtCallCallbacks( gw, XtNthumbProc, &w->scrollbar.top);
705 XtCallCallbacks( gw, XtNjumpProc, &w->scrollbar.top);
710 /************************************************************
712 * Public routines.
714 ************************************************************/
716 /* Set the scroll bar to the given location. */
718 extern void
719 XawScrollbarSetThumb( gw, top, shown )
720 Widget gw;
721 float top, shown;
723 ScrollbarWidget w = (ScrollbarWidget)gw;
725 if (w->scrollbar.direction == 'c') return; /* if still thumbing */
727 w->scrollbar.top = (top > 1.0) ? 1.0 :
728 (top >= 0.0) ? top :
729 w->scrollbar.top;
731 w->scrollbar.shown = (shown > 1.0) ? 1.0 :
732 (shown >= 0.0) ? shown :
733 w->scrollbar.shown;
735 PaintThumb( w );