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

Diff of /projs/emts/trunk/src/c_tk_base_7_5_w_mods/tkmenu.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.69  
changed lines
  Added in v.71

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25