1canvas::sqmap(n) Variations on a canvas canvas::sqmap(n)
2
3
4
5______________________________________________________________________________
6
8 canvas::sqmap - Canvas with map background based on square tiles
9
11 package require Tcl 8.4
12
13 package require Tk 8.4
14
15 package require canvas::sqmap ?0.2?
16
17 ::canvas::sqmap pathName ?options?
18
19 canvasName image set cell image
20
21 canvasName image unset cell
22
23 canvasName flush
24
25_________________________________________________________________
26
28 This package provides an extended canvas widget for the display of maps
29 based on a set of square image tiles. The tiles are the background of
30 the canvas, with all other canvas items added always shown in front of
31 them. The number of tiles shown, tile size, and where to get the images
32 to show are all configurable.
33
35 ::canvas::sqmap pathName ?options?
36 Creates the canvas pathName and configures it. The new widget
37 supports all of the options and methods of a regular canvas,
38 plus the options and methods described below.
39
40 The result of the command is pathName.
41
42 OPTIONS
43 -grid-cell-width
44 The value for this option is a non-negative integer. It speci‐
45 fies the width of the cells the background is made up of.
46
47 -grid-cell-height
48 The value for this option is a non-negative integer. It speci‐
49 fies the height of the cells the background is made up of.
50
51 -grid-cell-command
52 The value for this option is a command prefix. It is nvoked
53 whenever the canvas needs the image for a specific cell of the
54 background, with two additional arguments, the id of the cell,
55 and a command prefix to invoke when the image is ready, or known
56 to not exist.
57
58 The id of the cell is a 2-element list containing the row and
59 column number of the cell, in this order. The result command
60 prefix (named "$result" in the example below) has to be invoked
61 with either two or three arguments, i.e.
62
63 $result set $cellid $image ; # image is known and ready
64 $result unset $cellid ; # image does not exist
65
66 This option may be left undefined, i.e. the canvas can operate
67 without it. In that case the only images shown in grid cells are
68 those explicitly set with the method image set, see the next
69 section. All other grid cells will simply be empty.
70
71 -viewport-command
72 This option specifies a command prefix to invoke when the view‐
73 port of the canvas is changed, to allow users keep track of
74 where in the scroll-region we are at all times. This can be
75 used, for example, to drive derivate displays, or to keep items
76 in view by moving them as the viewport moves.
77
78 METHODS
79 canvasName image set cell image
80 Invoking this method places the image into the specified cell of
81 the background. The cell is given as a 2-element list containing
82 row and column number, in this order.
83
84 Note that an image is allowed to be associated with and dis‐
85 played in multiple cells of the canvas.
86
87 canvasName image unset cell
88 Invoking this method declares the specified cell of the back‐
89 ground as empty, an existing image shown by this cell will be
90 forgotten. The cell is given as a 2-element list containing row
91 and column number, in this order.
92
93 canvasName flush
94 Invoking this method forces the canvas to completely reload the
95 images for all cells. Do not use this method if the canvas is
96 operated without a -grid-cell-command, as in that case the can‐
97 vas will simply forget all images without being able to reload
98 them.
99
101 Note that the canvas does not take ownership of the images it shows in
102 the background. In other words, when we say that the canvas forgets an
103 image this means only that the association between a grid cell and
104 shown image is broken. The image is not deleted. Managing the lifecycle
105 of the images shown by the canvas is responsibility of the user of the
106 canvas.
107
109 canvas, cell, grid, image, map, square map, tile
110
111
112
113canvas 0.2 canvas::sqmap(n)