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