home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / tcl / tk3.3b1 / doc / GetCursor.3 < prev    next >
Encoding:
Text File  |  1993-04-01  |  8.2 KB  |  193 lines

  1. '\" Copyright (c) 1990 The Regents of the University of California.
  2. '\" All rights reserved.
  3. '\"
  4. '\" Permission is hereby granted, without written agreement and without
  5. '\" license or royalty fees, to use, copy, modify, and distribute this
  6. '\" documentation for any purpose, provided that the above copyright
  7. '\" notice and the following two paragraphs appear in all copies.
  8. '\"
  9. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  10. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  11. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  12. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  13. '\"
  14. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  15. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  16. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  17. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  18. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  19. '\" 
  20. '\" $Header: /user6/ouster/wish/man/RCS/GetCursor.3,v 1.9 93/04/01 09:41:26 ouster Exp $ SPRITE (Berkeley)
  21. '\" 
  22. .so man.macros
  23. .HS Tk_GetCursor tkc
  24. .BS
  25. .SH NAME
  26. Tk_GetCursor, Tk_GetCursorFromData, Tk_NameOfCursor, Tk_FreeCursor \- maintain database of cursors
  27. .SH SYNOPSIS
  28. .nf
  29. \fB#include <tk.h>\fR
  30. .sp
  31. Cursor
  32. \fBTk_GetCursor(\fIinterp, tkwin, nameId\fB)\fR
  33. .sp
  34. Cursor
  35. \fBTk_GetCursorFromData(\fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bg\fB)\fR
  36. .sp
  37. char *
  38. .VS
  39. \fBTk_NameOfCursor(\fIdisplay, cursor\fB)\fR
  40. .sp
  41. \fBTk_FreeCursor(\fIdisplay, cursor\fB)\fR
  42. .VE
  43. .SH ARGUMENTS
  44. .AS "unsigned long" *pixelPtr
  45. .AP Tcl_Interp *interp in
  46. Interpreter to use for error reporting.
  47. .AP Tk_Window tkwin in
  48. Token for window in which the cursor will be used.
  49. .AP Tk_Uid nameId in
  50. Description of cursor;  see below for possible values.
  51. .AP char *source in
  52. Data for cursor bitmap, in standard bitmap format.
  53. .AP char *mask in
  54. Data for mask bitmap, in standard bitmap format.
  55. .AP "unsigned int" width in
  56. Width of \fIsource\fR and \fImask\fR.
  57. .AP "unsigned int" height in
  58. Height of \fIsource\fR and \fImask\fR.
  59. .AP "unsigned int" xHot in
  60. X-location of cursor hot-spot.
  61. .AP "unsigned int" yHot in
  62. Y-location of cursor hot-spot.
  63. .AP Tk_Uid fg in
  64. Textual description of foreground color for cursor.
  65. .AP Tk_Uid bg in
  66. Textual description of background color for cursor.
  67. .AP Display *display in
  68. Display for which \fIcursor\fR was allocated.
  69. .VS
  70. .VE
  71. .AP Cursor cursor in
  72. X identifier for cursor.  If passed to\fBTk_FreeCursor\fR, must
  73. have been returned by some previous call to \fBTk_GetCursor\fR or
  74. \fBTk_GetCursorFromData\fR.
  75. .BE
  76.  
  77. .SH DESCRIPTION
  78. .PP
  79. These procedures manage a collection of cursors
  80. being used by an application.  The procedures allow cursors to be
  81. re-used efficiently, thereby avoiding server overhead, and also
  82. allow cursors to be named with character strings (actually Tk_Uids).
  83. .PP
  84. \fBTk_GetCursor\fR takes as argument a Tk_Uid describing a cursor,
  85. and returns the X identifier for a cursor corresponding to the
  86. description.  It re-uses an existing cursor if possible and
  87. creates a new one otherwise.  \fINameId\fR must be a standard Tcl
  88. list with one of the following forms:
  89. .TP
  90. \fIname\fR\ \ [\fIfgColor\fR\ \ [\fIbgColor\fR]]
  91. \fIName\fR is the name of a cursor in the standard X cursor font,
  92. i.e., any of the names defined in \fBcursorfont.h\fR, without
  93. the \fBXC_\fR.  Some example values are \fBX_cursor\fR, \fBhand2\fR,
  94. or \fBleft_ptr\fR.  Appendix B of ``The X Window System''
  95. by Scheifler & Gettys has illustrations showing what each of these
  96. cursors looks like.  If \fIfgColor\fR and \fIbgColor\fR are both
  97. specified, they give the foreground and background colors to use
  98. for the cursor (any of the forms acceptable to \fBTk_GetColor\fR
  99. may be used).  If only \fIfgColor\fR is specified, then there
  100. will be no background color:  the background will be transparent.
  101. If no colors are specified, then the cursor
  102. will use black for its foreground color and white for its background
  103. color.
  104. .TP
  105. \fB@\fIsourceName\ \ maskName\ \ fgColor\ \ bgColor\fR
  106. .br
  107. In this form, \fIsourceName\fR and \fImaskName\fR are the names of
  108. files describing bitmaps for the cursor's source bits and mask.
  109. Each file must be in standard X11 or X10 bitmap format.
  110. \fIFgColor\fR and \fIbgColor\fR 
  111. indicate the colors to use for the
  112. cursor, in any of the forms acceptable to \fBTk_GetColor\fR.
  113. .TP
  114. \fB@\fIsourceName\ \ fgColor\fR
  115. .br
  116. This form is similar to the one above, except that the source is
  117. used as mask also.  This means that the cursor's background is transparent.
  118. .PP
  119. \fBTk_GetCursorFromData\fR allows cursors to be created from
  120. in-memory descriptions of their source and mask bitmaps.  \fISource\fR
  121. points to standard bitmap data for the cursor's source bits, and
  122. \fImask\fR points to standard bitmap data describing
  123. which pixels of \fIsource\fR are to be drawn and which are to be
  124. considered transparent.  \fIWidth\fR and \fIheight\fR give the
  125. dimensions of the cursor, \fIxHot\fR and \fIyHot\fR indicate the
  126. location of the cursor's hot-spot (the point that is reported when
  127. an event occurs), and \fIfg\fR and \fIbg\fR describe the cursor's
  128. foreground and background colors textually (any of the forms
  129. suitable for \fBTk_GetColor\fR may be used).  Typically, the
  130. arguments to \fBTk_GetCursorFromData\fR are created by including
  131. a cursor file directly into the source code for a program, as in
  132. the following example:
  133. .nf
  134. .RS
  135. \fCCursor cursor;
  136. #include "source.cursor"
  137. #include "mask.cursor"
  138. cursor = Tk_GetCursorFromData(interp, tkwin, source_bits,
  139.     mask_bits, source_width, source_height, source_x_hot,
  140.     source_y_hot, Tk_GetUid("red"), Tk_GetUid("blue"));\fR
  141. .RE
  142. .fi
  143. .PP
  144. Under normal conditions, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR
  145. will return an identifier for the requested cursor.  If an error
  146. occurs in creating the cursor, such as when \fInameId\fR refers
  147. to a non-existent file, then \fBNone\fR is returned and an error
  148. message will be stored in \fIinterp->result\fR.
  149. .PP
  150. \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR maintain a
  151. database of all the cursors they have created.  Whenever possible,
  152. a call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR will
  153. return an existing cursor rather than creating a new one.  This
  154. approach can substantially reduce server overhead, so the Tk
  155. procedures should generally be used in preference to Xlib procedures
  156. like \fBXCreateFontCursor\fR or \fBXCreatePixmapCursor\fR, which
  157. create a new cursor on each call.
  158. .PP
  159. The procedure \fBTk_NameOfCursor\fR is roughly the inverse of
  160. \fBTk_GetCursor\fR.  If its \fIcursor\fR argument was created
  161. by \fBTk_GetCursor\fR, then the return value is the \fInameId\fR
  162. argument that was passed to \fBTk_GetCursor\fR to create the
  163. cursor.  If \fIcursor\fR was created by a call to \fBTk_GetCursorFromData\fR,
  164. or by any other mechanism, then the return value is a hexadecimal string
  165. giving the X identifier for the cursor.
  166. Note:  the string returned by \fBTk_NameOfCursor\fR is
  167. only guaranteed to persist until the next call to \fBTk_NameOfCursor\fR.
  168. .PP
  169. When a cursor returned by \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR
  170. is no longer needed, \fBTk_FreeCursor\fR should be called to release it.
  171. There should be exactly one call to \fBTk_FreeCursor\fR for
  172. each call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR.
  173. When a cursor is no longer in use anywhere (i.e. it has been freed as
  174. many times as it has been gotten) \fBTk_FreeCursor\fR will release
  175. it to the X server and remove it from the database.
  176.  
  177. .SH BUGS
  178. In determining whether an existing cursor can be used to satisfy
  179. a new request, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR
  180. consider only the immediate values of their arguments.  For
  181. example, when a file name is passed to \fBTk_GetCursor\fR,
  182. \fBTk_GetCursor\fR will assume it is safe to re-use an existing
  183. cursor created from the same file name:  it will not check to
  184. see whether the file itself has changed, or whether the current
  185. directory has changed, thereby causing the name to refer to
  186. a different file.  Similarly, \fBTk_GetCursorFromData\fR assumes
  187. that if the same \fIsource\fR pointer is used in two different calls,
  188. then the pointers refer to the same data;  it does not check to
  189. see if the actual data values have changed.
  190.  
  191. .SH KEYWORDS
  192. cursor
  193.