jpayne@69: /* jpayne@69: * tkMenubutton.h -- jpayne@69: * jpayne@69: * Declarations of types and functions used to implement the menubutton jpayne@69: * widget. jpayne@69: * jpayne@69: * Copyright (c) 1996-1997 by Sun Microsystems, Inc. jpayne@69: * jpayne@69: * See the file "license.terms" for information on usage and redistribution of jpayne@69: * this file, and for a DISCLAIMER OF ALL WARRANTIES. jpayne@69: */ jpayne@69: jpayne@69: #ifndef _TKMENUBUTTON jpayne@69: #define _TKMENUBUTTON jpayne@69: jpayne@69: #ifndef _TKINT jpayne@69: #include "tkInt.h" jpayne@69: #endif jpayne@69: jpayne@69: #ifndef _TKMENU jpayne@69: #include "tkMenu.h" jpayne@69: #endif jpayne@69: jpayne@69: /* jpayne@69: * Legal values for the "orient" field of TkMenubutton records. jpayne@69: */ jpayne@69: jpayne@69: enum direction { jpayne@69: DIRECTION_ABOVE, DIRECTION_BELOW, DIRECTION_FLUSH, jpayne@69: DIRECTION_LEFT, DIRECTION_RIGHT jpayne@69: }; jpayne@69: jpayne@69: /* jpayne@69: * Legal values for the "state" field of TkMenubutton records. jpayne@69: */ jpayne@69: jpayne@69: enum state { jpayne@69: STATE_ACTIVE, STATE_DISABLED, STATE_NORMAL jpayne@69: }; jpayne@69: jpayne@69: /* jpayne@69: * A data structure of the following type is kept for each widget managed by jpayne@69: * this file: jpayne@69: */ jpayne@69: jpayne@69: typedef struct { jpayne@69: Tk_Window tkwin; /* Window that embodies the widget. NULL means jpayne@69: * that the window has been destroyed but the jpayne@69: * data structures haven't yet been cleaned jpayne@69: * up. */ jpayne@69: Display *display; /* Display containing widget. Needed, among jpayne@69: * other things, so that resources can bee jpayne@69: * freed up even after tkwin has gone away. */ jpayne@69: Tcl_Interp *interp; /* Interpreter associated with menubutton. */ jpayne@69: Tcl_Command widgetCmd; /* Token for menubutton's widget command. */ jpayne@69: Tk_OptionTable optionTable; /* Table that defines configuration options jpayne@69: * available for this widget. */ jpayne@69: char *menuName; /* Name of menu associated with widget. jpayne@69: * Malloc-ed. */ jpayne@69: jpayne@69: /* jpayne@69: * Information about what's displayed in the menu button: jpayne@69: */ jpayne@69: jpayne@69: char *text; /* Text to display in button (malloc'ed) or jpayne@69: * NULL. */ jpayne@69: int underline; /* Index of character to underline. */ jpayne@69: char *textVarName; /* Name of variable (malloc'ed) or NULL. If jpayne@69: * non-NULL, button displays the contents of jpayne@69: * this variable. */ jpayne@69: Pixmap bitmap; /* Bitmap to display or None. If not None then jpayne@69: * text and textVar and underline are jpayne@69: * ignored. */ jpayne@69: char *imageString; /* Name of image to display (malloc'ed), or jpayne@69: * NULL. If non-NULL, bitmap, text, and jpayne@69: * textVarName are ignored. */ jpayne@69: Tk_Image image; /* Image to display in window, or NULL if jpayne@69: * none. */ jpayne@69: jpayne@69: /* jpayne@69: * Information used when displaying widget: jpayne@69: */ jpayne@69: jpayne@69: enum state state; /* State of button for display purposes: jpayne@69: * normal, active, or disabled. */ jpayne@69: Tk_3DBorder normalBorder; /* Structure used to draw 3-D border and jpayne@69: * background when window isn't active. NULL jpayne@69: * means no such border exists. */ jpayne@69: Tk_3DBorder activeBorder; /* Structure used to draw 3-D border and jpayne@69: * background when window is active. NULL jpayne@69: * means no such border exists. */ jpayne@69: int borderWidth; /* Width of border. */ jpayne@69: int relief; /* 3-d effect: TK_RELIEF_RAISED, etc. */ jpayne@69: int highlightWidth; /* Width in pixels of highlight to draw around jpayne@69: * widget when it has the focus. <= 0 means jpayne@69: * don't draw a highlight. */ jpayne@69: XColor *highlightBgColorPtr;/* Color for drawing traversal highlight area jpayne@69: * when highlight is off. */ jpayne@69: XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ jpayne@69: int inset; /* Total width of all borders, including jpayne@69: * traversal highlight and 3-D border. jpayne@69: * Indicates how much interior stuff must be jpayne@69: * offset from outside edges to leave room for jpayne@69: * borders. */ jpayne@69: Tk_Font tkfont; /* Information about text font, or NULL. */ jpayne@69: XColor *normalFg; /* Foreground color in normal mode. */ jpayne@69: XColor *activeFg; /* Foreground color in active mode. NULL means jpayne@69: * use normalFg instead. */ jpayne@69: XColor *disabledFg; /* Foreground color when disabled. NULL means jpayne@69: * use normalFg with a 50% stipple instead. */ jpayne@69: GC normalTextGC; /* GC for drawing text in normal mode. */ jpayne@69: GC activeTextGC; /* GC for drawing text in active mode (NULL jpayne@69: * means use normalTextGC). */ jpayne@69: Pixmap gray; /* Pixmap for displaying disabled text/icon if jpayne@69: * disabledFg is NULL. */ jpayne@69: GC disabledGC; /* Used to produce disabled effect for jpayne@69: * text. */ jpayne@69: GC stippleGC; /* Used to produce disabled stipple effect for jpayne@69: * images when disabled. */ jpayne@69: int leftBearing; /* Distance from text origin to leftmost drawn jpayne@69: * pixel (positive means to right). */ jpayne@69: int rightBearing; /* Amount text sticks right from its jpayne@69: * origin. */ jpayne@69: char *widthString; /* Value of -width option. Malloc'ed. */ jpayne@69: char *heightString; /* Value of -height option. Malloc'ed. */ jpayne@69: int width, height; /* If > 0, these specify dimensions to request jpayne@69: * for window, in characters for text and in jpayne@69: * pixels for bitmaps. In this case the actual jpayne@69: * size of the text string or bitmap is jpayne@69: * ignored in computing desired window jpayne@69: * size. */ jpayne@69: int wrapLength; /* Line length (in pixels) at which to wrap jpayne@69: * onto next line. <= 0 means don't wrap jpayne@69: * except at newlines. */ jpayne@69: int padX, padY; /* Extra space around text or bitmap (pixels jpayne@69: * on each side). */ jpayne@69: Tk_Anchor anchor; /* Where text/bitmap should be displayed jpayne@69: * inside window region. */ jpayne@69: Tk_Justify justify; /* Justification to use for multi-line jpayne@69: * text. */ jpayne@69: int textWidth; /* Width needed to display text as requested, jpayne@69: * in pixels. */ jpayne@69: int textHeight; /* Height needed to display text as requested, jpayne@69: * in pixels. */ jpayne@69: Tk_TextLayout textLayout; /* Saved text layout information. */ jpayne@69: int indicatorOn; /* Non-zero means display indicator; 0 means jpayne@69: * don't display. */ jpayne@69: int indicatorHeight; /* Height of indicator in pixels. This same jpayne@69: * amount of extra space is also left on each jpayne@69: * side of the indicator. 0 if no jpayne@69: * indicator. */ jpayne@69: int indicatorWidth; /* Width of indicator in pixels, including jpayne@69: * indicatorHeight in padding on each side. 0 jpayne@69: * if no indicator. */ jpayne@69: jpayne@69: /* jpayne@69: * Miscellaneous information: jpayne@69: */ jpayne@69: jpayne@69: int compound; /* Value of -compound option; specifies jpayne@69: * whether the menubutton should show both an jpayne@69: * image and text, and, if so, how. */ jpayne@69: enum direction direction; /* Direction for where to pop the menu. Valid jpayne@69: * directions are "above", "below", "left", jpayne@69: * "right", and "flush". "flush" means that jpayne@69: * the upper left corner of the menubutton is jpayne@69: * where the menu pops up. "above" and "below" jpayne@69: * will attempt to pop the menu compleletly jpayne@69: * above or below the menu respectively. jpayne@69: * "left" and "right" will pop the menu left jpayne@69: * or right, and the active item will be next jpayne@69: * to the button. */ jpayne@69: Tk_Cursor cursor; /* Current cursor for window, or NULL. */ jpayne@69: char *takeFocus; /* Value of -takefocus option; not used in the jpayne@69: * C code, but used by keyboard traversal jpayne@69: * scripts. Malloc'ed, but may be NULL. */ jpayne@69: int flags; /* Various flags; see below for jpayne@69: * definitions. */ jpayne@69: } TkMenuButton; jpayne@69: jpayne@69: /* jpayne@69: * Flag bits for buttons: jpayne@69: * jpayne@69: * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has jpayne@69: * already been queued to redraw this window. jpayne@69: * POSTED: Non-zero means that the menu associated with jpayne@69: * this button has been posted (typically because jpayne@69: * of an active button press). jpayne@69: * GOT_FOCUS: Non-zero means this button currently has the jpayne@69: * input focus. jpayne@69: */ jpayne@69: jpayne@69: #define REDRAW_PENDING 1 jpayne@69: #define POSTED 2 jpayne@69: #define GOT_FOCUS 4 jpayne@69: jpayne@69: /* jpayne@69: * The following constants define the dimensions of the cascade indicator, jpayne@69: * which is displayed if the "-indicatoron" option is true. The units for jpayne@69: * these options are 1/10 millimeters. jpayne@69: */ jpayne@69: jpayne@69: #define INDICATOR_WIDTH 40 jpayne@69: #define INDICATOR_HEIGHT 17 jpayne@69: jpayne@69: /* jpayne@69: * Declaration of procedures used in the implementation of the button widget. jpayne@69: */ jpayne@69: jpayne@69: MODULE_SCOPE void TkpComputeMenuButtonGeometry(TkMenuButton *mbPtr); jpayne@69: MODULE_SCOPE TkMenuButton *TkpCreateMenuButton(Tk_Window tkwin); jpayne@69: MODULE_SCOPE void TkpDisplayMenuButton(ClientData clientData); jpayne@69: MODULE_SCOPE void TkpDestroyMenuButton(TkMenuButton *mbPtr); jpayne@69: MODULE_SCOPE void TkMenuButtonWorldChanged(ClientData instanceData); jpayne@69: jpayne@69: #endif /* _TKMENUBUTTON */