| 1 | /* |
| 2 | * tkScrollbar.h -- |
| 3 | * |
| 4 | * Declarations of types and functions used to implement |
| 5 | * the scrollbar widget. |
| 6 | * |
| 7 | * Copyright (c) 1996 by Sun Microsystems, Inc. |
| 8 | * |
| 9 | * See the file "license.terms" for information on usage and redistribution |
| 10 | * of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 11 | * |
| 12 | * RCS: @(#) $Id: tkScrollbar.h,v 1.4 1998/09/14 18:23:17 stanton Exp $ |
| 13 | */ |
| 14 | |
| 15 | #ifndef _TKSCROLLBAR |
| 16 | #define _TKSCROLLBAR |
| 17 | |
| 18 | #ifndef _TKINT |
| 19 | #include "tkInt.h" |
| 20 | #endif |
| 21 | #include "tkVMacro.h" |
| 22 | |
| 23 | #ifdef BUILD_tk |
| 24 | # undef TCL_STORAGE_CLASS |
| 25 | # define TCL_STORAGE_CLASS DLLEXPORT |
| 26 | #endif |
| 27 | |
| 28 | /* |
| 29 | * A data structure of the following type is kept for each scrollbar |
| 30 | * widget. |
| 31 | */ |
| 32 | |
| 33 | typedef struct TkScrollbar { |
| 34 | Tk_Window tkwin; /* Window that embodies the scrollbar. NULL |
| 35 | * means that the window has been destroyed |
| 36 | * but the data structures haven't yet been |
| 37 | * cleaned up.*/ |
| 38 | Display *display; /* Display containing widget. Used, among |
| 39 | * other things, so that resources can be |
| 40 | * freed even after tkwin has gone away. */ |
| 41 | Tcl_Interp *interp; /* Interpreter associated with scrollbar. */ |
| 42 | Tcl_Command widgetCmd; /* Token for scrollbar's widget command. */ |
| 43 | int vertical; /* Non-zero means vertical orientation |
| 44 | * requested, zero means horizontal. */ |
| 45 | int width; /* Desired narrow dimension of scrollbar, |
| 46 | * in pixels. */ |
| 47 | LangCallback *command; /* Command prefix to use when invoking |
| 48 | * scrolling commands. NULL means don't |
| 49 | * invoke commands. Malloc'ed. */ |
| 50 | #if 0 |
| 51 | int commandSize; /* Number of non-NULL bytes in command. */ |
| 52 | #endif |
| 53 | int repeatDelay; /* How long to wait before auto-repeating |
| 54 | * on scrolling actions (in ms). */ |
| 55 | int repeatInterval; /* Interval between autorepeats (in ms). */ |
| 56 | int jump; /* Value of -jump option. */ |
| 57 | |
| 58 | /* |
| 59 | * Information used when displaying widget: |
| 60 | */ |
| 61 | |
| 62 | int borderWidth; /* Width of 3-D borders. */ |
| 63 | Tk_3DBorder bgBorder; /* Used for drawing background (all flat |
| 64 | * surfaces except for trough). */ |
| 65 | Tk_3DBorder activeBorder; /* For drawing backgrounds when active (i.e. |
| 66 | * when mouse is positioned over element). */ |
| 67 | XColor *troughColorPtr; /* Color for drawing trough. */ |
| 68 | int relief; /* Indicates whether window as a whole is |
| 69 | * raised, sunken, or flat. */ |
| 70 | int highlightWidth; /* Width in pixels of highlight to draw |
| 71 | * around widget when it has the focus. |
| 72 | * <= 0 means don't draw a highlight. */ |
| 73 | XColor *highlightBgColorPtr; |
| 74 | /* Color for drawing traversal highlight |
| 75 | * area when highlight is off. */ |
| 76 | XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ |
| 77 | int inset; /* Total width of all borders, including |
| 78 | * traversal highlight and 3-D border. |
| 79 | * Indicates how much interior stuff must |
| 80 | * be offset from outside edges to leave |
| 81 | * room for borders. */ |
| 82 | int elementBorderWidth; /* Width of border to draw around elements |
| 83 | * inside scrollbar (arrows and slider). |
| 84 | * -1 means use borderWidth. */ |
| 85 | int arrowLength; /* Length of arrows along long dimension of |
| 86 | * scrollbar, including space for a small gap |
| 87 | * between the arrow and the slider. |
| 88 | * Recomputed on window size changes. */ |
| 89 | int sliderFirst; /* Pixel coordinate of top or left edge |
| 90 | * of slider area, including border. */ |
| 91 | int sliderLast; /* Coordinate of pixel just after bottom |
| 92 | * or right edge of slider area, including |
| 93 | * border. */ |
| 94 | int activeField; /* Names field to be displayed in active |
| 95 | * colors, such as TOP_ARROW, or 0 for |
| 96 | * no field. */ |
| 97 | int activeRelief; /* Value of -activeRelief option: relief |
| 98 | * to use for active element. */ |
| 99 | |
| 100 | /* |
| 101 | * Information describing the application related to the scrollbar. |
| 102 | * This information is provided by the application by invoking the |
| 103 | * "set" widget command. This information can now be provided in |
| 104 | * two ways: the "old" form (totalUnits, windowUnits, firstUnit, |
| 105 | * and lastUnit), or the "new" form (firstFraction and lastFraction). |
| 106 | * FirstFraction and lastFraction will always be valid, but |
| 107 | * the old-style information is only valid if the NEW_STYLE_COMMANDS |
| 108 | * flag is 0. |
| 109 | */ |
| 110 | |
| 111 | int totalUnits; /* Total dimension of application, in |
| 112 | * units. Valid only if the NEW_STYLE_COMMANDS |
| 113 | * flag isn't set. */ |
| 114 | int windowUnits; /* Maximum number of units that can be |
| 115 | * displayed in the window at once. Valid |
| 116 | * only if the NEW_STYLE_COMMANDS flag isn't |
| 117 | * set. */ |
| 118 | int firstUnit; /* Number of last unit visible in |
| 119 | * application's window. Valid only if the |
| 120 | * NEW_STYLE_COMMANDS flag isn't set. */ |
| 121 | int lastUnit; /* Index of last unit visible in window. |
| 122 | * Valid only if the NEW_STYLE_COMMANDS |
| 123 | * flag isn't set. */ |
| 124 | double firstFraction; /* Position of first visible thing in window, |
| 125 | * specified as a fraction between 0 and |
| 126 | * 1.0. */ |
| 127 | double lastFraction; /* Position of last visible thing in window, |
| 128 | * specified as a fraction between 0 and |
| 129 | * 1.0. */ |
| 130 | |
| 131 | /* |
| 132 | * Miscellaneous information: |
| 133 | */ |
| 134 | |
| 135 | Tk_Cursor cursor; /* Current cursor for window, or None. */ |
| 136 | char *takeFocus; /* Value of -takefocus option; not used in |
| 137 | * the C code, but used by keyboard traversal |
| 138 | * scripts. Malloc'ed, but may be NULL. */ |
| 139 | int flags; /* Various flags; see below for |
| 140 | * definitions. */ |
| 141 | Tk_Tile tile, activeTile, troughTile; |
| 142 | GC activeTileGC; |
| 143 | Tk_TSOffset tsoffset; |
| 144 | } TkScrollbar; |
| 145 | |
| 146 | /* |
| 147 | * Legal values for "activeField" field of Scrollbar structures. These |
| 148 | * are also the return values from the ScrollbarPosition procedure. |
| 149 | */ |
| 150 | |
| 151 | #define OUTSIDE 0 |
| 152 | #define TOP_ARROW 1 |
| 153 | #define TOP_GAP 2 |
| 154 | #define SLIDER 3 |
| 155 | #define BOTTOM_GAP 4 |
| 156 | #define BOTTOM_ARROW 5 |
| 157 | |
| 158 | /* |
| 159 | * Flag bits for scrollbars: |
| 160 | * |
| 161 | * REDRAW_PENDING: Non-zero means a DoWhenIdle handler |
| 162 | * has already been queued to redraw |
| 163 | * this window. |
| 164 | * NEW_STYLE_COMMANDS: Non-zero means the new style of commands |
| 165 | * should be used to communicate with the |
| 166 | * widget: ".t yview scroll 2 lines", instead |
| 167 | * of ".t yview 40", for example. |
| 168 | * GOT_FOCUS: Non-zero means this window has the input |
| 169 | * focus. |
| 170 | */ |
| 171 | |
| 172 | #define REDRAW_PENDING 1 |
| 173 | #define NEW_STYLE_COMMANDS 2 |
| 174 | #define GOT_FOCUS 4 |
| 175 | |
| 176 | /* |
| 177 | * Declaration of scrollbar class procedures structure. |
| 178 | */ |
| 179 | |
| 180 | extern TkClassProcs tkpScrollbarProcs; |
| 181 | |
| 182 | /* |
| 183 | * Declaration of scrollbar configuration options. |
| 184 | */ |
| 185 | |
| 186 | extern Tk_ConfigSpec tkpScrollbarConfigSpecs[]; |
| 187 | |
| 188 | /* |
| 189 | * Declaration of procedures used in the implementation of the scrollbar |
| 190 | * widget. |
| 191 | */ |
| 192 | |
| 193 | EXTERN void TkScrollbarEventProc _ANSI_ARGS_(( |
| 194 | ClientData clientData, XEvent *eventPtr)); |
| 195 | EXTERN void TkScrollbarEventuallyRedraw _ANSI_ARGS_(( |
| 196 | TkScrollbar *scrollPtr)); |
| 197 | EXTERN void TkpComputeScrollbarGeometry _ANSI_ARGS_(( |
| 198 | TkScrollbar *scrollPtr)); |
| 199 | EXTERN TkScrollbar * TkpCreateScrollbar _ANSI_ARGS_((Tk_Window tkwin)); |
| 200 | EXTERN void TkpDestroyScrollbar _ANSI_ARGS_(( |
| 201 | TkScrollbar *scrollPtr)); |
| 202 | EXTERN void TkpDisplayScrollbar _ANSI_ARGS_(( |
| 203 | ClientData clientData)); |
| 204 | EXTERN void TkpConfigureScrollbar _ANSI_ARGS_(( |
| 205 | TkScrollbar *scrollPtr)); |
| 206 | EXTERN int TkpScrollbarPosition _ANSI_ARGS_(( |
| 207 | TkScrollbar *scrollPtr, int x, int y)); |
| 208 | |
| 209 | # undef TCL_STORAGE_CLASS |
| 210 | # define TCL_STORAGE_CLASS DLLIMPORT |
| 211 | |
| 212 | #endif /* _TKSCROLLBAR */ |