Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | # Copyright (c) 1992-1994 The Regents of the University of California. |
2 | # Copyright (c) 1994-1996 Sun Microsystems, Inc. | |
3 | # See the file "license.terms" for information on usage and redistribution | |
4 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. | |
5 | # | |
6 | ||
7 | =head1 NAME | |
8 | ||
9 | Tk::Canvas - Create and manipulate Canvas widgets | |
10 | ||
11 | =for category Tk Widget Classes | |
12 | ||
13 | =head1 SYNOPSIS | |
14 | ||
15 | I<$canvas> = I<$parent>-E<gt>B<Canvas>(?I<options>?); | |
16 | ||
17 | =head1 STANDARD OPTIONS | |
18 | ||
19 | B<-background> B<-highlightthickness> B<-insertwidth> B<-state> | |
20 | B<-borderwidth> B<-insertbackground> B<-relief> B<-tile> | |
21 | B<-cursor> B<-insertborderwidth> B<-selectbackground> B<-takefocus> | |
22 | B<-highlightbackground> B<-insertofftime> B<-selectborderwidth> B<-xscrollcommand> | |
23 | B<-highlightcolor> B<-insertontime> B<-selectforeground> B<-yscrollcommand> | |
24 | ||
25 | =head1 WIDGET-SPECIFIC OPTIONS | |
26 | ||
27 | =over 4 | |
28 | ||
29 | =item Name: B<closeEnough> | |
30 | ||
31 | =item Class: B<CloseEnough> | |
32 | ||
33 | =item Switch: B<-closeenough> | |
34 | ||
35 | Specifies a floating-point value indicating how close the mouse cursor | |
36 | must be to an item before it is considered to be ``inside'' the item. | |
37 | Defaults to 1.0. | |
38 | ||
39 | =item Name: B<confine> | |
40 | ||
41 | =item Class: B<Confine> | |
42 | ||
43 | =item Switch: B<-confine> | |
44 | ||
45 | Specifies a boolean value that indicates whether or not it should be | |
46 | allowable to set the canvas's view outside the region defined by the | |
47 | B<scrollRegion> argument. | |
48 | Defaults to true, which means that the view will | |
49 | be constrained within the scroll region. | |
50 | ||
51 | =item Name: B<height> | |
52 | ||
53 | =item Class: B<Height> | |
54 | ||
55 | =item Switch: B<-height> | |
56 | ||
57 | Specifies a desired window height that the canvas widget should request from | |
58 | its geometry manager. The value may be specified in any | |
59 | of the forms described in the L<"COORDINATES"> section below. | |
60 | ||
61 | =item Name: B<scrollRegion> | |
62 | ||
63 | =item Class: B<ScrollRegion> | |
64 | ||
65 | =item Switch: B<-scrollregion> | |
66 | ||
67 | Specifies a list with four coordinates describing the left, top, right, and | |
68 | bottom coordinates of a rectangular region. | |
69 | This region is used for scrolling purposes and is considered to be | |
70 | the boundary of the information in the canvas. | |
71 | Each of the coordinates may be specified | |
72 | in any of the forms given in the L<"COORDINATES"> section below. | |
73 | ||
74 | =item Name: B<state> | |
75 | ||
76 | =item Class: B<State> | |
77 | ||
78 | =item Switch: B<-state> | |
79 | ||
80 | Modifies the default state of the canvas where I<state> may be set to one of: | |
81 | normal, disabled, or hidden. Individual canvas objects all have their own | |
82 | state option, which overrides the default state. Many options can take | |
83 | separate specifications such that the appearance of the item can be different | |
84 | in different situations. The options that start with "active" control the | |
85 | appearence when the mouse pointer is over it, while the option starting | |
86 | with "disabled" controls the appearence when the state is disabled. | |
87 | ||
88 | =item Name: B<width> | |
89 | ||
90 | =item Class: B<width> | |
91 | ||
92 | =item Switch: B<-width> | |
93 | ||
94 | Specifies a desired window width that the canvas widget should request from | |
95 | its geometry manager. The value may be specified in any | |
96 | of the forms described in the L<"COORDINATES"> section below. | |
97 | ||
98 | =item Name: B<xScrollIncrement> | |
99 | ||
100 | =item Class: B<ScrollIncrement> | |
101 | ||
102 | =item Switch: B<-xscrollincrement> | |
103 | ||
104 | Specifies an increment for horizontal scrolling, in any of the usual forms | |
105 | permitted for screen distances. If the value of this option is greater | |
106 | than zero, the horizontal view in the window will be constrained so that | |
107 | the canvas x coordinate at the left edge of the window is always an even | |
108 | multiple of B<xScrollIncrement>; furthermore, the units for scrolling | |
109 | (e.g., the change in view when the left and right arrows of a scrollbar | |
110 | are selected) will also be B<xScrollIncrement>. If the value of | |
111 | this option is less than or equal to zero, then horizontal scrolling | |
112 | is unconstrained. | |
113 | ||
114 | =item Name: B<yScrollIncrement> | |
115 | ||
116 | =item Class: B<ScrollIncrement> | |
117 | ||
118 | =item Switch: B<-yscrollincrement> | |
119 | ||
120 | Specifies an increment for vertical scrolling, in any of the usual forms | |
121 | permitted for screen distances. If the value of this option is greater | |
122 | than zero, the vertical view in the window will be constrained so that | |
123 | the canvas y coordinate at the top edge of the window is always an even | |
124 | multiple of B<yScrollIncrement>; furthermore, the units for scrolling | |
125 | (e.g., the change in view when the top and bottom arrows of a scrollbar | |
126 | are selected) will also be B<yScrollIncrement>. If the value of | |
127 | this option is less than or equal to zero, then vertical scrolling | |
128 | is unconstrained. | |
129 | ||
130 | =back | |
131 | ||
132 | =head1 DESCRIPTION | |
133 | ||
134 | The B<Canvas> method creates a new window (given | |
135 | by the $canvas argument) and makes it into a canvas widget. | |
136 | Additional options, described above, may be specified on the | |
137 | command line or in the option database | |
138 | to configure aspects of the canvas such as its colors and 3-D relief. | |
139 | The B<canvas> command returns its | |
140 | $canvas argument. At the time this command is invoked, | |
141 | there must not exist a window named $canvas, but | |
142 | $canvas's parent must exist. | |
143 | ||
144 | Canvas widgets implement structured graphics. | |
145 | A canvas displays any number of I<items>, which may be things like | |
146 | rectangles, circles, lines, and text. | |
147 | Items may be manipulated (e.g. moved or re-colored) and | |
148 | L<callbacks|Tk::callbacks> may | |
149 | be associated with items in much the same way that the L<bind|Tk::bind> | |
150 | method allows callbacks to be bound to widgets. For example, | |
151 | a particular callback may be associated with the B<E<lt>Button-1E<gt>> event | |
152 | so that the callback is invoked whenever button 1 is pressed with | |
153 | the mouse cursor over an item. | |
154 | This means that items in a canvas can have behaviors defined by | |
155 | the Callbacks bound to them. | |
156 | ||
157 | =head1 DISPLAY LIST | |
158 | ||
159 | The items in a canvas are ordered for purposes of display, | |
160 | with the first item in the display list being displayed | |
161 | first, followed by the next item in the list, and so on. | |
162 | Items later in the display list obscure those that are | |
163 | earlier in the display list and are sometimes referred to | |
164 | as being I<``on top''> of earlier items. | |
165 | When a new item is created it is placed at the end of the | |
166 | display list, on top of everything else. | |
167 | Widget methods may be used to re-arrange the order of the | |
168 | display list. | |
169 | ||
170 | Window items are an exception to the above rules. The underlying | |
171 | window systems require them always to be drawn on top of other items. | |
172 | In addition, the stacking order of window items | |
173 | is not affected by any of the canvas methods; you must use | |
174 | the L<raise|Tk::Widget> and L<lower|Tk::Widget> Tk widget methods instead. | |
175 | ||
176 | =head1 ITEM IDS AND TAGS | |
177 | ||
178 | Items in a canvas widget may be named in either of two ways: | |
179 | by id or by tag. | |
180 | Each item has a unique identifying number which is assigned to | |
181 | that item when it is created. The id of an item never changes | |
182 | and id numbers are never re-used within the lifetime of a | |
183 | canvas widget. | |
184 | ||
185 | Each item may also have any number of I<tags> associated | |
186 | with it. A tag is just a string of characters, and it may | |
187 | take any form except that of an integer. | |
188 | For example, ``x123'' is OK but ``123'' isn't. | |
189 | The same tag may be associated with many different items. | |
190 | This is commonly done to group items in various interesting | |
191 | ways; for example, all selected items might be given the | |
192 | tag ``selected''. | |
193 | ||
194 | The tag B<all> is implicitly associated with every item | |
195 | in the canvas; it may be used to invoke operations on | |
196 | all the items in the canvas. | |
197 | ||
198 | The tag B<current> is managed automatically by Tk; | |
199 | it applies to the I<current item>, which is the | |
200 | topmost item whose drawn area covers the position of | |
201 | the mouse cursor. | |
202 | If the mouse is not in the canvas widget or is not over | |
203 | an item, then no item has the B<current> tag. | |
204 | ||
205 | When specifying items in canvas methods, if the | |
206 | specifier is an integer then it is assumed to refer to | |
207 | the single item with that id. | |
208 | If the specifier is not an integer, then it is assumed to | |
209 | refer to all of the items in the canvas that have a tag | |
210 | matching the specifier. | |
211 | The symbol I<tagOrId> is used below to indicate that | |
212 | an argument specifies either an id that selects a single | |
213 | item or a tag that selects zero or more items. | |
214 | ||
215 | I<tagOrId> may contain a logical expressions of | |
216 | tags by using operators: 'E<amp>E<amp>', '||', '^' '!', and parenthezised | |
217 | subexpressions. For example: | |
218 | ||
219 | $c-E<gt>find('withtag', '(aE<amp>E<amp>!b)|(!aE<amp>E<amp>b)'); | |
220 | ||
221 | or equivalently: | |
222 | ||
223 | $c-E<gt>find('withtag', 'a^b'); | |
224 | ||
225 | will find only those items with either "a" or "b" tags, but not both. | |
226 | ||
227 | Some methods only operate on a single item at a | |
228 | time; if I<tagOrId> is specified in a way that | |
229 | names multiple items, then the normal behavior is for | |
230 | the methods is to use the first (lowest) of these items in | |
231 | the display list that is suitable for the method. | |
232 | Exceptions are noted in the method descriptions | |
233 | below. | |
234 | ||
235 | =head1 COORDINATES | |
236 | ||
237 | All coordinates related to canvases are stored as floating-point | |
238 | numbers. | |
239 | Coordinates and distances are specified in screen units, | |
240 | which are floating-point numbers optionally followed | |
241 | by one of several letters. | |
242 | If no letter is supplied then the distance is in pixels. | |
243 | If the letter is B<m> then the distance is in millimeters on | |
244 | the screen; if it is B<c> then the distance is in centimeters; | |
245 | B<i> means inches, and B<p> means printers points (1/72 inch). | |
246 | Larger y-coordinates refer to points lower on the screen; larger | |
247 | x-coordinates refer to points farther to the right. | |
248 | ||
249 | =head1 TRANSFORMATIONS | |
250 | ||
251 | Normally the origin of the canvas coordinate system is at the | |
252 | upper-left corner of the window containing the canvas. | |
253 | It is possible to adjust the origin of the canvas | |
254 | coordinate system relative to the origin of the window using the | |
255 | B<xview> and B<yview> methods; this is typically used | |
256 | for scrolling. | |
257 | Canvases do not support scaling or rotation of the canvas coordinate | |
258 | system relative to the window coordinate system. | |
259 | ||
260 | Individual items may be moved or scaled using methods | |
261 | described below, but they may not be rotated. | |
262 | ||
263 | =head1 INDICES | |
264 | ||
265 | Text items support the notion of an I<index> for identifying | |
266 | particular positions within the item. | |
267 | ||
268 | Indices are used for methods such as inserting text, deleting | |
269 | a range of characters, and setting the insertion cursor position. | |
270 | An index may be specified in any of a number of ways, and | |
271 | different types of items may support different forms for | |
272 | specifying indices. | |
273 | ||
274 | In a similar fashion, line and polygon items support I<index> for | |
275 | identifying, inserting and deleting subsets of their coordinates. | |
276 | Indices are used for commands such as inserting or deleting | |
277 | a range of characters or coordinates, and setting the insertion | |
278 | cursor position. An index may be specified in any of a number | |
279 | of ways, and different types of items may support different forms | |
280 | for specifying indices. | |
281 | ||
282 | Text items support the following forms for an index; if you | |
283 | define new types of text-like items, it would be advisable to | |
284 | support as many of these forms as practical. | |
285 | Note that it is possible to refer to the character just after | |
286 | the last one in the text item; this is necessary for such | |
287 | tasks as inserting new text at the end of the item. | |
288 | Lines and Polygons don't support the insertion cursor | |
289 | and the selection. Their indices are supposed to be even | |
290 | always, because coordinates always appear in pairs. | |
291 | ||
292 | =over 4 | |
293 | ||
294 | =item I<number> | |
295 | ||
296 | A decimal number giving the position of the desired character | |
297 | within the text item. | |
298 | 0 refers to the first character, 1 to the next character, and | |
299 | so on. If indexes are odd for lines and polygons, they will be | |
300 | automatically decremented by one. | |
301 | A number less than 0 is treated as if it were zero, and a | |
302 | number greater than the length of the text item is treated | |
303 | as if it were equal to the length of the text item. For | |
304 | polygons, numbers less than 0 or greater then the length | |
305 | of the coordinate list will be adjusted by adding or substracting | |
306 | the length until the result is between zero and the length, | |
307 | inclusive. | |
308 | ||
309 | =item B<end> | |
310 | ||
311 | Refers to the character or coordinate just after the last one | |
312 | in the item (same as the number of characters or coordinates | |
313 | in the item). | |
314 | ||
315 | =item B<insert> | |
316 | ||
317 | Refers to the character just before which the insertion cursor | |
318 | is drawn in this item. Not valid for lines and polygons. | |
319 | ||
320 | =item B<sel.first> | |
321 | ||
322 | Refers to the first selected character in the item. | |
323 | If the selection isn't in this item then this form is illegal. | |
324 | ||
325 | =item B<sel.last> | |
326 | ||
327 | Refers to the last selected character in the item. | |
328 | If the selection isn't in this item then this form is illegal. | |
329 | ||
330 | =item B<[>I<x,y>B<]> | |
331 | ||
332 | Refers to the character or coordinate at the point given by I<x> and | |
333 | I<y>, where I<x> and I<y> are specified in the coordinate | |
334 | system of the canvas. | |
335 | If I<x> and I<y> lie outside the coordinates covered by the | |
336 | text item, then they refer to the first or last character in the | |
337 | line that is closest to the given point. | |
338 | The Tcl string form "@x,y" is also allowed. | |
339 | ||
340 | =back | |
341 | ||
342 | =head1 DASH PATTERNS | |
343 | ||
344 | Many items support the notion of an dash pattern for outlines. | |
345 | ||
346 | The first possible syntax is a list of integers. Each element | |
347 | represents the number of pixels of a line segment. Only the odd | |
348 | segments are drawn using the "outline" color. The other segments | |
349 | are drawn transparant. | |
350 | ||
351 | The second possible syntax is a character list containing only | |
352 | 5 possible characters B<[.,-_ ]>. The space can be used | |
353 | to enlarge the space between other line elements, and can not | |
354 | occur as the first position in the string. Some examples: | |
355 | ||
356 | -dash . = -dash [2,4] | |
357 | -dash - = -dash [6,4] | |
358 | -dash -. = -dash [6,4,2,4] | |
359 | -dash -.. = -dash [6,4,2,4,2,4] | |
360 | -dash '. ' = -dash [2,8] | |
361 | -dash ',' = -dash [4,4] | |
362 | ||
363 | The main difference of this syntax with the previous is that it | |
364 | it shape-conserving. This means that all values in the dash | |
365 | list will be multiplied by the line width before display. This | |
366 | assures that "." will always be displayed as a dot and "-" | |
367 | always as a dash regardless of the line width. | |
368 | ||
369 | On systems where only a limited set of dash patterns, the dash | |
370 | pattern will be displayed as the most close dash pattern that | |
371 | is available. For example, on Windows only the first 4 of the | |
372 | above examples are available. The last 2 examples will be | |
373 | displayed identically as the first one. | |
374 | ||
375 | =head1 WIDGET METHODS | |
376 | ||
377 | The B<Canvas> method creates a widget object. | |
378 | This object supports the B<configure> and B<cget> methods | |
379 | described in L<Tk::options> which can be used to enquire and | |
380 | modify the options described above. | |
381 | The widget also inherits all the methods provided by the generic | |
382 | L<Tk::Widget|Tk::Widget> class. | |
383 | ||
384 | The following additional methods are available for canvas widgets: | |
385 | ||
386 | =over 4 | |
387 | ||
388 | =item I<$canvas>-E<gt>B<addtag>(I<tag, searchSpec, >?I<arg, arg, ...>?) | |
389 | ||
390 | For each item that meets the constraints specified by | |
391 | I<searchSpec> and the I<arg>s, add | |
392 | I<tag> to the list of tags associated with the item if it | |
393 | isn't already present on that list. | |
394 | It is possible that no items will satisfy the constraints | |
395 | given by I<searchSpec> and I<arg>s, in which case the | |
396 | method has no effect. | |
397 | This command returns an empty string as result. | |
398 | I<SearchSpec> and I<arg>'s may take any of the following | |
399 | forms: | |
400 | ||
401 | =over 8 | |
402 | ||
403 | =item B<above >I<tagOrId> | |
404 | ||
405 | Selects the item just after (above) the one given by I<tagOrId> | |
406 | in the display list. | |
407 | If I<tagOrId> denotes more than one item, then the last (topmost) | |
408 | of these items in the display list is used. | |
409 | ||
410 | =item B<all> | |
411 | ||
412 | Selects all the items in the canvas. | |
413 | ||
414 | =item B<below >I<tagOrId> | |
415 | ||
416 | Selects the item just before (below) the one given by I<tagOrId> | |
417 | in the display list. | |
418 | If I<tagOrId> denotes more than one item, then the first (lowest) | |
419 | of these items in the display list is used. | |
420 | ||
421 | =item B<closest >I<x y >?I<halo>? ?I<start>? | |
422 | ||
423 | Selects the item closest to the point given by I<x> and I<y>. | |
424 | If more than one item is at the same closest distance (e.g. two | |
425 | items overlap the point), then the top-most of these items (the | |
426 | last one in the display list) is used. | |
427 | If I<halo> is specified, then it must be a non-negative | |
428 | value. | |
429 | Any item closer than I<halo> to the point is considered to | |
430 | overlap it. | |
431 | The I<start> argument may be used to step circularly through | |
432 | all the closest items. | |
433 | If I<start> is specified, it names an item using a tag or id | |
434 | (if by tag, it selects the first item in the display list with | |
435 | the given tag). | |
436 | Instead of selecting the topmost closest item, this form will | |
437 | select the topmost closest item that is below I<start> in | |
438 | the display list; if no such item exists, then the selection | |
439 | behaves as if the I<start> argument had not been specified. | |
440 | ||
441 | =item B<enclosed> I<x1> I<y1> I<x2> I<y2> | |
442 | ||
443 | Selects all the items completely enclosed within the rectangular | |
444 | region given by I<x1>, I<y1>, I<x2>, and I<y2>. | |
445 | I<X1> must be no greater then I<x2> and I<y1> must be | |
446 | no greater than I<y2>. | |
447 | ||
448 | =item B<overlapping> I<x1> I<y1> I<x2> I<y2> | |
449 | ||
450 | Selects all the items that overlap or are enclosed within the | |
451 | rectangular region given by I<x1>, I<y1>, I<x2>, | |
452 | and I<y2>. | |
453 | I<X1> must be no greater then I<x2> and I<y1> must be | |
454 | no greater than I<y2>. | |
455 | ||
456 | =item B<withtag >I<tagOrId> | |
457 | ||
458 | Selects all the items given by I<tagOrId>. | |
459 | ||
460 | =back | |
461 | ||
462 | =item I<$canvas>-E<gt>B<bbox>(I<tagOrId, >?I<tagOrId, tagOrId, ...>?) | |
463 | ||
464 | Returns a list with four elements giving an approximate bounding box | |
465 | for all the items named by the I<tagOrId> arguments. | |
466 | The list has the form ``I<x1 y1 x2 y2>'' such that the drawn | |
467 | areas of all the named elements are within the region bounded by | |
468 | I<x1> on the left, I<x2> on the right, I<y1> on the top, | |
469 | and I<y2> on the bottom. | |
470 | The return value may overestimate the actual bounding box by | |
471 | a few pixels. | |
472 | If no items match any of the I<tagOrId> arguments or if the | |
473 | matching items have empty bounding boxes (i.e. they have nothing | |
474 | to display) | |
475 | then an empty string is returned. | |
476 | ||
477 | =item I<$canvas>-E<gt>B<bind>(I<tagOrId>?, I<sequence>? ?,I<callback>?) | |
478 | ||
479 | This method associates I<callback> with all the items given by | |
480 | I<tagOrId> such that whenever the event sequence given by | |
481 | I<sequence> occurs for one of the items the callback will | |
482 | be invoked. | |
483 | This method is similar to the B<bind> method except that | |
484 | it operates on items in a canvas rather than entire widgets. | |
485 | See L<Tk::bind> for complete details | |
486 | on the syntax of I<sequence> and the substitutions performed | |
487 | on I<callback> before invoking it. | |
488 | If all arguments are specified then a new binding is created, replacing | |
489 | any existing binding for the same I<sequence> and I<tagOrId> | |
490 | (if the first character of I<command> is ``+'' then I<command> | |
491 | augments an existing binding rather than replacing it). | |
492 | In this case the return value is an empty string. | |
493 | If I<callback> is omitted then the method returns the I<callback> | |
494 | associated with I<tagOrId> and I<sequence> (an error occurs | |
495 | if there is no such binding). | |
496 | If both I<callback> and I<sequence> are omitted then the method | |
497 | returns a list of all the sequences for which bindings have been | |
498 | defined for I<tagOrId>. | |
499 | ||
500 | =over 8 | |
501 | ||
502 | The only events for which bindings may be specified are those related to | |
503 | the mouse and keyboard (such as B<Enter>, B<Leave>, | |
504 | B<ButtonPress>, B<Motion>, and B<KeyPress>) or virtual events. | |
505 | The handling of events in canvases uses the current item defined | |
506 | in L<"ITEM IDS AND TAGS"> above. B<Enter> and B<Leave> events trigger for an | |
507 | item when it becomes the current item or ceases to be the current item; | |
508 | note that these events are different than B<Enter> and B<Leave> | |
509 | events for windows. Mouse-related events are directed to the current | |
510 | item, if any. Keyboard-related events are directed to the focus item, if | |
511 | any (see the L<focus|/focus> method below for more on this). If a | |
512 | virtual event is used in a binding, that binding can trigger only if the | |
513 | virtual event is defined by an underlying mouse-related or | |
514 | keyboard-related event. | |
515 | ||
516 | It is possible for multiple bindings to match a particular event. | |
517 | This could occur, for example, if one binding is associated with the | |
518 | item's id and another is associated with one of the item's tags. | |
519 | When this occurs, all of the matching bindings are invoked. | |
520 | A binding associated with the B<all> tag is invoked first, | |
521 | followed by one binding for each of the item's tags (in order), | |
522 | followed by a binding associated with the item's id. | |
523 | If there are multiple matching bindings for a single tag, | |
524 | then only the most specific binding is invoked. | |
525 | A B<continue> in a callback terminates that | |
526 | subroutine, and a B<break> method terminates that subroutine | |
527 | and skips any remaining callbacks for the event, just as for the | |
528 | B<bind> method. | |
529 | ||
530 | If bindings have been created for a canvas window using the B<CanvasBind> | |
531 | method, then they are invoked in addition to bindings created for | |
532 | the canvas's items using the B<bind> method. | |
533 | The bindings for items will be invoked before any of the bindings | |
534 | for the window as a whole. | |
535 | ||
536 | =back | |
537 | ||
538 | =item I<$canvas>-E<gt>B<canvasx>(I<screenx>?, I<gridspacing>?) | |
539 | ||
540 | Given a window x-coordinate in the canvas I<screenx>, this method returns | |
541 | the canvas x-coordinate that is displayed at that location. | |
542 | If I<gridspacing> is specified, then the canvas coordinate is | |
543 | rounded to the nearest multiple of I<gridspacing> units. | |
544 | ||
545 | =item I<$canvas>-E<gt>B<canvasy>(I<screeny, >?I<gridspacing>?) | |
546 | ||
547 | Given a window y-coordinate in the canvas I<screeny> this method returns | |
548 | the canvas y-coordinate that is displayed at that location. | |
549 | If I<gridspacing> is specified, then the canvas coordinate is | |
550 | rounded to the nearest multiple of I<gridspacing> units. | |
551 | ||
552 | =item I<$canvas>-E<gt>B<coords>(I<tagOrId >?I<x0,y0 ...>?) | |
553 | ||
554 | Query or modify the coordinates that define an item. | |
555 | If no coordinates are specified, this method returns a list | |
556 | whose elements are the coordinates of the item named by | |
557 | I<tagOrId>. | |
558 | If coordinates are specified, then they replace the current | |
559 | coordinates for the named item. | |
560 | If I<tagOrId> refers to multiple items, then | |
561 | the first one in the display list is used. | |
562 | ||
563 | =item I<$canvas>-E<gt>B<create>(I<type, x, y, >?I<x, y, ...>?, ?I<option, value, ...>?) | |
564 | ||
565 | Create a new item in I<$canvas> of type I<type>. | |
566 | The exact format of the arguments after B<type> depends | |
567 | on B<type>, but usually they consist of the coordinates for | |
568 | one or more points, followed by specifications for zero or | |
569 | more item options. | |
570 | See the subsections on individual item types below for more | |
571 | on the syntax of this method. | |
572 | This method returns the id for the new item. | |
573 | ||
574 | =item I<$canvas>-E<gt>B<dchars>(I<tagOrId, first, >?I<last>?) | |
575 | ||
576 | For each item given by I<tagOrId>, delete the characters, or coordinates, | |
577 | in the range given by I<first> and I<last>, inclusive. | |
578 | If some of the items given by I<tagOrId> don't support | |
579 | Text items interpret I<first> and I<last> as indices to a character, | |
580 | line and polygon items interpret them indices to a coordinate (an x,y pair). | |
581 | within the item(s) as described in L<"INDICES"> above. | |
582 | If I<last> is omitted, it defaults to I<first>. | |
583 | This method returns an empty string. | |
584 | ||
585 | =item I<$canvas>-E<gt>B<delete>(?I<tagOrId, tagOrId, ...>?) | |
586 | ||
587 | Delete each of the items given by each I<tagOrId>, and return | |
588 | an empty string. | |
589 | ||
590 | =item I<$canvas>-E<gt>B<dtag>(I<tagOrId, >?I<tagToDelete>?) | |
591 | ||
592 | For each of the items given by I<tagOrId>, delete the | |
593 | tag given by I<tagToDelete> from the list of those | |
594 | associated with the item. | |
595 | If an item doesn't have the tag I<tagToDelete> then | |
596 | the item is unaffected by the method. | |
597 | If I<tagToDelete> is omitted then it defaults to I<tagOrId>. | |
598 | This method returns an empty string. | |
599 | ||
600 | =item I<$canvas>-E<gt>B<find>(I<searchCommand, >?I<arg, arg, ...>?) | |
601 | ||
602 | This method returns a list consisting of all the items that | |
603 | meet the constraints specified by I<searchCommand> and | |
604 | I<arg>'s. | |
605 | I<SearchCommand> and I<args> have any of the forms | |
606 | accepted by the B<addtag> method. | |
607 | The items are returned in stacking order, with the lowest item first. | |
608 | ||
609 | =item focus | |
610 | ||
611 | =item I<$canvas>-E<gt>B<focus>(?I<tagOrId>?) | |
612 | ||
613 | Set the keyboard focus for the canvas widget to the item given by | |
614 | I<tagOrId>. | |
615 | If I<tagOrId> refers to several items, then the focus is set | |
616 | to the first such item in the display list that supports the | |
617 | insertion cursor. | |
618 | If I<tagOrId> doesn't refer to any items, or if none of them | |
619 | support the insertion cursor, then the focus isn't changed. | |
620 | If I<tagOrId> is an empty | |
621 | string, then the focus item is reset so that no item has the focus. | |
622 | If I<tagOrId> is not specified then the method returns the | |
623 | id for the item that currently has the focus, or an empty string | |
624 | if no item has the focus. | |
625 | ||
626 | =over 8 | |
627 | ||
628 | Once the focus has been set to an item, the item will display | |
629 | the insertion cursor and all keyboard events will be directed | |
630 | to that item. | |
631 | The focus item within a canvas and the focus window on the | |
632 | screen (set with the B<focus> method) are totally independent: | |
633 | a given item doesn't actually have the input focus unless (a) | |
634 | its canvas is the focus window and (b) the item is the focus item | |
635 | within the canvas. | |
636 | In most cases it is advisable to follow the B<focus> widget | |
637 | method with the B<CanvasFocus> method to set the focus window to | |
638 | the canvas (if it wasn't there already). | |
639 | ||
640 | =back | |
641 | ||
642 | =item I<$canvas>-E<gt>B<gettags>(I<tagOrId>) | |
643 | ||
644 | Return a list whose elements are the tags associated with the | |
645 | item given by I<tagOrId>. | |
646 | If I<tagOrId> refers to more than one item, then the tags | |
647 | are returned from the first such item in the display list. | |
648 | If I<tagOrId> doesn't refer to any items, or if the item | |
649 | contains no tags, then an empty string is returned. | |
650 | ||
651 | =item I<$canvas>-E<gt>B<icursor>(I<tagOrId, index>) | |
652 | ||
653 | Set the position of the insertion cursor for the item(s) given by I<tagOrId> | |
654 | to just before the character whose position is given by I<index>. | |
655 | If some or all of the items given by I<tagOrId> don't support | |
656 | an insertion cursor then this method has no effect on them. | |
657 | See L<"INDICES"> above for a description of the | |
658 | legal forms for I<index>. | |
659 | Note: the insertion cursor is only displayed in an item if | |
660 | that item currently has the keyboard focus (see the widget | |
661 | method B<focus>, below), but the cursor position may | |
662 | be set even when the item doesn't have the focus. | |
663 | This method returns an empty string. | |
664 | ||
665 | =item I<$canvas>-E<gt>B<index>(I<tagOrId, index>) | |
666 | ||
667 | This method returns a decimal string giving the numerical index | |
668 | within I<tagOrId> corresponding to I<index>. | |
669 | I<Index> gives a textual description of the desired position | |
670 | as described in L<"INDICES"> above. | |
671 | Text items interpret I<index> as an index to a character, | |
672 | line and polygon items interpret it as an index to a coordinate (an x,y pair). | |
673 | The return value is guaranteed to lie between 0 and the number | |
674 | of characters, or coordinates, within the item, inclusive. | |
675 | If I<tagOrId> refers to multiple items, then the index | |
676 | is processed in the first of these items that supports indexing | |
677 | operations (in display list order). | |
678 | ||
679 | =item I<$canvas>-E<gt>B<insert>(I<tagOrId, beforeThis, string>) | |
680 | ||
681 | For each of the items given by I<tagOrId>, if the item supports | |
682 | text or coordinate, insertion then I<string> is inserted into the item's | |
683 | text just before the character, or coordinate, whose index is I<beforeThis>. | |
684 | Text items interpret I<beforethis> as an index to a character, | |
685 | line and polygon items interpret it as an index to a coordinate (an x,y pair). | |
686 | For lines and polygons the I<string> must be a valid coordinate | |
687 | sequence. | |
688 | See L<"INDICES"> above for information about the forms allowed | |
689 | for I<beforeThis>. | |
690 | This method returns an empty string. | |
691 | ||
692 | =item I<$canvas>-E<gt>B<itemcget>(I<tagOrId, >I<option>) | |
693 | ||
694 | Returns the current value of the configuration option for the | |
695 | item given by I<tagOrId> whose name is I<option>. | |
696 | This method is similar to the L<cget|Tk::option> method except that | |
697 | it applies to a particular item rather than the widget as a whole. | |
698 | I<Option> may have any of the values accepted by the B<create> | |
699 | method when the item was created. | |
700 | If I<tagOrId> is a tag that refers to more than one item, | |
701 | the first (lowest) such item is used. | |
702 | ||
703 | =item I<$canvas>-E<gt>B<itemconfigure>(I<tagOrId, >?I<option>?, ?I<value>?, ?I<option, value, ...>?) | |
704 | ||
705 | This method is similar to the L<configure|Tk::option> method except | |
706 | that it modifies item-specific options for the items given by | |
707 | I<tagOrId> instead of modifying options for the overall | |
708 | canvas widget. | |
709 | If no I<option> is specified, returns a list describing all of | |
710 | the available options for the first item given by I<tagOrId> | |
711 | (see L<Tk::options> for | |
712 | information on the format of this list). If I<option> is specified | |
713 | with no I<value>, then the method returns a list describing the | |
714 | one named option (this list will be identical to the corresponding | |
715 | sublist of the value returned if no I<option> is specified). If | |
716 | one or more I<option-value> pairs are specified, then the method | |
717 | modifies the given widget option(s) to have the given value(s) in | |
718 | each of the items given by I<tagOrId>; in | |
719 | this case the method returns an empty string. | |
720 | The I<option>s and I<value>s are the same as those permissible | |
721 | in the B<create> method when the item(s) were created; | |
722 | see the sections describing individual item types below for details | |
723 | on the legal options. | |
724 | ||
725 | =item I<$canvas>-E<gt>B<lower>(I<tagOrId, >?I<belowThis>?) | |
726 | ||
727 | Move all of the items given by I<tagOrId> to a new position | |
728 | in the display list just before the item given by I<belowThis>. | |
729 | If I<tagOrId> refers to more than one item then all are moved | |
730 | but the relative order of the moved items will not be changed. | |
731 | I<BelowThis> is a tag or id; if it refers to more than one | |
732 | item then the first (lowest) of these items in the display list is used | |
733 | as the destination location for the moved items. | |
734 | Note: this method has no effect on window items. Window items always | |
735 | obscure other item types, and the stacking order of window items is | |
736 | determined by the B<raise> and B<lower> methods of the widget, not the | |
737 | B<raise> and B<lower> methods for canvases. | |
738 | This method returns an empty string. | |
739 | ||
740 | =item I<$canvas>-E<gt>B<move>(I<tagOrId, xAmount, yAmount>) | |
741 | ||
742 | Move each of the items given by I<tagOrId> in the canvas coordinate | |
743 | space by adding I<xAmount> to the x-coordinate of each point | |
744 | associated with the item and I<yAmount> to the y-coordinate of | |
745 | each point associated with the item. | |
746 | This method returns an empty string. | |
747 | ||
748 | =item I<$canvas>-E<gt>B<postscript>(?I<option, value, option, value, ...>?) | |
749 | ||
750 | Generate a Postscript representation for part or all of the canvas. | |
751 | If the B<-file> option is specified then the Postscript is written | |
752 | to a file and an empty string is returned; otherwise the Postscript | |
753 | is returned as the result of the method. | |
754 | If the interpreter that owns the canvas is marked as safe, the operation | |
755 | will fail because safe interpreters are not allowed to write files. | |
756 | If the B<-channel> option is specified, the argument denotes the name | |
757 | of a channel already opened for writing. The Postscript is written to | |
758 | that channel, and the channel is left open for further writing at the end | |
759 | of the operation. | |
760 | The Postscript is created in Encapsulated Postscript form using | |
761 | version 3.0 of the Document Structuring Conventions. | |
762 | Note: by default Postscript is only generated for information that | |
763 | appears in the canvas's window on the screen. If the canvas is | |
764 | freshly created it may still have its initial size of 1x1 pixel | |
765 | so nothing will appear in the Postscript. To get around this problem | |
766 | either invoke the B<update> method to wait for the canvas window | |
767 | to reach its final size, or else use the B<-width> and B<-height> | |
768 | options to specify the area of the canvas to print. | |
769 | The I<option>-I<value> argument pairs provide additional | |
770 | information to control the generation of Postscript. The following | |
771 | options are supported: | |
772 | ||
773 | =over 8 | |
774 | ||
775 | =item B<-colormap> =E<gt> I<hashRef> | |
776 | ||
777 | I<HashRef> must be a reference to a hash variable or an anonymous hash | |
778 | that specifies a color mapping to use in the Postscript. | |
779 | Each value of the hash must consist of Postscript | |
780 | code to set a particular color value (e.g. ``B<1.0 1.0 0.0 setrgbcolor>''). | |
781 | When outputting color information in the Postscript, Tk checks | |
782 | to see if there is a key in the hash with the same | |
783 | name as the color. | |
784 | If so, Tk uses the value of the element as the Postscript method | |
785 | to set the color. | |
786 | If this option hasn't been specified, or if there isn't a key | |
787 | in I<hashRef> for a given color, then Tk uses the red, green, | |
788 | and blue intensities from the X color. | |
789 | ||
790 | =item B<-colormode> =E<gt> I<mode> | |
791 | ||
792 | Specifies how to output color information. I<Mode> must be either | |
793 | B<color> (for full color output), B<gray> (convert all colors | |
794 | to their gray-scale equivalents) or B<mono> (convert all colors | |
795 | to black or white). | |
796 | ||
797 | =item B<-file> =E<gt> I<fileName> | |
798 | ||
799 | Specifies the name of the file in which to write the Postscript. | |
800 | If this option isn't specified then the Postscript is returned as the | |
801 | result of the method instead of being written to a file. | |
802 | ||
803 | =item B<-fontmap> =E<gt> I<hashRef> | |
804 | ||
805 | I<HashRef> must be a reference to a hash variable or an anonymous hash | |
806 | that specifies a font mapping to use in the Postscript. | |
807 | Each value of the hash must consist of an array reference with | |
808 | two elements, which are the name and point size of a Postscript font. | |
809 | When outputting Postscript commands for a particular font, Tk | |
810 | checks to see if I<hashRef> contains a value with the same | |
811 | name as the font. | |
812 | If there is such an element, then the font information contained in | |
813 | that element is used in the Postscript. | |
814 | Otherwise Tk attempts to guess what Postscript font to use. | |
815 | Tk's guesses generally only work for well-known fonts such as | |
816 | Times and Helvetica and Courier, and only if the X font name does not | |
817 | omit any dashes up through the point size. | |
818 | For example, B<-*-Courier-Bold-R-Normal--*-120-*> will work but | |
819 | B<*Courier-Bold-R-Normal*120*> will not; Tk needs the dashes to | |
820 | parse the font name). | |
821 | ||
822 | =item B<-height> =E<gt> I<size> | |
823 | ||
824 | Specifies the height of the area of the canvas to print. | |
825 | Defaults to the height of the canvas window. | |
826 | ||
827 | =item B<-pageanchor> =E<gt> I<anchor> | |
828 | ||
829 | Specifies which point of the printed area of the canvas should appear over | |
830 | the positioning point on the page (which is given by the B<-pagex> | |
831 | and B<-pagey> options). | |
832 | For example, B<-pageanchor>=>B<n> means that the top center of the | |
833 | area of the canvas being printed (as it appears in the canvas window) | |
834 | should be over the positioning point. Defaults to B<center>. | |
835 | ||
836 | =item B<-pageheight> =E<gt> I<size> | |
837 | ||
838 | Specifies that the Postscript should be scaled in both x and y so | |
839 | that the printed area is I<size> high on the Postscript page. | |
840 | I<Size> consists of a floating-point number followed by | |
841 | B<c> for centimeters, B<i> for inches, B<m> for millimeters, | |
842 | or B<p> or nothing for printer's points (1/72 inch). | |
843 | Defaults to the height of the printed area on the screen. | |
844 | If both B<-pageheight> and B<-pagewidth> are specified then | |
845 | the scale factor from B<-pagewidth> is used (non-uniform scaling | |
846 | is not implemented). | |
847 | ||
848 | =item B<-pagewidth> =E<gt> I<size> | |
849 | ||
850 | Specifies that the Postscript should be scaled in both x and y so | |
851 | that the printed area is I<size> wide on the Postscript page. | |
852 | I<Size> has the same form as for B<-pageheight>. | |
853 | Defaults to the width of the printed area on the screen. | |
854 | If both B<-pageheight> and B<-pagewidth> are specified then | |
855 | the scale factor from B<-pagewidth> is used (non-uniform scaling | |
856 | is not implemented). | |
857 | ||
858 | =item B<-pagex> =E<gt> I<position> | |
859 | ||
860 | I<Position> gives the x-coordinate of the positioning point on | |
861 | the Postscript page, using any of the forms allowed for B<-pageheight>. | |
862 | Used in conjunction with the B<-pagey> and B<-pageanchor> options | |
863 | to determine where the printed area appears on the Postscript page. | |
864 | Defaults to the center of the page. | |
865 | ||
866 | =item B<-pagey> =E<gt> I<position> | |
867 | ||
868 | I<Position> gives the y-coordinate of the positioning point on | |
869 | the Postscript page, using any of the forms allowed for B<-pageheight>. | |
870 | Used in conjunction with the B<-pagex> and B<-pageanchor> options | |
871 | to determine where the printed area appears on the Postscript page. | |
872 | Defaults to the center of the page. | |
873 | ||
874 | =item B<-rotate> =E<gt> I<boolean> | |
875 | ||
876 | I<Boolean> specifies whether the printed area is to be rotated 90 | |
877 | degrees. | |
878 | In non-rotated output the x-axis of the printed area runs along | |
879 | the short dimension of the page (``portrait'' orientation); | |
880 | in rotated output the x-axis runs along the long dimension of the | |
881 | page (``landscape'' orientation). | |
882 | Defaults to non-rotated. | |
883 | ||
884 | =item B<-width> =E<gt> I<size> | |
885 | ||
886 | Specifies the width of the area of the canvas to print. | |
887 | Defaults to the width of the canvas window. | |
888 | ||
889 | =item B<-x> => I<position> | |
890 | ||
891 | Specifies the x-coordinate of the left edge of the area of the | |
892 | canvas that is to be printed, in canvas coordinates, not window | |
893 | coordinates. | |
894 | Defaults to the coordinate of the left edge of the window. | |
895 | ||
896 | =item B<-y> => I<position> | |
897 | ||
898 | Specifies the y-coordinate of the top edge of the area of the | |
899 | canvas that is to be printed, in canvas coordinates, not window | |
900 | coordinates. | |
901 | Defaults to the coordinate of the top edge of the window. | |
902 | ||
903 | =back | |
904 | ||
905 | =item I<$canvas>-E<gt>B<raise>(I<tagOrId, >?I<aboveThis>?) | |
906 | ||
907 | Move all of the items given by I<tagOrId> to a new position | |
908 | in the display list just after the item given by I<aboveThis>. | |
909 | If I<tagOrId> refers to more than one item then all are moved | |
910 | but the relative order of the moved items will not be changed. | |
911 | I<AboveThis> is a tag or id; if it refers to more than one | |
912 | item then the last (topmost) of these items in the display list is used | |
913 | as the destination location for the moved items. | |
914 | Note: this method has no effect on window items. Window items always | |
915 | obscure other item types, and the stacking order of window items is | |
916 | determined by the B<raise> and B<lower> widget commands, not the | |
917 | B<raise> and B<lower> methods for canvases. | |
918 | This method returns an empty string. | |
919 | ||
920 | =item I<$canvas>-E<gt>B<scale>(I<tagOrId, xOrigin, yOrigin, xScale, yScale>) | |
921 | ||
922 | Rescale all of the items given by I<tagOrId> in canvas coordinate | |
923 | space. | |
924 | I<XOrigin> and I<yOrigin> identify the origin for the scaling | |
925 | operation and I<xScale> and I<yScale> identify the scale | |
926 | factors for x- and y-coordinates, respectively (a scale factor of | |
927 | 1.0 implies no change to that coordinate). | |
928 | For each of the points defining each item, the x-coordinate is | |
929 | adjusted to change the distance from I<xOrigin> by a factor | |
930 | of I<xScale>. | |
931 | Similarly, each y-coordinate is adjusted to change the distance | |
932 | from I<yOrigin> by a factor of I<yScale>. | |
933 | This method returns an empty string. | |
934 | ||
935 | =item I<$canvas>-E<gt>B<scan>(I<option, args>) | |
936 | ||
937 | This method is used to implement scanning on canvases. It has | |
938 | two forms, depending on I<option>: | |
939 | ||
940 | =over 8 | |
941 | ||
942 | =item I<$canvas>-E<gt>B<scanMark>(I<x, y>) | |
943 | ||
944 | Records I<x> and I<y> and the canvas's current view; used | |
945 | in conjunction with later B<scanDragto> method. | |
946 | Typically this method is associated with a mouse button press in | |
947 | the widget and I<x> and I<y> are the coordinates of the | |
948 | mouse. It returns an empty string. | |
949 | ||
950 | =item I<$canvas>-E<gt>B<scanDragto>(I<x, y, ?gain?>.) | |
951 | ||
952 | This method computes the difference between its I<x> and I<y> | |
953 | arguments (which are typically mouse coordinates) and the I<x> and | |
954 | I<y> arguments to the last B<scanMark> method for the widget. | |
955 | It then adjusts the view by 10 times the | |
956 | difference in coordinates. This method is typically associated | |
957 | It then adjusts the view by I<gain> times the | |
958 | difference in coordinates, where I<gain> defaults to 10. | |
959 | This command is typically associated | |
960 | with mouse motion events in the widget, to produce the effect of | |
961 | dragging the canvas at high speed through its window. The return | |
962 | value is an empty string. | |
963 | ||
964 | =back | |
965 | ||
966 | =item I<$canvas>-E<gt>B<select>(I<option, >?I<tagOrId, arg>?) | |
967 | ||
968 | Manipulates the selection in one of several ways, depending on | |
969 | I<option>. | |
970 | The method may take any of the forms described below. | |
971 | In all of the descriptions below, I<tagOrId> must refer to | |
972 | an item that supports indexing and selection; if it refers to | |
973 | multiple items then the first of | |
974 | these that supports indexing and the selection is used. | |
975 | I<Index> gives a textual description of a position | |
976 | within I<tagOrId>, as described in L<"INDICES"> above. | |
977 | ||
978 | =over 8 | |
979 | ||
980 | =item I<$canvas>-E<gt>B<selectAdjust>(I<tagOrId, index>) | |
981 | ||
982 | Locate the end of the selection in I<tagOrId> nearest | |
983 | to the character given by I<index>, and adjust that | |
984 | end of the selection to be at I<index> (i.e. including | |
985 | but not going beyond I<index>). | |
986 | The other end of the selection is made the anchor point | |
987 | for future B<selectTo> method calls. | |
988 | If the selection isn't currently in I<tagOrId> then | |
989 | this method behaves the same as the B<selectTo> widget | |
990 | method. | |
991 | Returns an empty string. | |
992 | ||
993 | =item I<$canvas>-E<gt>B<selectClear> | |
994 | ||
995 | Clear the selection if it is in this widget. | |
996 | If the selection isn't in this widget then the method | |
997 | has no effect. | |
998 | Returns an empty string. | |
999 | ||
1000 | =item I<$canvas>-E<gt>B<selectFrom>(I<tagOrId, index>) | |
1001 | ||
1002 | Set the selection anchor point for the widget to be just | |
1003 | before the character | |
1004 | given by I<index> in the item given by I<tagOrId>. | |
1005 | This method doesn't change the selection; it just sets | |
1006 | the fixed end of the selection for future B<selectTo> | |
1007 | method calls. | |
1008 | Returns an empty string. | |
1009 | ||
1010 | =item I<$canvas>-E<gt>B<selectItem> | |
1011 | ||
1012 | Returns the id of the selected item, if the selection is in an | |
1013 | item in this canvas. | |
1014 | If the selection is not in this canvas then an empty string | |
1015 | is returned. | |
1016 | ||
1017 | =item I<$canvas>-E<gt>B<selectTo>(I<tagOrId, index>) | |
1018 | ||
1019 | Set the selection to consist of those characters of I<tagOrId> | |
1020 | between the selection anchor point and | |
1021 | I<index>. | |
1022 | The new selection will include the character given by I<index>; | |
1023 | it will include the character given by the anchor point only if | |
1024 | I<index> is greater than or equal to the anchor point. | |
1025 | The anchor point is determined by the most recent B<selectAdjust> | |
1026 | or B<selectFrom> method calls for this widget. | |
1027 | If the selection anchor point for the widget isn't currently in | |
1028 | I<tagOrId>, then it is set to the same character given | |
1029 | by I<index>. | |
1030 | Returns an empty string. | |
1031 | ||
1032 | =back | |
1033 | ||
1034 | =item I<$canvas>-E<gt>B<type>(I<tagOrId>) | |
1035 | ||
1036 | Returns the type of the item given by I<tagOrId>, such as | |
1037 | B<rectangle> or B<text>. | |
1038 | If I<tagOrId> refers to more than one item, then the type | |
1039 | of the first item in the display list is returned. | |
1040 | If I<tagOrId> doesn't refer to any items at all then | |
1041 | an empty string is returned. | |
1042 | ||
1043 | =item I<$canvas>-E<gt>B<xview>(?I<args>?) | |
1044 | ||
1045 | This method is used to query and change the horizontal position of the | |
1046 | information displayed in the canvas's window. | |
1047 | It can take any of the following forms: | |
1048 | ||
1049 | =over 8 | |
1050 | ||
1051 | =item I<$canvas>-E<gt>B<xview> | |
1052 | ||
1053 | Returns a list containing two elements. | |
1054 | Each element is a real fraction between 0 and 1; together they describe | |
1055 | the horizontal span that is visible in the window. | |
1056 | For example, if the first element is .2 and the second element is .6, | |
1057 | 20% of the canvas's area (as defined by the B<-scrollregion> option) | |
1058 | is off-screen to the left, the middle 40% is visible | |
1059 | in the window, and 40% of the canvas is off-screen to the right. | |
1060 | These are the same values passed to scrollbars via the B<-xscrollcommand> | |
1061 | option. | |
1062 | ||
1063 | =item I<$canvas>-E<gt>B<xviewMoveto>(I<fraction>) | |
1064 | ||
1065 | Adjusts the view in the window so that I<fraction> of the | |
1066 | total width of the canvas is off-screen to the left. | |
1067 | I<Fraction> must be a fraction between 0 and 1. | |
1068 | ||
1069 | =item I<$canvas>-E<gt>B<xviewScroll>(I<number, what>) | |
1070 | ||
1071 | This method shifts the view in the window left or right according to | |
1072 | I<number> and I<what>. | |
1073 | I<Number> must be an integer. | |
1074 | I<What> must be either B<units> or B<pages> or an abbreviation | |
1075 | of one of these. | |
1076 | If I<what> is B<units>, the view adjusts left or right in units | |
1077 | of the B<xScrollIncrement> option, if it is greater than zero, | |
1078 | or in units of one-tenth the window's width otherwise. | |
1079 | If I<what is >B<pages> then the view | |
1080 | adjusts in units of nine-tenths the window's width. | |
1081 | If I<number> is negative then information farther to the left | |
1082 | becomes visible; if it is positive then information farther to the right | |
1083 | becomes visible. | |
1084 | ||
1085 | =back | |
1086 | ||
1087 | =item I<$canvas>-E<gt>B<yview>(I<?args>?) | |
1088 | ||
1089 | This method is used to query and change the vertical position of the | |
1090 | information displayed in the canvas's window. | |
1091 | It can take any of the following forms: | |
1092 | ||
1093 | =over 8 | |
1094 | ||
1095 | =item I<$canvas>-E<gt>B<yview> | |
1096 | ||
1097 | Returns a list containing two elements. | |
1098 | Each element is a real fraction between 0 and 1; together they describe | |
1099 | the vertical span that is visible in the window. | |
1100 | For example, if the first element is .6 and the second element is 1.0, | |
1101 | the lowest 40% of the canvas's area (as defined by the B<-scrollregion> | |
1102 | option) is visible in the window. | |
1103 | These are the same values passed to scrollbars via the B<-yscrollcommand> | |
1104 | option. | |
1105 | ||
1106 | =item I<$canvas>-E<gt>B<yviewMoveto>(I<fraction>) | |
1107 | ||
1108 | Adjusts the view in the window so that I<fraction> of the canvas's | |
1109 | area is off-screen to the top. | |
1110 | I<Fraction> is a fraction between 0 and 1. | |
1111 | ||
1112 | =item I<$canvas>-E<gt>B<yviewScroll>(I<number, what>) | |
1113 | ||
1114 | This method adjusts the view in the window up or down according to | |
1115 | I<number> and I<what>. | |
1116 | I<Number> must be an integer. | |
1117 | I<What> must be either B<units> or B<pages>. | |
1118 | If I<what> is B<units>, the view adjusts up or down in units | |
1119 | of the B<yScrollIncrement> option, if it is greater than zero, | |
1120 | or in units of one-tenth the window's height otherwise. | |
1121 | If I<what> is B<pages> then | |
1122 | the view adjusts in units of nine-tenths the window's height. | |
1123 | If I<number> is negative then higher information becomes | |
1124 | visible; if it is positive then lower information | |
1125 | becomes visible. | |
1126 | ||
1127 | =back | |
1128 | ||
1129 | =back | |
1130 | ||
1131 | =head1 OVERVIEW OF ITEM TYPES | |
1132 | ||
1133 | The sections below describe the various types of items supported | |
1134 | by canvas widgets. Each item type is characterized by two things: | |
1135 | first, the form of the B<create> method used to create | |
1136 | instances of the type; and second, a set of configuration options | |
1137 | for items of that type, which may be used in the | |
1138 | B<create> and B<itemconfigure> methods. | |
1139 | Most items don't support indexing or selection or the methods | |
1140 | related to them, such as B<index> and B<insert>. | |
1141 | Where items do support these facilities, it is noted explicitly | |
1142 | in the descriptions below. | |
1143 | At present, text, line and polygon items provide this support. | |
1144 | For lines and polygons the indexing facility is used to manipulate | |
1145 | the coordinates of the item. | |
1146 | ||
1147 | =head1 ARC ITEMS | |
1148 | ||
1149 | Items of type B<arc> appear on the display as arc-shaped regions. | |
1150 | An arc is a section of an oval delimited by two angles (specified | |
1151 | by the B<-start> and B<-extent> options) and displayed in | |
1152 | one of several ways (specified by the B<-style> option). | |
1153 | Arcs are created with methods of the following form: | |
1154 | ||
1155 | $canvas->createArc(x1, y1, x2, y2, ?option, value, option, value, ...?) | |
1156 | ||
1157 | The arguments I<x1>, I<y1>, I<x2>, and I<y2> give | |
1158 | the coordinates of two diagonally opposite corners of a | |
1159 | rectangular region enclosing the oval that defines the arc. | |
1160 | After the coordinates there may be any number of I<option>-I<value> | |
1161 | pairs, each of which sets one of the configuration options | |
1162 | for the item. These same I<option>-I<value> pairs may be | |
1163 | used in B<itemconfigure> methods to change the item's | |
1164 | configuration. | |
1165 | The following options are supported for arcs: | |
1166 | ||
1167 | =over 4 | |
1168 | ||
1169 | =item B<-dash> =E<gt> I<pattern> | |
1170 | ||
1171 | =item B<-activedash> =E<gt> I<pattern> | |
1172 | ||
1173 | =item B<-disableddash> =E<gt> I<pattern> | |
1174 | ||
1175 | This option specifies dash patterns for the normal state, the active | |
1176 | state, and the disabled state of an arc item. | |
1177 | I<pattern> may have any of the forms accepted by B<Tk_GetDash>. | |
1178 | If the dash options are omitted then the default is a solid outline. | |
1179 | ||
1180 | =item B<-dashoffset> =E<gt> I<offset> | |
1181 | ||
1182 | The starting I<offset> into the pattern provided by the | |
1183 | B<-dash> option. | |
1184 | B<-dashoffset> is ignored if there is no B<-dash> pattern. | |
1185 | ||
1186 | =item B<-extent> =E<gt> I<degrees> | |
1187 | ||
1188 | Specifies the size of the angular range occupied by the arc. | |
1189 | The arc's range extends for I<degrees> degrees counter-clockwise | |
1190 | from the starting angle given by the B<-start> option. | |
1191 | I<Degrees> may be negative. | |
1192 | If it is greater than 360 or less than -360, then I<degrees> | |
1193 | modulo 360 is used as the extent. | |
1194 | ||
1195 | =item B<-fill> =E<gt> I<color> | |
1196 | ||
1197 | =item B<-activefill> =E<gt> I<color> | |
1198 | ||
1199 | =item B<-disabledfill> =E<gt> I<color> | |
1200 | ||
1201 | Specifies the color to be used to fill the arc region in its normal, active, and | |
1202 | disabled states, | |
1203 | I<Color> may have any of the forms accepted by B<Tk_GetColor>. | |
1204 | If I<color> is an empty string (the default), then | |
1205 | then the arc will not be filled. | |
1206 | ||
1207 | =item B<-outline> =E<gt> I<color> | |
1208 | ||
1209 | =item B<-activeoutline> =E<gt> I<color> | |
1210 | ||
1211 | =item B<-disabledoutline> =E<gt> I<color> | |
1212 | ||
1213 | This option specifies the color that should be used to draw the | |
1214 | outline of the arc in its normal, active and disabled states. | |
1215 | I<Color> may have any of the forms accepted by B<Tk_GetColor>. | |
1216 | This option defaults to B<black>. If I<color> is specified | |
1217 | as undef then no outline is drawn for the arc. | |
1218 | ||
1219 | =item B<-outlinestipple> =E<gt> I<bitmap> | |
1220 | ||
1221 | =item B<-activeoutlinestipple> =E<gt> I<bitmap> | |
1222 | ||
1223 | =item B<-disabledoutlinestipple> =E<gt> I<bitmap> | |
1224 | ||
1225 | This option specifies stipple patterns that should be used to draw the | |
1226 | outline of the arc in its normal, active and disabled states. | |
1227 | Indicates that the outline for the arc should be drawn with a stipple pattern; | |
1228 | I<bitmap> specifies the stipple pattern to use, in any of the | |
1229 | forms accepted by B<Tk_GetBitmap>. | |
1230 | If the B<-outline> option hasn't been specified then this option | |
1231 | has no effect. | |
1232 | If I<bitmap> is an empty string (the default), then the outline is drawn | |
1233 | in a solid fashion. | |
1234 | ||
1235 | =item B<-start> =E<gt> I<degrees> | |
1236 | ||
1237 | Specifies the beginning of the angular range occupied by the | |
1238 | arc. | |
1239 | I<Degrees> is given in units of degrees measured counter-clockwise | |
1240 | from the 3-o'clock position; it may be either positive or negative. | |
1241 | ||
1242 | =item B<-state> =E<gt> I<state> | |
1243 | ||
1244 | Modifies the state of the arc item where I<state> may be set to one of: | |
1245 | normal, disabled, hidden or "". If set to empty, the state of the canvas | |
1246 | itself is used. An arc item may also be in the "active" | |
1247 | state if the mouse is currently over it. Many options can take | |
1248 | separate specifications in normal, active and disabled states such that the | |
1249 | appearance of the item can be different in each state. | |
1250 | ||
1251 | =item B<-stipple> =E<gt> I<bitmap> | |
1252 | ||
1253 | =item B<-activestipple> =E<gt> I<bitmap> | |
1254 | ||
1255 | =item B<-disabledstipple> =E<gt> I<bitmap> | |
1256 | ||
1257 | This option specifies stipple patterns that should be used to fill the | |
1258 | the arc in its normal, active and disabled states. | |
1259 | I<bitmap> specifies the stipple pattern to use, in any of the | |
1260 | forms accepted by B<Tk_GetBitmap>. | |
1261 | If the B<-fill> option hasn't been specified then this option | |
1262 | has no effect. | |
1263 | If I<bitmap> is an empty string (the default), then filling is done | |
1264 | in a solid fashion. | |
1265 | ||
1266 | =item B<-style> =E<gt> I<type> | |
1267 | ||
1268 | Specifies how to draw the arc. If I<type> is B<pieslice> | |
1269 | (the default) then the arc's region is defined by a section | |
1270 | of the oval's perimeter plus two line segments, one between the center | |
1271 | of the oval and each end of the perimeter section. | |
1272 | If I<type> is B<chord> then the arc's region is defined | |
1273 | by a section of the oval's perimeter plus a single line segment | |
1274 | connecting the two end points of the perimeter section. | |
1275 | If I<type> is B<arc> then the arc's region consists of | |
1276 | a section of the perimeter alone. | |
1277 | In this last case the B<-fill> option is ignored. | |
1278 | ||
1279 | =item B<-tags> =E<gt> I<tagList> | |
1280 | ||
1281 | Specifies a set of tags to apply to the item. | |
1282 | I<TagList> consists of a list of tag names, which replace any | |
1283 | existing tags for the item. | |
1284 | I<TagList> may be an empty list. | |
1285 | ||
1286 | =item B<-updatecommand> =E<gt> I<command> | |
1287 | ||
1288 | Specifies a callback that is to be executed every time | |
1289 | the arc item is updated on the screen. | |
1290 | ||
1291 | =item B<-width> =E<gt> I<outlineWidth> | |
1292 | ||
1293 | =item B<-activewidth> =E<gt> I<outlineWidth> | |
1294 | ||
1295 | =item B<-disabledwidth> =E<gt> I<outlineWidth> | |
1296 | ||
1297 | Specifies the width of the outline to be drawn around | |
1298 | the arc's region, in its normal, active and disabled states. | |
1299 | I<outlineWidth> may be in any of the forms described in | |
1300 | the L<"COORDINATES"> section above. | |
1301 | If the B<-outline> option has been specified as undef | |
1302 | then this option has no effect. | |
1303 | Wide outlines will be drawn centered on the edges of the arc's region. | |
1304 | This option defaults to 1.0. | |
1305 | ||
1306 | =back | |
1307 | ||
1308 | =head1 BITMAP ITEMS | |
1309 | ||
1310 | Items of type B<bitmap> appear on the display as images with | |
1311 | two colors, foreground and background. | |
1312 | Bitmaps are created with methods of the following form: | |
1313 | ||
1314 | $canvas->createBitmap(x, y, ?option, value, option, value, ...?) | |
1315 | ||
1316 | The arguments I<x> and I<y> specify the coordinates of a | |
1317 | point used to position the bitmap on the display (see the B<-anchor> | |
1318 | option below for more information on how bitmaps are displayed). | |
1319 | After the coordinates there may be any number of I<option>-I<value> | |
1320 | pairs, each of which sets one of the configuration options | |
1321 | for the item. These same I<option>-I<value> pairs may be | |
1322 | used in B<itemconfigure> methods to change the item's | |
1323 | configuration. | |
1324 | The following options are supported for bitmaps: | |
1325 | ||
1326 | =over 4 | |
1327 | ||
1328 | =item B<-anchor> =E<gt> I<anchorPos> | |
1329 | ||
1330 | I<AnchorPos> tells how to position the bitmap relative to the | |
1331 | positioning point for the item; it may have any of the forms | |
1332 | accepted by B<Tk_GetAnchor>. For example, if I<anchorPos> | |
1333 | is B<center> then the bitmap is centered on the point; if | |
1334 | I<anchorPos> is B<n> then the bitmap will be drawn so that | |
1335 | its top center point is at the positioning point. | |
1336 | This option defaults to B<center>. | |
1337 | ||
1338 | =item B<-background> =E<gt> I<color> | |
1339 | ||
1340 | =item B<-activebackground> =E<gt> I<color> | |
1341 | ||
1342 | =item B<-disabledbackground> =E<gt> I<color> | |
1343 | ||
1344 | Specifies the color to use for each of the bitmap's '0' valued pixels | |
1345 | in its normal, active and disabled states. | |
1346 | I<Color> may have any of the forms accepted by B<Tk_GetColor>. | |
1347 | If this option isn't specified, or if it is specified as undef, | |
1348 | then nothing is displayed where the bitmap pixels are 0; this | |
1349 | produces a transparent effect. | |
1350 | ||
1351 | =item B<-bitmap> =E<gt> I<bitmap> | |
1352 | ||
1353 | =item B<-activebitmap> =E<gt> I<bitmap> | |
1354 | ||
1355 | =item B<-disabledbitmap> =E<gt> I<bitmap> | |
1356 | ||
1357 | Specifies the bitmaps to display in the item in its normal, active and | |
1358 | disabled states. | |
1359 | I<Bitmap> may have any of the forms accepted by B<Tk_GetBitmap>. | |
1360 | ||
1361 | =item B<-foreground> =E<gt> I<color> | |
1362 | ||
1363 | =item B<-activeforeground> =E<gt> I<bitmap> | |
1364 | ||
1365 | =item B<-disabledforeground> =E<gt> I<bitmap> | |
1366 | ||
1367 | Specifies the color to use for each of the bitmap's '1' valued pixels | |
1368 | in its normal, active and disabled states. | |
1369 | I<Color> may have any of the forms accepted by B<Tk_GetColor> and | |
1370 | defaults to B<black>. | |
1371 | ||
1372 | =item B<-state> =E<gt> I<state> | |
1373 | ||
1374 | Modifies the state of the bitmap item where I<state> may be set to one of: | |
1375 | normal, disabled, or hidden. An bitmap item may also be in the "active" | |
1376 | state if the mouse is currently over it. Many options can take | |
1377 | separate specifications in normal, active and disabled states such that the | |
1378 | appearance of the item can be different in each state. | |
1379 | ||
1380 | =item B<-tags> =E<gt> I<tagList> | |
1381 | ||
1382 | Specifies a set of tags to apply to the item. | |
1383 | I<TagList> consists of a list of tag names, which replace any | |
1384 | existing tags for the item. | |
1385 | I<TagList> may be an empty list. | |
1386 | ||
1387 | =item B<-updatecommand> =E<gt> I<command> | |
1388 | ||
1389 | Specifies a callback that is to be executed every time | |
1390 | the bitmap item is updated on the screen. | |
1391 | ||
1392 | =back | |
1393 | ||
1394 | =head1 GRID ITEMS | |
1395 | ||
1396 | Items of type B<grid> are intended for producing a visual reference for | |
1397 | interpreting other items. They can be drawn as either lines (with dash | |
1398 | style) or as rectangular "dots" at each grid point. | |
1399 | ||
1400 | Items of type B<grid> are unlike other items they always cover the | |
1401 | whole of the canvas, but are never enclosed by nor overlap any area | |
1402 | and are not near any point. That is they are intended to be always visible | |
1403 | but not "pickable", as such they do support the "active" state. | |
1404 | They are like other items in that: multiple | |
1405 | grids are permitted, they can be raised and lowered relative to other | |
1406 | items, they can be moved and scaled. As yet grids do not apear in | |
1407 | PostScript output. | |
1408 | ||
1409 | Grids have outline like configure options. Grids are created with methods of the | |
1410 | following form: | |
1411 | ||
1412 | $canvas->createGrid(x1, y1, x2, y2, ?option, value, option, value, ...?) | |
1413 | ||
1414 | The arguments I<x1>, I<y1> give the origin of the grid. I<x2>, and I<y2> give | |
1415 | the coordinates of the next grid point in their respective directions. | |
1416 | After the coordinates there may be any number of I<option>-I<value> | |
1417 | pairs, each of which sets one of the configuration options | |
1418 | for the item. These same I<option>-I<value> pairs may be | |
1419 | used in B<itemconfigure> methods to change the item's | |
1420 | configuration. | |
1421 | The following options are supported for grids: | |
1422 | ||
1423 | =over 4 | |
1424 | ||
1425 | =item B<-lines> =E<gt> I<boolean> | |
1426 | ||
1427 | If B<-lines> is set to a true value then lines are drawn for both X and Y | |
1428 | grids in the style determined by B<-dash>. Otherwise retangular "dots" | |
1429 | are drawn at each grid point. | |
1430 | ||
1431 | =item B<-dash> =E<gt> I<pattern> | |
1432 | ||
1433 | =item B<-disableddash> =E<gt> I<pattern> | |
1434 | ||
1435 | This option specifies dash patterns for the normal state, | |
1436 | and the disabled state of a grid item. | |
1437 | I<pattern> may have any of the forms accepted by B<Tk_GetDash>. | |
1438 | If the dash options are omitted then the default is a solid outline. | |
1439 | ||
1440 | =item B<-dashoffset> =E<gt> I<offset> | |
1441 | ||
1442 | The starting I<offset> into the pattern provided by the | |
1443 | B<-dash> option. | |
1444 | B<-dashoffset> is ignored if there is no B<-dash> pattern. | |
1445 | ||
1446 | =item B<-color> =E<gt> I<color> | |
1447 | ||
1448 | =item B<-disabledcolor> =E<gt> I<color> | |
1449 | ||
1450 | This option specifies the color that should be used to draw the | |
1451 | outline of the grid in its normal and disabled states. | |
1452 | I<Color> may have any of the forms accepted by B<Tk_GetColor>. | |
1453 | This option defaults to B<black>. | |
1454 | If I<color> is undef then no grid will be drawn. | |
1455 | ||
1456 | =item B<-stipple> =E<gt> I<bitmap> | |
1457 | ||
1458 | =item B<-disabledstipple> =E<gt> I<bitmap> | |
1459 | ||
1460 | This option specifies stipple patterns that should be used to draw the | |
1461 | outline of the rectangle in its normal and disabled states. | |
1462 | I<bitmap> specifies the stipple pattern to use, in any of the | |
1463 | forms accepted by B<Tk_GetBitmap>. | |
1464 | If I<bitmap> is an empty string (the default), then the outline is drawn | |
1465 | in a solid fashion. | |
1466 | ||
1467 | =item B<-state> =E<gt> I<state> | |
1468 | ||
1469 | Modifies the state of the rectangle item where I<state> may be set to one of: | |
1470 | normal, disabled, or hidden. Many options can take | |
1471 | separate specifications in normal and disabled states such that the | |
1472 | appearance of the item can be different in each state. | |
1473 | ||
1474 | =item B<-tags> =E<gt> I<tagList> | |
1475 | ||
1476 | Specifies a set of tags to apply to the item. | |
1477 | I<TagList> consists of a list of tag names, which replace any | |
1478 | existing tags for the item. | |
1479 | I<TagList> may be an empty list. | |
1480 | ||
1481 | =item B<-updatecommand> =E<gt> I<command> | |
1482 | ||
1483 | Specifies a callback that is to be executed every time | |
1484 | the grid item is updated on the screen. | |
1485 | ||
1486 | =item B<-width> =E<gt> I<outlineWidth> | |
1487 | ||
1488 | =item B<-disabledwidth> =E<gt> I<outlineWidth> | |
1489 | ||
1490 | Specifies the width of the lines drawn by the grid or the size (in both X and Y) | |
1491 | of the dots, in its normal and disabled states. | |
1492 | This option defaults to 1.0. | |
1493 | ||
1494 | =back | |
1495 | ||
1496 | =head1 IMAGE ITEMS | |
1497 | ||
1498 | Items of type B<image> are used to display images on a | |
1499 | canvas. | |
1500 | Images are created with methods of the following form: | |
1501 | ||
1502 | $canvas->createImage(x, y, ?option, value, option, value, ...?) | |
1503 | ||
1504 | The arguments I<x> and I<y> specify the coordinates of a | |
1505 | point used to position the image on the display (see the B<-anchor> | |
1506 | option below for more information). | |
1507 | After the coordinates there may be any number of I<option>-I<value> | |
1508 | pairs, each of which sets one of the configuration options | |
1509 | for the item. These same I<option>-I<value> pairs may be | |
1510 | used in B<itemconfigure> methods to change the item's | |
1511 | configuration. | |
1512 | The following options are supported for images: | |
1513 | ||
1514 | =over 4 | |
1515 | ||
1516 | =item B<-anchor> =E<gt> I<anchorPos> | |
1517 | ||
1518 | I<AnchorPos> tells how to position the image relative to the | |
1519 | positioning point for the item; it may have any of the forms | |
1520 | accepted by B<Tk_GetAnchor>. For example, if I<anchorPos> | |
1521 | is B<center> then the image is centered on the point; if | |
1522 | I<anchorPos> is B<n> then the image will be drawn so that | |
1523 | its top center point is at the positioning point. | |
1524 | This option defaults to B<center>. | |
1525 | ||
1526 | =item B<-image> =E<gt> I<name> | |
1527 | ||
1528 | =item B<-activeimage> =E<gt> I<name> | |
1529 | ||
1530 | =item B<-disabledimage> =E<gt> I<name> | |
1531 | ||
1532 | Specifies the name of the images to display in the item in is normal, | |
1533 | active and disabled states. | |
1534 | This image must have been created previously with the | |
1535 | B<imageCreate> method. | |
1536 | ||
1537 | =item B<-state> =E<gt> I<state> | |
1538 | ||
1539 | Modifies the state of the image item where I<state> may be set to one of: | |
1540 | normal, disabled, or hidden. An image item may also be in the "active" | |
1541 | state if the mouse is currently over it. Many options can take | |
1542 | separate specifications in normal, active and disabled states such that the | |
1543 | appearance of the item can be different in each state. | |
1544 | ||
1545 | =item B<-tags> =E<gt> I<tagList> | |
1546 | ||
1547 | Specifies a set of tags to apply to the item. | |
1548 | I<TagList> consists of a list of tag names, which replace any | |
1549 | existing tags for the item; it may be an empty list. | |
1550 | ||
1551 | =item B<-updatecommand> =E<gt> I<command> | |
1552 | ||
1553 | Specifies a callback that is to be executed every time | |
1554 | the image item is updated on the screen. | |
1555 | ||
1556 | =back | |
1557 | ||
1558 | =head1 LINE ITEMS | |
1559 | ||
1560 | Items of type B<line> appear on the display as one or more connected | |
1561 | line segments or curves. | |
1562 | Line items support coordinate indexing operations using the canvas | |
1563 | methods: B<dchars, index, insert.> | |
1564 | Lines are created with methods of the following form: | |
1565 | ||
1566 | $canvas->createLine(x1, y1..., xn, yn, ?option, value, option, value, ...?) | |
1567 | ||
1568 | The arguments I<x1> through I<yn> give | |
1569 | the coordinates for a series of two or more points that describe | |
1570 | a series of connected line segments. | |
1571 | After the coordinates there may be any number of I<option>-I<value> | |
1572 | pairs, each of which sets one of the configuration options | |
1573 | for the item. These same I<option>-I<value> pairs may be | |
1574 | used in B<itemconfigure> methods to change the item's | |
1575 | configuration. | |
1576 | The following options are supported for lines: | |
1577 | ||
1578 | =over 4 | |
1579 | ||
1580 | =item B<-arrow> =E<gt> I<where> | |
1581 | ||
1582 | Indicates whether or not arrowheads are to be drawn at one or both | |
1583 | ends of the line. | |
1584 | I<Where> must have one of the values B<none> (for no arrowheads), | |
1585 | B<first> (for an arrowhead at the first point of the line), | |
1586 | B<last> (for an arrowhead at the last point of the line), or | |
1587 | B<both> (for arrowheads at both ends). | |
1588 | This option defaults to B<none>. | |
1589 | ||
1590 | =item B<-arrowshape> =E<gt> I<shape> | |
1591 | ||
1592 | This option indicates how to draw arrowheads. | |
1593 | The I<shape> argument must be a list with three elements, each | |
1594 | specifying a distance in any of the forms described in | |
1595 | the L<"COORDINATES"> section above. | |
1596 | The first element of the list gives the distance along the line | |
1597 | from the neck of the arrowhead to its tip. | |
1598 | The second element gives the distance along the line from the | |
1599 | trailing points of the arrowhead to the tip, and the third | |
1600 | element gives the distance from the outside edge of the line to the | |
1601 | trailing points. | |
1602 | If this option isn't specified then Tk picks a ``reasonable'' shape. | |
1603 | ||
1604 | =item B<-capstyle> =E<gt> I<style> | |
1605 | ||
1606 | Specifies the ways in which caps are to be drawn at the endpoints | |
1607 | of the line. | |
1608 | I<Style> may have any of the forms accepted by B<Tk_GetCapStyle> | |
1609 | (B<butt>, B<projecting>, or B<round>). | |
1610 | If this option isn't specified then it defaults to B<butt>. | |
1611 | Where arrowheads are drawn the cap style is ignored. | |
1612 | ||
1613 | =item B<-dash> =E<gt> I<pattern> | |
1614 | ||
1615 | =item B<-activedash> =E<gt> I<pattern> | |
1616 | ||
1617 | =item B<-disableddash> =E<gt> I<pattern> | |
1618 | ||
1619 | This option specifies dash patterns for the normal state, the active | |
1620 | state, and the disabled state of a line item. | |
1621 | I<pattern> may have any of the forms accepted by B<Tk_GetDash>. | |
1622 | If the dash options are omitted then the default is a solid outline. | |
1623 | ||
1624 | =item B<-dashoffset> =E<gt> I<offset> | |
1625 | ||
1626 | The starting I<offset> into the pattern provided by the | |
1627 | B<-dash> option. | |
1628 | B<-dashoffset> is ignored if there is no B<-dash> pattern. | |
1629 | ||
1630 | =item B<-fill> =E<gt> I<color> | |
1631 | ||
1632 | =item B<-activefill> =E<gt> I<color> | |
1633 | ||
1634 | =item B<-disabledfill> =E<gt> I<color> | |
1635 | ||
1636 | Specifies the color to be used to fill the line in its normal, active, and | |
1637 | disabled states. | |
1638 | I<Color> may have | |
1639 | any of the forms acceptable to B<Tk_GetColor>. It may also be undef, | |
1640 | in which case the line will be transparent. | |
1641 | This option defaults to B<black>. | |
1642 | ||
1643 | =item B<-joinstyle> =E<gt> I<style> | |
1644 | ||
1645 | Specifies the ways in which joints are to be drawn at the vertices | |
1646 | of the line. | |
1647 | I<Style> may have any of the forms accepted by B<Tk_GetCapStyle> | |
1648 | (B<bevel>, B<miter>, or B<round>). | |
1649 | If this option isn't specified then it defaults to B<miter>. | |
1650 | If the line only contains two points then this option is | |
1651 | irrelevant. | |
1652 | ||
1653 | =item B<-smooth> =E<gt> I<boolean> | |
1654 | ||
1655 | I<Boolean> must have one of the forms accepted by B<Tk_GetBoolean>. | |
1656 | It indicates whether or not the line should be drawn as a curve. | |
1657 | If so, the line is rendered as a set of parabolic splines: one spline | |
1658 | is drawn for the first and second line segments, one for the second | |
1659 | and third, and so on. Straight-line segments can be generated within | |
1660 | a curve by duplicating the end-points of the desired line segment. | |
1661 | ||
1662 | =item B<-splinesteps> =E<gt> I<number> | |
1663 | ||
1664 | Specifies the degree of smoothness desired for curves: each spline | |
1665 | will be approximated with I<number> line segments. This | |
1666 | option is ignored unless the B<-smooth> option is true. | |
1667 | ||
1668 | =item B<-state> =E<gt> I<state> | |
1669 | ||
1670 | Modifies the state of the line item where I<state> may be set to one of: | |
1671 | normal, disabled, or hidden. A line item may also be in the "active" | |
1672 | state if the mouse is currently over it. Many options can take | |
1673 | separate specifications in normal, active and disabled states such that the | |
1674 | appearance of the item can be different in each state. | |
1675 | ||
1676 | =item B<-stipple> =E<gt> I<bitmap> | |
1677 | ||
1678 | =item B<-activestipple> =E<gt> I<bitmap> | |
1679 | ||
1680 | =item B<-disabledstipple> =E<gt> I<bitmap> | |
1681 | ||
1682 | This option specifies stipple patterns that should be used to fill the | |
1683 | the line in its normal, active and disabled states. | |
1684 | I<bitmap> specifies the stipple pattern to use, in any of the | |
1685 | forms accepted by B<Tk_GetBitmap>. | |
1686 | If I<bitmap> is an empty string (the default), then filling is | |
1687 | done in a solid fashion. | |
1688 | ||
1689 | =item B<-tags> =E<gt> I<tagList> | |
1690 | ||
1691 | Specifies a set of tags to apply to the item. | |
1692 | I<TagList> consists of a list of tag names, which replace any | |
1693 | existing tags for the item. | |
1694 | I<TagList> may be an empty list. | |
1695 | ||
1696 | =item B<-updatecommand> =E<gt> I<command> | |
1697 | ||
1698 | Specifies a callback that is to be executed every time | |
1699 | the line item is updated on the screen. | |
1700 | ||
1701 | =item B<-width> =E<gt> I<lineWidth> | |
1702 | ||
1703 | =item B<-activewidth> =E<gt> I<lineWidth> | |
1704 | ||
1705 | =item B<-disabledwidth> =E<gt> I<lineWidth> | |
1706 | ||
1707 | Specifies the width of the line | |
1708 | in its normal, active and disabled states. | |
1709 | I<lineWidth> may be in any of the forms | |
1710 | described in the L<"COORDINATES"> section above. | |
1711 | ||
1712 | Wide lines will be drawn centered on the path specified by the | |
1713 | points. | |
1714 | If this option isn't specified then it defaults to 1.0. | |
1715 | ||
1716 | =back | |
1717 | ||
1718 | =head1 OVAL ITEMS | |
1719 | ||
1720 | Items of type B<oval> appear as circular or oval regions on | |
1721 | the display. Each oval may have an outline, a fill, or | |
1722 | both. Ovals are created with methods of the | |
1723 | following form: | |
1724 | ||
1725 | $canvas->createOval(x1, y1, x2, y2, ?option, value, option, value, ...?) | |
1726 | ||
1727 | The arguments I<x1>, I<y1>, I<x2>, and I<y2> give | |
1728 | the coordinates of two diagonally opposite corners of a | |
1729 | rectangular region enclosing the oval. | |
1730 | The oval will include the top and left edges of the rectangle | |
1731 | not the lower or right edges. | |
1732 | If the region is square then the resulting oval is circular; | |
1733 | otherwise it is elongated in shape. | |
1734 | After the coordinates there may be any number of I<option>-I<value> | |
1735 | pairs, each of which sets one of the configuration options | |
1736 | for the item. These same I<option>-I<value> pairs may be | |
1737 | used in B<itemconfigure> methods to change the item's | |
1738 | configuration. | |
1739 | The following options are supported for ovals: | |
1740 | ||
1741 | =over 4 | |
1742 | ||
1743 | =item B<-dash> =E<gt> I<pattern> | |
1744 | ||
1745 | =item B<-activedash> =E<gt> I<pattern> | |
1746 | ||
1747 | =item B<-disableddash> =E<gt> I<pattern> | |
1748 | ||
1749 | This option specifies dash patterns for the normal state, the active | |
1750 | state, and the disabled state of an oval item. | |
1751 | I<pattern> may have any of the forms accepted by B<Tk_GetDash>. | |
1752 | If the dash options are omitted then the default is a solid outline. | |
1753 | ||
1754 | =item B<-dashoffset> =E<gt> I<offset> | |
1755 | ||
1756 | The starting I<offset> into the pattern provided by the | |
1757 | B<-dash> option. | |
1758 | B<-dashoffset> is ignored if there is no B<-dash> pattern. | |
1759 | ||
1760 | =item B<-fill> =E<gt> I<color> | |
1761 | ||
1762 | =item B<-activefill> =E<gt> I<color> | |
1763 | ||
1764 | =item B<-disabledfill> =E<gt> I<color> | |
1765 | ||
1766 | Specifies the color to be used to fill the oval in its normal, active, and | |
1767 | disabled states. | |
1768 | I<Color> may have any of the forms accepted by B<Tk_GetColor>. | |
1769 | If I<color> is undef (the default), then | |
1770 | then the oval will not be filled. | |
1771 | ||
1772 | =item B<-outline> =E<gt> I<color> | |
1773 | ||
1774 | =item B<-activeoutline> =E<gt> I<color> | |
1775 | ||
1776 | =item B<-disabledoutline> =E<gt> I<color> | |
1777 | ||
1778 | This option specifies the color that should be used to draw the | |
1779 | outline of the oval in its normal, active and disabled states. | |
1780 | I<Color> may have any of the forms accepted by B<Tk_GetColor>. | |
1781 | This option defaults to B<black>. | |
1782 | If I<color> is undef then no outline will be | |
1783 | drawn for the oval. | |
1784 | ||
1785 | =item B<-outlinestipple> =E<gt> I<bitmap> | |
1786 | ||
1787 | =item B<-activeoutlinestipple> =E<gt> I<bitmap> | |
1788 | ||
1789 | =item B<-disabledoutlinestipple> =E<gt> I<bitmap> | |
1790 | ||
1791 | This option specifies stipple patterns that should be used to draw the | |
1792 | outline of the oval in its normal, active and disabled states. | |
1793 | I<bitmap> specifies the stipple pattern to use, in any of the | |
1794 | forms accepted by B<Tk_GetBitmap>. | |
1795 | If the B<-outline> option hasn't been specified then this option | |
1796 | has no effect. | |
1797 | If I<bitmap> is an empty string (the default), then the outline is drawn | |
1798 | in a solid fashion. | |
1799 | ||
1800 | =item B<-state> =E<gt> I<state> | |
1801 | ||
1802 | Modifies the state of the oval item where I<state> may be set to one of: | |
1803 | normal, disabled, or hidden. An oval item may also be in the "active" | |
1804 | state if the mouse is currently over it. Many options can take | |
1805 | separate specifications in normal, active and disabled states such that the | |
1806 | appearance of the item can be different in each state. | |
1807 | ||
1808 | =item B<-stipple> =E<gt> I<bitmap> | |
1809 | ||
1810 | =item B<-activestipple> =E<gt> I<bitmap> | |
1811 | ||
1812 | =item B<-disabledstipple> =E<gt> I<bitmap> | |
1813 | ||
1814 | This option specifies stipple patterns that should be used to fill the | |
1815 | the oval in its normal, active and disabled states. | |
1816 | I<bitmap> specifies the stipple pattern to use, in any of the | |
1817 | forms accepted by B<Tk_GetBitmap>. | |
1818 | If the B<-fill> option hasn't been specified then this option | |
1819 | has no effect. | |
1820 | If I<bitmap> is an empty string (the default), then filling is done | |
1821 | in a solid fashion. | |
1822 | ||
1823 | =item B<-tags> =E<gt> I<tagList> | |
1824 | ||
1825 | Specifies a set of tags to apply to the item. | |
1826 | I<TagList> consists of a list of tag names, which replace any | |
1827 | existing tags for the item. | |
1828 | I<TagList> may be an empty list. | |
1829 | ||
1830 | =item B<-updatecommand> =E<gt> I<command> | |
1831 | ||
1832 | Specifies a callback that is to be executed every time | |
1833 | the oval item is updated on the screen. | |
1834 | ||
1835 | =item B<-width> =E<gt> I<outlineWidth> | |
1836 | ||
1837 | =item B<-activewidth> =E<gt> I<outlineWidth> | |
1838 | ||
1839 | =item B<-disabledwidth> =E<gt> I<outlineWidth> | |
1840 | ||
1841 | Specifies the width of the outline to be drawn around | |
1842 | the oval, in its normal, active and disabled states. | |
1843 | I<outlineWidth> specifies the width of the outline to be drawn around | |
1844 | the oval, in any of the forms described in the L<"COORDINATES"> section above. | |
1845 | ||
1846 | If the B<-outline> option hasn't been specified then this option | |
1847 | has no effect. | |
1848 | Wide outlines are drawn centered on the oval path defined by | |
1849 | I<x1>, I<y1>, I<x2>, and I<y2>. | |
1850 | This option defaults to 1.0. | |
1851 | ||
1852 | =back | |
1853 | ||
1854 | =head1 POLYGON ITEMS | |
1855 | ||
1856 | Items of type B<polygon> appear as polygonal or curved filled regions | |
1857 | on the display. | |
1858 | Polygon items support coordinate indexing operations using the canvas | |
1859 | methods: B<dchars, index, insert.> | |
1860 | Polygons are created with methods of the following form: | |
1861 | ||
1862 | $canvas->createPolygon(x1, y1, ..., xn, yn, ?option, value, option, value, ...?) | |
1863 | ||
1864 | The arguments I<x1> through I<yn> specify the coordinates for | |
1865 | three or more points that define a closed polygon. | |
1866 | The first and last points may be the same; whether they are or not, | |
1867 | Tk will draw the polygon as a closed polygon. | |
1868 | After the coordinates there may be any number of I<option>-I<value> | |
1869 | pairs, each of which sets one of the configuration options | |
1870 | for the item. These same I<option>-I<value> pairs may be | |
1871 | used in B<itemconfigure> methods to change the item's | |
1872 | configuration. | |
1873 | The following options are supported for polygons: | |
1874 | ||
1875 | =over 4 | |
1876 | ||
1877 | =item B<-dash> =E<gt> I<pattern> | |
1878 | ||
1879 | =item B<-activedash> =E<gt> I<pattern> | |
1880 | ||
1881 | =item B<-disableddash> =E<gt> I<pattern> | |
1882 | ||
1883 | This option specifies dash patterns for the normal state, the active | |
1884 | state, and the disabled state of an polygon item. | |
1885 | I<pattern> may have any of the forms accepted by B<Tk_GetDash>. | |
1886 | If the dash options are omitted then the default is a solid outline. | |
1887 | ||
1888 | =item B<-dashoffset> =E<gt> I<offset> | |
1889 | ||
1890 | The starting I<offset> into the pattern provided by the | |
1891 | B<-dash> option. | |
1892 | B<-dashoffset> is ignored if there is no B<-dash> pattern. | |
1893 | ||
1894 | =item B<-fill> =E<gt> I<color> | |
1895 | ||
1896 | =item B<-activefill> =E<gt> I<color> | |
1897 | ||
1898 | =item B<-disabledfill> =E<gt> I<color> | |
1899 | ||
1900 | Specifies the color to be used to fill the polygon in its normal, active, and | |
1901 | disabled states. | |
1902 | I<Color> | |
1903 | may have any of the forms acceptable to B<Tk_GetColor>. | |
1904 | If I<color> is undef then the polygon will be | |
1905 | transparent. | |
1906 | This option defaults to B<black>. | |
1907 | ||
1908 | =item B<-joinstyle> =E<gt> I<style> | |
1909 | ||
1910 | Specifies the ways in which joints are to be drawn at the vertices | |
1911 | of the outline. | |
1912 | I<Style> may have any of the forms accepted by B<Tk_GetCapStyle> | |
1913 | (B<bevel>, B<miter>, or B<round>). | |
1914 | If this option isn't specified then it defaults to B<miter>. | |
1915 | ||
1916 | =item B<-outline> =E<gt> I<color> | |
1917 | ||
1918 | =item B<-activeoutline> =E<gt> I<color> | |
1919 | ||
1920 | =item B<-disabledoutline> =E<gt> I<color> | |
1921 | ||
1922 | This option specifies the color that should be used to draw the | |
1923 | outline of the polygon in its normal, active and disabled states. | |
1924 | I<Color> may have any of the forms accepted by B<Tk_GetColor>. | |
1925 | If I<color> is undef then no outline will be | |
1926 | drawn for the polygon. | |
1927 | This option defaults to undef (no outline). | |
1928 | ||
1929 | =item B<-outlinestipple> =E<gt> I<bitmap> | |
1930 | ||
1931 | =item B<-activeoutlinestipple> =E<gt> I<bitmap> | |
1932 | ||
1933 | =item B<-disabledoutlinestipple> =E<gt> I<bitmap> | |
1934 | ||
1935 | This option specifies stipple patterns that should be used to draw the | |
1936 | outline of the polygon in its normal, active and disabled states. | |
1937 | I<bitmap> specifies the stipple pattern to use, in any of the | |
1938 | forms accepted by B<Tk_GetBitmap>. | |
1939 | If the B<-outline> option hasn't been specified then this option | |
1940 | has no effect. | |
1941 | If I<bitmap> is an empty string (the default), then the outline is drawn | |
1942 | in a solid fashion. | |
1943 | ||
1944 | =item B<-smooth> =E<gt> I<boolean> | |
1945 | ||
1946 | I<Boolean> must have one of the forms accepted by B<Tk_GetBoolean> | |
1947 | It indicates whether or not the polygon should be drawn with a | |
1948 | curved perimeter. | |
1949 | If so, the outline of the polygon becomes a set of parabolic splines, | |
1950 | one spline for the first and second line segments, one for the second | |
1951 | and third, and so on. Straight-line segments can be generated in a | |
1952 | smoothed polygon by duplicating the end-points of the desired line segment. | |
1953 | ||
1954 | =item B<-splinesteps> =E<gt> I<number> | |
1955 | ||
1956 | Specifies the degree of smoothness desired for curves: each spline | |
1957 | will be approximated with I<number> line segments. This | |
1958 | option is ignored unless the B<-smooth> option is true. | |
1959 | ||
1960 | =item B<-state> =E<gt> I<state> | |
1961 | ||
1962 | Modifies the state of the polygon item where I<state> may be set to one of: | |
1963 | normal, disabled, or hidden. A polygon item may also be in the "active" | |
1964 | state if the mouse is currently over it. Many options can take | |
1965 | separate specifications in normal, active and disabled states such that the | |
1966 | appearance of the item can be different in each state. | |
1967 | ||
1968 | =item B<-stipple> =E<gt> I<bitmap> | |
1969 | ||
1970 | =item B<-activestipple> =E<gt> I<bitmap> | |
1971 | ||
1972 | =item B<-disabledstipple> =E<gt> I<bitmap> | |
1973 | ||
1974 | This option specifies stipple patterns that should be used to fill the | |
1975 | the polygon in its normal, active and disabled states. | |
1976 | I<bitmap> specifies the stipple pattern to use, in any of the | |
1977 | forms accepted by B<Tk_GetBitmap>. | |
1978 | If I<bitmap> is an empty string (the default), then filling is | |
1979 | done in a solid fashion. | |
1980 | ||
1981 | =item B<-tags> =E<gt> I<tagList> | |
1982 | ||
1983 | Specifies a set of tags to apply to the item. | |
1984 | I<TagList> consists of a list of tag names, which replace any | |
1985 | existing tags for the item. | |
1986 | I<TagList> may be an empty list. | |
1987 | ||
1988 | =item B<-updatecommand> =E<gt> I<command> | |
1989 | ||
1990 | Specifies a callback that is to be executed every time | |
1991 | the polygon item is updated on the screen. | |
1992 | ||
1993 | =item B<-width> =E<gt> I<outlineWidth> | |
1994 | ||
1995 | =item B<-activewidth> =E<gt> I<outlineWidth> | |
1996 | ||
1997 | =item B<-disabledwidth> =E<gt> I<outlineWidth> | |
1998 | ||
1999 | =item Specifies the width of the outline to be drawn around | |
2000 | ||
2001 | the polygon, in its normal, active and disabled states. | |
2002 | I<outlineWidth> may be in any of the forms described in the COORDINATES | |
2003 | section above. | |
2004 | I<OutlineWidth> specifies the width of the outline to be drawn around | |
2005 | the polygon, in any of the forms described in the L<"COORDINATES"> section above. | |
2006 | If the B<-outline> option hasn't been specified then this option | |
2007 | has no effect. This option defaults to 1.0. | |
2008 | ||
2009 | Polygon items are different from other items such as rectangles, ovals | |
2010 | and arcs in that interior points are considered to be ``inside'' a | |
2011 | polygon (e.g. for purposes of the B<find closest> and | |
2012 | B<find overlapping> methods) even if it is not filled. | |
2013 | For most other item types, an | |
2014 | interior point is considered to be inside the item only if the item | |
2015 | is filled or if it has neither a fill nor an outline. If you would | |
2016 | like an unfilled polygon whose interior points are not considered | |
2017 | to be inside the polygon, use a line item instead. | |
2018 | ||
2019 | =back | |
2020 | ||
2021 | =head1 RECTANGLE ITEMS | |
2022 | ||
2023 | Items of type B<rectangle> appear as rectangular regions on | |
2024 | the display. Each rectangle may have an outline, a fill, or | |
2025 | both. Rectangles are created with methods of the | |
2026 | following form: | |
2027 | ||
2028 | $canvas->createRectangle(x1, y1, x2, y2, ?option, value, option, value, ...?) | |
2029 | ||
2030 | The arguments I<x1>, I<y1>, I<x2>, and I<y2> give | |
2031 | the coordinates of two diagonally opposite corners of the rectangle | |
2032 | (the rectangle will include its upper and left edges but not | |
2033 | its lower or right edges). | |
2034 | After the coordinates there may be any number of I<option>-I<value> | |
2035 | pairs, each of which sets one of the configuration options | |
2036 | for the item. These same I<option>-I<value> pairs may be | |
2037 | used in B<itemconfigure> methods to change the item's | |
2038 | configuration. | |
2039 | The following options are supported for rectangles: | |
2040 | ||
2041 | =over 4 | |
2042 | ||
2043 | =item B<-dash> =E<gt> I<pattern> | |
2044 | ||
2045 | =item B<-activedash> =E<gt> I<pattern> | |
2046 | ||
2047 | =item B<-disableddash> =E<gt> I<pattern> | |
2048 | ||
2049 | This option specifies dash patterns for the normal state, the active | |
2050 | state, and the disabled state of a rectangle item. | |
2051 | I<pattern> may have any of the forms accepted by B<Tk_GetDash>. | |
2052 | If the dash options are omitted then the default is a solid outline. | |
2053 | ||
2054 | =item B<-dashoffset> =E<gt> I<offset> | |
2055 | ||
2056 | The starting I<offset> into the pattern provided by the | |
2057 | B<-dash> option. | |
2058 | B<-dashoffset> is ignored if there is no B<-dash> pattern. | |
2059 | ||
2060 | =item B<-fill> =E<gt> I<color> | |
2061 | ||
2062 | =item B<-activefill> =E<gt> I<color> | |
2063 | ||
2064 | =item B<-disabledfill> =E<gt> I<color> | |
2065 | ||
2066 | Specifies the color to be used to fill the rectangle in its normal, active, and | |
2067 | disabled states. | |
2068 | I<Color> | |
2069 | may be specified in any of the forms accepted by B<Tk_GetColor>. | |
2070 | If I<color> is undef (the default), | |
2071 | then the rectangle will not be filled. | |
2072 | ||
2073 | =item B<-outline> =E<gt> I<color> | |
2074 | ||
2075 | =item B<-activeoutline> =E<gt> I<color> | |
2076 | ||
2077 | =item B<-disabledoutline> =E<gt> I<color> | |
2078 | ||
2079 | This option specifies the color that should be used to draw the | |
2080 | outline of the rectangle in its normal, active and disabled states. | |
2081 | I<Color> may have any of the forms accepted by B<Tk_GetColor>. | |
2082 | This option defaults to B<black>. | |
2083 | If I<color> is undef then no outline will be | |
2084 | drawn for the rectangle. | |
2085 | ||
2086 | =item B<-outlinestipple> =E<gt> I<bitmap> | |
2087 | ||
2088 | =item B<-activeoutlinestipple> =E<gt> I<bitmap> | |
2089 | ||
2090 | =item B<-disabledoutlinestipple> =E<gt> I<bitmap> | |
2091 | ||
2092 | This option specifies stipple patterns that should be used to draw the | |
2093 | outline of the rectangle in its normal, active and disabled states. | |
2094 | I<bitmap> specifies the stipple pattern to use, in any of the | |
2095 | forms accepted by B<Tk_GetBitmap>. | |
2096 | If the B<-outline> option hasn't been specified then this option | |
2097 | has no effect. | |
2098 | If I<bitmap> is an empty string (the default), then the outline is drawn | |
2099 | in a solid fashion. | |
2100 | ||
2101 | =item B<-state> =E<gt> I<state> | |
2102 | ||
2103 | Modifies the state of the rectangle item where I<state> may be set to one of: | |
2104 | normal, disabled, or hidden. A rectangle item may also be in the "active" | |
2105 | state if the mouse is currently over it. Many options can take | |
2106 | separate specifications in normal, active and disabled states such that the | |
2107 | appearance of the item can be different in each state. | |
2108 | ||
2109 | =item B<-stipple> =E<gt> I<bitmap> | |
2110 | ||
2111 | =item B<-activestipple> =E<gt> I<bitmap> | |
2112 | ||
2113 | =item B<-disabledstipple> =E<gt> I<bitmap> | |
2114 | ||
2115 | This option specifies stipple patterns that should be used to fill the | |
2116 | the rectangle in its normal, active and disabled states. | |
2117 | I<bitmap> specifies the stipple pattern to use, in any of the | |
2118 | forms accepted by B<Tk_GetBitmap>. | |
2119 | If the B<-fill> option hasn't been specified then this option | |
2120 | has no effect. | |
2121 | If I<bitmap> is an empty string (the default), then filling | |
2122 | is done in a solid fashion. | |
2123 | ||
2124 | =item B<-tags> =E<gt> I<tagList> | |
2125 | ||
2126 | Specifies a set of tags to apply to the item. | |
2127 | I<TagList> consists of a list of tag names, which replace any | |
2128 | existing tags for the item. | |
2129 | I<TagList> may be an empty list. | |
2130 | ||
2131 | =item B<-updatecommand> =E<gt> I<command> | |
2132 | ||
2133 | Specifies a callback that is to be executed every time | |
2134 | the rectangle item is updated on the screen. | |
2135 | ||
2136 | =item B<-width> =E<gt> I<outlineWidth> | |
2137 | ||
2138 | =item B<-activewidth> =E<gt> I<outlineWidth> | |
2139 | ||
2140 | =item B<-disabledwidth> =E<gt> I<outlineWidth> | |
2141 | ||
2142 | Specifies the width of the outline to be drawn around | |
2143 | the rectangle, in its normal, active and disabled states. | |
2144 | I<OutlineWidth> specifies the width of the outline to be drawn around | |
2145 | the rectangle, in any of the forms described in the L<"COORDINATES"> section above. | |
2146 | ||
2147 | If the B<-outline> option hasn't been specified then this option | |
2148 | has no effect. | |
2149 | Wide outlines are drawn centered on the rectangular path | |
2150 | defined by I<x1>, I<y1>, I<x2>, and I<y2>. | |
2151 | This option defaults to 1.0. | |
2152 | ||
2153 | =back | |
2154 | ||
2155 | =head1 TEXT ITEMS | |
2156 | ||
2157 | A text item displays a string of characters on the screen in one | |
2158 | or more lines. | |
2159 | Text items support indexing and selection, along with the | |
2160 | following text-related canvas methods: B<dchars>, | |
2161 | B<focus>, B<icursor>, B<index>, B<insert>, | |
2162 | B<select>. | |
2163 | Text items are created with methods of the following | |
2164 | form: | |
2165 | ||
2166 | $canvas->createText(x, y, ?option, value, option, value, ...?) | |
2167 | ||
2168 | The arguments I<x> and I<y> specify the coordinates of a | |
2169 | point used to position the text on the display (see the options | |
2170 | below for more information on how text is displayed). | |
2171 | After the coordinates there may be any number of I<option>-I<value> | |
2172 | pairs, each of which sets one of the configuration options | |
2173 | for the item. These same I<option>-I<value> pairs may be | |
2174 | used in B<itemconfigure> methods to change the item's | |
2175 | configuration. | |
2176 | The following options are supported for text items: | |
2177 | ||
2178 | =over 4 | |
2179 | ||
2180 | =item B<-anchor> =E<gt> I<anchorPos> | |
2181 | ||
2182 | I<AnchorPos> tells how to position the text relative to the | |
2183 | positioning point for the text; it may have any of the forms | |
2184 | accepted by B<Tk_GetAnchor>. For example, if I<anchorPos> | |
2185 | is B<center> then the text is centered on the point; if | |
2186 | I<anchorPos> is B<n> then the text will be drawn such that | |
2187 | the top center point of the rectangular region occupied by the | |
2188 | text will be at the positioning point. | |
2189 | This option defaults to B<center>. | |
2190 | ||
2191 | =item B<-fill> =E<gt> I<color> | |
2192 | ||
2193 | =item B<-activefill> =E<gt> I<color> | |
2194 | ||
2195 | =item B<-disabledfill> =E<gt> I<color> | |
2196 | ||
2197 | Specifies the color to be used to fill the text in its normal, active, and | |
2198 | disabled states. | |
2199 | I<Color> may have any of the forms accepted by B<Tk_GetColor>. | |
2200 | If I<color> is undef then the text will be transparent. | |
2201 | If this option isn't specified then it defaults to B<black>. | |
2202 | ||
2203 | =item B<-font> =E<gt> I<fontName> | |
2204 | ||
2205 | Specifies the font to use for the text item. | |
2206 | I<FontName> may be any string acceptable to B<Tk_GetFontStruct>. | |
2207 | If this option isn't specified, it defaults to a system-dependent | |
2208 | font. | |
2209 | ||
2210 | =item B<-justify> =E<gt> I<how> | |
2211 | ||
2212 | Specifies how to justify the text within its bounding region. | |
2213 | I<How> must be one of the values B<left>, B<right>, | |
2214 | or B<center>. | |
2215 | This option will only matter if the text is displayed as multiple | |
2216 | lines. | |
2217 | If the option is omitted, it defaults to B<left>. | |
2218 | ||
2219 | =item B<-state> =E<gt> I<state> | |
2220 | ||
2221 | Modifies the state of the text item where I<state> may be set to one of: | |
2222 | normal, disabled, or hidden. A text item may also be in the "active" | |
2223 | state if the mouse is currently over it. Many options can take | |
2224 | separate specifications in normal, active and disabled states such that the | |
2225 | appearance of the item can be different in each state. | |
2226 | ||
2227 | =item B<-stipple> =E<gt> I<bitmap> | |
2228 | ||
2229 | =item B<-activestipple> =E<gt> I<bitmap> | |
2230 | ||
2231 | =item B<-disabledstipple> =E<gt> I<bitmap> | |
2232 | ||
2233 | This option specifies stipple patterns that should be used to fill the | |
2234 | the text in its normal, active and disabled states. | |
2235 | I<bitmap> specifies the stipple pattern to use, in any of the | |
2236 | forms accepted by B<Tk_GetBitmap>. | |
2237 | If I<bitmap> is an empty string (the default) then the text | |
2238 | is drawn in a solid fashion. | |
2239 | ||
2240 | =item B<-tags> =E<gt> I<tagList> | |
2241 | ||
2242 | Specifies a set of tags to apply to the item. | |
2243 | I<TagList> consists of a list of tag names, which replace any | |
2244 | existing tags for the item. | |
2245 | I<TagList> may be an empty list. | |
2246 | ||
2247 | =item B<-text> =E<gt> I<string> | |
2248 | ||
2249 | I<String> specifies the characters to be displayed in the text item. | |
2250 | Newline characters cause line breaks. | |
2251 | The characters in the item may also be changed with the | |
2252 | B<insert> and B<delete> methods. | |
2253 | This option defaults to an empty string. | |
2254 | ||
2255 | =item B<-updatecommand> =E<gt> I<command> | |
2256 | ||
2257 | Specifies a callback that is to be executed every time | |
2258 | the text item is updated on the screen. | |
2259 | ||
2260 | =item B<-width> =E<gt> I<lineLength> | |
2261 | ||
2262 | Specifies a maximum line length for the text, in any of the forms | |
2263 | described in the L<"COORDINATES"> section above. | |
2264 | If this option is zero (the default) the text is broken into | |
2265 | lines only at newline characters. | |
2266 | However, if this option is non-zero then any line that would | |
2267 | be longer than I<lineLength> is broken just before a space | |
2268 | character to make the line shorter than I<lineLength>; the | |
2269 | space character is treated as if it were a newline | |
2270 | character. | |
2271 | ||
2272 | =back | |
2273 | ||
2274 | =head1 WINDOW ITEMS | |
2275 | ||
2276 | Items of type B<window> cause a particular window to be displayed | |
2277 | at a given position on the canvas. | |
2278 | Window items are created with methods of the following form: | |
2279 | ||
2280 | S< >I<$canvas>->B<createWindow>(I<x, y>?, I<-option>=>I<value>, I<-option>=>I<value>, ...?) | |
2281 | ||
2282 | The arguments I<x> and I<y> specify the coordinates of a | |
2283 | point used to position the window on the display (see the B<-anchor> | |
2284 | option below for more information on how bitmaps are displayed). | |
2285 | After the coordinates there may be any number of I<option-value> | |
2286 | pairs, each of which sets one of the configuration options | |
2287 | for the item. These same I<option>-I<value> pairs may be | |
2288 | used in B<itemconfigure> method to change the item's | |
2289 | configuration. | |
2290 | The following options are supported for window items: | |
2291 | ||
2292 | =over 4 | |
2293 | ||
2294 | =item B<-anchor> =E<gt> I<anchorPos> | |
2295 | ||
2296 | I<AnchorPos> tells how to position the window relative to the | |
2297 | positioning point for the item; it may have any of the forms | |
2298 | accepted by B<Tk_GetAnchor>. For example, if I<anchorPos> | |
2299 | is B<center> then the window is centered on the point; if | |
2300 | I<anchorPos> is B<n> then the window will be drawn so that | |
2301 | its top center point is at the positioning point. | |
2302 | This option defaults to B<center>. | |
2303 | ||
2304 | =item B<-height> =E<gt> I<pixels> | |
2305 | ||
2306 | Specifies the height to assign to the item's window. | |
2307 | I<Pixels> may have any of the | |
2308 | forms described in the L<"COORDINATES"> section above. | |
2309 | If this option isn't specified, or if it is specified as an empty | |
2310 | string, then the window is given whatever height it requests internally. | |
2311 | ||
2312 | =item B<-state> =E<gt> I<state> | |
2313 | ||
2314 | Modifies the state of the window item where I<state> may be set to one of: | |
2315 | normal, disabled, or hidden. | |
2316 | ||
2317 | =item B<-tags> =E<gt> I<tagList> | |
2318 | ||
2319 | Specifies a set of tags to apply to the item. | |
2320 | I<TagList> consists of a list of tag names, which replace any | |
2321 | existing tags for the item. | |
2322 | I<TagList> may be an empty list. | |
2323 | ||
2324 | =item B<-updatecommand> =E<gt> I<command> | |
2325 | ||
2326 | Specifies a callback that is to be executed every time | |
2327 | the window item is updated on the screen. | |
2328 | ||
2329 | =item B<-width> =E<gt> I<pixels> | |
2330 | ||
2331 | Specifies the width to assign to the item's window. | |
2332 | I<Pixels> may have any of the | |
2333 | forms described in the L<"COORDINATES"> section above. | |
2334 | If this option isn't specified, or if it is specified as an empty | |
2335 | string, then the window is given whatever width it requests internally. | |
2336 | ||
2337 | =item B<-window> =E<gt> I<$widget> | |
2338 | ||
2339 | Specifies the window to associate with this item. | |
2340 | The window specified by $widget must either be a child of | |
2341 | the canvas widget or a child of some ancestor of the canvas widget. | |
2342 | I<PathName> may not refer to a top-level window. | |
2343 | ||
2344 | Note: due to restrictions in the ways that windows are managed, it is not | |
2345 | possible to draw other graphical items (such as lines and images) on top | |
2346 | of window items. A window item always obscures any graphics that | |
2347 | overlap it, regardless of their order in the display list. | |
2348 | ||
2349 | =back | |
2350 | ||
2351 | =head1 APPLICATION-DEFINED ITEM TYPES | |
2352 | ||
2353 | It is possible for individual applications to define new item | |
2354 | types for canvas widgets using C code. | |
2355 | See the documentation for B<Tk_CreateItemType>. | |
2356 | ||
2357 | =head1 BINDINGS | |
2358 | ||
2359 | Canvas has default bindings to allow scrolling if necessary: | |
2360 | <Up>, <Down>, <Left> and <Right> (and their <Control-*> counter | |
2361 | parts). Further <Proir>, <Next>, <Home> and <End>. These | |
2362 | bindings allow you to navigate the same way as in other | |
2363 | widgets that can scroll. | |
2364 | ||
2365 | =head1 CREDITS | |
2366 | ||
2367 | Tk's canvas widget is a blatant ripoff of ideas from Joel Bartlett's | |
2368 | I<ezd> program. I<Ezd> provides structured graphics in a Scheme | |
2369 | environment and preceded canvases by a year or two. Its simple | |
2370 | mechanisms for placing and animating graphical objects inspired the | |
2371 | functions of canvases. | |
2372 | ||
2373 | =head1 KEYWORDS | |
2374 | ||
2375 | canvas, widget | |
2376 | ||
2377 | =cut | |
2378 |