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