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