1 |
578 |
markom |
/*
|
2 |
|
|
* tkButton.h --
|
3 |
|
|
*
|
4 |
|
|
* Declarations of types and functions used to implement
|
5 |
|
|
* button-like widgets.
|
6 |
|
|
*
|
7 |
|
|
* Copyright (c) 1996 by Sun Microsystems, Inc.
|
8 |
|
|
*
|
9 |
|
|
* See the file "license.terms" for information on usage and redistribution
|
10 |
|
|
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
11 |
|
|
*
|
12 |
|
|
* RCS: @(#) $Id: tkButton.h,v 1.1.1.1 2002-01-16 10:25:50 markom Exp $
|
13 |
|
|
*/
|
14 |
|
|
|
15 |
|
|
#ifndef _TKBUTTON
|
16 |
|
|
#define _TKBUTTON
|
17 |
|
|
|
18 |
|
|
#ifndef _TKINT
|
19 |
|
|
#include "tkInt.h"
|
20 |
|
|
#endif
|
21 |
|
|
|
22 |
|
|
#ifdef BUILD_tk
|
23 |
|
|
# undef TCL_STORAGE_CLASS
|
24 |
|
|
# define TCL_STORAGE_CLASS DLLEXPORT
|
25 |
|
|
#endif
|
26 |
|
|
|
27 |
|
|
/*
|
28 |
|
|
* A data structure of the following type is kept for each
|
29 |
|
|
* widget managed by this file:
|
30 |
|
|
*/
|
31 |
|
|
|
32 |
|
|
typedef struct {
|
33 |
|
|
Tk_Window tkwin; /* Window that embodies the button. NULL
|
34 |
|
|
* means that the window has been destroyed. */
|
35 |
|
|
Display *display; /* Display containing widget. Needed to
|
36 |
|
|
* free up resources after tkwin is gone. */
|
37 |
|
|
Tcl_Interp *interp; /* Interpreter associated with button. */
|
38 |
|
|
Tcl_Command widgetCmd; /* Token for button's widget command. */
|
39 |
|
|
int type; /* Type of widget: restricts operations
|
40 |
|
|
* that may be performed on widget. See
|
41 |
|
|
* below for possible values. */
|
42 |
|
|
|
43 |
|
|
/*
|
44 |
|
|
* Information about what's in the button.
|
45 |
|
|
*/
|
46 |
|
|
|
47 |
|
|
char *text; /* Text to display in button (malloc'ed)
|
48 |
|
|
* or NULL. */
|
49 |
|
|
int underline; /* Index of character to underline. < 0 means
|
50 |
|
|
* don't underline anything. */
|
51 |
|
|
char *textVarName; /* Name of variable (malloc'ed) or NULL.
|
52 |
|
|
* If non-NULL, button displays the contents
|
53 |
|
|
* of this variable. */
|
54 |
|
|
Pixmap bitmap; /* Bitmap to display or None. If not None
|
55 |
|
|
* then text and textVar are ignored. */
|
56 |
|
|
char *imageString; /* Name of image to display (malloc'ed), or
|
57 |
|
|
* NULL. If non-NULL, bitmap, text, and
|
58 |
|
|
* textVarName are ignored. */
|
59 |
|
|
Tk_Image image; /* Image to display in window, or NULL if
|
60 |
|
|
* none. */
|
61 |
|
|
char *selectImageString; /* Name of image to display when selected
|
62 |
|
|
* (malloc'ed), or NULL. */
|
63 |
|
|
Tk_Image selectImage; /* Image to display in window when selected,
|
64 |
|
|
* or NULL if none. Ignored if image is
|
65 |
|
|
* NULL. */
|
66 |
|
|
|
67 |
|
|
/*
|
68 |
|
|
* Information used when displaying widget:
|
69 |
|
|
*/
|
70 |
|
|
|
71 |
|
|
Tk_Uid state; /* State of button for display purposes:
|
72 |
|
|
* normal, active, or disabled. */
|
73 |
|
|
Tk_3DBorder normalBorder; /* Structure used to draw 3-D
|
74 |
|
|
* border and background when window
|
75 |
|
|
* isn't active. NULL means no such
|
76 |
|
|
* border exists. */
|
77 |
|
|
Tk_3DBorder activeBorder; /* Structure used to draw 3-D
|
78 |
|
|
* border and background when window
|
79 |
|
|
* is active. NULL means no such
|
80 |
|
|
* border exists. */
|
81 |
|
|
int borderWidth; /* Width of border. */
|
82 |
|
|
int relief; /* 3-d effect: TK_RELIEF_RAISED, etc. */
|
83 |
|
|
int highlightWidth; /* Width in pixels of highlight to draw
|
84 |
|
|
* around widget when it has the focus.
|
85 |
|
|
* <= 0 means don't draw a highlight. */
|
86 |
|
|
Tk_3DBorder highlightBorder;
|
87 |
|
|
/* Structure used to draw 3-D default ring
|
88 |
|
|
* and focus highlight area when highlight
|
89 |
|
|
* is off. */
|
90 |
|
|
XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
|
91 |
|
|
|
92 |
|
|
int inset; /* Total width of all borders, including
|
93 |
|
|
* traversal highlight and 3-D border.
|
94 |
|
|
* Indicates how much interior stuff must
|
95 |
|
|
* be offset from outside edges to leave
|
96 |
|
|
* room for borders. */
|
97 |
|
|
Tk_Font tkfont; /* Information about text font, or NULL. */
|
98 |
|
|
XColor *normalFg; /* Foreground color in normal mode. */
|
99 |
|
|
XColor *activeFg; /* Foreground color in active mode. NULL
|
100 |
|
|
* means use normalFg instead. */
|
101 |
|
|
XColor *disabledFg; /* Foreground color when disabled. NULL
|
102 |
|
|
* means use normalFg with a 50% stipple
|
103 |
|
|
* instead. */
|
104 |
|
|
GC normalTextGC; /* GC for drawing text in normal mode. Also
|
105 |
|
|
* used to copy from off-screen pixmap onto
|
106 |
|
|
* screen. */
|
107 |
|
|
GC activeTextGC; /* GC for drawing text in active mode (NULL
|
108 |
|
|
* means use normalTextGC). */
|
109 |
|
|
Pixmap gray; /* Pixmap for displaying disabled text if
|
110 |
|
|
* disabledFg is NULL. */
|
111 |
|
|
GC disabledGC; /* Used to produce disabled effect. If
|
112 |
|
|
* disabledFg isn't NULL, this GC is used to
|
113 |
|
|
* draw button text or icon. Otherwise
|
114 |
|
|
* text or icon is drawn with normalGC and
|
115 |
|
|
* this GC is used to stipple background
|
116 |
|
|
* across it. For labels this is None. */
|
117 |
|
|
GC copyGC; /* Used for copying information from an
|
118 |
|
|
* off-screen pixmap to the screen. */
|
119 |
|
|
char *widthString; /* Value of -width option. Malloc'ed. */
|
120 |
|
|
char *heightString; /* Value of -height option. Malloc'ed. */
|
121 |
|
|
int width, height; /* If > 0, these specify dimensions to request
|
122 |
|
|
* for window, in characters for text and in
|
123 |
|
|
* pixels for bitmaps. In this case the actual
|
124 |
|
|
* size of the text string or bitmap is
|
125 |
|
|
* ignored in computing desired window size. */
|
126 |
|
|
int wrapLength; /* Line length (in pixels) at which to wrap
|
127 |
|
|
* onto next line. <= 0 means don't wrap
|
128 |
|
|
* except at newlines. */
|
129 |
|
|
int padX, padY; /* Extra space around text (pixels to leave
|
130 |
|
|
* on each side). Ignored for bitmaps and
|
131 |
|
|
* images. */
|
132 |
|
|
Tk_Anchor anchor; /* Where text/bitmap should be displayed
|
133 |
|
|
* inside button region. */
|
134 |
|
|
Tk_Justify justify; /* Justification to use for multi-line text. */
|
135 |
|
|
int indicatorOn; /* True means draw indicator, false means
|
136 |
|
|
* don't draw it. */
|
137 |
|
|
Tk_3DBorder selectBorder; /* For drawing indicator background, or perhaps
|
138 |
|
|
* widget background, when selected. */
|
139 |
|
|
int textWidth; /* Width needed to display text as requested,
|
140 |
|
|
* in pixels. */
|
141 |
|
|
int textHeight; /* Height needed to display text as requested,
|
142 |
|
|
* in pixels. */
|
143 |
|
|
Tk_TextLayout textLayout; /* Saved text layout information. */
|
144 |
|
|
int indicatorSpace; /* Horizontal space (in pixels) allocated for
|
145 |
|
|
* display of indicator. */
|
146 |
|
|
int indicatorDiameter; /* Diameter of indicator, in pixels. */
|
147 |
|
|
Tk_Uid defaultState; /* State of default ring: normal, active, or
|
148 |
|
|
* disabled. */
|
149 |
|
|
|
150 |
|
|
/*
|
151 |
|
|
* For check and radio buttons, the fields below are used
|
152 |
|
|
* to manage the variable indicating the button's state.
|
153 |
|
|
*/
|
154 |
|
|
|
155 |
|
|
char *selVarName; /* Name of variable used to control selected
|
156 |
|
|
* state of button. Malloc'ed (if
|
157 |
|
|
* not NULL). */
|
158 |
|
|
char *onValue; /* Value to store in variable when
|
159 |
|
|
* this button is selected. Malloc'ed (if
|
160 |
|
|
* not NULL). */
|
161 |
|
|
char *offValue; /* Value to store in variable when this
|
162 |
|
|
* button isn't selected. Malloc'ed
|
163 |
|
|
* (if not NULL). Valid only for check
|
164 |
|
|
* buttons. */
|
165 |
|
|
|
166 |
|
|
/*
|
167 |
|
|
* Miscellaneous information:
|
168 |
|
|
*/
|
169 |
|
|
|
170 |
|
|
Tk_Cursor cursor; /* Current cursor for window, or None. */
|
171 |
|
|
char *takeFocus; /* Value of -takefocus option; not used in
|
172 |
|
|
* the C code, but used by keyboard traversal
|
173 |
|
|
* scripts. Malloc'ed, but may be NULL. */
|
174 |
|
|
char *command; /* Command to execute when button is
|
175 |
|
|
* invoked; valid for buttons only.
|
176 |
|
|
* If not NULL, it's malloc-ed. */
|
177 |
|
|
int flags; /* Various flags; see below for
|
178 |
|
|
* definitions. */
|
179 |
|
|
} TkButton;
|
180 |
|
|
|
181 |
|
|
/*
|
182 |
|
|
* Possible "type" values for buttons. These are the kinds of
|
183 |
|
|
* widgets supported by this file. The ordering of the type
|
184 |
|
|
* numbers is significant: greater means more features and is
|
185 |
|
|
* used in the code.
|
186 |
|
|
*/
|
187 |
|
|
|
188 |
|
|
#define TYPE_LABEL 0
|
189 |
|
|
#define TYPE_BUTTON 1
|
190 |
|
|
#define TYPE_CHECK_BUTTON 2
|
191 |
|
|
#define TYPE_RADIO_BUTTON 3
|
192 |
|
|
|
193 |
|
|
/*
|
194 |
|
|
* Flag bits for buttons:
|
195 |
|
|
*
|
196 |
|
|
* REDRAW_PENDING: Non-zero means a DoWhenIdle handler
|
197 |
|
|
* has already been queued to redraw
|
198 |
|
|
* this window.
|
199 |
|
|
* SELECTED: Non-zero means this button is selected,
|
200 |
|
|
* so special highlight should be drawn.
|
201 |
|
|
* GOT_FOCUS: Non-zero means this button currently
|
202 |
|
|
* has the input focus.
|
203 |
|
|
*/
|
204 |
|
|
|
205 |
|
|
#define REDRAW_PENDING 1
|
206 |
|
|
#define SELECTED 2
|
207 |
|
|
#define GOT_FOCUS 4
|
208 |
|
|
|
209 |
|
|
/*
|
210 |
|
|
* Mask values used to selectively enable entries in the
|
211 |
|
|
* configuration specs:
|
212 |
|
|
*/
|
213 |
|
|
|
214 |
|
|
#define LABEL_MASK TK_CONFIG_USER_BIT
|
215 |
|
|
#define BUTTON_MASK TK_CONFIG_USER_BIT << 1
|
216 |
|
|
#define CHECK_BUTTON_MASK TK_CONFIG_USER_BIT << 2
|
217 |
|
|
#define RADIO_BUTTON_MASK TK_CONFIG_USER_BIT << 3
|
218 |
|
|
#define ALL_MASK (LABEL_MASK | BUTTON_MASK \
|
219 |
|
|
| CHECK_BUTTON_MASK | RADIO_BUTTON_MASK)
|
220 |
|
|
|
221 |
|
|
/*
|
222 |
|
|
* Declaration of variables shared between the files in the button module.
|
223 |
|
|
*/
|
224 |
|
|
|
225 |
|
|
extern TkClassProcs tkpButtonProcs;
|
226 |
|
|
extern Tk_ConfigSpec tkpButtonConfigSpecs[];
|
227 |
|
|
|
228 |
|
|
/*
|
229 |
|
|
* Declaration of procedures used in the implementation of the button
|
230 |
|
|
* widget.
|
231 |
|
|
*/
|
232 |
|
|
|
233 |
|
|
EXTERN void TkButtonWorldChanged _ANSI_ARGS_((
|
234 |
|
|
ClientData instanceData));
|
235 |
|
|
EXTERN void TkpComputeButtonGeometry _ANSI_ARGS_((
|
236 |
|
|
TkButton *butPtr));
|
237 |
|
|
EXTERN TkButton * TkpCreateButton _ANSI_ARGS_((Tk_Window tkwin));
|
238 |
|
|
#ifndef TkpDestroyButton
|
239 |
|
|
EXTERN void TkpDestroyButton _ANSI_ARGS_((TkButton *butPtr));
|
240 |
|
|
#endif
|
241 |
|
|
#ifndef TkpDisplayButton
|
242 |
|
|
EXTERN void TkpDisplayButton _ANSI_ARGS_((ClientData clientData));
|
243 |
|
|
#endif
|
244 |
|
|
EXTERN int TkInvokeButton _ANSI_ARGS_((TkButton *butPtr));
|
245 |
|
|
|
246 |
|
|
# undef TCL_STORAGE_CLASS
|
247 |
|
|
# define TCL_STORAGE_CLASS DLLIMPORT
|
248 |
|
|
|
249 |
|
|
#endif /* _TKBUTTON */
|