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