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

  1. '\"
  2. '\" Copyright (c) 1992 The Regents of the University of California.
  3. '\" All rights reserved.
  4. '\"
  5. '\" Permission is hereby granted, without written agreement and without
  6. '\" license or royalty fees, to use, copy, modify, and distribute this
  7. '\" documentation for any purpose, provided that the above copyright
  8. '\" notice and the following two paragraphs appear in all copies.
  9. '\"
  10. '\" IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
  11. '\" FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  12. '\" ARISING OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  13. '\" CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  14. '\"
  15. '\" THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  16. '\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  17. '\" AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  18. '\" ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  19. '\" PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  20. '\" 
  21. '\" $Header: /user6/ouster/wish/man/RCS/canvas.n,v 1.17 93/04/01 09:52:32 ouster Exp $ SPRITE (Berkeley)
  22. '/"
  23. .so man.macros
  24. .HS canvas tk
  25. .BS
  26. '\" Note:  do not modify the .SH NAME line immediately below!
  27. .SH NAME
  28. canvas \- Create and manipulate canvas widgets
  29. .SH SYNOPSIS
  30. \fBcanvas\fI \fIpathName \fR?\fIoptions\fR?
  31. .SH "STANDARD OPTIONS"
  32. .LP
  33. .nf
  34. .ta 4c 8c 12c
  35. \fBbackground\fR    \fBinsertBorderWidth\fR    \fBrelief\fR    \fBxScrollCommand\fR
  36. .VS
  37. \fBborderWidth\fR    \fBinsertOffTime\fR    \fBselectBackground\fR    \fByScrollCommand\fR
  38. \fBcursor\fR    \fBinsertOnTime\fR    \fBselectBorderWidth\fR
  39. \fBinsertBackground\fR    \fBinsertWidth\fR    \fBselectForeground\fR
  40. .VE
  41. .fi
  42. .LP
  43. See the ``options'' manual entry for details on the standard options.
  44. .SH "WIDGET-SPECIFIC OPTIONS"
  45. .ta 4c
  46. .LP
  47. .nf
  48. Name:    \fBcloseEnough\fR
  49. Class:    \fBCloseEnough\fR
  50. Command-Line Switch:    \fB\-closeenough\fR
  51. .fi
  52. .IP
  53. Specifies a floating-point value indicating how close the mouse cursor
  54. must be to an item before it is considered to be ``inside'' the item.
  55. Defaults to 1.0.
  56. .LP
  57. .nf
  58. .VS
  59. Name:    \fBconfine\fR
  60. Class:    \fBConfine\fR
  61. Command-Line Switch:    \fB\-confine\fR
  62. .fi
  63. .IP
  64. Specifies a boolean value that indicates whether or not it should be
  65. allowable to set the canvas's view outside the region defined by the
  66. \fBscrollRegion\fR argument.
  67. Defaults to true, which means that the view will
  68. be constrained within the scroll region.
  69. .VE
  70. .LP
  71. .nf
  72. Name:    \fBheight\fR
  73. Class:    \fBHeight\fR
  74. Command-Line Switch:    \fB\-height\fR
  75. .fi
  76. .IP
  77. Specifies a desired window height that the canvas widget should request from
  78. its geometry manager.  The value may be specified in any
  79. of the forms described in the COORDINATES section below.
  80. .LP
  81. .nf
  82. Name:    \fBscrollIncrement\fR
  83. Class:    \fBScrollIncrement\fR
  84. Command-Line Switch:    \fB\-scrollincrement\fR
  85. .fi
  86. .IP
  87. Specifies a distance used as increment during scrolling:  when one of
  88. the arrow buttons on an associated scrollbar is pressed, the picture
  89. will shift by this distance.  The distance may be specified in any
  90. of the forms described in the COORDINATES section below.
  91. .LP
  92. .nf
  93. Name:    \fBscrollRegion\fR
  94. Class:    \fBScrollRegion\fR
  95. Command-Line Switch:    \fB\-scrollregion\fR
  96. .fi
  97. .IP
  98. Specifies a list with four coordinates describing the left, top, right, and
  99. bottom coordinates of a rectangular region.
  100. This region is used for scrolling purposes and is considered to be
  101. the boundary of the information in the canvas.
  102. Each of the coordinates may be specified
  103. in any of the forms given in the COORDINATES section below.
  104. .LP
  105. .nf
  106. Name:    \fBwidth\fR
  107. Class:    \fBwidth\fR
  108. Command-Line Switch:    \fB\-width\fR
  109. .fi
  110. .IP
  111. Specifies a desired window width that the canvas widget should request from
  112. its geometry manager.  The value may be specified in any
  113. of the forms described in the COORDINATES section below.
  114. .BE
  115.  
  116. .SH INTRODUCTION
  117. .PP
  118. The \fBcanvas\fR command creates a new window (given
  119. by the \fIpathName\fR argument) and makes it into a canvas widget.
  120. Additional options, described above, may be specified on the
  121. command line or in the option database
  122. to configure aspects of the canvas such as its colors and 3-D relief.
  123. The \fBcanvas\fR command returns its
  124. \fIpathName\fR argument.  At the time this command is invoked,
  125. there must not exist a window named \fIpathName\fR, but
  126. \fIpathName\fR's parent must exist.
  127. .PP
  128. Canvas widgets implement structured graphics.
  129. A canvas displays any number of \fIitems\fR, which may be things like
  130. rectangles, circles, lines, and text.
  131. Items may be manipulated (e.g. moved or re-colored) and commands may
  132. be associated with items in much the same way that the \fBbind\fR
  133. command allows commands to be bound to widgets.  For example,
  134. a particular command may be associated with the <Button-1> event
  135. so that the command is invoked whenever button 1 is pressed with
  136. the mouse cursor over an item.
  137. This means that items in a canvas can have behaviors defined by
  138. the Tcl scripts bound to them.
  139.  
  140. .SH "DISPLAY LIST"
  141. .PP
  142. The items in a canvas are ordered for purposes of display,
  143. with the first item in the display list being displayed
  144. first, followed by the next item in the list, and so on.
  145. Items later in the display list obscure those that are
  146. earlier in the display list and are sometimes referred to
  147. as being ``on top'' of earlier items.
  148. When a new item is created it is placed at the end of the
  149. display list, on top of everything else.
  150. Widget commands may be used to re-arrange the order of the
  151. display list.
  152.  
  153. .SH "ITEM IDS AND TAGS"
  154. .PP
  155. Items in a canvas widget may be named in either of two ways:
  156. by id or by tag.
  157. Each item has a unique identifying number which is assigned to
  158. that item when it is created.  The id of an item never changes
  159. and id numbers are never re-used within the lifetime of a
  160. canvas widget.
  161. .PP
  162. Each item may also have any number of \fItags\fR associated
  163. with it.  A tag is just a string of characters, and it may
  164. take any form except that of an integer.
  165. For example, ``x123'' is OK but ``123'' isn't.
  166. The same tag may be associated with many different items.
  167. This is commonly done to group items in various interesting
  168. ways;  for example, all selected items might be given the
  169. tag ``selected''.
  170. .PP
  171. The tag \fBall\fR is implicitly associated with every item
  172. in the canvas;  it may be used to invoke operations on
  173. all the items in the canvas.
  174. .PP
  175. The tag \fBcurrent\fR is managed automatically by Tk;
  176. it applies to the \fIcurrent item\fR, which is the
  177. topmost item whose drawn area covers the position of
  178. the mouse cursor.
  179. If the mouse is not in the canvas widget or is not over
  180. an item, then no item has the \fBcurrent\fR tag.
  181. .PP
  182. When specifying items in canvas widget commands, if the
  183. specifier is an integer then it is assumed to refer to
  184. the single item with that id.
  185. If the specifier is not an integer, then it is assumed to
  186. refer to all of the items in the canvas that have a tag
  187. matching the specifier.
  188. The symbol \fItagOrId\fR is used below to indicate that
  189. an argument specifies either an id that selects a single
  190. item or a tag that selects zero or more items.
  191. Some widget commands only operate on a single item at a
  192. time;  if \fItagOrId\fR is specified in a way that
  193. names multiple items, then the normal behavior is for
  194. the command to use the first (lowest) of these items in
  195. the display list that is suitable for the command.
  196. Exceptions are noted in the widget command descriptions
  197. below.
  198.  
  199. .SH "COORDINATES"
  200. .PP
  201. All coordinates related to canvases are stored as floating-point
  202. numbers.
  203. Coordinates and distances are specified in screen units,
  204. which are floating-point numbers optionally followed
  205. by one of several letters.
  206. If no letter is supplied then the distance is in pixels.
  207. If the letter is \fBm\fR then the distance is in millimeters on
  208. the screen;  if it is \fBc\fR then the distance is in centimeters;
  209. \fBi\fR means inches, and \fBp\fR means printers points (1/72 inch).
  210. Larger y-coordinates refer to points lower on the screen;  larger
  211. x-coordinates refer to points farther to the right.
  212.  
  213. .SH TRANSFORMATIONS
  214. .PP
  215. Normally the origin of the canvas coordinate system is at the
  216. upper-left corner of the window containing the canvas.
  217. It is possible to adjust the origin of the canvas
  218. coordinate system relative to the origin of the window using the
  219. \fBxview\fR and \fByview\fR widget commands;  this is typically used
  220. for scrolling.
  221. Canvases do not support scaling or rotation of the canvas coordinate
  222. system relative to the window coordinate system.
  223. .PP
  224. Indidividual items may be moved or scaled using widget commands
  225. described below, but they may not be rotated.
  226.  
  227. .SH "INDICES"
  228. .PP
  229. Text items support the notion of an \fIindex\fR for identifying
  230. particular positions within the item.
  231. Indices are used for commands such as inserting text, deleting
  232. a range of characters, and setting the insertion cursor position.
  233. An index may be specified in any of a number of ways, and
  234. different types of items may support different forms for
  235. specifying indices.
  236. Text items support the following forms for an index;  if you
  237. define new types of text-like items, it would be advisable to
  238. support as many of these forms as practical.
  239. Note that it is possible to refer to the character just after
  240. the last one in the text item;  this is necessary for such
  241. tasks as inserting new text at the end of the item.
  242. .TP 10
  243. \fInumber\fR
  244. A decimal number giving the position of the desired character
  245. within the text item.
  246. 0 refers to the first character, 1 to the next character, and
  247. so on.
  248. A number less than 0 is treated as if it were zero, and a
  249. number greater than the length of the text item is treated
  250. as if it were equal to the length of the text item.
  251. .TP 10
  252. \fBend\fR
  253. Refers to the character just after the last one in the item
  254. (same as the number of characters in the item).
  255. .TP 10
  256. \fBinsert\fR
  257. .VS
  258. .VE
  259. Refers to the character just before which the insertion cursor
  260. is drawn in this item.
  261. .TP 10
  262. \fBsel.first\fR
  263. Refers to the first selected character in the item.
  264. If the selection isn't in this item then this form is illegal.
  265. .TP 10
  266. \fBsel.last\fR
  267. Refers to the last selected character in the item.
  268. If the selection isn't in this item then this form is illegal.
  269. .TP 10
  270. \fB@\fIx,y\fR
  271. Refers to the character at the point given by \fIx\fR and
  272. \fIy\fR, where \fIx\fR and \fIy\fR are specified in the coordinate
  273. system of the canvas.
  274. If \fIx\fR and \fIy\fR lie outside the coordinates covered by the
  275. text item, then they refer to the first or last character in the
  276. line that is closest to the given point.
  277.  
  278. .SH "WIDGET COMMAND"
  279. .PP
  280. The \fBcanvas\fR command creates a new Tcl command whose
  281. name is \fIpathName\fR.  This
  282. command may be used to invoke various
  283. operations on the widget.  It has the following general form:
  284. .DS C
  285. \fIpathName option \fR?\fIarg arg ...\fR?
  286. .DE
  287. \fIOption\fR and the \fIarg\fRs
  288. determine the exact behavior of the command.
  289. The following widget commands are possible for canvas widgets:
  290. .TP
  291. \fIpathName \fBaddtag \fItag searchSpec \fR?\fIarg arg ...\fR?
  292. For each item that meets the constraints specified by
  293. \fIsearchSpec\fR and the \fIarg\fRs, add
  294. \fItag\fR to the list of tags associated with the item if it
  295. isn't already present on that list.
  296. It is possible that no items will satisfy the constraints
  297. given by \fIsearchSpec and \fIarg\fRs, in which case the
  298. command has no effect.
  299. This command returns an empty string as result.
  300. \fISearchSpec\fR and \fIarg\fR's may take any of the following
  301. forms:
  302. .RS
  303. .TP
  304. \fBabove \fItagOrId\fR
  305. Selects the item just after (above) the one given by \fItagOrId\fR
  306. in the display list.
  307. If \fItagOrId\fR denotes more than one item, then the last (topmost)
  308. of these items in the display list is used.
  309. .TP
  310. \fBall\fR
  311. Selects all the items in the canvas.
  312. .TP
  313. \fBbelow \fItagOrId\fR
  314. Selects the item just before (below) the one given by \fItagOrId\fR
  315. in the display list.
  316. If \fItagOrId\fR denotes more than one item, then the first (lowest)
  317. of these items in the display list is used.
  318. .TP
  319. \fBclosest \fIx y \fR?\fIhalo\fR? ?\fIstart\fR?
  320. Selects the item closest to the point given by \fIx\fR and \fIy\fR.
  321. If more than one item is at the same closest distance (e.g. two
  322. items overlap the point), then the top-most of these items (the
  323. last one in the display list) is used.
  324. If \fIhalo\fR is specified, then it must be a non-negative
  325. value.
  326. Any item closer than \fIhalo\fR to the point is considered to
  327. overlap it.
  328. The \fIstart\fR argument may be used to step circularly through
  329. all the closest items.
  330. If \fIstart\fR is specified, it names an item using a tag or id
  331. (if by tag, it selects the first item in the display list with
  332. the given tag).
  333. Instead of selecting the topmost closest item, this form will
  334. select the topmost closest item that is below \fIstart\fR in
  335. the display list;  if no such item exists, then the selection
  336. behaves as if the \fIstart\fR argument had not been specified.
  337. .TP
  338. \fBenclosed\fR \fIx1\fR \fIy1\fR \fIx2\fR \fIy2\fR
  339. Selects all the items completely enclosed within the rectangular
  340. region given by \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR.
  341. \fIX1\fR must be no greater then \fIx2\fR and \fIy1\fR must be
  342. no greater than \fIy2\fR.
  343. .TP
  344. \fBoverlapping\fR \fIx1\fR \fIy1\fR \fIx2\fR \fIy2\fR
  345. Selects all the items that overlap or are enclosed within the
  346. rectangular region given by \fIx1\fR, \fIy1\fR, \fIx2\fR,
  347. and \fIy2\fR.
  348. \fIX1\fR must be no greater then \fIx2\fR and \fIy1\fR must be
  349. no greater than \fIy2\fR.
  350. .TP
  351. \fBwithtag \fItagOrId\fR
  352. Selects all the items given by \fItagOrId\fR.
  353. .RE
  354. .TP
  355. \fIpathName \fBbbox \fItagOrId\fR ?\fItagOrId tagOrId ...\fR?
  356. .VS
  357. Returns a list with four elements giving an approximate bounding box
  358. for all the items named by the \fItagOrId\fR arguments.
  359. The list has the form ``\fIx1 y1 x2 y2\fR'' such that the drawn
  360. areas of all the named elements are within the region bounded by
  361. \fIx1\fR on the left, \fIx2\fR on the right, \fIy1\fR on the top,
  362. and \fIy2\fR on the bottom.
  363. The return value may overestimate the actual bounding box by
  364. a few pixels.
  365. If no items match any of the \fItagOrId\fR arguments then an
  366. empty string is returned.
  367. .VE
  368. .TP
  369. \fIpathName \fBbind \fItagOrId\fR ?\fIsequence\fR? ?\fIcommand\fR?
  370. This command associates \fIcommand\fR with all the items given by
  371. \fItagOrId\fR such that whenever the event sequence given by
  372. \fIsequence\fR occurs for one of the items the command will
  373. be invoked.
  374. This widget command is similar to the \fBbind\fR command except that
  375. it operates on items in a canvas rather than entire widgets.
  376. See the \fBbind\fR manual entry for complete details
  377. on the syntax of \fIsequence\fR and the substitutions performed
  378. on \fIcommand\fR before invoking it.
  379. If all arguments are specified then a new binding is created, replacing
  380. any existing binding for the same \fIsequence\fR and \fItagOrId\fR
  381. (if the first character of \fIcommand\fR is ``+'' then \fIcommand\fR
  382. augments an existing binding rather than replacing it).
  383. In this case the return value is an empty string.
  384. If \fIcommand\fR is omitted then the command returns the \fIcommand\fR
  385. associated with \fItagOrId\fR and \fIsequence\fR (an error occurs
  386. if there is no such binding).
  387. If both \fIcommand\fR and \fIsequence\fR are omitted then the command
  388. returns a list of all the sequences for which bindings have been
  389. defined for \fItagOrId\fR.
  390. .RS
  391. .LP
  392. The only events for which bindings may be specified are those related
  393. to the mouse and keyboard, such as \fBEnter\fR, \fBLeave\fR,
  394. \fBButtonPress\fR, \fBMotion\fR, and \fBKeyPress\fR.
  395. The handling of events in canvases uses the current item defined
  396. in ITEM IDS AND TAGS above.
  397. \fBEnter\fR and \fBLeave\fR events trigger for an item when it
  398. becomes the current item or ceases to be the current item;  note
  399. that these events are different than \fBEnter\fR and \fBLeave\fR
  400. events for windows.
  401. Mouse-related events are directed to the current item, if any.
  402. Keyboard-related events are directed to the focus item, if any
  403. (see the \fBfocus\fR widget command below for more on this).
  404. .LP
  405. It is possible for multiple commands to be bound to a single
  406. event sequence for a single object.
  407. This occurs, for example, if one command is associated with the
  408. item's id and another is associated with one of the item's tags.
  409. When this occurs, the first matching binding is used.
  410. A binding for the item's id has highest priority, followed by
  411. the oldest tag for the item and proceeding through all of the
  412. item's tags up through the most-recently-added one.
  413. If a binding is associated with the tag \fBall\fR, the binding
  414. will have lower priority than all other bindings associated
  415. with the item.
  416. .RE
  417. .TP
  418. \fIpathName \fBcanvasx \fIscreenx\fR ?\fIgridspacing\fR?
  419. Given a screen x-coordinate \fIscreenx\fR this command returns
  420. the canvas x-coordinate that is displayed at that location.
  421. If \fIgridspacing\fR is specified, then the canvas coordinate is
  422. rounded to the nearest multiple of \fIgridspacing\fR units.
  423. .TP
  424. \fIpathName \fBcanvasy \fIscreeny\fR ?\fIgridspacing\fR?
  425. Given a screen y-coordinate \fIscreeny\fR this command returns
  426. the canvas y-coordinate that is displayed at that location.
  427. If \fIgridspacing\fR is specified, then the canvas coordinate is
  428. rounded to the nearest multiple of \fIgridspacing\fR units.
  429. .TP
  430. \fIpathName \fBconfigure ?\fIoption\fR? ?\fIvalue\fR? ?\fIoption value ...\fR?
  431. Query or modify the configuration options of the widget.
  432. If no \fIoption\fR is specified, returns a list describing all of
  433. the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
  434. information on the format of this list).  If \fIoption\fR is specified
  435. with no \fIvalue\fR, then the command returns a list describing the
  436. one named option (this list will be identical to the corresponding
  437. sublist of the value returned if no \fIoption\fR is specified).  If
  438. one or more \fIoption\-value\fR pairs are specified, then the command
  439. modifies the given widget option(s) to have the given value(s);  in
  440. this case the command returns an empty string.
  441. \fIOption\fR may have any of the values accepted by the \fBcanvas\fR
  442. command.
  443. .TP
  444. \fIpathName\fR \fBcoords \fItagOrId \fR?\fIx0 y0 ...\fR?
  445. .VS
  446. Query or modify the coordinates that define an item.
  447. If no coordinates are specified, this command returns a list
  448. whose elements are the coordinates of the item named by
  449. \fItagOrId\fR.
  450. If coordinates are specified, then they replace the current
  451. coordinates for the named item.
  452. If \fItagOrId\fR refers to multiple items, then
  453. the first one in the display list is used.
  454. .VE
  455. .TP
  456. \fIpathName \fBcreate \fItype x y \fR?\fIx y ...\fR? ?\fIoption value ...\fR?
  457. Create a new item in \fIpathName\fR of type \fItype\fR.
  458. The exact format of the arguments after \fBtype\fR depends
  459. on \fBtype\fR, but usually they consist of the coordinates for
  460. one or more points, followed by specifications for zero or
  461. more item options.
  462. See the subsections on individual item types below for more
  463. on the syntax of this command.
  464. This command returns the id for the new item.
  465. .TP
  466. \fIpathName \fBdchars \fItagOrId first \fR?\fIlast\fR?
  467. For each item given by \fItagOrId\fR, delete the characters
  468. in the range given by \fIfirst\fR and \fIlast\fR,
  469. inclusive.
  470. If some of the items given by \fItagOrId\fR don't support
  471. text operations, then they are ignored.
  472. \fIFirst\fR and \fIlast\fR are indices of characters
  473. within the item(s) as described in INDICES above.
  474. If \fIlast\fR is omitted, it defaults to \fIfirst\fR.
  475. This command returns an empty string.
  476. .TP
  477. \fIpathName \fBdelete \fR?\fItagOrId tagOrId ...\fR?
  478. Delete each of the items given by each \fItagOrId\fR, and return
  479. .VS
  480. an empty string.
  481. .VE
  482. .TP
  483. \fIpathName \fBdtag \fItagOrId \fR?tagToDelete\fR?
  484. For each of the items given by \fItagOrId\fR, delete the
  485. tag given by \fItagToDelete\fR from the list of those
  486. associated with the item.
  487. If an item doesn't have the tag \fItagToDelete\fR then
  488. the item is unaffected by the command.
  489. If \fItagToDelete\fR is omitted then it defaults to \fItagOrId\fR.
  490. This command returns an empty string.
  491. .TP
  492. \fIpathName \fBfind \fIsearchCommand \fR?\fIarg arg ...\fR?
  493. This command returns a list consisting of all the items that
  494. meet the constraints specified by \fIsearchCommand\fR and
  495. \fIarg\fR's.
  496. \fISearchCommand\fR and \fIargs\fR have any of the forms
  497. accepted by the \fBaddtag\fR command.
  498. .TP
  499. \fIpathName \fBfocus \fR?\fItagOrId\fR?
  500. Set the keyboard focus for the canvas widget to the item given by
  501. \fItagOrId\fR.
  502. If \fItagOrId\fR refers to several items, then the focus is set
  503. to the first such item in the display list that supports the
  504. insertion cursor.
  505. If \fItagOrId\fR doesn't refer to any items, or if none of them
  506. support the insertion cursor, then the focus isn't changed.
  507. If \fItagOrId\fR is an empty
  508. string, then the focus item is reset so that no item has the focus.
  509. If \fItagOrId\fR is not specified then the command returns the
  510. id for the item that currently has the focus, or an empty string
  511. if no item has the focus.
  512. .RS
  513. .LP
  514. Once the focus has been set to an item, the item will display
  515. the insertion cursor and all keyboard events will be directed
  516. to that item.
  517. The focus item within a canvas and the focus window on the
  518. screen (set with the \fBfocus\fR command) are totally independent:
  519. a given item doesn't actually have the input focus unless (a)
  520. its canvas is the focus window and (b) the item is the focus item
  521. within the canvas.
  522. In most cases it is advisable to follow the \fBfocus\fR widget
  523. command with the \fBfocus\fR command to set the focus window to
  524. the canvas (if it wasn't there already).
  525. .RE
  526. .TP
  527. \fIpathName \fBgettags\fR \fItagOrId\fR
  528. Return a list whose elements are the tags associated with the
  529. item given by \fItagOrId\fR.
  530. If \fItagOrId\fR refers to more than one item, then the tags
  531. are returned from the first such item in the display list.
  532. If \fItagOrId\fR doesn't refer to any items, or if the item
  533. contains no tags, then an empty string is returned.
  534. .TP
  535. \fIpathName \fBicursor \fItagOrId index\fR
  536. .VS
  537. Set the position of the insertion cursor for the item(s)
  538. given by \fItagOrId\fR
  539. to just before the character whose position is given by \fIindex\fR.
  540. If some or all of the items given by \fItagOrId\fR don't support
  541. an insertion cursor then this command has no effect on them.
  542. See INDICES above for a description of the
  543. legal forms for \fIindex\fR.
  544. Note:  the insertion cursor is only displayed in an item if
  545. that item currently has the keyboard focus (see the widget
  546. command \fBfocus\fR, below), but the cursor position may
  547. be set even when the item doesn't have the focus.
  548. This command returns an empty string.
  549. .VE
  550. .TP
  551. \fIpathName \fBindex \fItagOrId index\fR
  552. This command returns a decimal string giving the numerical index
  553. within \fItagOrId\fR corresponding to \fIindex\fR.
  554. \fIIndex\fR gives a textual description of the desired position
  555. as described in INDICES above.
  556. The return value is guaranteed to lie between 0 and the number
  557. of characters within the item, inclusive.
  558. If \fItagOrId\fR refers to multiple items, then the index
  559. is processed in the first of these items that supports indexing
  560. operations (in display list order).
  561. .TP
  562. \fIpathName \fBinsert \fItagOrId beforeThis string\fR
  563. For each of the items given by \fItagOrId\fR, if the item supports
  564. text insertion then \fIstring\fR is inserted into the item's
  565. text just before the character whose index is \fIbeforeThis\fR.
  566. See INDICES above for information about the forms allowed
  567. for \fIbeforeThis\fR.
  568. This command returns an empty string.
  569. .TP
  570. \fIpathName \fBitemconfigure \fItagOrId\fR ?\fIoption\fR? ?\fIvalue\fR? ?\fIoption value ...\fR?
  571. This command is similar to the \fBconfigure\fR widget command except
  572. that it modifies item-specific options for the items given by
  573. \fItagOrId\fR instead of modifying options for the overall
  574. canvas widget.
  575. If no \fIoption\fR is specified, returns a list describing all of
  576. the available options for the first item given by \fItagOrId\fR
  577. (see \fBTk_ConfigureInfo\fR for
  578. information on the format of this list).  If \fIoption\fR is specified
  579. with no \fIvalue\fR, then the command returns a list describing the
  580. one named option (this list will be identical to the corresponding
  581. sublist of the value returned if no \fIoption\fR is specified).  If
  582. one or more \fIoption\-value\fR pairs are specified, then the command
  583. modifies the given widget option(s) to have the given value(s) in
  584. each of the items given by \fItagOrId\fR;  in
  585. this case the command returns an empty string.
  586. The \fIoption\fRs and \fIvalue\fRs are the same as those permissible
  587. in the \fBcreate\fR widget command when the item(s) were created;
  588. see the sections describing individual item types below for details
  589. on the legal options.
  590. .TP
  591. \fIpathName \fBlower \fItagOrId \fR?\fIbelowThis\fR?
  592. Move all of the items given by \fItagOrId\fR to a new position
  593. in the display list just before the item given by \fIbelowThis\fR.
  594. If \fItagOrId\fR refers to more than one item then all are moved
  595. but the relative order of the moved items will not be changed.
  596. \fIBelowThis\fR is a tag or id;  if it refers to more than one
  597. item then the first (lowest) of these items in the display list is used
  598. as the destination location for the moved items.
  599. This command returns an empty string.
  600. .TP
  601. \fIpathName \fBmove \fItagOrId xAmount yAmount\fR
  602. Move each of the items given by \fItagOrId\fR in the canvas coordinate
  603. space by adding \fIxAmount\fR to the x-coordinate of each point
  604. associated with the item and \fIyAmount\fR to the y-coordinate of
  605. each point associated with the item.
  606. This command returns an empty string.
  607. .TP
  608. \fIpathName \fBpostscript \fR?\fIoption value option value ...\fR?
  609. .VS
  610. Generate a Postscript representation for part or all of the canvas.
  611. If the \fB\-file\fR option is specified then the Postscript is written
  612. to a file and an empty string is returned;  otherwise the Postscript
  613. is returned as the result of the command.
  614. The Postscript is created in Encapsulated Postscript form using
  615. version 3.0 of the Document Structuring Conventions.
  616. The \fIoption\fR\-\fIvalue\fR argument pairs provide additional
  617. information to control the generation of Postscript.  The following
  618. options are supported:
  619. .RS
  620. .TP
  621. \fB\-colormap \fIvarName\fR
  622. \fIVarName\fR must be the name of a global array variable
  623. that specifies a color mapping to use in the Postscript.
  624. Each element of \fIvarName\fR must consist of Postscript
  625. code to set a particular color value (e.g. ``\fB1.0 1.0 0.0 setrgbcolor\fR'').
  626. When outputting color information in the Postscript, Tk checks
  627. to see if there is an element of \fIvarName\fR with the same
  628. name as the color.
  629. If so, Tk uses the value of the element as the Postscript command
  630. to set the color.
  631. If this option hasn't been specified, or if there isn't an entry
  632. in \fIvarName\fR for a given color, then Tk uses the red, green,
  633. and blue intensities from the X color.
  634. .TP
  635. \fB\-colormode \fImode\fR
  636. Specifies how to output color information.  \fIMode\fR must be either
  637. \fBcolor\fR (for full color output), \fBgray\fR (convert all colors
  638. to their gray-scale equivalents) or \fBmono\fR (convert all colors
  639. to black or white).
  640. .TP
  641. \fB\-file \fIfileName\fR
  642. Specifies the name of the file in which to write the Postscript.
  643. If this option isn't specified then the Postscript is returned as the
  644. result of the command instead of being written to a file.
  645. .TP
  646. \fB\-fontmap \fIvarName\fR
  647. \fIVarName\fR must be the name of a global array variable
  648. that specifies a font mapping to use in the Postscript.
  649. Each element of \fIvarName\fR must consist of a Tcl list with
  650. two elements, which are the name and point size of a Postscript font.
  651. When outputting Postscript commands for a particular font, Tk
  652. checks to see if \fIvarName\fR contains an element with the same
  653. name as the font.
  654. If there is such an element, then the font information contained in
  655. that element is used in the Postscript.
  656. Otherwise Tk attempts to guess what Postscript font to use.
  657. Tk's guesses generally only work for well-known fonts such as
  658. Times and Helvetica and Courier, and only if the X font name does not
  659. omit any dashes up through the point size.
  660. For example, \fB\-*\-Courier\-Bold\-R\-Normal\-\-*\-120\-*\fR will work but
  661. \fB*Courier\-Bold\-R\-Normal*120*\fR will not;  Tk needs the dashes to
  662. parse the font name).
  663. .TP
  664. \fB\-height \fIsize\fR
  665. Specifies the height of the area of the canvas to print.
  666. Defaults to the height of the canvas window.
  667. .TP
  668. \fB\-pageanchor \fIanchor\fR
  669. Specifies which point of the printed area should be appear over
  670. the positioning point on the page (which is given by the \fB\-pagex\fR
  671. and \fB\-pagey\fR options).
  672. For example, \fB\-pageanchor n\fR means that the top center of the
  673. printed area should be over the positioning point.
  674. Defaults to \fBcenter\fR.
  675. .TP
  676. \fB\-pageheight \fIsize\fR
  677. Specifies that the Postscript should be scaled in both x and y so
  678. that the printed area is \fIsize\fR high on the Postscript page.
  679. \fISize\fR consists of a floating-point number followed by
  680. \fBc\fR for centimeters, \fBi\fR for inches, \fBm\fR for millimeters,
  681. or \fBp\fR or nothing for printer's points (1/72 inch).
  682. Defaults to the height of the printed area on the screen.
  683. If both \fB\-pageheight\fR and \fB\-pagewidth\fR are specified then
  684. the scale factor from the later option is used (non-uniform scaling
  685. is not implemented).
  686. .TP
  687. \fB\-pagewidth \fIsize\fR
  688. Specifies that the Postscript should be scaled in both x and y so
  689. that the printed area is \fIsize\fR wide on the Postscript page.
  690. \fISize\fR has the same form as for \fB\-pageheight\fR.
  691. Defaults to the width of the printed area on the screen.
  692. If both \fB\-pageheight\fR and \fB\-pagewidth\fR are specified then
  693. the scale factor from the later option is used (non-uniform scaling
  694. is not implemented).
  695. .TP
  696. \fB\-pagex \fIposition\fR
  697. \fIPosition\fR gives the x-coordinate of the positioning point on
  698. the Postscript page, using any of the forms allowed for \fB\-pageheight\fR.
  699. Used in conjunction with the \fB\-pagey\fR and \fB\-pageanchor\fR options
  700. to determine where the printed area appears on the Postscript page.
  701. Defaults to the center of the page.
  702. .TP
  703. \fB\-pagey \fIposition\fR
  704. \fIPosition\fR gives the y-coordinate of the positioning point on
  705. the Postscript page, using any of the forms allowed for \fB\-pageheight\fR.
  706. Used in conjunction with the \fB\-pagex\fR and \fB\-pageanchor\fR options
  707. to determine where the printed area appears on the Postscript page.
  708. Defaults to the center of the page.
  709. .TP
  710. \fB\-rotate \fIboolean\fR
  711. \fIBoolean\fR specifies whether the printed area is to be rotated 90
  712. degrees.
  713. In non-rotated output the x-axis of the printed area runs along
  714. the short dimension of the page (``portrait'' orientation);
  715. in rotated output the x-axis runs along the long dimension of the
  716. page (``landscape'' orientation).
  717. Defaults to non-rotated.
  718. .TP
  719. \fB\-width \fIsize\fR
  720. Specifies the width of the area of the canvas to print.
  721. Defaults to the width of the canvas window.
  722. .TP
  723. \fB\-x \fIposition\fR
  724. Specifies the x-coordinate of the left edge of the area of the
  725. canvas that is to be printed, in canvas coordinates, not window
  726. coordinates.
  727. Defaults to the coordinate of the left edge of the window.
  728. .TP
  729. \fB\-y \fIposition\fR
  730. Specifies the y-coordinate of the top edge of the area of the
  731. canvas that is to be printed, in canvas coordinates, not window
  732. coordinates.
  733. Defaults to the coordinate of the top edge of the window.
  734. .RE
  735. .VE
  736. .TP
  737. \fIpathName \fBraise \fItagOrId \fR?aboveThis\fR?
  738. Move all of the items given by \fItagOrId\fR to a new position
  739. in the display list just after the item given by \fIaboveThis\fR.
  740. If \fItagOrId\fR refers to more than one item then all are moved
  741. but the relative order of the moved items will not be changed.
  742. \fIAboveThis\fR is a tag or id;  if it refers to more than one
  743. item then the last (topmost) of these items in the display list is used
  744. as the destination location for the moved items.
  745. This command returns an empty string.
  746. .TP
  747. \fIpathName \fBscale \fItagOrId xOrigin yOrigin xScale yScale\fR
  748. Rescale all of the items given by \fItagOrId\fR in canvas coordinate
  749. space.
  750. \fIXOrigin\fR and \fIyOrigin\fR identify the origin for the scaling
  751. operation and \fIxScale\fR and \fIyScale\fR identify the scale
  752. factors for x- and y-coordinates, respectively (a scale factor of
  753. 1.0 implies no change to that coordinate).
  754. For each of the points defining each item, the x-coordinate is
  755. adjusted to change the distance from \fIxOrigin\fR by a factor
  756. of \fIxScale\fR.
  757. Similarly, each y-coordinate is adjusted to change the distance
  758. from \fIyOrigin\fR by a factor of \fIyScale\fR.
  759. This command returns an empty string.
  760. .TP
  761. \fIpathName \fBscan\fR \fIoption args\fR
  762. This command is used to implement scanning on canvases.  It has
  763. two forms, depending on \fIoption\fR:
  764. .RS
  765. .TP
  766. \fIpathName \fBscan mark \fIx y\fR
  767. Records \fIx\fR and \fIy\fR and the canvas's current view;  used
  768. in conjunction with later \fBscan dragto\fR commands.
  769. Typically this command is associated with a mouse button press in
  770. the widget and \fIx\fR and \fIy\fR are the coordinates of the
  771. mouse.  It returns an empty string.
  772. .TP
  773. \fIpathName \fBscan dragto \fIx y\fR.
  774. This command computes the difference between its \fIx\fR and \fIy\fR
  775. arguments (which are typically mouse coordinates) and the \fIx\fR and
  776. \fIy\fR arguments to the last \fBscan mark\fR command for the widget.
  777. It then adjusts the view by 10 times the
  778. difference in coordinates.  This command is typically associated
  779. with mouse motion events in the widget, to produce the effect of
  780. dragging the canvas at high speed through its window.  The return
  781. value is an empty string.
  782. .RE
  783. .TP
  784. \fIpathName \fBselect \fIoption\fR ?\fItagOrId arg\fR?
  785. Manipulates the selection in one of several ways, depending on
  786. \fIoption\fR.
  787. The command may take any of the forms described below.
  788. In all of the descriptions below, \fItagOrId\fR must refer to
  789. an item that supports indexing and selection;  if it refers to
  790. multiple items then the first of
  791. these that supports indexing and the selection is used.
  792. \fIIndex\fR gives a textual description of a position
  793. within \fItagOrId\fR, as described in INDICES above.
  794. .RS
  795. .TP
  796. \fIpathName \fBselect adjust \fItagOrId index\fR
  797. Locate the end of the selection in \fItagOrId\fR nearest
  798. to the character given by \fIindex\fR, and adjust that
  799. end of the selection to be at \fIindex\fR (i.e. including
  800. but not going beyond \fIindex\fR).
  801. The other end of the selection is made the anchor point
  802. for future \fBselect to\fR commands.
  803. If the selection isn't currently in \fItagOrId\fR then
  804. this command behaves the same as the \fBselect to\fR widget
  805. command.
  806. Returns an empty string.
  807. .TP
  808. \fIpathName \fBselect clear\fR
  809. Clear the selection if it is in this widget.
  810. If the selection isn't in this widget then the command
  811. has no effect.
  812. Returns an empty string.
  813. .TP
  814. \fIpathName \fBselect from \fItagOrId index\fR
  815. Set the selection anchor point for the widget to be just
  816. before the character
  817. given by \fIindex\fR in the item given by \fItagOrId\fR.
  818. This command doesn't change the selection;  it just sets
  819. the fixed end of the selection for future \fBselect to\fR
  820. commands.
  821. Returns an empty string.
  822. .TP
  823. \fIpathName \fBselect item\fR
  824. Returns the id of the selected item, if the selection is in an
  825. item in this canvas.
  826. If the selection is not in this canvas then an empty string
  827. is returned.
  828. .TP
  829. \fIpathName \fBselect to \fItagOrId index\fR
  830. Set the selection to consist of those characters of \fItagOrId\fR
  831. between the selection anchor point and
  832. \fIindex\fR.
  833. The new selection will include the character given by \fIindex\fR;
  834. it will include the character given by the anchor point only if
  835. \fIindex\fR is greater than or equal to the anchor point.
  836. The anchor point is determined by the most recent \fBselect adjust\fR
  837. or \fBselect from\fR command for this widget.
  838. If the selection anchor point for the widget isn't currently in
  839. \fItagOrId\fR, then it is set to the same character given
  840. by \fIindex\fR.
  841. Returns an empty string.
  842. .RE
  843. .TP
  844. \fIpathName \fBtype\fI tagOrId\fR
  845. Returns the type of the item given by \fItagOrId\fR, such as
  846. \fBrectangle\fR or \fBtext\fR.
  847. If \fItagOrId\fR refers to more than one item, then the type
  848. of the first item in the display list is returned.
  849. If \fItagOrId\fR doesn't refer to any items at all then
  850. an empty string is returned.
  851. .TP
  852. \fIpathName \fBxview\fI index\fR
  853. Change the view in the canvas so that the canvas position given by
  854. \fIindex\fR appears at the left edge of the window.
  855. This command is typically used by scrollbars to scroll the
  856. canvas.
  857. \fIIndex\fR counts in units of scroll increments (the value of the
  858. \fBscrollIncrement\fR option):  a value of 0 corresponds to the left
  859. edge of the scroll region (as defined by the \fBscrollRegion\fR
  860. option),  a value of 1 means one scroll unit to the right of this,
  861. and so on.  The return value is an empty string.
  862. .TP
  863. \fIpathName \fByview\fI index\fR
  864. Change the view in the canvas so that the canvas position given by
  865. \fIindex\fR appears at the top edge of the window.
  866. This command is typically used by scrollbars to scroll the
  867. canvas.
  868. \fIIndex\fR counts in units of scroll increments (the value of the
  869. \fBscrollIncrement\fR option):  a value of 0 corresponds to the top
  870. edge of the scroll region (as defined by the \fBscrollRegion\fR
  871. option),  a value of 1 means one scroll unit below this,
  872. and so on.  The return value is an empty string.
  873.  
  874. .SH "OVERVIEW OF ITEM TYPES"
  875. .PP
  876. The sections below describe the various types of items supported
  877. by canvas widgets.  Each item type is characterized by two things:
  878. first, the form of the \fBcreate\fR command used to create
  879. instances of the type;  and second, a set of configuration options
  880. for items of that type, which may be used in the
  881. \fBcreate\fR and \fBitemconfigure\fR widget commands.
  882. Most items don't support indexing or selection or the commands
  883. related to them, such as \fBindex\fR and \fBinsert\fR.
  884. Where items do support these facilities, it is noted explicitly
  885. in the descriptions below (at present, only text items provide
  886. this support).
  887.  
  888. .SH "ARC ITEMS"
  889. .PP
  890. .VS
  891. Items of type \fBarc\fR appear on the display as arc-shaped regions.
  892. An arc is a section of an oval delimited by two angles (specified
  893. by the \fB\-start\fR and \fB\-extent\fR options) and displayed in
  894. one of several ways (specified by the \fB\-style\fR option).
  895. Arcs are created with widget commands of the following form:
  896. .DS
  897. \fIpathName \fBcreate arc \fIx1 y1 x2 y2 \fR?\fIoption value option value ...\fR?
  898. .DE
  899. The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR give
  900. the coordinates of two diagonally opposite corners of a
  901. rectangular region enclosing the oval that defines the arc.
  902. After the coordinates there may be any number of \fIoption\fR-\fIvalue\fR
  903. pairs, each of which sets one of the configuration options
  904. for the item.  These same \fIoption\fR\-\fIvalue\fR pairs may be
  905. used in \fBitemconfigure\fR widget commands to change the item's
  906. configuration.
  907. The following options are supported for arcs:
  908. .TP
  909. \fB\-extent \fIdegrees\fR
  910. Specifies the size of the angular range occupied by the arc.
  911. The arc's range extends for \fIdegrees\fR degrees counter-clockwise
  912. from the starting angle given by the \fB\-start\fR option.
  913. \fIDegrees\fR may be negative.
  914. .TP
  915. \fB\-fill \fIcolor\fR
  916. Fill the region of the arc with \fIcolor\fR.
  917. \fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
  918. If \fIcolor\fR is an empty string (the default), then
  919. then the arc will not be filled.
  920. .TP
  921. \fB\-outline \fIcolor\fR
  922. \fIColor\fR specifies a color to use for drawing the arc's
  923. outline;  it may have any of the forms accepted by \fBTk_GetColor\fR.
  924. This option defaults to \fBblack\fR.  If the arc's style is
  925. \fBarc\fR then this option is ignored (the section of perimeter is
  926. filled using the \fB\-fill\fR option).  If \fIcolor\fR is specified
  927. as an empty string then no outline is drawn for the arc.
  928. .TP
  929. \fB\-start \fIdegrees\fR
  930. Specifies the beginning of the angular range occupied by the
  931. arc.
  932. \fIDegrees\fR is given in units of degrees measured counter-clockwise
  933. from the 3-o'clock position;  it may be either positive or negative.
  934. .TP
  935. \fB\-stipple \fIbitmap\fR
  936. Indicates that the arc should be filled in a stipple pattern;
  937. \fIbitmap\fR specifies the stipple pattern to use, in any of the
  938. forms accepted by \fBTk_GetBitmap\fR.
  939. If the \fB\-fill\fR option hasn't been specified then this option
  940. has no effect.
  941. If \fIbitmap\fR is an empty string (the default), then filling is done
  942. in a solid fashion.
  943. .TP
  944. \fB\-style \fItype\fR
  945. Specifies how to draw the arc.  If \fItype\fR is \fBpieslice\fR
  946. (the default) then the arc's region is defined by a section
  947. of the oval's perimeter plus two line segments, one between the center
  948. of the oval and each end of the perimeter section.
  949. If \fItype\fR is \fBchord\fR then the arc's region is defined
  950. by a section of the oval's perimeter plus a single line segment
  951. connecting the two end points of the perimeter section.
  952. If \fItype\fR is \fBarc\fR then the arc's region consists of
  953. a section of the perimeter alone.  In this last case there is
  954. no outline for the arc and the \fB\-outline\fR option is ignored.
  955. .TP
  956. \fB\-tags \fItagList\fR
  957. Specifies a set of tags to apply to the item.
  958. \fITagList\fR consists of a list of tag names, which replace any
  959. existing tags for the item.
  960. \fITagList\fR may be an empty list.
  961. .TP
  962. \fB\-width \fIoutlineWidth\fR
  963. Specifies the width of the outline to be drawn around
  964. the arc's region, in any of the forms described in the COORDINATES
  965. section above.
  966. If the \fB\-outline\fR option has been specified as an empty string
  967. then this option has no effect.
  968. Wide outlines will be drawn centered on the edges of the arc's region.
  969. This option defaults to 1.0.
  970.  
  971. .SH "BITMAP ITEMS"
  972. .PP
  973. Items of type \fBbitmap\fR appear on the display as images with
  974. two colors, foreground and background.
  975. Bitmaps are created with widget commands of the following form:
  976. .DS
  977. \fIpathName \fBcreate bitmap \fIx y \fR?\fIoption value option value ...\fR?
  978. .DE
  979. The arguments \fIx\fR and \fIy\fR specify the coordinates of a
  980. point used to position the bitmap on the display (see the \fB\-anchor\fR
  981. option below for more information on how bitmaps are displayed).
  982. After the coordinates there may be any number of \fIoption\fR-\fIvalue\fR
  983. pairs, each of which sets one of the configuration options
  984. for the item.  These same \fIoption\fR\-\fIvalue\fR pairs may be
  985. used in \fBitemconfigure\fR widget commands to change the item's
  986. configuration.
  987. The following options are supported for bitmaps:
  988. .TP
  989. \fB\-anchor \fIanchorPos\fR
  990. \fIAnchorPos\fR tells how to position the bitmap relative to the
  991. positioning point for the item;  it may have any of the forms
  992. accepted by \fBTk_GetAnchor\fR.  For example, if \fIanchorPos\fR
  993. is \fBcenter\fR then the bitmap is centered on the point;  if
  994. \fIanchorPos\fR is \fBn\fR then the bitmap will be drawn so that
  995. its top center point is at the positioning point.
  996. This option defaults to \fBcenter\fR.
  997. .TP
  998. \fB\-background \fIcolor\fR
  999. Specifies a color to use for each of the bitmap pixels
  1000. whose value is 0.
  1001. \fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
  1002. If this option isn't specified, or if it is specified as an empty
  1003. string, then the background color for the canvas is used.
  1004. .TP
  1005. \fB\-bitmap \fIbitmap\fR
  1006. Specifies the bitmap to display in the item.
  1007. \fIBitmap\fR may have any of the forms accepted by \fBTk_GetBitmap\fR.
  1008. .TP
  1009. \fB\-foreground \fIcolor\fR
  1010. Specifies a color to use for each of the bitmap pixels
  1011. whose value is 1.
  1012. \fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR and
  1013. defaults to \fBblack\fR.
  1014. .TP
  1015. \fB\-tags \fItagList\fR
  1016. Specifies a set of tags to apply to the item.
  1017. \fITagList\fR consists of a list of tag names, which replace any
  1018. existing tags for the item.
  1019. \fITagList\fR may be an empty list.
  1020. .VE
  1021.  
  1022. .SH "LINE ITEMS"
  1023. .PP
  1024. Items of type \fBline\fR appear on the display as one or more connected
  1025. line segments or curves.
  1026. Lines are created with widget commands of the following form:
  1027. .DS
  1028. \fIpathName \fBcreate line \fIx1 y1... xn yn \fR?\fIoption value option value ...\fR?
  1029. .DE
  1030. The arguments \fIx1\fR through \fIyn\fR give
  1031. the coordinates for a series of two or more points that describe
  1032. a series of connected line segments.
  1033. After the coordinates there may be any number of \fIoption\fR-\fIvalue\fR
  1034. pairs, each of which sets one of the configuration options
  1035. for the item.  These same \fIoption\fR\-\fIvalue\fR pairs may be
  1036. used in \fBitemconfigure\fR widget commands to change the item's
  1037. configuration.
  1038. The following options are supported for lines:
  1039. .TP
  1040. \fB\-arrow \fIwhere\fR
  1041. Indicates whether or not arrowheads are to be drawn at one or both
  1042. ends of the line.
  1043. \fIWhere\fR must have one of the values \fBnone\fR (for no arrowheads),
  1044. \fBfirst\fR (for an arrowhead at the first point of the line),
  1045. \fBlast\fR (for an arrowhead at the last point of the line), or
  1046. \fBboth\fR (for arrowheads at both ends).
  1047. This option defaults to \fBnone\fR.
  1048. .TP
  1049. \fB\-arrowshape \fIshape\fR
  1050. This option indicates how to draw arrowheads.
  1051. The \fIshape\fR argument must be a list with three elements, each
  1052. specifying a distance in any of the forms described in
  1053. the COORDINATES section above.
  1054. The first element of the list gives the distance along the line
  1055. from the neck of the arrowhead to its tip.
  1056. The second element gives the distance along the line from the
  1057. trailing points of the arrowhead to the tip, and the third
  1058. element gives the distance from the outside edge of the line to the
  1059. trailing points.
  1060. If this option isn't specified then Tk picks a ``reasonable'' shape.
  1061. .TP
  1062. \fB\-capstyle \fIstyle\fR
  1063. Specifies the ways in which caps are to be drawn at the endpoints
  1064. of the line.
  1065. \fIStyle\fR may have any of the forms accepted by \fBTk_GetCapStyle\fR
  1066. (\fBbutt\fR, \fBprojecting\fR, or \fBround\fR).
  1067. If this option isn't specified then it defaults to \fBbutt\fR.
  1068. Where arrowheads are drawn the cap style is ignored.
  1069. .TP
  1070. \fB\-fill \fIcolor\fR
  1071. \fIColor\fR specifies a color to use for drawing the line; it may have
  1072. any of the forms acceptable to \fBTk_GetColor\fR.  It may also be an
  1073. empty string, in which case the line will be transparent.
  1074. This option defaults to \fBblack\fR.
  1075. .TP
  1076. \fB\-joinstyle \fIstyle\fR
  1077. Specifies the ways in which joints are to be drawn at the vertices
  1078. of the line.
  1079. \fIStyle\fR may have any of the forms accepted by \fBTk_GetCapStyle\fR
  1080. (\fBbevel\fR, \fBmiter\fR, or \fBround\fR).
  1081. If this option isn't specified then it defaults to \fBmiter\fR.
  1082. If the line only contains two points then this option is
  1083. irrelevant.
  1084. .TP
  1085. \fB\-smooth \fIboolean\fR
  1086. .VS
  1087. \fIBoolean\fR must have one of the forms accepted by \fBTk_GetBoolean\fR.
  1088. It indicates whether or not the line should be drawn as a curve.
  1089. If so, the line is rendered as a set of Bezier splines: one spline
  1090. is drawn for the first and second line segments, one for the second
  1091. and third, and so on.  Straight-line segments can be generated within
  1092. a curve by duplicating the end-points of the desired line segment.
  1093. .TP
  1094. \fB\-splinesteps \fInumber\fR
  1095. Specifies the degree of smoothness desired for curves:  each spline
  1096. will be approximated with \fInumber\fR line segments.  This
  1097. option is ignored unless the \fB\-smooth\fR option is true.
  1098. .VE
  1099. .TP
  1100. \fB\-stipple \fIbitmap\fR
  1101. Indicates that the line should be filled in a stipple pattern;
  1102. \fIbitmap\fR specifies the stipple pattern to use, in any of the
  1103. forms accepted by \fBTk_GetBitmap\fR.
  1104. If \fIbitmap\fR is an empty string (the default), then filling is
  1105. done in a solid fashion.
  1106. .TP
  1107. \fB\-tags \fItagList\fR
  1108. .VS
  1109. Specifies a set of tags to apply to the item.
  1110. \fITagList\fR consists of a list of tag names, which replace any
  1111. existing tags for the item.
  1112. \fITagList\fR may be an empty list.
  1113. .VE
  1114. .TP
  1115. \fB\-width \fIlineWidth\fR
  1116. \fILineWidth\fR specifies the width of the line, in any of the forms
  1117. described in the COORDINATES section above.
  1118. Wide lines will be drawn centered on the path specified by the
  1119. points.
  1120. If this option isn't specified then it defaults to 1.0.
  1121.  
  1122. .SH "OVAL ITEMS"
  1123. .PP
  1124. Items of type \fBoval\fR appear as circular or oval regions on
  1125. the display.  Each oval may have an outline, a fill, or
  1126. both.  Ovals are created with widget commands of the
  1127. following form:
  1128. .DS
  1129. \fIpathName \fBcreate oval \fIx1 y1 x2 y2 \fR?\fIoption value option value ...\fR?
  1130. .DE
  1131. The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR give
  1132. the coordinates of two diagonally opposite corners of a
  1133. rectangular region enclosing the oval.
  1134. The oval will touch this enclosing region at its top,
  1135. bottom, left, and right edges.
  1136. If the region is square then the resulting oval is circular;
  1137. otherwise it is elongated in shape.
  1138. After the coordinates there may be any number of \fIoption\fR-\fIvalue\fR
  1139. pairs, each of which sets one of the configuration options
  1140. for the item.  These same \fIoption\fR\-\fIvalue\fR pairs may be
  1141. used in \fBitemconfigure\fR widget commands to change the item's
  1142. configuration.
  1143. The following options are supported for ovals:
  1144. .TP
  1145. \fB\-fill \fIcolor\fR
  1146. Fill the area of the oval with \fIcolor\fR.
  1147. \fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
  1148. If \fIcolor\fR is an empty string (the default), then
  1149. then the oval will not be filled.
  1150. .TP
  1151. \fB\-outline \fIcolor\fR
  1152. \fIColor\fR specifies a color to use for drawing the oval's
  1153. outline;  it may have any of the forms accepted by \fBTk_GetColor\fR.
  1154. This option defaults to \fBblack\fR.
  1155. If \fIcolor\fR is an empty string then no outline will be
  1156. drawn for the oval.
  1157. .TP
  1158. \fB\-stipple \fIbitmap\fR
  1159. Indicates that the oval should be filled in a stipple pattern;
  1160. \fIbitmap\fR specifies the stipple pattern to use, in any of the
  1161. forms accepted by \fBTk_GetBitmap\fR.
  1162. If the \fB\-fill\fR option hasn't been specified then this option
  1163. has no effect.
  1164. If \fIbitmap\fR is an empty string (the default), then filling is done
  1165. in a solid fashion.
  1166. .TP
  1167. \fB\-tags \fItagList\fR
  1168. .VS
  1169. Specifies a set of tags to apply to the item.
  1170. \fITagList\fR consists of a list of tag names, which replace any
  1171. existing tags for the item.
  1172. \fITagList\fR may be an empty list.
  1173. .VE
  1174. .TP
  1175. \fB\-width \fIoutlineWidth\fR
  1176. \fIoutlineWidth\fR specifies the width of the outline to be drawn around
  1177. the oval, in any of the forms described in the COORDINATES section above.
  1178. If the \fB\-outline\fR option hasn't been specified then this option
  1179. has no effect.
  1180. .VS
  1181. Wide outlines are drawn centered on the oval path defined by
  1182. \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR.
  1183. .VE
  1184. This option defaults to 1.0.
  1185.  
  1186. .SH "POLYGON ITEMS"
  1187. .PP
  1188. Items of type \fBpolygon\fR appear as polygonal or curved filled regions
  1189. on the display.
  1190. Polygons are created with widget commands of the following form:
  1191. .DS
  1192. \fIpathName \fBcreate polygon \fIx1 y1 ... xn yn \fR?\fIoption value option value ...\fR?
  1193. .DE
  1194. The arguments \fIx1\fR through \fIyn\fR specify the coordinates for
  1195. three or more points that define a closed polygon.
  1196. The first and last points may be the same;  whether they are or not,
  1197. Tk will draw the polygon as a closed polygon.
  1198. After the coordinates there may be any number of \fIoption\fR-\fIvalue\fR
  1199. pairs, each of which sets one of the configuration options
  1200. for the item.  These same \fIoption\fR\-\fIvalue\fR pairs may be
  1201. used in \fBitemconfigure\fR widget commands to change the item's
  1202. configuration.
  1203. The following options are supported for polygons:
  1204. .TP
  1205. \fB\-fill \fIcolor\fR
  1206. \fIColor\fR specifies a color to use for filling the area of the
  1207. polygon; it may have any of the forms acceptable to \fBTk_GetColor\fR.
  1208. If \fIcolor\fR is an empty string then the polygon will be
  1209. transparent.
  1210. This option defaults to \fBblack\fR.
  1211. .TP
  1212. \fB\-smooth \fIboolean\fR
  1213. .VS
  1214. \fIBoolean\fR must have one of the forms accepted by \fBTk_GetBoolean\fR
  1215. It indicates whether or not the polygon should be drawn with a
  1216. curved perimeter.
  1217. If so, the outline of the polygon becomes a set of Bezier splines,
  1218. one spline for the first and second line segments, one for the second
  1219. and third, and so on.  Straight-line segments can be generated in a
  1220. smoothed polygon by duplicating the end-points of the desired line segment.
  1221. .TP
  1222. \fB\-splinesteps \fInumber\fR
  1223. Specifies the degree of smoothness desired for curves:  each spline
  1224. will be approximated with \fInumber\fR line segments.  This
  1225. option is ignored unless the \fB\-smooth\fR option is true.
  1226. .VE
  1227. .TP
  1228. \fB\-stipple \fIbitmap\fR
  1229. Indicates that the polygon should be filled in a stipple pattern;
  1230. \fIbitmap\fR specifies the stipple pattern to use, in any of the
  1231. forms accepted by \fBTk_GetBitmap\fR.
  1232. If \fIbitmap\fR is an empty string (the default), then filling is
  1233. done in a solid fashion.
  1234. .TP
  1235. \fB\-tags \fItagList\fR
  1236. .VS
  1237. Specifies a set of tags to apply to the item.
  1238. \fITagList\fR consists of a list of tag names, which replace any
  1239. existing tags for the item.
  1240. \fITagList\fR may be an empty list.
  1241. .VE
  1242.  
  1243. .SH "RECTANGLE ITEMS"
  1244. .PP
  1245. Items of type \fBrectangle\fR appear as rectangular regions on
  1246. the display.  Each rectangle may have an outline, a fill, or
  1247. both.  Rectangles are created with widget commands of the
  1248. following form:
  1249. .DS
  1250. \fIpathName \fBcreate rectangle \fIx1 y1 x2 y2 \fR?\fIoption value option value ...\fR?
  1251. .DE
  1252. The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR give
  1253. the coordinates of two diagonally opposite corners of the rectangle.
  1254. After the coordinates there may be any number of \fIoption\fR-\fIvalue\fR
  1255. pairs, each of which sets one of the configuration options
  1256. for the item.  These same \fIoption\fR\-\fIvalue\fR pairs may be
  1257. used in \fBitemconfigure\fR widget commands to change the item's
  1258. configuration.
  1259. The following options are supported for rectangles:
  1260. .TP
  1261. \fB\-fill \fIcolor\fR
  1262. Fill the area of the rectangle with \fIcolor\fR, which may be
  1263. specified in any of the forms accepted by \fBTk_GetColor\fR.
  1264. If \fIcolor\fR is an empty string (the default), then
  1265. then the rectangle will not be filled.
  1266. .TP
  1267. \fB\-outline \fIcolor\fR
  1268. Draw an outline around the edge of the rectangle in \fIcolor\fR.
  1269. \fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
  1270. This option defaults to \fBblack\fR.
  1271. If \fIcolor\fR is an empty string then no outline will be
  1272. drawn for the rectangle.
  1273. .TP
  1274. \fB\-stipple \fIbitmap\fR
  1275. Indicates that the rectangle should be filled in a stipple pattern;
  1276. \fIbitmap\fR specifies the stipple pattern to use, in any of the
  1277. forms accepted by \fBTk_GetBitmap\fR.
  1278. If the \fB\-fill\fR option hasn't been specified then this option
  1279. has no effect.
  1280. If \fIbitmap\fR is an empty string (the default), then filling
  1281. is done in a solid fashion.
  1282. .TP
  1283. \fB\-tags \fItagList\fR
  1284. .VS
  1285. Specifies a set of tags to apply to the item.
  1286. \fITagList\fR consists of a list of tag names, which replace any
  1287. existing tags for the item.
  1288. \fITagList\fR may be an empty list.
  1289. .VE
  1290. .TP
  1291. \fB\-width \fIoutlineWidth\fR
  1292. \fIOutlineWidth\fR specifies the width of the outline to be drawn around
  1293. the rectangle, in any of the forms described in the COORDINATES section above.
  1294. If the \fB\-outline\fR option hasn't been specified then this option
  1295. has no effect.
  1296. .VS
  1297. Wide outlines are drawn centered on the rectangular path
  1298. defined by \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR.
  1299. .VE
  1300. This option defaults to 1.0.
  1301.  
  1302. .SH "TEXT ITEMS"
  1303. .PP
  1304. A text item displays a string of characters on the screen in one
  1305. or more lines.
  1306. Text items support indexing and selection, along with the
  1307. following text-related canvas widget commands:  \fBdchars\fR,
  1308. \fBfocus\fR, \fBicursor\fR, \fBindex\fR, \fBinsert\fR,
  1309. .VS
  1310. .VE
  1311. \fBselect\fR.
  1312. Text items are created with widget commands of the following
  1313. form:
  1314. .DS
  1315. \fIpathName \fBcreate text \fIx y \fR?\fIoption value option value ...\fR?
  1316. .DE
  1317. The arguments \fIx\fR and \fIy\fR specify the coordinates of a
  1318. point used to position the text on the display (see the options
  1319. below for more information on how text is displayed).
  1320. After the coordinates there may be any number of \fIoption\fR-\fIvalue\fR
  1321. pairs, each of which sets one of the configuration options
  1322. for the item.  These same \fIoption\fR\-\fIvalue\fR pairs may be
  1323. used in \fBitemconfigure\fR widget commands to change the item's
  1324. configuration.
  1325. The following options are supported for text items:
  1326. .TP
  1327. \fB\-anchor \fIanchorPos\fR
  1328. \fIAnchorPos\fR tells how to position the text relative to the
  1329. positioning point for the text;  it may have any of the forms
  1330. accepted by \fBTk_GetAnchor\fR.  For example, if \fIanchorPos\fR
  1331. is \fBcenter\fR then the text is centered on the point;  if
  1332. \fIanchorPos\fR is \fBn\fR then the text will be drawn such that
  1333. the top center point of the rectangular region occupied by the
  1334. text will be at the positioning point.
  1335. This option defaults to \fBcenter\fR.
  1336. .TP
  1337. \fB\-fill \fIcolor\fR
  1338. \fIColor\fR specifies a color to use for filling the text characters;
  1339. it may have any of the forms accepted by \fBTk_GetColor\fR.
  1340. If this option isn't specified then it defaults to \fBblack\fR.
  1341. .TP
  1342. \fB\-font \fIfontName\fR
  1343. Specifies the font to use for the text item.
  1344. \fIFontName\fR may be any string acceptable to \fBTk_GetFontStruct\fR.
  1345. If this option isn't specified, it defaults to a system-dependent
  1346. font.
  1347. .TP
  1348. \fB\-justify \fIhow\fR
  1349. Specifies how to justify the text within its bounding region.
  1350. \fIHow\fR must be one of the values \fBleft\fR, \fBright\fR,
  1351. or \fBcenter\fR.
  1352. This option will only matter if the text is displayed as multiple
  1353. lines.
  1354. If the option is omitted, it defaults to \fBleft\fR.
  1355. .TP
  1356. \fB\-stipple \fIbitmap\fR
  1357. Indicates that the text should be drawn in a stippled pattern
  1358. rather than solid;
  1359. \fIbitmap\fR specifies the stipple pattern to use, in any of the
  1360. forms accepted by \fBTk_GetBitmap\fR.
  1361. If \fIbitmap\fR is an empty string (the default) then the text
  1362. is drawn in a solid fashion.
  1363. .TP
  1364. \fB\-tags \fItagList\fR
  1365. .VS
  1366. Specifies a set of tags to apply to the item.
  1367. \fITagList\fR consists of a list of tag names, which replace any
  1368. existing tags for the item.
  1369. \fITagList\fR may be an empty list.
  1370. .VE
  1371. .TP
  1372. \fB\-text \fIstring\fR
  1373. \fIString\fR specifies the characters to be displayed in the text item.
  1374. Newline characters cause line breaks.
  1375. The characters in the item may also be changed with the
  1376. \fBinsert\fR and \fBdelete\fR widget commands.
  1377. This option defaults to an empty string.
  1378. .TP
  1379. \fB\-width \fIlineLength\fR
  1380. Specifies a maximum line length for the text, in any of the forms
  1381. described in the COORDINATES section abov.
  1382. If this option is zero (the default) the text is broken into
  1383. lines only at newline characters.
  1384. However, if this option is non-zero then any line that would
  1385. be longer than \fIlineLength\fR is broken just before a space
  1386. character to make the line shorter than \fIlineLength\fR;  the
  1387. space character is treated as if it were a newline
  1388. character.
  1389.  
  1390. .SH "WINDOW ITEMS"
  1391. .PP
  1392. .VS
  1393. Items of type \fBwindow\fR cause a particular window to be displayed
  1394. at a given position on the canvas.
  1395. Window items are created with widget commands of the following form:
  1396. .DS
  1397. \fIpathName \fBcreate window \fIx y \fR?\fIoption value option value ...\fR?
  1398. .DE
  1399. The arguments \fIx\fR and \fIy\fR specify the coordinates of a
  1400. point used to position the window on the display (see the \fB\-anchor\fR
  1401. option below for more information on how bitmaps are displayed).
  1402. After the coordinates there may be any number of \fIoption\fR-\fIvalue\fR
  1403. pairs, each of which sets one of the configuration options
  1404. for the item.  These same \fIoption\fR\-\fIvalue\fR pairs may be
  1405. used in \fBitemconfigure\fR widget commands to change the item's
  1406. configuration.
  1407. The following options are supported for window items:
  1408. .TP
  1409. \fB\-anchor \fIanchorPos\fR
  1410. \fIAnchorPos\fR tells how to position the window relative to the
  1411. positioning point for the item;  it may have any of the forms
  1412. accepted by \fBTk_GetAnchor\fR.  For example, if \fIanchorPos\fR
  1413. is \fBcenter\fR then the window is centered on the point;  if
  1414. \fIanchorPos\fR is \fBn\fR then the window will be drawn so that
  1415. its top center point is at the positioning point.
  1416. This option defaults to \fBcenter\fR.
  1417. .TP
  1418. \fB\-height \fIpixels\fR
  1419. Specifies the height to assign to the item's window.
  1420. \fIPixels\fR may have any of the
  1421. forms described in the COORDINATES section above.
  1422. If this option isn't specified, or if it is specified as an empty
  1423. string, then the window is given whatever height it requests internally.
  1424. .TP
  1425. \fB\-tags \fItagList\fR
  1426. Specifies a set of tags to apply to the item.
  1427. \fITagList\fR consists of a list of tag names, which replace any
  1428. existing tags for the item.
  1429. \fITagList\fR may be an empty list.
  1430. .TP
  1431. \fB\-width \fIpixels\fR
  1432. Specifies the width to assign to the item's window.
  1433. \fIPixels\fR may have any of the
  1434. forms described in the COORDINATES section above.
  1435. If this option isn't specified, or if it is specified as an empty
  1436. string, then the window is given whatever width it requests internally.
  1437. .TP
  1438. \fB\-window \fIpathName\fR
  1439. Specifies the window to associate with this item.
  1440. The window specified by \fIpathName\fR must either be a child of
  1441. the canvas widget or a child of some ancestor of the canvas widget.
  1442. \fIPathName\fR may not refer to a top-level window.
  1443. .VE
  1444.  
  1445. .SH "APPLICATION-DEFINED ITEM TYPES"
  1446. .PP
  1447. It is possible for individual applications to define new item
  1448. types for canvas widgets using C code.
  1449. The interfaces for this mechanism are not presently documented,
  1450. and it's possible they may change, but you should be able to
  1451. see how they work by examining the code for some of the existing
  1452. item types.
  1453.  
  1454. .SH BINDINGS
  1455. .PP
  1456. In the current implementation, new canvases are not given any
  1457. default behavior:  you'll have to execute explicit Tcl commands
  1458. to give the canvas its behavior.
  1459.  
  1460. .SH CREDITS
  1461. .PP
  1462. Tk's canvas widget is a blatant ripoff of ideas from Joel Bartlett's
  1463. \fIezd\fR program.  \fIEzd\fR provides structured graphics in a Scheme
  1464. environment and preceded canvases by a year or two.  Its simple
  1465. mechanisms for placing and animating graphical objects inspired the
  1466. functions of canvases.
  1467.  
  1468. .SH KEYWORDS
  1469. canvas, widget
  1470.