annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/tkButton.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 * tkButton.h --
jpayne@69 3 *
jpayne@69 4 * Declarations of types and functions used to implement button-like
jpayne@69 5 * widgets.
jpayne@69 6 *
jpayne@69 7 * Copyright (c) 1996-1998 by Sun Microsystems, Inc.
jpayne@69 8 *
jpayne@69 9 * See the file "license.terms" for information on usage and redistribution of
jpayne@69 10 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
jpayne@69 11 */
jpayne@69 12
jpayne@69 13 #ifndef _TKBUTTON
jpayne@69 14 #define _TKBUTTON
jpayne@69 15
jpayne@69 16 #ifndef _TKINT
jpayne@69 17 #include "tkInt.h"
jpayne@69 18 #endif
jpayne@69 19
jpayne@69 20 /*
jpayne@69 21 * Legal values for the "compound" field of TkButton records.
jpayne@69 22 */
jpayne@69 23
jpayne@69 24 enum compound {
jpayne@69 25 COMPOUND_BOTTOM, COMPOUND_CENTER, COMPOUND_LEFT, COMPOUND_NONE,
jpayne@69 26 COMPOUND_RIGHT, COMPOUND_TOP
jpayne@69 27 };
jpayne@69 28
jpayne@69 29 /*
jpayne@69 30 * Legal values for the "state" field of TkButton records.
jpayne@69 31 */
jpayne@69 32
jpayne@69 33 enum state {
jpayne@69 34 STATE_ACTIVE, STATE_DISABLED, STATE_NORMAL
jpayne@69 35 };
jpayne@69 36
jpayne@69 37 /*
jpayne@69 38 * Legal values for the "defaultState" field of TkButton records.
jpayne@69 39 */
jpayne@69 40
jpayne@69 41 enum defaultState {
jpayne@69 42 DEFAULT_ACTIVE, DEFAULT_DISABLED, DEFAULT_NORMAL
jpayne@69 43 };
jpayne@69 44
jpayne@69 45 /*
jpayne@69 46 * A data structure of the following type is kept for each widget managed by
jpayne@69 47 * this file:
jpayne@69 48 */
jpayne@69 49
jpayne@69 50 typedef struct {
jpayne@69 51 Tk_Window tkwin; /* Window that embodies the button. NULL means
jpayne@69 52 * that the window has been destroyed. */
jpayne@69 53 Display *display; /* Display containing widget. Needed to free
jpayne@69 54 * up resources after tkwin is gone. */
jpayne@69 55 Tcl_Interp *interp; /* Interpreter associated with button. */
jpayne@69 56 Tcl_Command widgetCmd; /* Token for button's widget command. */
jpayne@69 57 int type; /* Type of widget, such as TYPE_LABEL:
jpayne@69 58 * restricts operations that may be performed
jpayne@69 59 * on widget. See below for legal values. */
jpayne@69 60 Tk_OptionTable optionTable; /* Table that defines configuration options
jpayne@69 61 * available for this widget. */
jpayne@69 62
jpayne@69 63 /*
jpayne@69 64 * Information about what's in the button.
jpayne@69 65 */
jpayne@69 66
jpayne@69 67 Tcl_Obj *textPtr; /* Value of -text option: specifies text to
jpayne@69 68 * display in button. */
jpayne@69 69 int underline; /* Value of -underline option: specifies index
jpayne@69 70 * of character to underline. < 0 means don't
jpayne@69 71 * underline anything. */
jpayne@69 72 Tcl_Obj *textVarNamePtr; /* Value of -textvariable option: specifies
jpayne@69 73 * name of variable or NULL. If non-NULL,
jpayne@69 74 * button displays the contents of this
jpayne@69 75 * variable. */
jpayne@69 76 Pixmap bitmap; /* Value of -bitmap option. If not None,
jpayne@69 77 * specifies bitmap to display and text and
jpayne@69 78 * textVar are ignored. */
jpayne@69 79 Tcl_Obj *imagePtr; /* Value of -image option: specifies image to
jpayne@69 80 * display in window, or NULL if none. If
jpayne@69 81 * non-NULL, bitmap, text, and textVarName are
jpayne@69 82 * ignored.*/
jpayne@69 83 Tk_Image image; /* Derived from imagePtr by calling
jpayne@69 84 * Tk_GetImage, or NULL if imagePtr is
jpayne@69 85 * NULL. */
jpayne@69 86 Tcl_Obj *selectImagePtr; /* Value of -selectimage option: specifies
jpayne@69 87 * image to display in window when selected,
jpayne@69 88 * or NULL if none. Ignored if imagePtr is
jpayne@69 89 * NULL. */
jpayne@69 90 Tk_Image selectImage; /* Derived from selectImagePtr by calling
jpayne@69 91 * Tk_GetImage, or NULL if selectImagePtr is
jpayne@69 92 * NULL. */
jpayne@69 93 Tcl_Obj *tristateImagePtr; /* Value of -tristateimage option: specifies
jpayne@69 94 * image to display in window when selected,
jpayne@69 95 * or NULL if none. Ignored if imagePtr is
jpayne@69 96 * NULL. */
jpayne@69 97 Tk_Image tristateImage; /* Derived from tristateImagePtr by calling
jpayne@69 98 * Tk_GetImage, or NULL if tristateImagePtr is
jpayne@69 99 * NULL. */
jpayne@69 100
jpayne@69 101 /*
jpayne@69 102 * Information used when displaying widget:
jpayne@69 103 */
jpayne@69 104
jpayne@69 105 enum state state; /* Value of -state option: specifies state of
jpayne@69 106 * button for display purposes.*/
jpayne@69 107 Tk_3DBorder normalBorder; /* Value of -background option: specifies
jpayne@69 108 * color for background (and border) when
jpayne@69 109 * window isn't active. */
jpayne@69 110 Tk_3DBorder activeBorder; /* Value of -activebackground option: this is
jpayne@69 111 * the color used to draw 3-D border and
jpayne@69 112 * background when widget is active. */
jpayne@69 113 Tcl_Obj *borderWidthPtr; /* Value of -borderWidth option: specifies
jpayne@69 114 * width of border in pixels. */
jpayne@69 115 int borderWidth; /* Integer value corresponding to
jpayne@69 116 * borderWidthPtr. Always >= 0. */
jpayne@69 117 int relief; /* Value of -relief option: specifies 3-d
jpayne@69 118 * effect for border, such as
jpayne@69 119 * TK_RELIEF_RAISED. */
jpayne@69 120 int overRelief; /* Value of -overrelief option: specifies a
jpayne@69 121 * 3-d effect for the border, such as
jpayne@69 122 * TK_RELIEF_RAISED, to be used when the mouse
jpayne@69 123 * is over the button. */
jpayne@69 124 int offRelief; /* Value of -offrelief option: specifies a 3-d
jpayne@69 125 * effect for the border, such as
jpayne@69 126 * TK_RELIEF_RAISED, to be used when a
jpayne@69 127 * checkbutton or radiobutton without
jpayne@69 128 * indicator is off. */
jpayne@69 129 Tcl_Obj *highlightWidthPtr; /* Value of -highlightthickness option:
jpayne@69 130 * specifies width in pixels of highlight to
jpayne@69 131 * draw around widget when it has the focus.
jpayne@69 132 * <= 0 means don't draw a highlight. */
jpayne@69 133 int highlightWidth; /* Integer value corresponding to
jpayne@69 134 * highlightWidthPtr. Always >= 0. */
jpayne@69 135 Tk_3DBorder highlightBorder;/* Value of -highlightbackground option:
jpayne@69 136 * specifies background with which to draw 3-D
jpayne@69 137 * default ring and focus highlight area when
jpayne@69 138 * highlight is off. */
jpayne@69 139 XColor *highlightColorPtr; /* Value of -highlightcolor option: specifies
jpayne@69 140 * color for drawing traversal highlight. */
jpayne@69 141 int inset; /* Total width of all borders, including
jpayne@69 142 * traversal highlight and 3-D border.
jpayne@69 143 * Indicates how much interior stuff must be
jpayne@69 144 * offset from outside edges to leave room for
jpayne@69 145 * borders. */
jpayne@69 146 Tk_Font tkfont; /* Value of -font option: specifies font to
jpayne@69 147 * use for display text. */
jpayne@69 148 XColor *normalFg; /* Value of -font option: specifies foreground
jpayne@69 149 * color in normal mode. */
jpayne@69 150 XColor *activeFg; /* Value of -activeforeground option:
jpayne@69 151 * foreground color in active mode. NULL means
jpayne@69 152 * use -foreground instead. */
jpayne@69 153 XColor *disabledFg; /* Value of -disabledforeground option:
jpayne@69 154 * foreground color when disabled. NULL means
jpayne@69 155 * use normalFg with a 50% stipple instead. */
jpayne@69 156 GC normalTextGC; /* GC for drawing text in normal mode. Also
jpayne@69 157 * used to copy from off-screen pixmap onto
jpayne@69 158 * screen. */
jpayne@69 159 GC activeTextGC; /* GC for drawing text in active mode (NULL
jpayne@69 160 * means use normalTextGC). */
jpayne@69 161 GC disabledGC; /* Used to produce disabled effect for text
jpayne@69 162 * and check/radio marks. */
jpayne@69 163 GC stippleGC; /* Used to produce disabled stipple effect for
jpayne@69 164 * images when disabled. */
jpayne@69 165 Pixmap gray; /* Pixmap for displaying disabled text if
jpayne@69 166 * disabledFg is NULL. */
jpayne@69 167 GC copyGC; /* Used for copying information from an
jpayne@69 168 * off-screen pixmap to the screen. */
jpayne@69 169 Tcl_Obj *widthPtr; /* Value of -width option. */
jpayne@69 170 int width; /* Integer value corresponding to widthPtr. */
jpayne@69 171 Tcl_Obj *heightPtr; /* Value of -height option. */
jpayne@69 172 int height; /* Integer value corresponding to heightPtr. */
jpayne@69 173 Tcl_Obj *wrapLengthPtr; /* Value of -wraplength option: specifies line
jpayne@69 174 * length (in pixels) at which to wrap onto
jpayne@69 175 * next line. <= 0 means don't wrap except at
jpayne@69 176 * newlines. */
jpayne@69 177 int wrapLength; /* Integer value corresponding to
jpayne@69 178 * wrapLengthPtr. */
jpayne@69 179 Tcl_Obj *padXPtr; /* Value of -padx option: specifies how many
jpayne@69 180 * pixels of extra space to leave on left and
jpayne@69 181 * right of text. Ignored for bitmaps and
jpayne@69 182 * images. */
jpayne@69 183 int padX; /* Integer value corresponding to padXPtr. */
jpayne@69 184 Tcl_Obj *padYPtr; /* Value of -padx option: specifies how many
jpayne@69 185 * pixels of extra space to leave above and
jpayne@69 186 * below text. Ignored for bitmaps and
jpayne@69 187 * images. */
jpayne@69 188 int padY; /* Integer value corresponding to padYPtr. */
jpayne@69 189 Tk_Anchor anchor; /* Value of -anchor option: specifies where
jpayne@69 190 * text/bitmap should be displayed inside
jpayne@69 191 * button region. */
jpayne@69 192 Tk_Justify justify; /* Value of -justify option: specifies how to
jpayne@69 193 * align lines of multi-line text. */
jpayne@69 194 int indicatorOn; /* Value of -indicatoron option: 1 means draw
jpayne@69 195 * indicator in checkbuttons and radiobuttons,
jpayne@69 196 * 0 means don't draw it. */
jpayne@69 197 Tk_3DBorder selectBorder; /* Value of -selectcolor option: specifies
jpayne@69 198 * color for drawing indicator background, or
jpayne@69 199 * perhaps widget background, when
jpayne@69 200 * selected. */
jpayne@69 201 int textWidth; /* Width needed to display text as requested,
jpayne@69 202 * in pixels. */
jpayne@69 203 int textHeight; /* Height needed to display text as requested,
jpayne@69 204 * in pixels. */
jpayne@69 205 Tk_TextLayout textLayout; /* Saved text layout information. */
jpayne@69 206 int indicatorSpace; /* Horizontal space (in pixels) allocated for
jpayne@69 207 * display of indicator. */
jpayne@69 208 int indicatorDiameter; /* Diameter of indicator, in pixels. */
jpayne@69 209 enum defaultState defaultState;
jpayne@69 210 /* Value of -default option, such as
jpayne@69 211 * DEFAULT_NORMAL: specifies state of default
jpayne@69 212 * ring for buttons (normal, active, or
jpayne@69 213 * disabled). NULL for other classes. */
jpayne@69 214
jpayne@69 215 /*
jpayne@69 216 * For check and radio buttons, the fields below are used to manage the
jpayne@69 217 * variable indicating the button's state.
jpayne@69 218 */
jpayne@69 219
jpayne@69 220 Tcl_Obj *selVarNamePtr; /* Value of -variable option: specifies name
jpayne@69 221 * of variable used to control selected state
jpayne@69 222 * of button. */
jpayne@69 223 Tcl_Obj *onValuePtr; /* Value of -offvalue option: specifies value
jpayne@69 224 * to store in variable when this button is
jpayne@69 225 * selected. */
jpayne@69 226 Tcl_Obj *offValuePtr; /* Value of -offvalue option: specifies value
jpayne@69 227 * to store in variable when this button isn't
jpayne@69 228 * selected. Used only by checkbuttons. */
jpayne@69 229 Tcl_Obj *tristateValuePtr; /* Value of -tristatevalue option: specifies
jpayne@69 230 * value to display Tristate or Multivalue
jpayne@69 231 * mode when variable matches this value.
jpayne@69 232 * Used by check- buttons. */
jpayne@69 233
jpayne@69 234 /*
jpayne@69 235 * Miscellaneous information:
jpayne@69 236 */
jpayne@69 237
jpayne@69 238 Tk_Cursor cursor; /* Value of -cursor option: if not NULL,
jpayne@69 239 * specifies current cursor for window. */
jpayne@69 240 Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the
jpayne@69 241 * C code, but used by keyboard traversal
jpayne@69 242 * scripts. */
jpayne@69 243 Tcl_Obj *commandPtr; /* Value of -command option: specifies script
jpayne@69 244 * to execute when button is invoked. If
jpayne@69 245 * widget is label or has no command, this is
jpayne@69 246 * NULL. */
jpayne@69 247 int compound; /* Value of -compound option; specifies
jpayne@69 248 * whether the button should show both an
jpayne@69 249 * image and text, and, if so, how. */
jpayne@69 250 int repeatDelay; /* Value of -repeatdelay option; specifies the
jpayne@69 251 * number of ms after which the button will
jpayne@69 252 * start to auto-repeat its command. */
jpayne@69 253 int repeatInterval; /* Value of -repeatinterval option; specifies
jpayne@69 254 * the number of ms between auto-repeat
jpayne@69 255 * invocataions of the button command. */
jpayne@69 256 int flags; /* Various flags; see below for
jpayne@69 257 * definitions. */
jpayne@69 258 } TkButton;
jpayne@69 259
jpayne@69 260 /*
jpayne@69 261 * Possible "type" values for buttons. These are the kinds of widgets
jpayne@69 262 * supported by this file. The ordering of the type numbers is significant:
jpayne@69 263 * greater means more features and is used in the code.
jpayne@69 264 */
jpayne@69 265
jpayne@69 266 #define TYPE_LABEL 0
jpayne@69 267 #define TYPE_BUTTON 1
jpayne@69 268 #define TYPE_CHECK_BUTTON 2
jpayne@69 269 #define TYPE_RADIO_BUTTON 3
jpayne@69 270
jpayne@69 271 /*
jpayne@69 272 * Flag bits for buttons:
jpayne@69 273 *
jpayne@69 274 * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has
jpayne@69 275 * already been queued to redraw this window.
jpayne@69 276 * SELECTED: Non-zero means this button is selected, so
jpayne@69 277 * special highlight should be drawn.
jpayne@69 278 * GOT_FOCUS: Non-zero means this button currently has the
jpayne@69 279 * input focus.
jpayne@69 280 * BUTTON_DELETED: Non-zero needs that this button has been
jpayne@69 281 * deleted, or is in the process of being deleted
jpayne@69 282 */
jpayne@69 283
jpayne@69 284 #define REDRAW_PENDING (1 << 0)
jpayne@69 285 #define SELECTED (1 << 1)
jpayne@69 286 #define GOT_FOCUS (1 << 2)
jpayne@69 287 #define BUTTON_DELETED (1 << 3)
jpayne@69 288 #define TRISTATED (1 << 4)
jpayne@69 289
jpayne@69 290 /*
jpayne@69 291 * Declaration of button class functions structure
jpayne@69 292 * and button/label defaults, for use in optionSpecs.
jpayne@69 293 */
jpayne@69 294
jpayne@69 295 MODULE_SCOPE const Tk_ClassProcs tkpButtonProcs;
jpayne@69 296 MODULE_SCOPE char tkDefButtonHighlightWidth[TCL_INTEGER_SPACE];
jpayne@69 297 MODULE_SCOPE char tkDefButtonPadx[TCL_INTEGER_SPACE];
jpayne@69 298 MODULE_SCOPE char tkDefButtonPady[TCL_INTEGER_SPACE];
jpayne@69 299 MODULE_SCOPE char tkDefButtonBorderWidth[TCL_INTEGER_SPACE];
jpayne@69 300 MODULE_SCOPE char tkDefLabelHighlightWidth[TCL_INTEGER_SPACE];
jpayne@69 301 MODULE_SCOPE char tkDefLabelPadx[TCL_INTEGER_SPACE];
jpayne@69 302 MODULE_SCOPE char tkDefLabelPady[TCL_INTEGER_SPACE];
jpayne@69 303
jpayne@69 304 /*
jpayne@69 305 * Declaration of functions used in the implementation of the button widget.
jpayne@69 306 */
jpayne@69 307
jpayne@69 308 #ifndef TkpButtonSetDefaults
jpayne@69 309 MODULE_SCOPE void TkpButtonSetDefaults(void);
jpayne@69 310 #endif
jpayne@69 311 MODULE_SCOPE void TkButtonWorldChanged(ClientData instanceData);
jpayne@69 312 MODULE_SCOPE void TkpComputeButtonGeometry(TkButton *butPtr);
jpayne@69 313 MODULE_SCOPE TkButton *TkpCreateButton(Tk_Window tkwin);
jpayne@69 314 #ifndef TkpDestroyButton
jpayne@69 315 MODULE_SCOPE void TkpDestroyButton(TkButton *butPtr);
jpayne@69 316 #endif
jpayne@69 317 #ifndef TkpDisplayButton
jpayne@69 318 MODULE_SCOPE void TkpDisplayButton(ClientData clientData);
jpayne@69 319 #endif
jpayne@69 320 MODULE_SCOPE int TkInvokeButton(TkButton *butPtr);
jpayne@69 321
jpayne@69 322 #endif /* _TKBUTTON */