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 / tkScrollbar.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  7.0 KB  |  201 lines  |  [TEXT/CWIE]

  1. /*
  2.  * tkScrollbar.h --
  3.  *
  4.  *    Declarations of types and functions used to implement
  5.  *    the scrollbar widget.
  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: @(#) tkScrollbar.h 1.8 96/11/05 11:34:58
  13.  */
  14.  
  15. #ifndef _TKSCROLLBAR
  16. #define _TKSCROLLBAR
  17.  
  18. #ifndef _TKINT
  19. #include "tkInt.h"
  20. #endif
  21.  
  22. /*
  23.  * A data structure of the following type is kept for each scrollbar
  24.  * widget.
  25.  */
  26.  
  27. typedef struct TkScrollbar {
  28.     Tk_Window tkwin;        /* Window that embodies the scrollbar.  NULL
  29.                  * means that the window has been destroyed
  30.                  * but the data structures haven't yet been
  31.                  * cleaned up.*/
  32.     Display *display;        /* Display containing widget.  Used, among
  33.                  * other things, so that resources can be
  34.                  * freed even after tkwin has gone away. */
  35.     Tcl_Interp *interp;        /* Interpreter associated with scrollbar. */
  36.     Tcl_Command widgetCmd;    /* Token for scrollbar's widget command. */
  37.     Tk_Uid orientUid;        /* Orientation for window ("vertical" or
  38.                  * "horizontal"). */
  39.     int vertical;        /* Non-zero means vertical orientation
  40.                  * requested, zero means horizontal. */
  41.     int width;            /* Desired narrow dimension of scrollbar,
  42.                  * in pixels. */
  43.     char *command;        /* Command prefix to use when invoking
  44.                  * scrolling commands.  NULL means don't
  45.                  * invoke commands.  Malloc'ed. */
  46.     int commandSize;        /* Number of non-NULL bytes in command. */
  47.     int repeatDelay;        /* How long to wait before auto-repeating
  48.                  * on scrolling actions (in ms). */
  49.     int repeatInterval;        /* Interval between autorepeats (in ms). */
  50.     int jump;            /* Value of -jump option. */
  51.  
  52.     /*
  53.      * Information used when displaying widget:
  54.      */
  55.  
  56.     int borderWidth;        /* Width of 3-D borders. */
  57.     Tk_3DBorder bgBorder;    /* Used for drawing background (all flat
  58.                  * surfaces except for trough). */
  59.     Tk_3DBorder activeBorder;    /* For drawing backgrounds when active (i.e.
  60.                  * when mouse is positioned over element). */
  61.     XColor *troughColorPtr;    /* Color for drawing trough. */
  62.     int relief;            /* Indicates whether window as a whole is
  63.                  * raised, sunken, or flat. */
  64.     int highlightWidth;        /* Width in pixels of highlight to draw
  65.                  * around widget when it has the focus.
  66.                  * <= 0 means don't draw a highlight. */
  67.     XColor *highlightBgColorPtr;
  68.                 /* Color for drawing traversal highlight
  69.                  * area when highlight is off. */
  70.     XColor *highlightColorPtr;    /* Color for drawing traversal highlight. */
  71.     int inset;            /* Total width of all borders, including
  72.                  * traversal highlight and 3-D border.
  73.                  * Indicates how much interior stuff must
  74.                  * be offset from outside edges to leave
  75.                  * room for borders. */
  76.     int elementBorderWidth;    /* Width of border to draw around elements
  77.                  * inside scrollbar (arrows and slider).
  78.                  * -1 means use borderWidth. */
  79.     int arrowLength;        /* Length of arrows along long dimension of
  80.                  * scrollbar, including space for a small gap
  81.                  * between the arrow and the slider.
  82.                  * Recomputed on window size changes. */
  83.     int sliderFirst;        /* Pixel coordinate of top or left edge
  84.                  * of slider area, including border. */
  85.     int sliderLast;        /* Coordinate of pixel just after bottom
  86.                  * or right edge of slider area, including
  87.                  * border. */
  88.     int activeField;        /* Names field to be displayed in active
  89.                  * colors, such as TOP_ARROW, or 0 for
  90.                  * no field. */
  91.     int activeRelief;        /* Value of -activeRelief option: relief
  92.                  * to use for active element. */
  93.  
  94.     /*
  95.      * Information describing the application related to the scrollbar.
  96.      * This information is provided by the application by invoking the
  97.      * "set" widget command.  This information can now be provided in
  98.      * two ways:  the "old" form (totalUnits, windowUnits, firstUnit,
  99.      * and lastUnit), or the "new" form (firstFraction and lastFraction).
  100.      * FirstFraction and lastFraction will always be valid, but
  101.      * the old-style information is only valid if the NEW_STYLE_COMMANDS
  102.      * flag is 0.
  103.      */
  104.  
  105.     int totalUnits;        /* Total dimension of application, in
  106.                  * units.  Valid only if the NEW_STYLE_COMMANDS
  107.                  * flag isn't set. */
  108.     int windowUnits;        /* Maximum number of units that can be
  109.                  * displayed in the window at once.  Valid
  110.                  * only if the NEW_STYLE_COMMANDS flag isn't
  111.                  * set. */
  112.     int firstUnit;        /* Number of last unit visible in
  113.                  * application's window.  Valid only if the
  114.                  * NEW_STYLE_COMMANDS flag isn't set. */
  115.     int lastUnit;        /* Index of last unit visible in window.
  116.                  * Valid only if the NEW_STYLE_COMMANDS
  117.                  * flag isn't set. */
  118.     double firstFraction;    /* Position of first visible thing in window,
  119.                  * specified as a fraction between 0 and
  120.                  * 1.0. */
  121.     double lastFraction;    /* Position of last visible thing in window,
  122.                  * specified as a fraction between 0 and
  123.                  * 1.0. */
  124.  
  125.     /*
  126.      * Miscellaneous information:
  127.      */
  128.  
  129.     Tk_Cursor cursor;        /* Current cursor for window, or None. */
  130.     char *takeFocus;        /* Value of -takefocus option;  not used in
  131.                  * the C code, but used by keyboard traversal
  132.                  * scripts.  Malloc'ed, but may be NULL. */
  133.     int flags;            /* Various flags;  see below for
  134.                  * definitions. */
  135. } TkScrollbar;
  136.  
  137. /*
  138.  * Legal values for "activeField" field of Scrollbar structures.  These
  139.  * are also the return values from the ScrollbarPosition procedure.
  140.  */
  141.  
  142. #define OUTSIDE        0
  143. #define TOP_ARROW    1
  144. #define TOP_GAP        2
  145. #define SLIDER        3
  146. #define BOTTOM_GAP    4
  147. #define BOTTOM_ARROW    5
  148.  
  149. /*
  150.  * Flag bits for scrollbars:
  151.  * 
  152.  * REDRAW_PENDING:        Non-zero means a DoWhenIdle handler
  153.  *                has already been queued to redraw
  154.  *                this window.
  155.  * NEW_STYLE_COMMANDS:        Non-zero means the new style of commands
  156.  *                should be used to communicate with the
  157.  *                widget:  ".t yview scroll 2 lines", instead
  158.  *                of ".t yview 40", for example.
  159.  * GOT_FOCUS:            Non-zero means this window has the input
  160.  *                focus.
  161.  */
  162.  
  163. #define REDRAW_PENDING        1
  164. #define NEW_STYLE_COMMANDS    2
  165. #define GOT_FOCUS        4
  166.  
  167. /*
  168.  * Declaration of scrollbar class procedures structure.
  169.  */
  170.  
  171. extern TkClassProcs tkpScrollbarProcs;
  172.  
  173. /*
  174.  * Declaration of scrollbar configuration options.
  175.  */
  176.  
  177. extern Tk_ConfigSpec tkpScrollbarConfigSpecs[];
  178.  
  179. /*
  180.  * Declaration of procedures used in the implementation of the scrollbar
  181.  * widget. 
  182.  */
  183.  
  184. EXTERN void        TkScrollbarEventProc _ANSI_ARGS_((
  185.                 ClientData clientData, XEvent *eventPtr));
  186. EXTERN void        TkScrollbarEventuallyRedraw _ANSI_ARGS_((
  187.                 TkScrollbar *scrollPtr));
  188. EXTERN void        TkpComputeScrollbarGeometry _ANSI_ARGS_((
  189.                 TkScrollbar *scrollPtr));
  190. EXTERN TkScrollbar *    TkpCreateScrollbar _ANSI_ARGS_((Tk_Window tkwin));
  191. EXTERN void         TkpDestroyScrollbar _ANSI_ARGS_((
  192.                     TkScrollbar *scrollPtr));
  193. EXTERN void        TkpDisplayScrollbar _ANSI_ARGS_((
  194.                 ClientData clientData));
  195. EXTERN void        TkpConfigureScrollbar _ANSI_ARGS_((
  196.                 TkScrollbar *scrollPtr));
  197. EXTERN int        TkpScrollbarPosition _ANSI_ARGS_((
  198.                 TkScrollbar *scrollPtr, int x, int y));
  199.  
  200. #endif /* _TKSCROLLBAR */
  201.