📄 tkmenu.h
字号:
/* * tkMenu.h -- * * Declarations shared among all of the files that implement menu widgets. * * Copyright (c) 1996-1997 by Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * SCCS: @(#) tkMenu.h 1.60 97/06/20 14:43:21 */#ifndef _TKMENU#define _TKMENU#ifndef _TK#include "tk.h"#endif#ifndef _TKINT#include "tkInt.h"#endif#ifndef _DEFAULT#include "default.h"#endif#ifdef BUILD_tk# undef TCL_STORAGE_CLASS# define TCL_STORAGE_CLASS DLLEXPORT#endif/* * Dummy types used by the platform menu code. */typedef struct TkMenuPlatformData_ *TkMenuPlatformData;typedef struct TkMenuPlatformEntryData_ *TkMenuPlatformEntryData;/* * One of the following data structures is kept for each entry of each * menu managed by this file: */typedef struct TkMenuEntry { int type; /* Type of menu entry; see below for * valid types. */ struct TkMenu *menuPtr; /* Menu with which this entry is associated. */ char *label; /* Main text label displayed in entry (NULL * if no label). Malloc'ed. */ int labelLength; /* Number of non-NULL characters in label. */ Tk_Uid state; /* State of button for display purposes: * normal, active, or disabled. */ int underline; /* Index of character to underline. */ Pixmap bitmap; /* Bitmap to display in menu entry, or None. * If not None then label is ignored. */ char *imageString; /* Name of image to display (malloc'ed), or * NULL. If non-NULL, bitmap, text, and * textVarName are ignored. */ Tk_Image image; /* Image to display in menu entry, or NULL if * none. */ char *selectImageString; /* Name of image to display when selected * (malloc'ed), or NULL. */ Tk_Image selectImage; /* Image to display in entry when selected, * or NULL if none. Ignored if image is * NULL. */ char *accel; /* Accelerator string displayed at right * of menu entry. NULL means no such * accelerator. Malloc'ed. */ int accelLength; /* Number of non-NULL characters in * accelerator. */ int indicatorOn; /* True means draw indicator, false means * don't draw it. */ /* * Display attributes */ Tk_3DBorder border; /* Structure used to draw background for * entry. NULL means use overall border * for menu. */ XColor *fg; /* Foreground color to use for entry. NULL * means use foreground color from menu. */ Tk_3DBorder activeBorder; /* Used to draw background and border when * element is active. NULL means use * activeBorder from menu. */ XColor *activeFg; /* Foreground color to use when entry is * active. NULL means use active foreground * from menu. */ XColor *indicatorFg; /* Color for indicators in radio and check * button entries. NULL means use indicatorFg * GC from menu. */ Tk_Font tkfont; /* Text font for menu entries. NULL means * use overall font for menu. */ int columnBreak; /* If this is 0, this item appears below * the item in front of it. If this is * 1, this item starts a new column. */ int hideMargin; /* If this is 0, then the item has enough * margin to accomodate a standard check * mark and a default right margin. If this * is 1, then the item has no such margins. * and checkbuttons and radiobuttons with * this set will have a rectangle drawn * in the indicator around the item if * the item is checked. * This is useful palette menus.*/ int indicatorSpace; /* The width of the indicator space for this * entry. */ int labelWidth; /* Number of pixels to allow for displaying * labels in menu entries. */ /* * Information used to implement this entry's action: */ char *command; /* Command to invoke when entry is invoked. * Malloc'ed. */ char *name; /* Name of variable (for check buttons and * radio buttons) or menu (for cascade * entries). Malloc'ed.*/ char *onValue; /* Value to store in variable when selected * (only for radio and check buttons). * Malloc'ed. */ char *offValue; /* Value to store in variable when not * selected (only for check buttons). * Malloc'ed. */ /* * Information used for drawing this menu entry. */ int width; /* Number of pixels occupied by entry in * horizontal dimension. Not used except * in menubars. The width of norma menus * is dependent on the rest of the menu. */ int x; /* X-coordinate of leftmost pixel in entry */ int height; /* Number of pixels occupied by entry in * vertical dimension, including raised * border drawn around entry when active. */ int y; /* Y-coordinate of topmost pixel in entry. */ GC textGC; /* GC for drawing text in entry. NULL means * use overall textGC for menu. */ GC activeGC; /* GC for drawing text in entry when active. * NULL means use overall activeGC for * menu. */ GC disabledGC; /* Used to produce disabled effect for entry. * NULL means use overall disabledGC from * menu structure. See comments for * disabledFg in menu structure for more * information. */ GC indicatorGC; /* For drawing indicators. None means use * GC from menu. */ /* * Miscellaneous fields. */ int entryFlags; /* Various flags. See below for definitions. */ int index; /* Need to know which index we are. This * is zero-based. This is the top-left entry * of the menu. */ /* * Bookeeping for master menus and cascade menus. */ struct TkMenuReferences *childMenuRefPtr; /* A pointer to the hash table entry for * the child menu. Stored here when the menu * entry is configured so that a hash lookup * is not necessary later.*/ struct TkMenuEntry *nextCascadePtr; /* The next cascade entry that is a parent of * this entry's child cascade menu. NULL * end of list, this is not a cascade entry, * or the menu that this entry point to * does not yet exist. */ TkMenuPlatformEntryData platformEntryData; /* The data for the specific type of menu. * Depends on platform and menu type what * kind of options are in this structure. */} TkMenuEntry;/* * Flag values defined for menu entries: * * ENTRY_SELECTED: Non-zero means this is a radio or check * button and that it should be drawn in * the "selected" state. * ENTRY_NEEDS_REDISPLAY: Non-zero means the entry should be redisplayed. * ENTRY_LAST_COLUMN: Used by the drawing code. If the entry is in the * last column, the space to its right needs to * be filled. * ENTRY_PLATFORM_FLAG1 - 4 These flags are reserved for use by the * platform-dependent implementation of menus * and should not be used by anything else. */#define ENTRY_SELECTED 1#define ENTRY_NEEDS_REDISPLAY 2#define ENTRY_LAST_COLUMN 4#define ENTRY_PLATFORM_FLAG1 (1 << 30)#define ENTRY_PLATFORM_FLAG2 (1 << 29)#define ENTRY_PLATFORM_FLAG3 (1 << 28)#define ENTRY_PLATFORM_FLAG4 (1 << 27)/* * Types defined for MenuEntries: */#define COMMAND_ENTRY 0#define SEPARATOR_ENTRY 1#define CHECK_BUTTON_ENTRY 2#define RADIO_BUTTON_ENTRY 3#define CASCADE_ENTRY 4#define TEAROFF_ENTRY 5/* * Mask bits for above types: */#define COMMAND_MASK TK_CONFIG_USER_BIT#define SEPARATOR_MASK (TK_CONFIG_USER_BIT << 1)#define CHECK_BUTTON_MASK (TK_CONFIG_USER_BIT << 2)#define RADIO_BUTTON_MASK (TK_CONFIG_USER_BIT << 3)#define CASCADE_MASK (TK_CONFIG_USER_BIT << 4)#define TEAROFF_MASK (TK_CONFIG_USER_BIT << 5)#define ALL_MASK (COMMAND_MASK | SEPARATOR_MASK \ | CHECK_BUTTON_MASK | RADIO_BUTTON_MASK | CASCADE_MASK | TEAROFF_MASK)/* * A data structure of the following type is kept for each * menu widget: */typedef struct TkMenu { Tk_Window tkwin; /* Window that embodies the pane. NULL * means that the window has been destroyed * but the data structures haven't yet been * cleaned up.*/ Display *display; /* Display containing widget. Needed, among * other things, so that resources can be * freed up even after tkwin has gone away. */ Tcl_Interp *interp; /* Interpreter associated with menu. */ Tcl_Command widgetCmd; /* Token for menu's widget command. */ TkMenuEntry **entries; /* Array of pointers to all the entries * in the menu. NULL means no entries. */ int numEntries; /* Number of elements in entries. */ int active; /* Index of active entry. -1 means * nothing active. */ int menuType; /* MASTER_MENU, TEAROFF_MENU, or MENUBAR. * See below for definitions. */ char *menuTypeName; /* Used to control whether created tkwin * is a toplevel or not. "normal", "menubar", * or "toplevel" */ /* * Information used when displaying widget: */ Tk_3DBorder border; /* Structure used to draw 3-D * border and background for menu. */ int borderWidth; /* Width of border around whole menu. */ Tk_3DBorder activeBorder; /* Used to draw background and border for * active element (if any). */ int activeBorderWidth; /* Width of border around active element. */ int relief; /* 3-d effect: TK_RELIEF_RAISED, etc. */ Tk_Font tkfont; /* Text font for menu entries. */ XColor *fg; /* Foreground color for entries. */ XColor *disabledFg; /* Foreground color when disabled. NULL * means use normalFg with a 50% stipple * instead. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -