home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tk8.0 / generic / tkButton.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  8.5 KB  |  242 lines  |  [TEXT/CWIE]

  1. /*
  2.  * tkButton.h --
  3.  *
  4.  *    Declarations of types and functions used to implement
  5.  *    button-like widgets.
  6.  *
  7.  * Copyright (c) 1996 by Sun Microsystems, Inc.
  8.  *
  9.  * See the file "license.terms" for information on usage and redistribution
  10.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  11.  *
  12.  * SCCS: @(#) tkButton.h 1.5 97/06/06 11:19:24
  13.  */
  14.  
  15. #ifndef _TKBUTTON
  16. #define _TKBUTTON
  17.  
  18. #ifndef _TKINT
  19. #include "tkInt.h"
  20. #endif
  21.  
  22. /*
  23.  * A data structure of the following type is kept for each
  24.  * widget managed by this file:
  25.  */
  26.  
  27. typedef struct {
  28.     Tk_Window tkwin;        /* Window that embodies the button.  NULL
  29.                  * means that the window has been destroyed. */
  30.     Display *display;        /* Display containing widget.  Needed to
  31.                  * free up resources after tkwin is gone. */
  32.     Tcl_Interp *interp;        /* Interpreter associated with button. */
  33.     Tcl_Command widgetCmd;    /* Token for button's widget command. */
  34.     int type;            /* Type of widget:  restricts operations
  35.                  * that may be performed on widget.  See
  36.                  * below for possible values. */
  37.  
  38.     /*
  39.      * Information about what's in the button.
  40.      */
  41.  
  42.     char *text;            /* Text to display in button (malloc'ed)
  43.                  * or NULL. */
  44.     int underline;        /* Index of character to underline.  < 0 means
  45.                  * don't underline anything. */
  46.     char *textVarName;        /* Name of variable (malloc'ed) or NULL.
  47.                  * If non-NULL, button displays the contents
  48.                  * of this variable. */
  49.     Pixmap bitmap;        /* Bitmap to display or None.  If not None
  50.                  * then text and textVar are ignored. */
  51.     char *imageString;        /* Name of image to display (malloc'ed), or
  52.                  * NULL.  If non-NULL, bitmap, text, and
  53.                  * textVarName are ignored. */
  54.     Tk_Image image;        /* Image to display in window, or NULL if
  55.                  * none. */
  56.     char *selectImageString;    /* Name of image to display when selected
  57.                  * (malloc'ed), or NULL. */
  58.     Tk_Image selectImage;    /* Image to display in window when selected,
  59.                  * or NULL if none.  Ignored if image is
  60.                  * NULL. */
  61.  
  62.     /*
  63.      * Information used when displaying widget:
  64.      */
  65.  
  66.     Tk_Uid state;        /* State of button for display purposes:
  67.                  * normal, active, or disabled. */
  68.     Tk_3DBorder normalBorder;    /* Structure used to draw 3-D
  69.                  * border and background when window
  70.                  * isn't active.  NULL means no such
  71.                  * border exists. */
  72.     Tk_3DBorder activeBorder;    /* Structure used to draw 3-D
  73.                  * border and background when window
  74.                  * is active.  NULL means no such
  75.                  * border exists. */
  76.     int borderWidth;        /* Width of border. */
  77.     int relief;            /* 3-d effect: TK_RELIEF_RAISED, etc. */
  78.     int highlightWidth;        /* Width in pixels of highlight to draw
  79.                  * around widget when it has the focus.
  80.                  * <= 0 means don't draw a highlight. */
  81.     Tk_3DBorder highlightBorder;
  82.                 /* Structure used to draw 3-D default ring
  83.                  * and focus highlight area when highlight
  84.                  * is off. */
  85.     XColor *highlightColorPtr;    /* Color for drawing traversal highlight. */
  86.  
  87.     int inset;            /* Total width of all borders, including
  88.                  * traversal highlight and 3-D border.
  89.                  * Indicates how much interior stuff must
  90.                  * be offset from outside edges to leave
  91.                  * room for borders. */
  92.     Tk_Font tkfont;        /* Information about text font, or NULL. */
  93.     XColor *normalFg;        /* Foreground color in normal mode. */
  94.     XColor *activeFg;        /* Foreground color in active mode.  NULL
  95.                  * means use normalFg instead. */
  96.     XColor *disabledFg;        /* Foreground color when disabled.  NULL
  97.                  * means use normalFg with a 50% stipple
  98.                  * instead. */
  99.     GC normalTextGC;        /* GC for drawing text in normal mode.  Also
  100.                  * used to copy from off-screen pixmap onto
  101.                  * screen. */
  102.     GC activeTextGC;        /* GC for drawing text in active mode (NULL
  103.                  * means use normalTextGC). */
  104.     Pixmap gray;        /* Pixmap for displaying disabled text if
  105.                  * disabledFg is NULL. */
  106.     GC disabledGC;        /* Used to produce disabled effect.  If
  107.                  * disabledFg isn't NULL, this GC is used to
  108.                  * draw button text or icon.  Otherwise
  109.                  * text or icon is drawn with normalGC and
  110.                  * this GC is used to stipple background
  111.                  * across it.  For labels this is None. */
  112.     GC copyGC;            /* Used for copying information from an
  113.                  * off-screen pixmap to the screen. */
  114.     char *widthString;        /* Value of -width option.  Malloc'ed. */
  115.     char *heightString;        /* Value of -height option.  Malloc'ed. */
  116.     int width, height;        /* If > 0, these specify dimensions to request
  117.                  * for window, in characters for text and in
  118.                  * pixels for bitmaps.  In this case the actual
  119.                  * size of the text string or bitmap is
  120.                  * ignored in computing desired window size. */
  121.     int wrapLength;        /* Line length (in pixels) at which to wrap
  122.                  * onto next line.  <= 0 means don't wrap
  123.                  * except at newlines. */
  124.     int padX, padY;        /* Extra space around text (pixels to leave
  125.                  * on each side).  Ignored for bitmaps and
  126.                  * images. */
  127.     Tk_Anchor anchor;        /* Where text/bitmap should be displayed
  128.                  * inside button region. */
  129.     Tk_Justify justify;        /* Justification to use for multi-line text. */
  130.     int indicatorOn;        /* True means draw indicator, false means
  131.                  * don't draw it. */
  132.     Tk_3DBorder selectBorder;    /* For drawing indicator background, or perhaps
  133.                  * widget background, when selected. */
  134.     int textWidth;        /* Width needed to display text as requested,
  135.                  * in pixels. */
  136.     int textHeight;        /* Height needed to display text as requested,
  137.                  * in pixels. */
  138.     Tk_TextLayout textLayout;    /* Saved text layout information. */
  139.     int indicatorSpace;        /* Horizontal space (in pixels) allocated for
  140.                  * display of indicator. */
  141.     int indicatorDiameter;    /* Diameter of indicator, in pixels. */
  142.     Tk_Uid defaultState;    /* State of default ring: normal, active, or
  143.                  * disabled. */
  144.         
  145.     /*
  146.      * For check and radio buttons, the fields below are used
  147.      * to manage the variable indicating the button's state.
  148.      */
  149.  
  150.     char *selVarName;        /* Name of variable used to control selected
  151.                  * state of button.  Malloc'ed (if
  152.                  * not NULL). */
  153.     char *onValue;        /* Value to store in variable when
  154.                  * this button is selected.  Malloc'ed (if
  155.                  * not NULL). */
  156.     char *offValue;        /* Value to store in variable when this
  157.                  * button isn't selected.  Malloc'ed
  158.                  * (if not NULL).  Valid only for check
  159.                  * buttons. */
  160.  
  161.     /*
  162.      * Miscellaneous information:
  163.      */
  164.  
  165.     Tk_Cursor cursor;        /* Current cursor for window, or None. */
  166.     char *takeFocus;        /* Value of -takefocus option;  not used in
  167.                  * the C code, but used by keyboard traversal
  168.                  * scripts.  Malloc'ed, but may be NULL. */
  169.     char *command;        /* Command to execute when button is
  170.                  * invoked; valid for buttons only.
  171.                  * If not NULL, it's malloc-ed. */
  172.     int flags;            /* Various flags;  see below for
  173.                  * definitions. */
  174. } TkButton;
  175.  
  176. /*
  177.  * Possible "type" values for buttons.  These are the kinds of
  178.  * widgets supported by this file.  The ordering of the type
  179.  * numbers is significant:  greater means more features and is
  180.  * used in the code.
  181.  */
  182.  
  183. #define TYPE_LABEL        0
  184. #define TYPE_BUTTON        1
  185. #define TYPE_CHECK_BUTTON    2
  186. #define TYPE_RADIO_BUTTON    3
  187.  
  188. /*
  189.  * Flag bits for buttons:
  190.  *
  191.  * REDRAW_PENDING:        Non-zero means a DoWhenIdle handler
  192.  *                has already been queued to redraw
  193.  *                this window.
  194.  * SELECTED:            Non-zero means this button is selected,
  195.  *                so special highlight should be drawn.
  196.  * GOT_FOCUS:            Non-zero means this button currently
  197.  *                has the input focus.
  198.  */
  199.  
  200. #define REDRAW_PENDING        1
  201. #define SELECTED        2
  202. #define GOT_FOCUS        4
  203.  
  204. /*
  205.  * Mask values used to selectively enable entries in the
  206.  * configuration specs:
  207.  */
  208.  
  209. #define LABEL_MASK        TK_CONFIG_USER_BIT
  210. #define BUTTON_MASK        TK_CONFIG_USER_BIT << 1
  211. #define CHECK_BUTTON_MASK    TK_CONFIG_USER_BIT << 2
  212. #define RADIO_BUTTON_MASK    TK_CONFIG_USER_BIT << 3
  213. #define ALL_MASK        (LABEL_MASK | BUTTON_MASK \
  214.     | CHECK_BUTTON_MASK | RADIO_BUTTON_MASK)
  215.  
  216. /*
  217.  * Declaration of variables shared between the files in the button module.
  218.  */
  219.  
  220. extern TkClassProcs tkpButtonProcs;
  221. extern Tk_ConfigSpec tkpButtonConfigSpecs[];
  222.  
  223. /*
  224.  * Declaration of procedures used in the implementation of the button
  225.  * widget. 
  226.  */
  227.  
  228. EXTERN void        TkButtonWorldChanged _ANSI_ARGS_((
  229.                 ClientData instanceData));
  230. EXTERN void        TkpComputeButtonGeometry _ANSI_ARGS_((
  231.                 TkButton *butPtr));
  232. EXTERN TkButton *    TkpCreateButton _ANSI_ARGS_((Tk_Window tkwin));
  233. #ifndef TkpDestroyButton
  234. EXTERN void         TkpDestroyButton _ANSI_ARGS_((TkButton *butPtr));
  235. #endif
  236. #ifndef TkpDisplayButton
  237. EXTERN void        TkpDisplayButton _ANSI_ARGS_((ClientData clientData));
  238. #endif
  239. EXTERN int        TkInvokeButton  _ANSI_ARGS_((TkButton *butPtr));
  240.  
  241. #endif /* _TKBUTTON */
  242.