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