/[dtapublic]/projs/trunk/shared_source/c_tk_base_7_5_w_mods/tkmenu.h
ViewVC logotype

Contents of /projs/trunk/shared_source/c_tk_base_7_5_w_mods/tkmenu.h

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:keywords Header

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25