jpayne@69: /* jpayne@69: * tkScrollbar.h -- jpayne@69: * jpayne@69: * Declarations of types and functions used to implement the scrollbar jpayne@69: * widget. jpayne@69: * jpayne@69: * Copyright (c) 1996 by Sun Microsystems, Inc. jpayne@69: * jpayne@69: * See the file "license.terms" for information on usage and redistribution of jpayne@69: * this file, and for a DISCLAIMER OF ALL WARRANTIES. jpayne@69: */ jpayne@69: jpayne@69: #ifndef _TKSCROLLBAR jpayne@69: #define _TKSCROLLBAR jpayne@69: jpayne@69: #ifndef _TKINT jpayne@69: #include "tkInt.h" jpayne@69: #endif jpayne@69: jpayne@69: /* jpayne@69: * A data structure of the following type is kept for each scrollbar widget. jpayne@69: */ jpayne@69: jpayne@69: typedef struct TkScrollbar { jpayne@69: Tk_Window tkwin; /* Window that embodies the scrollbar. NULL jpayne@69: * means that the window has been destroyed jpayne@69: * but the data structures haven't yet been jpayne@69: * cleaned up.*/ jpayne@69: Display *display; /* Display containing widget. Used, among jpayne@69: * other things, so that resources can be jpayne@69: * freed even after tkwin has gone away. */ jpayne@69: Tcl_Interp *interp; /* Interpreter associated with scrollbar. */ jpayne@69: Tcl_Command widgetCmd; /* Token for scrollbar's widget command. */ jpayne@69: int vertical; /* Non-zero means vertical orientation jpayne@69: * requested, zero means horizontal. */ jpayne@69: int width; /* Desired narrow dimension of scrollbar, in jpayne@69: * pixels. */ jpayne@69: char *command; /* Command prefix to use when invoking jpayne@69: * scrolling commands. NULL means don't invoke jpayne@69: * commands. Malloc'ed. */ jpayne@69: int commandSize; /* Number of non-NULL bytes in command. */ jpayne@69: int repeatDelay; /* How long to wait before auto-repeating on jpayne@69: * scrolling actions (in ms). */ jpayne@69: int repeatInterval; /* Interval between autorepeats (in ms). */ jpayne@69: int jump; /* Value of -jump option. */ jpayne@69: jpayne@69: /* jpayne@69: * Information used when displaying widget: jpayne@69: */ jpayne@69: jpayne@69: int borderWidth; /* Width of 3-D borders. */ jpayne@69: Tk_3DBorder bgBorder; /* Used for drawing background (all flat jpayne@69: * surfaces except for trough). */ jpayne@69: Tk_3DBorder activeBorder; /* For drawing backgrounds when active (i.e. jpayne@69: * when mouse is positioned over element). */ jpayne@69: XColor *troughColorPtr; /* Color for drawing trough. */ jpayne@69: int relief; /* Indicates whether window as a whole is jpayne@69: * raised, sunken, or flat. */ jpayne@69: int highlightWidth; /* Width in pixels of highlight to draw around jpayne@69: * widget when it has the focus. <= 0 means jpayne@69: * don't draw a highlight. */ jpayne@69: XColor *highlightBgColorPtr; jpayne@69: /* Color for drawing traversal highlight area jpayne@69: * when highlight is off. */ jpayne@69: XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ jpayne@69: int inset; /* Total width of all borders, including jpayne@69: * traversal highlight and 3-D border. jpayne@69: * Indicates how much interior stuff must be jpayne@69: * offset from outside edges to leave room for jpayne@69: * borders. */ jpayne@69: int elementBorderWidth; /* Width of border to draw around elements jpayne@69: * inside scrollbar (arrows and slider). -1 jpayne@69: * means use borderWidth. */ jpayne@69: int arrowLength; /* Length of arrows along long dimension of jpayne@69: * scrollbar, including space for a small gap jpayne@69: * between the arrow and the slider. jpayne@69: * Recomputed on window size changes. */ jpayne@69: int sliderFirst; /* Pixel coordinate of top or left edge of jpayne@69: * slider area, including border. */ jpayne@69: int sliderLast; /* Coordinate of pixel just after bottom or jpayne@69: * right edge of slider area, including jpayne@69: * border. */ jpayne@69: int activeField; /* Names field to be displayed in active jpayne@69: * colors, such as TOP_ARROW, or 0 for no jpayne@69: * field. */ jpayne@69: int activeRelief; /* Value of -activeRelief option: relief to jpayne@69: * use for active element. */ jpayne@69: jpayne@69: /* jpayne@69: * Information describing the application related to the scrollbar. This jpayne@69: * information is provided by the application by invoking the "set" widget jpayne@69: * command. This information can now be provided in two ways: the "old" jpayne@69: * form (totalUnits, windowUnits, firstUnit, and lastUnit), or the "new" jpayne@69: * form (firstFraction and lastFraction). FirstFraction and lastFraction jpayne@69: * will always be valid, but the old-style information is only valid if jpayne@69: * the NEW_STYLE_COMMANDS flag is 0. jpayne@69: */ jpayne@69: jpayne@69: int totalUnits; /* Total dimension of application, in units. jpayne@69: * Valid only if the NEW_STYLE_COMMANDS flag jpayne@69: * isn't set. */ jpayne@69: int windowUnits; /* Maximum number of units that can be jpayne@69: * displayed in the window at once. Valid only jpayne@69: * if the NEW_STYLE_COMMANDS flag isn't set. */ jpayne@69: int firstUnit; /* Number of last unit visible in jpayne@69: * application's window. Valid only if the jpayne@69: * NEW_STYLE_COMMANDS flag isn't set. */ jpayne@69: int lastUnit; /* Index of last unit visible in window. jpayne@69: * Valid only if the NEW_STYLE_COMMANDS flag jpayne@69: * isn't set. */ jpayne@69: double firstFraction; /* Position of first visible thing in window, jpayne@69: * specified as a fraction between 0 and jpayne@69: * 1.0. */ jpayne@69: double lastFraction; /* Position of last visible thing in window, jpayne@69: * specified as a fraction between 0 and jpayne@69: * 1.0. */ jpayne@69: jpayne@69: /* jpayne@69: * Miscellaneous information: jpayne@69: */ jpayne@69: jpayne@69: Tk_Cursor cursor; /* Current cursor for window, or NULL. */ jpayne@69: char *takeFocus; /* Value of -takefocus option; not used in the jpayne@69: * C code, but used by keyboard traversal jpayne@69: * scripts. Malloc'ed, but may be NULL. */ jpayne@69: int flags; /* Various flags; see below for jpayne@69: * definitions. */ jpayne@69: } TkScrollbar; jpayne@69: jpayne@69: /* jpayne@69: * Legal values for "activeField" field of Scrollbar structures. These are jpayne@69: * also the return values from the ScrollbarPosition function. jpayne@69: */ jpayne@69: jpayne@69: #define OUTSIDE 0 jpayne@69: #define TOP_ARROW 1 jpayne@69: #define TOP_GAP 2 jpayne@69: #define SLIDER 3 jpayne@69: #define BOTTOM_GAP 4 jpayne@69: #define BOTTOM_ARROW 5 jpayne@69: jpayne@69: /* jpayne@69: * Flag bits for scrollbars: jpayne@69: * jpayne@69: * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has jpayne@69: * already been queued to redraw this window. jpayne@69: * NEW_STYLE_COMMANDS: Non-zero means the new style of commands jpayne@69: * should be used to communicate with the widget: jpayne@69: * ".t yview scroll 2 lines", instead of jpayne@69: * ".t yview 40", for example. jpayne@69: * GOT_FOCUS: Non-zero means this window has the input jpayne@69: * focus. jpayne@69: */ jpayne@69: jpayne@69: #define REDRAW_PENDING 1 jpayne@69: #define NEW_STYLE_COMMANDS 2 jpayne@69: #define GOT_FOCUS 4 jpayne@69: jpayne@69: /* jpayne@69: * Declaration of scrollbar class functions structure jpayne@69: * and default scrollbar width, for use in configSpec. jpayne@69: */ jpayne@69: jpayne@69: MODULE_SCOPE const Tk_ClassProcs tkpScrollbarProcs; jpayne@69: MODULE_SCOPE char tkDefScrollbarWidth[TCL_INTEGER_SPACE]; jpayne@69: jpayne@69: /* jpayne@69: * Declaration of functions used in the implementation of the scrollbar jpayne@69: * widget. jpayne@69: */ jpayne@69: jpayne@69: MODULE_SCOPE void TkScrollbarEventProc(ClientData clientData, jpayne@69: XEvent *eventPtr); jpayne@69: MODULE_SCOPE void TkScrollbarEventuallyRedraw(TkScrollbar *scrollPtr); jpayne@69: MODULE_SCOPE void TkpComputeScrollbarGeometry(TkScrollbar *scrollPtr); jpayne@69: MODULE_SCOPE TkScrollbar *TkpCreateScrollbar(Tk_Window tkwin); jpayne@69: MODULE_SCOPE void TkpDestroyScrollbar(TkScrollbar *scrollPtr); jpayne@69: MODULE_SCOPE void TkpDisplayScrollbar(ClientData clientData); jpayne@69: MODULE_SCOPE void TkpConfigureScrollbar(TkScrollbar *scrollPtr); jpayne@69: MODULE_SCOPE int TkpScrollbarPosition(TkScrollbar *scrollPtr, jpayne@69: int x, int y); jpayne@69: jpayne@69: #endif /* _TKSCROLLBAR */