jpayne@69
|
1 /*
|
jpayne@69
|
2 * tkMenu.h --
|
jpayne@69
|
3 *
|
jpayne@69
|
4 * Declarations shared among all of the files that implement menu
|
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 _TKMENU
|
jpayne@69
|
14 #define _TKMENU
|
jpayne@69
|
15
|
jpayne@69
|
16 #ifndef _TKINT
|
jpayne@69
|
17 #include "tkInt.h"
|
jpayne@69
|
18 #endif
|
jpayne@69
|
19
|
jpayne@69
|
20 #ifndef _DEFAULT
|
jpayne@69
|
21 #include "default.h"
|
jpayne@69
|
22 #endif
|
jpayne@69
|
23
|
jpayne@69
|
24 /*
|
jpayne@69
|
25 * Dummy types used by the platform menu code.
|
jpayne@69
|
26 */
|
jpayne@69
|
27
|
jpayne@69
|
28 typedef struct TkMenuPlatformData_ *TkMenuPlatformData;
|
jpayne@69
|
29 typedef struct TkMenuPlatformEntryData_ *TkMenuPlatformEntryData;
|
jpayne@69
|
30
|
jpayne@69
|
31 /*
|
jpayne@69
|
32 * Legal values for the "compound" field of TkMenuEntry and TkMenuButton
|
jpayne@69
|
33 * records.
|
jpayne@69
|
34 */
|
jpayne@69
|
35
|
jpayne@69
|
36 enum compound {
|
jpayne@69
|
37 COMPOUND_BOTTOM, COMPOUND_CENTER, COMPOUND_LEFT, COMPOUND_NONE,
|
jpayne@69
|
38 COMPOUND_RIGHT, COMPOUND_TOP
|
jpayne@69
|
39 };
|
jpayne@69
|
40
|
jpayne@69
|
41 /*
|
jpayne@69
|
42 * Additional menu entry drawing parameters for Windows platform.
|
jpayne@69
|
43 * DRAW_MENU_ENTRY_ARROW makes TkpDrawMenuEntry draw the arrow
|
jpayne@69
|
44 * itself when cascade entry is disabled.
|
jpayne@69
|
45 * DRAW_MENU_ENTRY_NOUNDERLINE forbids underline when ODS_NOACCEL
|
jpayne@69
|
46 * is set, thus obeying the system-wide Windows UI setting.
|
jpayne@69
|
47 */
|
jpayne@69
|
48
|
jpayne@69
|
49 enum drawingParameters {
|
jpayne@69
|
50 DRAW_MENU_ENTRY_ARROW = (1<<0),
|
jpayne@69
|
51 DRAW_MENU_ENTRY_NOUNDERLINE = (1<<1)
|
jpayne@69
|
52 };
|
jpayne@69
|
53
|
jpayne@69
|
54 /*
|
jpayne@69
|
55 * One of the following data structures is kept for each entry of each menu
|
jpayne@69
|
56 * managed by this file:
|
jpayne@69
|
57 */
|
jpayne@69
|
58
|
jpayne@69
|
59 typedef struct TkMenuEntry {
|
jpayne@69
|
60 int type; /* Type of menu entry; see below for valid
|
jpayne@69
|
61 * types. */
|
jpayne@69
|
62 struct TkMenu *menuPtr; /* Menu with which this entry is
|
jpayne@69
|
63 * associated. */
|
jpayne@69
|
64 Tk_OptionTable optionTable; /* Option table for this menu entry. */
|
jpayne@69
|
65 Tcl_Obj *labelPtr; /* Main text label displayed in entry (NULL if
|
jpayne@69
|
66 * no label). */
|
jpayne@69
|
67 int labelLength; /* Number of non-NULL characters in label. */
|
jpayne@69
|
68 int state; /* State of button for display purposes:
|
jpayne@69
|
69 * normal, active, or disabled. */
|
jpayne@69
|
70 int underline; /* Value of -underline option: specifies index
|
jpayne@69
|
71 * of character to underline (<0 means don't
|
jpayne@69
|
72 * underline anything). */
|
jpayne@69
|
73 Tcl_Obj *underlinePtr; /* Index of character to underline. */
|
jpayne@69
|
74 Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or NULL.
|
jpayne@69
|
75 * If not NULL then label is ignored. */
|
jpayne@69
|
76 Tcl_Obj *imagePtr; /* Name of image to display, or NULL. If not
|
jpayne@69
|
77 * NULL, bitmap, text, and textVarName are
|
jpayne@69
|
78 * ignored. */
|
jpayne@69
|
79 Tk_Image image; /* Image to display in menu entry, or NULL if
|
jpayne@69
|
80 * none. */
|
jpayne@69
|
81 Tcl_Obj *selectImagePtr; /* Name of image to display when selected, or
|
jpayne@69
|
82 * NULL. */
|
jpayne@69
|
83 Tk_Image selectImage; /* Image to display in entry when selected, or
|
jpayne@69
|
84 * NULL if none. Ignored if image is NULL. */
|
jpayne@69
|
85 Tcl_Obj *accelPtr; /* Accelerator string displayed at right of
|
jpayne@69
|
86 * menu entry. NULL means no such accelerator.
|
jpayne@69
|
87 * Malloc'ed. */
|
jpayne@69
|
88 int accelLength; /* Number of non-NULL characters in
|
jpayne@69
|
89 * accelerator. */
|
jpayne@69
|
90 int indicatorOn; /* True means draw indicator, false means
|
jpayne@69
|
91 * don't draw it. This field is ignored unless
|
jpayne@69
|
92 * the entry is a radio or check button. */
|
jpayne@69
|
93 /*
|
jpayne@69
|
94 * Display attributes
|
jpayne@69
|
95 */
|
jpayne@69
|
96
|
jpayne@69
|
97 Tcl_Obj *borderPtr; /* Structure used to draw background for
|
jpayne@69
|
98 * entry. NULL means use overall border for
|
jpayne@69
|
99 * menu. */
|
jpayne@69
|
100 Tcl_Obj *fgPtr; /* Foreground color to use for entry. NULL
|
jpayne@69
|
101 * means use foreground color from menu. */
|
jpayne@69
|
102 Tcl_Obj *activeBorderPtr; /* Used to draw background and border when
|
jpayne@69
|
103 * element is active. NULL means use
|
jpayne@69
|
104 * activeBorder from menu. */
|
jpayne@69
|
105 Tcl_Obj *activeFgPtr; /* Foreground color to use when entry is
|
jpayne@69
|
106 * active. NULL means use active foreground
|
jpayne@69
|
107 * from menu. */
|
jpayne@69
|
108 Tcl_Obj *indicatorFgPtr; /* Color for indicators in radio and check
|
jpayne@69
|
109 * button entries. NULL means use indicatorFg
|
jpayne@69
|
110 * GC from menu. */
|
jpayne@69
|
111 Tcl_Obj *fontPtr; /* Text font for menu entries. NULL means use
|
jpayne@69
|
112 * overall font for menu. */
|
jpayne@69
|
113 int columnBreak; /* If this is 0, this item appears below the
|
jpayne@69
|
114 * item in front of it. If this is 1, this
|
jpayne@69
|
115 * item starts a new column. This field is
|
jpayne@69
|
116 * always 0 for tearoff and separator
|
jpayne@69
|
117 * entries. */
|
jpayne@69
|
118 int hideMargin; /* If this is 0, then the item has enough
|
jpayne@69
|
119 * margin to accommodate a standard check mark
|
jpayne@69
|
120 * and a default right margin. If this is 1,
|
jpayne@69
|
121 * then the item has no such margins, and
|
jpayne@69
|
122 * checkbuttons and radiobuttons with this set
|
jpayne@69
|
123 * will have a rectangle drawn in the
|
jpayne@69
|
124 * indicator around the item if the item is
|
jpayne@69
|
125 * checked. This is useful for palette menus.
|
jpayne@69
|
126 * This field is ignored for separators and
|
jpayne@69
|
127 * tearoffs. */
|
jpayne@69
|
128 int indicatorSpace; /* The width of the indicator space for this
|
jpayne@69
|
129 * entry. */
|
jpayne@69
|
130 int labelWidth; /* Number of pixels to allow for displaying
|
jpayne@69
|
131 * labels in menu entries. */
|
jpayne@69
|
132 int compound; /* Value of -compound option; specifies
|
jpayne@69
|
133 * whether the entry should show both an image
|
jpayne@69
|
134 * and text, and, if so, how. */
|
jpayne@69
|
135
|
jpayne@69
|
136 /*
|
jpayne@69
|
137 * Information used to implement this entry's action:
|
jpayne@69
|
138 */
|
jpayne@69
|
139
|
jpayne@69
|
140 Tcl_Obj *commandPtr; /* Command to invoke when entry is invoked.
|
jpayne@69
|
141 * Malloc'ed. */
|
jpayne@69
|
142 Tcl_Obj *namePtr; /* Name of variable (for check buttons and
|
jpayne@69
|
143 * radio buttons) or menu (for cascade
|
jpayne@69
|
144 * entries). Malloc'ed. */
|
jpayne@69
|
145 Tcl_Obj *onValuePtr; /* Value to store in variable when selected
|
jpayne@69
|
146 * (only for radio and check buttons).
|
jpayne@69
|
147 * Malloc'ed. */
|
jpayne@69
|
148 Tcl_Obj *offValuePtr; /* Value to store in variable when not
|
jpayne@69
|
149 * selected (only for check buttons).
|
jpayne@69
|
150 * Malloc'ed. */
|
jpayne@69
|
151
|
jpayne@69
|
152 /*
|
jpayne@69
|
153 * Information used for drawing this menu entry.
|
jpayne@69
|
154 */
|
jpayne@69
|
155
|
jpayne@69
|
156 int width; /* Number of pixels occupied by entry in
|
jpayne@69
|
157 * horizontal dimension. Not used except in
|
jpayne@69
|
158 * menubars. The width of norma menus is
|
jpayne@69
|
159 * dependent on the rest of the menu. */
|
jpayne@69
|
160 int x; /* X-coordinate of leftmost pixel in entry. */
|
jpayne@69
|
161 int height; /* Number of pixels occupied by entry in
|
jpayne@69
|
162 * vertical dimension, including raised border
|
jpayne@69
|
163 * drawn around entry when active. */
|
jpayne@69
|
164 int y; /* Y-coordinate of topmost pixel in entry. */
|
jpayne@69
|
165 GC textGC; /* GC for drawing text in entry. NULL means
|
jpayne@69
|
166 * use overall textGC for menu. */
|
jpayne@69
|
167 GC activeGC; /* GC for drawing text in entry when active.
|
jpayne@69
|
168 * NULL means use overall activeGC for
|
jpayne@69
|
169 * menu. */
|
jpayne@69
|
170 GC disabledGC; /* Used to produce disabled effect for entry.
|
jpayne@69
|
171 * NULL means use overall disabledGC from menu
|
jpayne@69
|
172 * structure. See comments for disabledFg in
|
jpayne@69
|
173 * menu structure for more information. */
|
jpayne@69
|
174 GC indicatorGC; /* For drawing indicators. NULL means use GC
|
jpayne@69
|
175 * from menu. */
|
jpayne@69
|
176
|
jpayne@69
|
177 /*
|
jpayne@69
|
178 * Miscellaneous fields.
|
jpayne@69
|
179 */
|
jpayne@69
|
180
|
jpayne@69
|
181 int entryFlags; /* Various flags. See below for
|
jpayne@69
|
182 * definitions. */
|
jpayne@69
|
183 int index; /* Need to know which index we are. This is
|
jpayne@69
|
184 * zero-based. This is the top-left entry of
|
jpayne@69
|
185 * the menu. */
|
jpayne@69
|
186
|
jpayne@69
|
187 /*
|
jpayne@69
|
188 * Bookeeping for main menus and cascade menus.
|
jpayne@69
|
189 */
|
jpayne@69
|
190
|
jpayne@69
|
191 struct TkMenuReferences *childMenuRefPtr;
|
jpayne@69
|
192 /* A pointer to the hash table entry for the
|
jpayne@69
|
193 * child menu. Stored here when the menu entry
|
jpayne@69
|
194 * is configured so that a hash lookup is not
|
jpayne@69
|
195 * necessary later.*/
|
jpayne@69
|
196 struct TkMenuEntry *nextCascadePtr;
|
jpayne@69
|
197 /* The next cascade entry that is a parent of
|
jpayne@69
|
198 * this entry's child cascade menu. NULL end
|
jpayne@69
|
199 * of list, this is not a cascade entry, or
|
jpayne@69
|
200 * the menu that this entry point to does not
|
jpayne@69
|
201 * yet exist. */
|
jpayne@69
|
202 TkMenuPlatformEntryData platformEntryData;
|
jpayne@69
|
203 /* The data for the specific type of menu.
|
jpayne@69
|
204 * Depends on platform and menu type what kind
|
jpayne@69
|
205 * of options are in this structure. */
|
jpayne@69
|
206 } TkMenuEntry;
|
jpayne@69
|
207
|
jpayne@69
|
208 /*
|
jpayne@69
|
209 * Flag values defined for menu entries:
|
jpayne@69
|
210 *
|
jpayne@69
|
211 * ENTRY_SELECTED: Non-zero means this is a radio or check button
|
jpayne@69
|
212 * and that it should be drawn in the "selected"
|
jpayne@69
|
213 * state.
|
jpayne@69
|
214 * ENTRY_NEEDS_REDISPLAY: Non-zero means the entry should be redisplayed.
|
jpayne@69
|
215 * ENTRY_LAST_COLUMN: Used by the drawing code. If the entry is in
|
jpayne@69
|
216 * the last column, the space to its right needs
|
jpayne@69
|
217 * to be filled.
|
jpayne@69
|
218 * ENTRY_PLATFORM_FLAG1 - 4 These flags are reserved for use by the
|
jpayne@69
|
219 * platform-dependent implementation of menus
|
jpayne@69
|
220 * and should not be used by anything else.
|
jpayne@69
|
221 */
|
jpayne@69
|
222
|
jpayne@69
|
223 #define ENTRY_SELECTED 1
|
jpayne@69
|
224 #define ENTRY_NEEDS_REDISPLAY 2
|
jpayne@69
|
225 #define ENTRY_LAST_COLUMN 4
|
jpayne@69
|
226 #define ENTRY_PLATFORM_FLAG1 (1 << 30)
|
jpayne@69
|
227 #define ENTRY_PLATFORM_FLAG2 (1 << 29)
|
jpayne@69
|
228 #define ENTRY_PLATFORM_FLAG3 (1 << 28)
|
jpayne@69
|
229 #define ENTRY_PLATFORM_FLAG4 (1 << 27)
|
jpayne@69
|
230
|
jpayne@69
|
231 /*
|
jpayne@69
|
232 * Types defined for MenuEntries:
|
jpayne@69
|
233 */
|
jpayne@69
|
234
|
jpayne@69
|
235 #define CASCADE_ENTRY 0
|
jpayne@69
|
236 #define CHECK_BUTTON_ENTRY 1
|
jpayne@69
|
237 #define COMMAND_ENTRY 2
|
jpayne@69
|
238 #define RADIO_BUTTON_ENTRY 3
|
jpayne@69
|
239 #define SEPARATOR_ENTRY 4
|
jpayne@69
|
240 #define TEAROFF_ENTRY 5
|
jpayne@69
|
241
|
jpayne@69
|
242 /*
|
jpayne@69
|
243 * Menu states
|
jpayne@69
|
244 */
|
jpayne@69
|
245
|
jpayne@69
|
246 #define ENTRY_ACTIVE 0
|
jpayne@69
|
247 #define ENTRY_NORMAL 1
|
jpayne@69
|
248 #define ENTRY_DISABLED 2
|
jpayne@69
|
249
|
jpayne@69
|
250 /*
|
jpayne@69
|
251 * A data structure of the following type is kept for each menu widget:
|
jpayne@69
|
252 */
|
jpayne@69
|
253
|
jpayne@69
|
254 typedef struct TkMenu {
|
jpayne@69
|
255 Tk_Window tkwin; /* Window that embodies the pane. NULL means
|
jpayne@69
|
256 * that the window has been destroyed but the
|
jpayne@69
|
257 * data structures haven't yet been cleaned
|
jpayne@69
|
258 * up. */
|
jpayne@69
|
259 Display *display; /* Display containing widget. Needed, among
|
jpayne@69
|
260 * other things, so that resources can be
|
jpayne@69
|
261 * freed up even after tkwin has gone away. */
|
jpayne@69
|
262 Tcl_Interp *interp; /* Interpreter associated with menu. */
|
jpayne@69
|
263 Tcl_Command widgetCmd; /* Token for menu's widget command. */
|
jpayne@69
|
264 TkMenuEntry **entries; /* Array of pointers to all the entries in the
|
jpayne@69
|
265 * menu. NULL means no entries. */
|
jpayne@69
|
266 int numEntries; /* Number of elements in entries. */
|
jpayne@69
|
267 int active; /* Index of active entry. -1 means nothing
|
jpayne@69
|
268 * active. */
|
jpayne@69
|
269 int menuType; /* MAIN_MENU, TEAROFF_MENU, or MENUBAR. See
|
jpayne@69
|
270 * below for definitions. */
|
jpayne@69
|
271 Tcl_Obj *menuTypePtr; /* Used to control whether created tkwin is a
|
jpayne@69
|
272 * toplevel or not. "normal", "menubar", or
|
jpayne@69
|
273 * "toplevel" */
|
jpayne@69
|
274
|
jpayne@69
|
275 /*
|
jpayne@69
|
276 * Information used when displaying widget:
|
jpayne@69
|
277 */
|
jpayne@69
|
278
|
jpayne@69
|
279 Tcl_Obj *borderPtr; /* Structure used to draw 3-D border and
|
jpayne@69
|
280 * background for menu. */
|
jpayne@69
|
281 Tcl_Obj *borderWidthPtr; /* Width of border around whole menu. */
|
jpayne@69
|
282 Tcl_Obj *activeBorderPtr; /* Used to draw background and border for
|
jpayne@69
|
283 * active element (if any). */
|
jpayne@69
|
284 Tcl_Obj *activeBorderWidthPtr;
|
jpayne@69
|
285 /* Width of border around active element. */
|
jpayne@69
|
286 Tcl_Obj *reliefPtr; /* 3-d effect: TK_RELIEF_RAISED, etc. */
|
jpayne@69
|
287 Tcl_Obj *fontPtr; /* Text font for menu entries. */
|
jpayne@69
|
288 Tcl_Obj *fgPtr; /* Foreground color for entries. */
|
jpayne@69
|
289 Tcl_Obj *disabledFgPtr; /* Foreground color when disabled. NULL means
|
jpayne@69
|
290 * use normalFg with a 50% stipple instead. */
|
jpayne@69
|
291 Tcl_Obj *activeFgPtr; /* Foreground color for active entry. */
|
jpayne@69
|
292 Tcl_Obj *indicatorFgPtr; /* Color for indicators in radio and check
|
jpayne@69
|
293 * button entries. */
|
jpayne@69
|
294 Pixmap gray; /* Bitmap for drawing disabled entries in a
|
jpayne@69
|
295 * stippled fashion. None means not allocated
|
jpayne@69
|
296 * yet. */
|
jpayne@69
|
297 GC textGC; /* GC for drawing text and other features of
|
jpayne@69
|
298 * menu entries. */
|
jpayne@69
|
299 GC disabledGC; /* Used to produce disabled effect. If
|
jpayne@69
|
300 * disabledFg isn't NULL, this GC is used to
|
jpayne@69
|
301 * draw text and icons for disabled entries.
|
jpayne@69
|
302 * Otherwise text and icons are drawn with
|
jpayne@69
|
303 * normalGC and this GC is used to stipple
|
jpayne@69
|
304 * background across them. */
|
jpayne@69
|
305 GC activeGC; /* GC for drawing active entry. */
|
jpayne@69
|
306 GC indicatorGC; /* For drawing indicators. */
|
jpayne@69
|
307 GC disabledImageGC; /* Used for drawing disabled images. They have
|
jpayne@69
|
308 * to be stippled. This is created when the
|
jpayne@69
|
309 * image is about to be drawn the first
|
jpayne@69
|
310 * time. */
|
jpayne@69
|
311
|
jpayne@69
|
312 /*
|
jpayne@69
|
313 * Information about geometry of menu.
|
jpayne@69
|
314 */
|
jpayne@69
|
315
|
jpayne@69
|
316 int totalWidth; /* Width of entire menu. */
|
jpayne@69
|
317 int totalHeight; /* Height of entire menu. */
|
jpayne@69
|
318
|
jpayne@69
|
319 /*
|
jpayne@69
|
320 * Miscellaneous information:
|
jpayne@69
|
321 */
|
jpayne@69
|
322
|
jpayne@69
|
323 int tearoff; /* 1 means this menu can be torn off. On some
|
jpayne@69
|
324 * platforms, the user can drag an outline of
|
jpayne@69
|
325 * the menu by just dragging outside of the
|
jpayne@69
|
326 * menu, and the tearoff is created where the
|
jpayne@69
|
327 * mouse is released. On others, an indicator
|
jpayne@69
|
328 * (such as a dashed stripe) is drawn, and
|
jpayne@69
|
329 * when the menu is selected, the tearoff is
|
jpayne@69
|
330 * created. */
|
jpayne@69
|
331 Tcl_Obj *titlePtr; /* The title to use when this menu is torn
|
jpayne@69
|
332 * off. If this is NULL, a default scheme will
|
jpayne@69
|
333 * be used to generate a title for tearoff. */
|
jpayne@69
|
334 Tcl_Obj *tearoffCommandPtr; /* If non-NULL, points to a command to run
|
jpayne@69
|
335 * whenever the menu is torn-off. */
|
jpayne@69
|
336 Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the
|
jpayne@69
|
337 * C code, but used by keyboard traversal
|
jpayne@69
|
338 * scripts. Malloc'ed, but may be NULL. */
|
jpayne@69
|
339 Tcl_Obj *cursorPtr; /* Current cursor for window, or NULL. */
|
jpayne@69
|
340 Tcl_Obj *postCommandPtr; /* Used to detect cycles in cascade hierarchy
|
jpayne@69
|
341 * trees when preprocessing postcommands on
|
jpayne@69
|
342 * some platforms. See PostMenu for more
|
jpayne@69
|
343 * details. */
|
jpayne@69
|
344 int postCommandGeneration; /* Need to do pre-invocation post command
|
jpayne@69
|
345 * traversal. */
|
jpayne@69
|
346 int menuFlags; /* Flags for use by X; see below for
|
jpayne@69
|
347 * definition. */
|
jpayne@69
|
348 TkMenuEntry *postedCascade; /* Points to menu entry for cascaded submenu
|
jpayne@69
|
349 * that is currently posted or NULL if no
|
jpayne@69
|
350 * submenu posted. */
|
jpayne@69
|
351 struct TkMenu *nextInstancePtr;
|
jpayne@69
|
352 /* The next instance of this menu in the
|
jpayne@69
|
353 * chain. */
|
jpayne@69
|
354 struct TkMenu *masterMenuPtr;
|
jpayne@69
|
355 /* A pointer to the original menu for this
|
jpayne@69
|
356 * clone chain. Points back to this structure
|
jpayne@69
|
357 * if this menu is a main menu. */
|
jpayne@69
|
358 void *reserved1; /* not used any more. */
|
jpayne@69
|
359 Tk_Window parentTopLevelPtr;/* If this menu is a menubar, this is the
|
jpayne@69
|
360 * toplevel that owns the menu. Only
|
jpayne@69
|
361 * applicable for menubar clones. */
|
jpayne@69
|
362 struct TkMenuReferences *menuRefPtr;
|
jpayne@69
|
363 /* Each menu is hashed into a table with the
|
jpayne@69
|
364 * name of the menu's window as the key. The
|
jpayne@69
|
365 * information in this hash table includes a
|
jpayne@69
|
366 * pointer to the menu (so that cascades can
|
jpayne@69
|
367 * find this menu), a pointer to the list of
|
jpayne@69
|
368 * toplevel widgets that have this menu as its
|
jpayne@69
|
369 * menubar, and a list of menu entries that
|
jpayne@69
|
370 * have this menu specified as a cascade. */
|
jpayne@69
|
371 TkMenuPlatformData platformData;
|
jpayne@69
|
372 /* The data for the specific type of menu.
|
jpayne@69
|
373 * Depends on platform and menu type what kind
|
jpayne@69
|
374 * of options are in this structure. */
|
jpayne@69
|
375 Tk_OptionSpec *extensionPtr;/* Needed by the configuration package for
|
jpayne@69
|
376 * this widget to be extended. */
|
jpayne@69
|
377 Tk_SavedOptions *errorStructPtr;
|
jpayne@69
|
378 /* We actually have to allocate these because
|
jpayne@69
|
379 * multiple menus get changed during one
|
jpayne@69
|
380 * ConfigureMenu call. */
|
jpayne@69
|
381 } TkMenu;
|
jpayne@69
|
382
|
jpayne@69
|
383 /*
|
jpayne@69
|
384 * When the toplevel configure -menu command is executed, the menu may not
|
jpayne@69
|
385 * exist yet. We need to keep a linked list of windows that reference a
|
jpayne@69
|
386 * particular menu.
|
jpayne@69
|
387 */
|
jpayne@69
|
388
|
jpayne@69
|
389 typedef struct TkMenuTopLevelList {
|
jpayne@69
|
390 struct TkMenuTopLevelList *nextPtr;
|
jpayne@69
|
391 /* The next window in the list. */
|
jpayne@69
|
392 Tk_Window tkwin; /* The window that has this menu as its
|
jpayne@69
|
393 * menubar. */
|
jpayne@69
|
394 } TkMenuTopLevelList;
|
jpayne@69
|
395
|
jpayne@69
|
396 /*
|
jpayne@69
|
397 * The following structure is used to keep track of things which reference a
|
jpayne@69
|
398 * menu. It is created when:
|
jpayne@69
|
399 * - a menu is created.
|
jpayne@69
|
400 * - a cascade entry is added to a menu with a non-null name
|
jpayne@69
|
401 * - the "-menu" configuration option is used on a toplevel widget with a
|
jpayne@69
|
402 * non-null parameter.
|
jpayne@69
|
403 *
|
jpayne@69
|
404 * One of these three fields must be non-NULL, but any of the fields may be
|
jpayne@69
|
405 * NULL. This structure makes it easy to determine whether or not anything
|
jpayne@69
|
406 * like recalculating platform data or geometry is necessary when one of the
|
jpayne@69
|
407 * three actions above is performed.
|
jpayne@69
|
408 */
|
jpayne@69
|
409
|
jpayne@69
|
410 typedef struct TkMenuReferences {
|
jpayne@69
|
411 struct TkMenu *menuPtr; /* The menu data structure. This is NULL if
|
jpayne@69
|
412 * the menu does not exist. */
|
jpayne@69
|
413 TkMenuTopLevelList *topLevelListPtr;
|
jpayne@69
|
414 /* First in the list of all toplevels that
|
jpayne@69
|
415 * have this menu as its menubar. NULL if no
|
jpayne@69
|
416 * toplevel widgets have this menu as its
|
jpayne@69
|
417 * menubar. */
|
jpayne@69
|
418 TkMenuEntry *parentEntryPtr;/* First in the list of all cascade menu
|
jpayne@69
|
419 * entries that have this menu as their child.
|
jpayne@69
|
420 * NULL means no cascade entries. */
|
jpayne@69
|
421 Tcl_HashEntry *hashEntryPtr;/* This is needed because the pathname of the
|
jpayne@69
|
422 * window (which is what we hash on) may not
|
jpayne@69
|
423 * be around when we are deleting. */
|
jpayne@69
|
424 } TkMenuReferences;
|
jpayne@69
|
425
|
jpayne@69
|
426 /*
|
jpayne@69
|
427 * Flag bits for menus:
|
jpayne@69
|
428 *
|
jpayne@69
|
429 * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has
|
jpayne@69
|
430 * already been queued to redraw this window.
|
jpayne@69
|
431 * RESIZE_PENDING: Non-zero means a call to ComputeMenuGeometry
|
jpayne@69
|
432 * has already been scheduled.
|
jpayne@69
|
433 * MENU_DELETION_PENDING Non-zero means that we are currently
|
jpayne@69
|
434 * destroying this menu's internal structures.
|
jpayne@69
|
435 * This is useful when we are in the middle of
|
jpayne@69
|
436 * cleaning this main menu's chain of menus up
|
jpayne@69
|
437 * when TkDestroyMenu was called again on this
|
jpayne@69
|
438 * menu (via a destroy binding or somesuch).
|
jpayne@69
|
439 * MENU_WIN_DESTRUCTION_PENDING Non-zero means we are in the middle of
|
jpayne@69
|
440 * destroying this menu's Tk_Window.
|
jpayne@69
|
441 * MENU_PLATFORM_FLAG1... Reserved for use by the platform-specific menu
|
jpayne@69
|
442 * code.
|
jpayne@69
|
443 */
|
jpayne@69
|
444
|
jpayne@69
|
445 #define REDRAW_PENDING 1
|
jpayne@69
|
446 #define RESIZE_PENDING 2
|
jpayne@69
|
447 #define MENU_DELETION_PENDING 4
|
jpayne@69
|
448 #define MENU_WIN_DESTRUCTION_PENDING 8
|
jpayne@69
|
449 #define MENU_PLATFORM_FLAG1 (1 << 30)
|
jpayne@69
|
450 #define MENU_PLATFORM_FLAG2 (1 << 29)
|
jpayne@69
|
451 #define MENU_PLATFORM_FLAG3 (1 << 28)
|
jpayne@69
|
452
|
jpayne@69
|
453 /*
|
jpayne@69
|
454 * Each menu created by the user is a MAIN_MENU. When a menu is torn off, a
|
jpayne@69
|
455 * TEAROFF_MENU instance is created. When a menu is assigned to a toplevel as
|
jpayne@69
|
456 * a menu bar, a MENUBAR instance is created. All instances have the same
|
jpayne@69
|
457 * configuration information. If the main instance is deleted, all instances
|
jpayne@69
|
458 * are deleted. If one of the other instances is deleted, only that instance
|
jpayne@69
|
459 * is deleted.
|
jpayne@69
|
460 */
|
jpayne@69
|
461
|
jpayne@69
|
462 #define UNKNOWN_TYPE -1
|
jpayne@69
|
463 #define MAIN_MENU 0
|
jpayne@69
|
464 #define MASTER_MENU 0
|
jpayne@69
|
465 #define TEAROFF_MENU 1
|
jpayne@69
|
466 #define MENUBAR 2
|
jpayne@69
|
467
|
jpayne@69
|
468 /*
|
jpayne@69
|
469 * Various geometry definitions:
|
jpayne@69
|
470 */
|
jpayne@69
|
471
|
jpayne@69
|
472 #define CASCADE_ARROW_HEIGHT 10
|
jpayne@69
|
473 #define CASCADE_ARROW_WIDTH 8
|
jpayne@69
|
474 #define DECORATION_BORDER_WIDTH 2
|
jpayne@69
|
475
|
jpayne@69
|
476 /*
|
jpayne@69
|
477 * Menu-related functions that are shared among Tk modules but not exported to
|
jpayne@69
|
478 * the outside world:
|
jpayne@69
|
479 */
|
jpayne@69
|
480
|
jpayne@69
|
481 MODULE_SCOPE int TkActivateMenuEntry(TkMenu *menuPtr, int index);
|
jpayne@69
|
482 MODULE_SCOPE void TkBindMenu(Tk_Window tkwin, TkMenu *menuPtr);
|
jpayne@69
|
483 MODULE_SCOPE TkMenuReferences*TkCreateMenuReferences(Tcl_Interp *interp,
|
jpayne@69
|
484 const char *name);
|
jpayne@69
|
485 MODULE_SCOPE void TkDestroyMenu(TkMenu *menuPtr);
|
jpayne@69
|
486 MODULE_SCOPE void TkEventuallyRecomputeMenu(TkMenu *menuPtr);
|
jpayne@69
|
487 MODULE_SCOPE void TkEventuallyRedrawMenu(TkMenu *menuPtr,
|
jpayne@69
|
488 TkMenuEntry *mePtr);
|
jpayne@69
|
489 MODULE_SCOPE TkMenuReferences*TkFindMenuReferences(Tcl_Interp *interp, const char *name);
|
jpayne@69
|
490 MODULE_SCOPE TkMenuReferences*TkFindMenuReferencesObj(Tcl_Interp *interp,
|
jpayne@69
|
491 Tcl_Obj *namePtr);
|
jpayne@69
|
492 MODULE_SCOPE int TkFreeMenuReferences(TkMenuReferences *menuRefPtr);
|
jpayne@69
|
493 MODULE_SCOPE Tcl_HashTable *TkGetMenuHashTable(Tcl_Interp *interp);
|
jpayne@69
|
494 MODULE_SCOPE int TkGetMenuIndex(Tcl_Interp *interp, TkMenu *menuPtr,
|
jpayne@69
|
495 Tcl_Obj *objPtr, int lastOK, int *indexPtr);
|
jpayne@69
|
496 MODULE_SCOPE void TkMenuInitializeDrawingFields(TkMenu *menuPtr);
|
jpayne@69
|
497 MODULE_SCOPE void TkMenuInitializeEntryDrawingFields(TkMenuEntry *mePtr);
|
jpayne@69
|
498 MODULE_SCOPE int TkInvokeMenu(Tcl_Interp *interp, TkMenu *menuPtr,
|
jpayne@69
|
499 int index);
|
jpayne@69
|
500 MODULE_SCOPE void TkMenuConfigureDrawOptions(TkMenu *menuPtr);
|
jpayne@69
|
501 MODULE_SCOPE int TkMenuConfigureEntryDrawOptions(
|
jpayne@69
|
502 TkMenuEntry *mePtr, int index);
|
jpayne@69
|
503 MODULE_SCOPE void TkMenuFreeDrawOptions(TkMenu *menuPtr);
|
jpayne@69
|
504 MODULE_SCOPE void TkMenuEntryFreeDrawOptions(TkMenuEntry *mePtr);
|
jpayne@69
|
505 MODULE_SCOPE void TkMenuEventProc(ClientData clientData,
|
jpayne@69
|
506 XEvent *eventPtr);
|
jpayne@69
|
507 MODULE_SCOPE void TkMenuImageProc(ClientData clientData, int x, int y,
|
jpayne@69
|
508 int width, int height, int imgWidth,
|
jpayne@69
|
509 int imgHeight);
|
jpayne@69
|
510 MODULE_SCOPE void TkMenuInit(void);
|
jpayne@69
|
511 MODULE_SCOPE void TkMenuSelectImageProc(ClientData clientData, int x,
|
jpayne@69
|
512 int y, int width, int height, int imgWidth,
|
jpayne@69
|
513 int imgHeight);
|
jpayne@69
|
514 MODULE_SCOPE Tcl_Obj * TkNewMenuName(Tcl_Interp *interp,
|
jpayne@69
|
515 Tcl_Obj *parentNamePtr, TkMenu *menuPtr);
|
jpayne@69
|
516 MODULE_SCOPE int TkPostCommand(TkMenu *menuPtr);
|
jpayne@69
|
517 MODULE_SCOPE int TkPostSubmenu(Tcl_Interp *interp, TkMenu *menuPtr,
|
jpayne@69
|
518 TkMenuEntry *mePtr);
|
jpayne@69
|
519 MODULE_SCOPE int TkPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr,
|
jpayne@69
|
520 int x, int y);
|
jpayne@69
|
521 MODULE_SCOPE int TkPreprocessMenu(TkMenu *menuPtr);
|
jpayne@69
|
522 MODULE_SCOPE void TkRecomputeMenu(TkMenu *menuPtr);
|
jpayne@69
|
523
|
jpayne@69
|
524 /*
|
jpayne@69
|
525 * These routines are the platform-dependent routines called by the common
|
jpayne@69
|
526 * code.
|
jpayne@69
|
527 */
|
jpayne@69
|
528
|
jpayne@69
|
529 MODULE_SCOPE void TkpComputeMenubarGeometry(TkMenu *menuPtr);
|
jpayne@69
|
530 MODULE_SCOPE void TkpComputeStandardMenuGeometry(TkMenu *menuPtr);
|
jpayne@69
|
531 MODULE_SCOPE int TkpConfigureMenuEntry(TkMenuEntry *mePtr);
|
jpayne@69
|
532 MODULE_SCOPE void TkpDestroyMenu(TkMenu *menuPtr);
|
jpayne@69
|
533 MODULE_SCOPE void TkpDestroyMenuEntry(TkMenuEntry *mEntryPtr);
|
jpayne@69
|
534 MODULE_SCOPE void TkpDrawMenuEntry(TkMenuEntry *mePtr,
|
jpayne@69
|
535 Drawable d, Tk_Font tkfont,
|
jpayne@69
|
536 const Tk_FontMetrics *menuMetricsPtr, int x,
|
jpayne@69
|
537 int y, int width, int height, int strictMotif,
|
jpayne@69
|
538 int drawingParameters);
|
jpayne@69
|
539 MODULE_SCOPE void TkpMenuInit(void);
|
jpayne@69
|
540 MODULE_SCOPE int TkpMenuNewEntry(TkMenuEntry *mePtr);
|
jpayne@69
|
541 MODULE_SCOPE int TkpNewMenu(TkMenu *menuPtr);
|
jpayne@69
|
542 MODULE_SCOPE int TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr,
|
jpayne@69
|
543 int x, int y, int index);
|
jpayne@69
|
544 MODULE_SCOPE int TkpPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr,
|
jpayne@69
|
545 int x, int y, int index);
|
jpayne@69
|
546 MODULE_SCOPE void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr);
|
jpayne@69
|
547
|
jpayne@69
|
548 #endif /* _TKMENU */
|