tkScrollbar.h 6.7 KB

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