XTkScrollbar.mesa
Copyright Ó 1990, 1991, 1992 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, October 22, 1990 3:28:21 pm PDT
Christian Jacobi, June 9, 1992 4:14 pm PDT
DIRECTORY
XTk USING [Class, Event, TQ, Widget, WidgetSpec];
Simple scrollbar widgets.
A scrollbar widget implements a raw scroll bar. It has no knowledge what scrolling means, or, what entity is scrolled.
State is simply remembered and painted. If resized, it is the clients business to compute a new state.
XTkScrollbar: CEDAR DEFINITIONS
~ BEGIN
Scrollbar: TYPE = XTk.Widget;
scrollbarClass: READONLY XTk.Class;
Direction: TYPE = {horizontal, vertical};
State: TYPE = RECORD [start, next: REAL];
[start..next) denotes the displayed area, in range [0..1); .
CreateScrollbar: PROC [widgetSpec: XTk.WidgetSpec ¬ [], direction: Direction ¬ vertical, state: State ¬ [0, 1]] RETURNS [Scrollbar];
Creates a scrollbar widget.
IsScrollbar: PROC [widget: XTk.Widget] RETURNS [BOOL];
Predicate whether calling GetState, etc. makes sense.
GetDirection: PROC [scrollbar: Scrollbar] RETURNS [direction: Direction];
Returns the direction of a scrollbar.
GetState: PROC [scrollbar: Scrollbar] RETURNS [state: State];
Returns the current state of the scrollbar.
ParentalSetState: PROC [scrollbar: Scrollbar, state: State, event: XTk.Event ¬ NIL];
Changes current state of the scrollbar; must be called by logical parent only (scroll proc will not be called). Eventually the new state will be displayed.
event is optional, it is forwarded to registered notifiers
PublicSetState: PROC [scrollbar: Scrollbar, action: Action, value: REAL, event: XTk.Event ¬ NIL];
Tries to set the state of the scrollbar; can be called by anybody, e.g. interactively.
The proposed state will be forwarded to the scroll proc.
event is optional, it is forwarded to the scroll proc
stateChanged: READONLY ATOM; -- ¬ $ScrollbarState
Notifiers will be called by ParentalSetState.
Action: TYPE = {none, backward, forward, thumb, configure};
ScrollProc: TYPE = PROC [scrollbar: Scrollbar, action: Action, value: REAL, event: XTk.Event, clientData: REF];
ScrollProc is the type of the client supplied (filter) procedure which is called when an (maybe interactive) action with a scrollbar occurrs. This procedure is supposed to do the actual work, and, eventually call ParentalSetState to display the new state.
Clients ought to make a choice and act on "configure" actions only once, not for both: the general configure notification mechanism, and, this ScrollProc.
"action" is the reason this procedure is being called.
"value"
for interactive backward, forward, thumb in [0..1);
for configure: widgetLength.
"event" cause of action, if available. Useful for time stamp, breaking recursive calls, etc.
"clientData" from registration.
SetScrollProc: PROC [scrollbar: Scrollbar, scrollProc: ScrollProc, clientData: REF ¬ NIL, tq: XTk.TQ ¬ NIL];
Sets a (filter) procedure to handle interactive actions.
scrollerProc: called to notify interactions.
clientData: passed to scrollerProc.
tq: ThreadQueue used to call scrollProc. For NIL, a reasonable choice will be made.
END.