1 |
/* $Header$ */ |
2 |
|
3 |
/* |
4 |
* tkScale.h -- |
5 |
* |
6 |
* Declarations of types and functions used to implement |
7 |
* the scale widget. |
8 |
* |
9 |
* Copyright (c) 1996 by Sun Microsystems, Inc. |
10 |
* Copyright (c) 1999-2000 by Scriptics Corporation. |
11 |
* |
12 |
* See the file "license.terms" for information on usage and redistribution |
13 |
* of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
14 |
* |
15 |
* RCS: @(#) $Id: tkscale.h,v 1.1.1.1 2001/06/13 05:07:47 dtashley Exp $ |
16 |
*/ |
17 |
|
18 |
#ifndef _TKSCALE |
19 |
#define _TKSCALE |
20 |
|
21 |
#ifndef _TK |
22 |
#include "tk.h" |
23 |
#endif |
24 |
|
25 |
#ifdef BUILD_tk |
26 |
# undef TCL_STORAGE_CLASS |
27 |
# define TCL_STORAGE_CLASS DLLEXPORT |
28 |
#endif |
29 |
|
30 |
/* |
31 |
* Legal values for the "orient" field of TkScale records. |
32 |
*/ |
33 |
|
34 |
enum orient { |
35 |
ORIENT_HORIZONTAL, ORIENT_VERTICAL |
36 |
}; |
37 |
|
38 |
/* |
39 |
* Legal values for the "state" field of TkScale records. |
40 |
*/ |
41 |
|
42 |
enum state { |
43 |
STATE_ACTIVE, STATE_DISABLED, STATE_NORMAL |
44 |
}; |
45 |
|
46 |
/* |
47 |
* A data structure of the following type is kept for each scale |
48 |
* widget managed by this file: |
49 |
*/ |
50 |
|
51 |
typedef struct TkScale { |
52 |
Tk_Window tkwin; /* Window that embodies the scale. NULL |
53 |
* means that the window has been destroyed |
54 |
* but the data structures haven't yet been |
55 |
* cleaned up.*/ |
56 |
Display *display; /* Display containing widget. Used, among |
57 |
* other things, so that resources can be |
58 |
* freed even after tkwin has gone away. */ |
59 |
Tcl_Interp *interp; /* Interpreter associated with scale. */ |
60 |
Tcl_Command widgetCmd; /* Token for scale's widget command. */ |
61 |
Tk_OptionTable optionTable; /* Table that defines configuration options |
62 |
* available for this widget. */ |
63 |
enum orient orient; /* Orientation for window (vertical or |
64 |
* horizontal). */ |
65 |
int width; /* Desired narrow dimension of scale, |
66 |
* in pixels. */ |
67 |
int length; /* Desired long dimension of scale, |
68 |
* in pixels. */ |
69 |
double value; /* Current value of scale. */ |
70 |
Tcl_Obj *varNamePtr; /* Name of variable or NULL. |
71 |
* If non-NULL, scale's value tracks |
72 |
* the contents of this variable and |
73 |
* vice versa. */ |
74 |
double fromValue; /* Value corresponding to left or top of |
75 |
* scale. */ |
76 |
double toValue; /* Value corresponding to right or bottom |
77 |
* of scale. */ |
78 |
double tickInterval; /* Distance between tick marks; |
79 |
* 0 means don't display any tick marks. */ |
80 |
double resolution; /* If > 0, all values are rounded to an |
81 |
* even multiple of this value. */ |
82 |
int digits; /* Number of significant digits to print |
83 |
* in values. 0 means we get to choose the |
84 |
* number based on resolution and/or the |
85 |
* range of the scale. */ |
86 |
char format[10]; /* Sprintf conversion specifier computed from |
87 |
* digits and other information. */ |
88 |
double bigIncrement; /* Amount to use for large increments to |
89 |
* scale value. (0 means we pick a value). */ |
90 |
char *command; /* Command prefix to use when invoking Tcl |
91 |
* commands because the scale value changed. |
92 |
* NULL means don't invoke commands. */ |
93 |
int repeatDelay; /* How long to wait before auto-repeating |
94 |
* on scrolling actions (in ms). */ |
95 |
int repeatInterval; /* Interval between autorepeats (in ms). */ |
96 |
char *label; /* Label to display above or to right of |
97 |
* scale; NULL means don't display a label. */ |
98 |
int labelLength; /* Number of non-NULL chars. in label. */ |
99 |
enum state state; /* Values are active, normal, or disabled. |
100 |
* Value of scale cannot be changed when |
101 |
* disabled. */ |
102 |
|
103 |
/* |
104 |
* Information used when displaying widget: |
105 |
*/ |
106 |
|
107 |
int borderWidth; /* Width of 3-D border around window. */ |
108 |
Tk_3DBorder bgBorder; /* Used for drawing slider and other |
109 |
* background areas. */ |
110 |
Tk_3DBorder activeBorder; /* For drawing the slider when active. */ |
111 |
int sliderRelief; /* Is slider to be drawn raised, sunken, |
112 |
* etc. */ |
113 |
XColor *troughColorPtr; /* Color for drawing trough. */ |
114 |
GC troughGC; /* For drawing trough. */ |
115 |
GC copyGC; /* Used for copying from pixmap onto screen. */ |
116 |
Tk_Font tkfont; /* Information about text font, or NULL. */ |
117 |
XColor *textColorPtr; /* Color for drawing text. */ |
118 |
GC textGC; /* GC for drawing text in normal mode. */ |
119 |
int relief; /* Indicates whether window as a whole is |
120 |
* raised, sunken, or flat. */ |
121 |
int highlightWidth; /* Width in pixels of highlight to draw |
122 |
* around widget when it has the focus. |
123 |
* <= 0 means don't draw a highlight. */ |
124 |
Tk_3DBorder highlightBorder;/* Value of -highlightbackground option: |
125 |
* specifies background with which to draw 3-D |
126 |
* default ring and focus highlight area when |
127 |
* highlight is off. */ |
128 |
XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ |
129 |
int inset; /* Total width of all borders, including |
130 |
* traversal highlight and 3-D border. |
131 |
* Indicates how much interior stuff must |
132 |
* be offset from outside edges to leave |
133 |
* room for borders. */ |
134 |
int sliderLength; /* Length of slider, measured in pixels along |
135 |
* long dimension of scale. */ |
136 |
int showValue; /* Non-zero means to display the scale value |
137 |
* below or to the left of the slider; zero |
138 |
* means don't display the value. */ |
139 |
|
140 |
/* |
141 |
* Layout information for horizontal scales, assuming that window |
142 |
* gets the size it requested: |
143 |
*/ |
144 |
|
145 |
int horizLabelY; /* Y-coord at which to draw label. */ |
146 |
int horizValueY; /* Y-coord at which to draw value text. */ |
147 |
int horizTroughY; /* Y-coord of top of slider trough. */ |
148 |
int horizTickY; /* Y-coord at which to draw tick text. */ |
149 |
/* |
150 |
* Layout information for vertical scales, assuming that window |
151 |
* gets the size it requested: |
152 |
*/ |
153 |
|
154 |
int vertTickRightX; /* X-location of right side of tick-marks. */ |
155 |
int vertValueRightX; /* X-location of right side of value string. */ |
156 |
int vertTroughX; /* X-location of scale's slider trough. */ |
157 |
int vertLabelX; /* X-location of origin of label. */ |
158 |
|
159 |
/* |
160 |
* Miscellaneous information: |
161 |
*/ |
162 |
|
163 |
int fontHeight; /* Height of scale font. */ |
164 |
Tk_Cursor cursor; /* Current cursor for window, or None. */ |
165 |
Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in |
166 |
* the C code, but used by keyboard traversal |
167 |
* scripts. May be NULL. */ |
168 |
int flags; /* Various flags; see below for |
169 |
* definitions. */ |
170 |
} TkScale; |
171 |
|
172 |
/* |
173 |
* Flag bits for scales: |
174 |
* |
175 |
* REDRAW_SLIDER - 1 means slider (and numerical readout) need |
176 |
* to be redrawn. |
177 |
* REDRAW_OTHER - 1 means other stuff besides slider and value |
178 |
* need to be redrawn. |
179 |
* REDRAW_ALL - 1 means the entire widget needs to be redrawn. |
180 |
* REDRAW_PENDING - 1 means any sort of redraw is pending |
181 |
* ACTIVE - 1 means the widget is active (the mouse is |
182 |
* in its window). |
183 |
* INVOKE_COMMAND - 1 means the scale's command needs to be |
184 |
* invoked during the next redisplay (the |
185 |
* value of the scale has changed since the |
186 |
* last time the command was invoked). |
187 |
* SETTING_VAR - 1 means that the associated variable is |
188 |
* being set by us, so there's no need for |
189 |
* ScaleVarProc to do anything. |
190 |
* NEVER_SET - 1 means that the scale's value has never |
191 |
* been set before (so must invoke -command and |
192 |
* set associated variable even if the value |
193 |
* doesn't appear to have changed). |
194 |
* GOT_FOCUS - 1 means that the focus is currently in |
195 |
* this widget. |
196 |
* SCALE_DELETED - 1 means the scale widget is being deleted |
197 |
*/ |
198 |
|
199 |
#define REDRAW_SLIDER (1<<0) |
200 |
#define REDRAW_OTHER (1<<1) |
201 |
#define REDRAW_ALL (REDRAW_OTHER|REDRAW_SLIDER) |
202 |
#define REDRAW_PENDING (1<<2) |
203 |
#define ACTIVE (1<<3) |
204 |
#define INVOKE_COMMAND (1<<4) |
205 |
#define SETTING_VAR (1<<5) |
206 |
#define NEVER_SET (1<<6) |
207 |
#define GOT_FOCUS (1<<7) |
208 |
#define SCALE_DELETED (1<<8) |
209 |
|
210 |
/* |
211 |
* Symbolic values for the active parts of a slider. These are |
212 |
* the values that may be returned by the ScaleElement procedure. |
213 |
*/ |
214 |
|
215 |
#define OTHER 0 |
216 |
#define TROUGH1 1 |
217 |
#define SLIDER 2 |
218 |
#define TROUGH2 3 |
219 |
|
220 |
/* |
221 |
* Space to leave between scale area and text, and between text and |
222 |
* edge of window. |
223 |
*/ |
224 |
|
225 |
#define SPACING 2 |
226 |
|
227 |
/* |
228 |
* How many characters of space to provide when formatting the |
229 |
* scale's value: |
230 |
*/ |
231 |
|
232 |
#define PRINT_CHARS 150 |
233 |
|
234 |
/* |
235 |
* Declaration of procedures used in the implementation of the scale |
236 |
* widget. |
237 |
*/ |
238 |
|
239 |
extern void TkEventuallyRedrawScale _ANSI_ARGS_((TkScale *scalePtr, |
240 |
int what)); |
241 |
extern double TkRoundToResolution _ANSI_ARGS_((TkScale *scalePtr, |
242 |
double value)); |
243 |
extern TkScale * TkpCreateScale _ANSI_ARGS_((Tk_Window tkwin)); |
244 |
extern void TkpDestroyScale _ANSI_ARGS_((TkScale *scalePtr)); |
245 |
extern void TkpDisplayScale _ANSI_ARGS_((ClientData clientData)); |
246 |
extern int TkpScaleElement _ANSI_ARGS_((TkScale *scalePtr, |
247 |
int x, int y)); |
248 |
extern void TkScaleSetValue _ANSI_ARGS_((TkScale *scalePtr, |
249 |
double value, int setVar, int invokeCommand)); |
250 |
extern double TkScalePixelToValue _ANSI_ARGS_((TkScale *scalePtr, |
251 |
int x, int y)); |
252 |
extern int TkScaleValueToPixel _ANSI_ARGS_((TkScale *scalePtr, |
253 |
double value)); |
254 |
|
255 |
# undef TCL_STORAGE_CLASS |
256 |
# define TCL_STORAGE_CLASS DLLIMPORT |
257 |
|
258 |
#endif /* _TKSCALE */ |
259 |
|
260 |
/* End of tkscale.h */ |