home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / man / lib / tk / GetCursor.man < prev    next >
Encoding:
Text File  |  1992-08-24  |  10.9 KB  |  352 lines

  1. '\"
  2. '\" Copyright 1990 Regents of the University of California
  3. '\" Permission to use, copy, modify, and distribute this
  4. '\" documentation for any purpose and without fee is hereby
  5. '\" granted, provided that this notice appears in all copies.
  6. '\" The University of California makes no representations about
  7. '\" the suitability of this material for any purpose.  It is
  8. '\" provided "as is" without express or implied warranty.
  9. '\" 
  10. '\" $Header: /user6/ouster/wish/man/RCS/GetCursor.man,v 1.6 92/08/20 08:35:43 ouster Exp $ SPRITE (Berkeley)
  11. '\" 
  12. .\" The definitions below are for supplemental macros used in Sprite
  13. .\" manual entries.
  14. .\"
  15. .\" .HS name section [date [version]]
  16. .\"    Replacement for .TH in other man pages.  See below for valid
  17. .\"    section names.
  18. .\"
  19. .\" .AP type name in/out [indent]
  20. .\"    Start paragraph describing an argument to a library procedure.
  21. .\"    type is type of argument (int, etc.), in/out is either "in", "out",
  22. .\"    or "in/out" to describe whether procedure reads or modifies arg,
  23. .\"    and indent is equivalent to second arg of .IP (shouldn't ever be
  24. .\"    needed;  use .AS below instead)
  25. .\"
  26. .\" .AS [type [name]]
  27. .\"    Give maximum sizes of arguments for setting tab stops.  Type and
  28. .\"    name are examples of largest possible arguments that will be passed
  29. .\"    to .AP later.  If args are omitted, default tab stops are used.
  30. .\"
  31. .\" .BS
  32. .\"    Start box enclosure.  From here until next .BE, everything will be
  33. .\"    enclosed in one large box.
  34. .\"
  35. .\" .BE
  36. .\"    End of box enclosure.
  37. .\"
  38. .\" .VS
  39. .\"    Begin vertical sidebar, for use in marking newly-changed parts
  40. .\"    of man pages.
  41. .\"
  42. .\" .VE
  43. .\"    End of vertical sidebar.
  44. .\"
  45. .\" .DS
  46. .\"    Begin an indented unfilled display.
  47. .\"
  48. .\" .DE
  49. .\"    End of indented unfilled display.
  50. .\"
  51. '\"    # Heading for Sprite man pages
  52. .de HS
  53. .if '\\$2'cmds'       .TH \\$1 1 \\$3 \\$4
  54. .if '\\$2'lib'        .TH \\$1 3 \\$3 \\$4
  55. .if '\\$2'tcl'        .TH \\$1 3 \\$3 \\$4
  56. .if '\\$2'tk'         .TH \\$1 3 \\$3 \\$4
  57. .if t .wh -1.3i ^B
  58. .nr ^l \\n(.l
  59. .ad b
  60. ..
  61. '\"    # Start an argument description
  62. .de AP
  63. .ie !"\\$4"" .TP \\$4
  64. .el \{\
  65. .   ie !"\\$2"" .TP \\n()Cu
  66. .   el          .TP 15
  67. .\}
  68. .ie !"\\$3"" \{\
  69. .ta \\n()Au \\n()Bu
  70. \&\\$1    \\fI\\$2\\fP    (\\$3)
  71. .\".b
  72. .\}
  73. .el \{\
  74. .br
  75. .ie !"\\$2"" \{\
  76. \&\\$1    \\fI\\$2\\fP
  77. .\}
  78. .el \{\
  79. \&\\fI\\$1\\fP
  80. .\}
  81. .\}
  82. ..
  83. '\"    # define tabbing values for .AP
  84. .de AS
  85. .nr )A 10n
  86. .if !"\\$1"" .nr )A \\w'\\$1'u+3n
  87. .nr )B \\n()Au+15n
  88. .\"
  89. .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
  90. .nr )C \\n()Bu+\\w'(in/out)'u+2n
  91. ..
  92. '\"    # BS - start boxed text
  93. '\"    # ^y = starting y location
  94. '\"    # ^b = 1
  95. .de BS
  96. .br
  97. .mk ^y
  98. .nr ^b 1u
  99. .if n .nf
  100. .if n .ti 0
  101. .if n \l'\\n(.lu\(ul'
  102. .if n .fi
  103. ..
  104. '\"    # BE - end boxed text (draw box now)
  105. .de BE
  106. .nf
  107. .ti 0
  108. .mk ^t
  109. .ie n \l'\\n(^lu\(ul'
  110. .el \{\
  111. .\"    Draw four-sided box normally, but don't draw top of
  112. .\"    box if the box started on an earlier page.
  113. .ie !\\n(^b-1 \{\
  114. \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  115. .\}
  116. .el \}\
  117. \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
  118. .\}
  119. .\}
  120. .fi
  121. .br
  122. .nr ^b 0
  123. ..
  124. '\"    # VS - start vertical sidebar
  125. '\"    # ^Y = starting y location
  126. '\"    # ^v = 1 (for troff;  for nroff this doesn't matter)
  127. .de VS
  128. .mk ^Y
  129. .ie n 'mc \s12\(br\s0
  130. .el .nr ^v 1u
  131. ..
  132. '\"    # VE - end of vertical sidebar
  133. .de VE
  134. .ie n 'mc
  135. .el \{\
  136. .ev 2
  137. .nf
  138. .ti 0
  139. .mk ^t
  140. \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
  141. .sp -1
  142. .fi
  143. .ev
  144. .\}
  145. .nr ^v 0
  146. ..
  147. '\"    # Special macro to handle page bottom:  finish off current
  148. '\"    # box/sidebar if in box/sidebar mode, then invoked standard
  149. '\"    # page bottom macro.
  150. .de ^B
  151. .ev 2
  152. 'ti 0
  153. 'nf
  154. .mk ^t
  155. .if \\n(^b \{\
  156. .\"    Draw three-sided box if this is the box's first page,
  157. .\"    draw two sides but no top otherwise.
  158. .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  159. .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
  160. .\}
  161. .if \\n(^v \{\
  162. .nr ^x \\n(^tu+1v-\\n(^Yu
  163. \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
  164. .\}
  165. .bp
  166. 'fi
  167. .ev
  168. .if \\n(^b \{\
  169. .mk ^y
  170. .nr ^b 2
  171. .\}
  172. .if \\n(^v \{\
  173. .mk ^Y
  174. .\}
  175. ..
  176. '\"    # DS - begin display
  177. .de DS
  178. .RS
  179. .nf
  180. .sp
  181. ..
  182. '\"    # DE - end display
  183. .de DE
  184. .fi
  185. .RE
  186. .sp .5
  187. ..
  188. .HS Tk_GetCursor tk
  189. .BS
  190. .SH NAME
  191. Tk_GetCursor, Tk_GetCursorFromData, Tk_NameOfCursor, Tk_FreeCursor \- maintain database of cursors
  192. .SH SYNOPSIS
  193. .nf
  194. \fB#include <tk.h>\fR
  195. .sp
  196. Cursor
  197. \fBTk_GetCursor(\fIinterp, tkwin, nameId\fB)\fR
  198. .sp
  199. Cursor
  200. \fBTk_GetCursorFromData(\fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bg\fB)\fR
  201. .sp
  202. char *
  203. \fBTk_NameOfCursor(\fIcursor\fB)\fR
  204. .sp
  205. \fBTk_FreeCursor(\fIcursor\fB)\fR
  206. .SH ARGUMENTS
  207. .AS "unsigned long" *pixelPtr
  208. .AP Tcl_Interp *interp in
  209. Interpreter to use for error reporting.
  210. .AP Tk_Window tkwin in
  211. Token for window in which the cursor will be used.
  212. .AP Tk_Uid nameId in
  213. Description of cursor;  see below for possible values.
  214. .AP char *source in
  215. Data for cursor bitmap, in standard bitmap format.
  216. .AP char *mask in
  217. Data for mask bitmap, in standard bitmap format.
  218. .AP "unsigned int" width in
  219. Width of \fIsource\fR and \fImask\fR.
  220. .AP "unsigned int" height in
  221. Height of \fIsource\fR and \fImask\fR.
  222. .AP "unsigned int" xHot in
  223. X-location of cursor hot-spot.
  224. .AP "unsigned int" yHot in
  225. Y-location of cursor hot-spot.
  226. .AP Tk_Uid fg in
  227. Textual description of foreground color for cursor.
  228. .AP Tk_Uid bg in
  229. Textual description of background color for cursor.
  230. .AP Cursor cursor in
  231. X identifier for cursor.  If passed to\fBTk_FreeCursor\fR, must
  232. have been returned by some previous call to \fBTk_GetCursor\fR or
  233. \fBTk_GetCursorFromData\fR.
  234. .BE
  235.  
  236. .SH DESCRIPTION
  237. .PP
  238. These procedures manage a collection of cursors
  239. being used by an application.  The procedures allow cursors to be
  240. re-used efficiently, thereby avoiding server overhead, and also
  241. allow cursors to be named with character strings (actually Tk_Uids).
  242. .PP
  243. \fBTk_GetCursor\fR takes as argument a Tk_Uid describing a cursor,
  244. and returns the X identifier for a cursor corresponding to the
  245. description.  It re-uses an existing cursor if possible and
  246. creates a new one otherwise.  \fINameId\fR must be a standard Tcl
  247. list with one of the following forms:
  248. .TP
  249. \fIname\fR\ \ [\fIfgColor\fR\ \ [\fIbgColor\fR]]
  250. \fIName\fR is the name of a cursor in the standard X cursor font,
  251. i.e., any of the names defined in \fBcursorfont.h\fR, without
  252. the \fBXC_\fR.  Some example values are \fBX_cursor\fR, \fBhand2\fR,
  253. or \fBleft_ptr\fR.  Appendix B of ``The X Window System''
  254. by Scheifler & Gettys has illustrations showing what each of these
  255. cursors looks like.  If \fIfgColor\fR and \fIbgColor\fR are both
  256. specified, they give the foreground and background colors to use
  257. for the cursor (any of the forms acceptable to \fBTk_GetColor\fR
  258. may be used).  If only \fIfgColor\fR is specified, then there
  259. will be no background color:  the background will be transparent.
  260. If no colors are specified, then the cursor
  261. will use black for its foreground color and white for its background
  262. color.
  263. .TP
  264. \fB@\fIsourceName\ \ maskName\ \ fgColor\ \ bgColor\fR
  265. .br
  266. In this form, \fIsourceName\fR and \fImaskName\fR are the names of
  267. files describing bitmaps for the cursor's source bits and mask.
  268. Each file must be in standard X11 or X10 bitmap format.
  269. \fIFgColor\fR and \fIbgColor\fR 
  270. indicate the colors to use for the
  271. cursor, in any of the forms acceptable to \fBTk_GetColor\fR.
  272. .TP
  273. \fB@\fIsourceName\ \ fgColor\fR
  274. .br
  275. This form is similar to the one above, except that the source is
  276. used as mask also.  This means that the cursor's background is transparent.
  277. .PP
  278. \fBTk_GetCursorFromData\fR allows cursors to be created from
  279. in-memory descriptions of their source and mask bitmaps.  \fISource\fR
  280. points to standard bitmap data for the cursor's source bits, and
  281. \fImask\fR points to standard bitmap data describing
  282. which pixels of \fIsource\fR are to be drawn and which are to be
  283. considered transparent.  \fIWidth\fR and \fIheight\fR give the
  284. dimensions of the cursor, \fIxHot\fR and \fIyHot\fR indicate the
  285. location of the cursor's hot-spot (the point that is reported when
  286. an event occurs), and \fIfg\fR and \fIbg\fR describe the cursor's
  287. foreground and background colors textually (any of the forms
  288. suitable for \fBTk_GetColor\fR may be used).  Typically, the
  289. arguments to \fBTk_GetCursorFromData\fR are created by including
  290. a cursor file directly into the source code for a program, as in
  291. the following example:
  292. .nf
  293. .RS
  294. \fCCursor cursor;
  295. #include "source.cursor"
  296. #include "mask.cursor"
  297. cursor = Tk_GetCursorFromData(interp, tkwin, source_bits,
  298.     mask_bits, source_width, source_height, source_x_hot,
  299.     source_y_hot, Tk_GetUid("red"), Tk_GetUid("blue"));\fR
  300. .RE
  301. .fi
  302. .PP
  303. Under normal conditions, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR
  304. will return an identifier for the requested cursor.  If an error
  305. occurs in creating the cursor, such as when \fInameId\fR refers
  306. to a non-existent file, then \fBNone\fR is returned and an error
  307. message will be stored in \fIinterp->result\fR.
  308. .PP
  309. \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR maintain a
  310. database of all the cursors they have created.  Whenever possible,
  311. a call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR will
  312. return an existing cursor rather than creating a new one.  This
  313. approach can substantially reduce server overhead, so the Tk
  314. procedures should generally be used in preference to Xlib procedures
  315. like \fBXCreateFontCursor\fR or \fBXCreatePixmapCursor\fR, which
  316. create a new cursor on each call.
  317. .PP
  318. The procedure \fBTk_NameOfCursor\fR is roughly the inverse of
  319. \fBTk_GetCursor\fR.  If its \fIcursor\fR argument was created
  320. by \fBTk_GetCursor\fR, then the return value is the \fInameId\fR
  321. argument that was passed to \fBTk_GetCursor\fR to create the
  322. cursor.  If \fIcursor\fR was created by a call to \fBTk_GetCursorFromData\fR,
  323. or by any other mechanism, then the return value is a hexadecimal string
  324. giving the X identifier for the cursor.
  325. Note:  the string returned by \fBTk_NameOfCursor\fR is
  326. only guaranteed to persist until the next call to \fBTk_NameOfCursor\fR.
  327. .PP
  328. When a cursor returned by \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR
  329. is no longer needed, \fBTk_FreeCursor\fR should be called to release it.
  330. There should be exactly one call to \fBTk_FreeCursor\fR for
  331. each call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR.
  332. When a cursor is no longer in use anywhere (i.e. it has been freed as
  333. many times as it has been gotten) \fBTk_FreeCursor\fR will release
  334. it to the X server and remove it from the database.
  335.  
  336. .SH BUGS
  337. In determining whether an existing cursor can be used to satisfy
  338. a new request, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR
  339. consider only the immediate values of their arguments.  For
  340. example, when a file name is passed to \fBTk_GetCursor\fR,
  341. \fBTk_GetCursor\fR will assume it is safe to re-use an existing
  342. cursor created from the same file name:  it will not check to
  343. see whether the file itself has changed, or whether the current
  344. directory has changed, thereby causing the name to refer to
  345. a different file.  Similarly, \fBTk_GetCursorFromData\fR assumes
  346. that if the same \fIsource\fR pointer is used in two different calls,
  347. then the pointers refer to the same data;  it does not check to
  348. see if the actual data values have changed.
  349.  
  350. .SH KEYWORDS
  351. cursor
  352.