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