1 |
578 |
markom |
/*
|
2 |
|
|
* tkScale.h --
|
3 |
|
|
*
|
4 |
|
|
* Declarations of types and functions used to implement
|
5 |
|
|
* the scale 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: tkScale.h,v 1.1.1.1 2002-01-16 10:25:52 markom Exp $
|
13 |
|
|
*/
|
14 |
|
|
|
15 |
|
|
#ifndef _TKSCALE
|
16 |
|
|
#define _TKSCALE
|
17 |
|
|
|
18 |
|
|
#ifndef _TK
|
19 |
|
|
#include "tk.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 scale
|
29 |
|
|
* widget managed by this file:
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
|
|
typedef struct TkScale {
|
33 |
|
|
Tk_Window tkwin; /* Window that embodies the scale. 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 scale. */
|
41 |
|
|
Tcl_Command widgetCmd; /* Token for scale's widget command. */
|
42 |
|
|
Tk_Uid orientUid; /* Orientation for window ("vertical" or
|
43 |
|
|
* "horizontal"). */
|
44 |
|
|
int vertical; /* Non-zero means vertical orientation,
|
45 |
|
|
* zero means horizontal. */
|
46 |
|
|
int width; /* Desired narrow dimension of scale,
|
47 |
|
|
* in pixels. */
|
48 |
|
|
int length; /* Desired long dimension of scale,
|
49 |
|
|
* in pixels. */
|
50 |
|
|
double value; /* Current value of scale. */
|
51 |
|
|
char *varName; /* Name of variable (malloc'ed) or NULL.
|
52 |
|
|
* If non-NULL, scale's value tracks
|
53 |
|
|
* the contents of this variable and
|
54 |
|
|
* vice versa. */
|
55 |
|
|
double fromValue; /* Value corresponding to left or top of
|
56 |
|
|
* scale. */
|
57 |
|
|
double toValue; /* Value corresponding to right or bottom
|
58 |
|
|
* of scale. */
|
59 |
|
|
double tickInterval; /* Distance between tick marks; 0 means
|
60 |
|
|
* don't display any tick marks. */
|
61 |
|
|
double resolution; /* If > 0, all values are rounded to an
|
62 |
|
|
* even multiple of this value. */
|
63 |
|
|
int digits; /* Number of significant digits to print
|
64 |
|
|
* in values. 0 means we get to choose the
|
65 |
|
|
* number based on resolution and/or the
|
66 |
|
|
* range of the scale. */
|
67 |
|
|
char format[10]; /* Sprintf conversion specifier computed from
|
68 |
|
|
* digits and other information. */
|
69 |
|
|
double bigIncrement; /* Amount to use for large increments to
|
70 |
|
|
* scale value. (0 means we pick a value). */
|
71 |
|
|
char *command; /* Command prefix to use when invoking Tcl
|
72 |
|
|
* commands because the scale value changed.
|
73 |
|
|
* NULL means don't invoke commands.
|
74 |
|
|
* Malloc'ed. */
|
75 |
|
|
int repeatDelay; /* How long to wait before auto-repeating
|
76 |
|
|
* on scrolling actions (in ms). */
|
77 |
|
|
int repeatInterval; /* Interval between autorepeats (in ms). */
|
78 |
|
|
char *label; /* Label to display above or to right of
|
79 |
|
|
* scale; NULL means don't display a
|
80 |
|
|
* label. Malloc'ed. */
|
81 |
|
|
int labelLength; /* Number of non-NULL chars. in label. */
|
82 |
|
|
Tk_Uid state; /* Normal or disabled. Value cannot be
|
83 |
|
|
* changed when scale is disabled. */
|
84 |
|
|
|
85 |
|
|
/*
|
86 |
|
|
* Information used when displaying widget:
|
87 |
|
|
*/
|
88 |
|
|
|
89 |
|
|
int borderWidth; /* Width of 3-D border around window. */
|
90 |
|
|
Tk_3DBorder bgBorder; /* Used for drawing slider and other
|
91 |
|
|
* background areas. */
|
92 |
|
|
Tk_3DBorder activeBorder; /* For drawing the slider when active. */
|
93 |
|
|
int sliderRelief; /* Is slider to be drawn raised, sunken, etc. */
|
94 |
|
|
XColor *troughColorPtr; /* Color for drawing trough. */
|
95 |
|
|
GC troughGC; /* For drawing trough. */
|
96 |
|
|
GC copyGC; /* Used for copying from pixmap onto screen. */
|
97 |
|
|
Tk_Font tkfont; /* Information about text font, or NULL. */
|
98 |
|
|
XColor *textColorPtr; /* Color for drawing text. */
|
99 |
|
|
GC textGC; /* GC for drawing text in normal mode. */
|
100 |
|
|
int relief; /* Indicates whether window as a whole is
|
101 |
|
|
* raised, sunken, or flat. */
|
102 |
|
|
int highlightWidth; /* Width in pixels of highlight to draw
|
103 |
|
|
* around widget when it has the focus.
|
104 |
|
|
* <= 0 means don't draw a highlight. */
|
105 |
|
|
XColor *highlightBgColorPtr;
|
106 |
|
|
/* Color for drawing traversal highlight
|
107 |
|
|
* area when highlight is off. */
|
108 |
|
|
XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
|
109 |
|
|
int inset; /* Total width of all borders, including
|
110 |
|
|
* traversal highlight and 3-D border.
|
111 |
|
|
* Indicates how much interior stuff must
|
112 |
|
|
* be offset from outside edges to leave
|
113 |
|
|
* room for borders. */
|
114 |
|
|
int sliderLength; /* Length of slider, measured in pixels along
|
115 |
|
|
* long dimension of scale. */
|
116 |
|
|
int showValue; /* Non-zero means to display the scale value
|
117 |
|
|
* below or to the left of the slider; zero
|
118 |
|
|
* means don't display the value. */
|
119 |
|
|
|
120 |
|
|
/*
|
121 |
|
|
* Layout information for horizontal scales, assuming that window
|
122 |
|
|
* gets the size it requested:
|
123 |
|
|
*/
|
124 |
|
|
|
125 |
|
|
int horizLabelY; /* Y-coord at which to draw label. */
|
126 |
|
|
int horizValueY; /* Y-coord at which to draw value text. */
|
127 |
|
|
int horizTroughY; /* Y-coord of top of slider trough. */
|
128 |
|
|
int horizTickY; /* Y-coord at which to draw tick text. */
|
129 |
|
|
/*
|
130 |
|
|
* Layout information for vertical scales, assuming that window
|
131 |
|
|
* gets the size it requested:
|
132 |
|
|
*/
|
133 |
|
|
|
134 |
|
|
int vertTickRightX; /* X-location of right side of tick-marks. */
|
135 |
|
|
int vertValueRightX; /* X-location of right side of value string. */
|
136 |
|
|
int vertTroughX; /* X-location of scale's slider trough. */
|
137 |
|
|
int vertLabelX; /* X-location of origin of label. */
|
138 |
|
|
|
139 |
|
|
/*
|
140 |
|
|
* Miscellaneous information:
|
141 |
|
|
*/
|
142 |
|
|
|
143 |
|
|
Tk_Cursor cursor; /* Current cursor for window, or None. */
|
144 |
|
|
char *takeFocus; /* Value of -takefocus option; not used in
|
145 |
|
|
* the C code, but used by keyboard traversal
|
146 |
|
|
* scripts. Malloc'ed, but may be NULL. */
|
147 |
|
|
int flags; /* Various flags; see below for
|
148 |
|
|
* definitions. */
|
149 |
|
|
} TkScale;
|
150 |
|
|
|
151 |
|
|
/*
|
152 |
|
|
* Flag bits for scales:
|
153 |
|
|
*
|
154 |
|
|
* REDRAW_SLIDER - 1 means slider (and numerical readout) need
|
155 |
|
|
* to be redrawn.
|
156 |
|
|
* REDRAW_OTHER - 1 means other stuff besides slider and value
|
157 |
|
|
* need to be redrawn.
|
158 |
|
|
* REDRAW_ALL - 1 means the entire widget needs to be redrawn.
|
159 |
|
|
* ACTIVE - 1 means the widget is active (the mouse is
|
160 |
|
|
* in its window).
|
161 |
|
|
* INVOKE_COMMAND - 1 means the scale's command needs to be
|
162 |
|
|
* invoked during the next redisplay (the
|
163 |
|
|
* value of the scale has changed since the
|
164 |
|
|
* last time the command was invoked).
|
165 |
|
|
* SETTING_VAR - 1 means that the associated variable is
|
166 |
|
|
* being set by us, so there's no need for
|
167 |
|
|
* ScaleVarProc to do anything.
|
168 |
|
|
* NEVER_SET - 1 means that the scale's value has never
|
169 |
|
|
* been set before (so must invoke -command and
|
170 |
|
|
* set associated variable even if the value
|
171 |
|
|
* doesn't appear to have changed).
|
172 |
|
|
* GOT_FOCUS - 1 means that the focus is currently in
|
173 |
|
|
* this widget.
|
174 |
|
|
*/
|
175 |
|
|
|
176 |
|
|
#define REDRAW_SLIDER 1
|
177 |
|
|
#define REDRAW_OTHER 2
|
178 |
|
|
#define REDRAW_ALL 3
|
179 |
|
|
#define ACTIVE 4
|
180 |
|
|
#define INVOKE_COMMAND 0x10
|
181 |
|
|
#define SETTING_VAR 0x20
|
182 |
|
|
#define NEVER_SET 0x40
|
183 |
|
|
#define GOT_FOCUS 0x80
|
184 |
|
|
|
185 |
|
|
/*
|
186 |
|
|
* Symbolic values for the active parts of a slider. These are
|
187 |
|
|
* the values that may be returned by the ScaleElement procedure.
|
188 |
|
|
*/
|
189 |
|
|
|
190 |
|
|
#define OTHER 0
|
191 |
|
|
#define TROUGH1 1
|
192 |
|
|
#define SLIDER 2
|
193 |
|
|
#define TROUGH2 3
|
194 |
|
|
|
195 |
|
|
/*
|
196 |
|
|
* Space to leave between scale area and text, and between text and
|
197 |
|
|
* edge of window.
|
198 |
|
|
*/
|
199 |
|
|
|
200 |
|
|
#define SPACING 2
|
201 |
|
|
|
202 |
|
|
/*
|
203 |
|
|
* How many characters of space to provide when formatting the
|
204 |
|
|
* scale's value:
|
205 |
|
|
*/
|
206 |
|
|
|
207 |
|
|
#define PRINT_CHARS 150
|
208 |
|
|
|
209 |
|
|
/*
|
210 |
|
|
* Declaration of procedures used in the implementation of the scrollbar
|
211 |
|
|
* widget.
|
212 |
|
|
*/
|
213 |
|
|
|
214 |
|
|
EXTERN void TkEventuallyRedrawScale _ANSI_ARGS_((TkScale *scalePtr,
|
215 |
|
|
int what));
|
216 |
|
|
EXTERN double TkRoundToResolution _ANSI_ARGS_((TkScale *scalePtr,
|
217 |
|
|
double value));
|
218 |
|
|
EXTERN TkScale * TkpCreateScale _ANSI_ARGS_((Tk_Window tkwin));
|
219 |
|
|
EXTERN void TkpDestroyScale _ANSI_ARGS_((TkScale *scalePtr));
|
220 |
|
|
EXTERN void TkpDisplayScale _ANSI_ARGS_((ClientData clientData));
|
221 |
|
|
EXTERN double TkpPixelToValue _ANSI_ARGS_((TkScale *scalePtr,
|
222 |
|
|
int x, int y));
|
223 |
|
|
EXTERN int TkpScaleElement _ANSI_ARGS_((TkScale *scalePtr,
|
224 |
|
|
int x, int y));
|
225 |
|
|
EXTERN void TkpSetScaleValue _ANSI_ARGS_((TkScale *scalePtr,
|
226 |
|
|
double value, int setVar, int invokeCommand));
|
227 |
|
|
EXTERN int TkpValueToPixel _ANSI_ARGS_((TkScale *scalePtr,
|
228 |
|
|
double value));
|
229 |
|
|
|
230 |
|
|
# undef TCL_STORAGE_CLASS
|
231 |
|
|
# define TCL_STORAGE_CLASS DLLIMPORT
|
232 |
|
|
|
233 |
|
|
#endif /* _TKSCALE */
|