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