Mercurial > repos > rliterman > csp2
comparison CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/tkEntry.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 * tkEntry.h -- | |
3 * | |
4 * This module defined the structures for the Entry & SpinBox widgets. | |
5 * | |
6 * See the file "license.terms" for information on usage and redistribution of | |
7 * this file, and for a DISCLAIMER OF ALL WARRANTIES. | |
8 * | |
9 * Copyright (c) 2002 Apple Inc. | |
10 */ | |
11 | |
12 #ifndef _TKENTRY | |
13 #define _TKENTRY | |
14 | |
15 #ifndef _TKINT | |
16 #include "tkInt.h" | |
17 #endif | |
18 | |
19 enum EntryType { | |
20 TK_ENTRY, TK_SPINBOX | |
21 }; | |
22 | |
23 /* | |
24 * A data structure of the following type is kept for each Entry widget | |
25 * managed by this file: | |
26 */ | |
27 | |
28 typedef struct { | |
29 Tk_Window tkwin; /* Window that embodies the entry. NULL means | |
30 * that the window has been destroyed but the | |
31 * data structures haven't yet been cleaned | |
32 * up.*/ | |
33 Display *display; /* Display containing widget. Used, among | |
34 * other things, so that resources can be | |
35 * freed even after tkwin has gone away. */ | |
36 Tcl_Interp *interp; /* Interpreter associated with entry. */ | |
37 Tcl_Command widgetCmd; /* Token for entry's widget command. */ | |
38 Tk_OptionTable optionTable; /* Table that defines configuration options | |
39 * available for this widget. */ | |
40 enum EntryType type; /* Specialized type of Entry widget */ | |
41 | |
42 /* | |
43 * Fields that are set by widget commands other than "configure". | |
44 */ | |
45 | |
46 const char *string; /* Pointer to storage for string; | |
47 * NULL-terminated; malloc-ed. */ | |
48 int insertPos; /* Character index before which next typed | |
49 * character will be inserted. */ | |
50 | |
51 /* | |
52 * Information about what's selected, if any. | |
53 */ | |
54 | |
55 int selectFirst; /* Character index of first selected character | |
56 * (-1 means nothing selected. */ | |
57 int selectLast; /* Character index just after last selected | |
58 * character (-1 means nothing selected. */ | |
59 int selectAnchor; /* Fixed end of selection (i.e. "select to" | |
60 * operation will use this as one end of the | |
61 * selection). */ | |
62 | |
63 /* | |
64 * Information for scanning: | |
65 */ | |
66 | |
67 int scanMarkX; /* X-position at which scan started (e.g. | |
68 * button was pressed here). */ | |
69 int scanMarkIndex; /* Character index of character that was at | |
70 * left of window when scan started. */ | |
71 | |
72 /* | |
73 * Configuration settings that are updated by Tk_ConfigureWidget. | |
74 */ | |
75 | |
76 Tk_3DBorder normalBorder; /* Used for drawing border around whole | |
77 * window, plus used for background. */ | |
78 Tk_3DBorder disabledBorder; /* Used for drawing border around whole window | |
79 * in disabled state, plus used for | |
80 * background. */ | |
81 Tk_3DBorder readonlyBorder; /* Used for drawing border around whole window | |
82 * in readonly state, plus used for | |
83 * background. */ | |
84 int borderWidth; /* Width of 3-D border around window. */ | |
85 Tk_Cursor cursor; /* Current cursor for window, or NULL. */ | |
86 int exportSelection; /* Non-zero means tie internal entry selection | |
87 * to X selection. */ | |
88 Tk_Font tkfont; /* Information about text font, or NULL. */ | |
89 XColor *fgColorPtr; /* Text color in normal mode. */ | |
90 XColor *dfgColorPtr; /* Text color in disabled mode. */ | |
91 XColor *highlightBgColorPtr;/* Color for drawing traversal highlight area | |
92 * when highlight is off. */ | |
93 XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ | |
94 int highlightWidth; /* Width in pixels of highlight to draw around | |
95 * widget when it has the focus. <= 0 means | |
96 * don't draw a highlight. */ | |
97 Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion | |
98 * cursor. */ | |
99 int insertBorderWidth; /* Width of 3-D border around insert cursor. */ | |
100 int insertOffTime; /* Number of milliseconds cursor should spend | |
101 * in "off" state for each blink. */ | |
102 int insertOnTime; /* Number of milliseconds cursor should spend | |
103 * in "on" state for each blink. */ | |
104 int insertWidth; /* Total width of insert cursor. */ | |
105 Tk_Justify justify; /* Justification to use for text within | |
106 * window. */ | |
107 int relief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ | |
108 Tk_3DBorder selBorder; /* Border and background for selected | |
109 * characters. */ | |
110 int selBorderWidth; /* Width of border around selection. */ | |
111 XColor *selFgColorPtr; /* Foreground color for selected text. */ | |
112 int state; /* Normal or disabled. Entry is read-only when | |
113 * disabled. */ | |
114 char *textVarName; /* Name of variable (malloc'ed) or NULL. If | |
115 * non-NULL, entry's string tracks the | |
116 * contents of this variable and vice | |
117 * versa. */ | |
118 char *takeFocus; /* Value of -takefocus option; not used in the | |
119 * C code, but used by keyboard traversal | |
120 * scripts. Malloc'ed, but may be NULL. */ | |
121 int prefWidth; /* Desired width of window, measured in | |
122 * average characters. */ | |
123 char *scrollCmd; /* Command prefix for communicating with | |
124 * scrollbar(s). Malloc'ed. NULL means no | |
125 * command to issue. */ | |
126 char *showChar; /* Value of -show option. If non-NULL, first | |
127 * character is used for displaying all | |
128 * characters in entry. Malloc'ed. This is | |
129 * only used by the Entry widget. */ | |
130 | |
131 /* | |
132 * Fields whose values are derived from the current values of the | |
133 * configuration settings above. | |
134 */ | |
135 | |
136 const char *displayString; /* String to use when displaying. This may be | |
137 * a pointer to string, or a pointer to | |
138 * malloced memory with the same character | |
139 * length as string but whose characters are | |
140 * all equal to showChar. */ | |
141 int numBytes; /* Length of string in bytes. */ | |
142 int numChars; /* Length of string in characters. Both string | |
143 * and displayString have the same character | |
144 * length, but may have different byte lengths | |
145 * due to being made from different UTF-8 | |
146 * characters. */ | |
147 int numDisplayBytes; /* Length of displayString in bytes. */ | |
148 int inset; /* Number of pixels on the left and right | |
149 * sides that are taken up by XPAD, | |
150 * borderWidth (if any), and highlightWidth | |
151 * (if any). */ | |
152 Tk_TextLayout textLayout; /* Cached text layout information. */ | |
153 int layoutX, layoutY; /* Origin for layout. */ | |
154 int leftX; /* X position at which character at leftIndex | |
155 * is drawn (varies depending on justify). */ | |
156 int leftIndex; /* Character index of left-most character | |
157 * visible in window. */ | |
158 Tcl_TimerToken insertBlinkHandler; | |
159 /* Timer handler used to blink cursor on and | |
160 * off. */ | |
161 GC textGC; /* For drawing normal text. */ | |
162 GC selTextGC; /* For drawing selected text. */ | |
163 GC highlightGC; /* For drawing traversal highlight. */ | |
164 int avgWidth; /* Width of average character. */ | |
165 int xWidth; /* Extra width to reserve for widget. Used by | |
166 * spinboxes for button space. */ | |
167 int flags; /* Miscellaneous flags; see below for | |
168 * definitions. */ | |
169 | |
170 int validate; /* Non-zero means try to validate */ | |
171 char *validateCmd; /* Command prefix to use when invoking | |
172 * validate command. NULL means don't invoke | |
173 * commands. Malloc'ed. */ | |
174 char *invalidCmd; /* Command called when a validation returns 0 | |
175 * (successfully fails), defaults to {}. */ | |
176 } Entry; | |
177 | |
178 /* | |
179 * A data structure of the following type is kept for each spinbox widget | |
180 * managed by this file: | |
181 */ | |
182 | |
183 typedef struct { | |
184 Entry entry; /* A pointer to the generic entry structure. | |
185 * This must be the first element of the | |
186 * Spinbox. */ | |
187 | |
188 /* | |
189 * Spinbox specific configuration settings. | |
190 */ | |
191 | |
192 Tk_3DBorder activeBorder; /* Used for drawing border around active | |
193 * buttons. */ | |
194 Tk_3DBorder buttonBorder; /* Used for drawing border around buttons. */ | |
195 Tk_Cursor bCursor; /* cursor for buttons, or NULL. */ | |
196 int bdRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ | |
197 int buRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ | |
198 char *command; /* Command to invoke for spin buttons. NULL | |
199 * means no command to issue. */ | |
200 | |
201 /* | |
202 * Spinbox specific fields for use with configuration settings above. | |
203 */ | |
204 | |
205 int wrap; /* whether to wrap around when spinning */ | |
206 | |
207 int selElement; /* currently selected control */ | |
208 int curElement; /* currently mouseover control */ | |
209 | |
210 int repeatDelay; /* repeat delay */ | |
211 int repeatInterval; /* repeat interval */ | |
212 | |
213 double fromValue; /* Value corresponding to left/top of dial */ | |
214 double toValue; /* Value corresponding to right/bottom of | |
215 * dial */ | |
216 double increment; /* If > 0, all values are rounded to an even | |
217 * multiple of this value. */ | |
218 char *formatBuf; /* string into which to format value. | |
219 * Malloc'ed. */ | |
220 char *reqFormat; /* Sprintf conversion specifier used for the | |
221 * value that the users requests. Malloc'ed */ | |
222 char *valueFormat; /* Sprintf conversion specifier used for the | |
223 * value. */ | |
224 char digitFormat[16]; /* Sprintf conversion specifier computed from | |
225 * digits and other information; used for the | |
226 * value. */ | |
227 | |
228 char *valueStr; /* Values List. Malloc'ed. */ | |
229 Tcl_Obj *listObj; /* Pointer to the list object being used */ | |
230 int eIndex; /* Holds the current index into elements */ | |
231 int nElements; /* Holds the current count of elements */ | |
232 } Spinbox; | |
233 | |
234 /* | |
235 * Assigned bits of "flags" fields of Entry structures, and what those bits | |
236 * mean: | |
237 * | |
238 * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has | |
239 * already been queued to redisplay the entry. | |
240 * BORDER_NEEDED: Non-zero means 3-D border must be redrawn | |
241 * around window during redisplay. Normally only | |
242 * text portion needs to be redrawn. | |
243 * CURSOR_ON: Non-zero means insert cursor is displayed at | |
244 * present. 0 means it isn't displayed. | |
245 * GOT_FOCUS: Non-zero means this window has the input | |
246 * focus. | |
247 * UPDATE_SCROLLBAR: Non-zero means scrollbar should be updated | |
248 * during next redisplay operation. | |
249 * GOT_SELECTION: Non-zero means we've claimed the selection. | |
250 * ENTRY_DELETED: This entry has been effectively destroyed. | |
251 * VALIDATING: Non-zero means we are in a validateCmd | |
252 * VALIDATE_VAR: Non-zero means we are attempting to validate | |
253 * the entry's textvariable with validateCmd | |
254 * VALIDATE_ABORT: Non-zero if validatecommand signals an abort | |
255 * for current procedure and make no changes | |
256 * ENTRY_VAR_TRACED: Non-zero if a var trace is set. | |
257 */ | |
258 | |
259 #define REDRAW_PENDING 1 | |
260 #define BORDER_NEEDED 2 | |
261 #define CURSOR_ON 4 | |
262 #define GOT_FOCUS 8 | |
263 #define UPDATE_SCROLLBAR 0x10 | |
264 #define GOT_SELECTION 0x20 | |
265 #define ENTRY_DELETED 0x40 | |
266 #define VALIDATING 0x80 | |
267 #define VALIDATE_VAR 0x100 | |
268 #define VALIDATE_ABORT 0x200 | |
269 #define ENTRY_VAR_TRACED 0x400 | |
270 | |
271 /* | |
272 * The following enum is used to define a type for the -state option of the | |
273 * Entry widget. These values are used as indices into the string table below. | |
274 */ | |
275 | |
276 enum state { | |
277 STATE_DISABLED, STATE_NORMAL, STATE_READONLY | |
278 }; | |
279 | |
280 /* | |
281 * This is the element index corresponding to the strings in selElementNames. | |
282 * If you modify them, you must modify the numbers here. | |
283 */ | |
284 | |
285 enum selelement { | |
286 SEL_NONE, SEL_BUTTONDOWN, SEL_BUTTONUP, SEL_NULL, SEL_ENTRY | |
287 }; | |
288 | |
289 /* | |
290 * Declaration of functions used in the implementation of the native side of | |
291 * the Entry widget. | |
292 */ | |
293 | |
294 MODULE_SCOPE int TkpDrawEntryBorderAndFocus(Entry *entryPtr, | |
295 Drawable d, int isSpinbox); | |
296 MODULE_SCOPE int TkpDrawSpinboxButtons(Spinbox *sbPtr, Drawable d); | |
297 | |
298 #endif /* _TKENTRY */ |