Debian Codegraph @

pod/pTk/CanvTkwin.pod

raw
1 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
2 # See the file "license.terms" for information on usage and redistribution
3 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
4 #
5 #
6
7 =head1 NAME
8
9 Tk_CanvasTkwin, Tk_CanvasGetCoord, Tk_CanvasDrawableCoords, Tk_CanvasSetStippleOrigin, Tk_CanvasWindowCoords, Tk_CanvasEventuallyRedraw, Tk_CanvasTagsOption - utility procedures for canvas type managers
10
11 =for category C Programming
12
13 =head1 SYNOPSIS
14
15 B<#include E<lt>tk.hE<gt>>
16
17 Tk_Window
18 B<Tk_CanvasTkwin>(I<canvas>)
19
20 int
21 B<Tk_CanvasGetCoord>(I<interp, canvas, string, doublePtr>)
22
23 B<Tk_CanvasDrawableCoords>(I<canvas, x, y, drawableXPtr, drawableYPtr>)
24
25 B<Tk_CanvasSetStippleOrigin>(I<canvas, gc>)
26
27 B<Tk_CanvasWindowCoords>(I<canvas, x, y, screenXPtr, screenYPtr>)
28
29 B<Tk_CanvasEventuallyRedraw>(I<canvas, x1, y1, x2, y2>)
30
31 Tk_OptionParseProc *B<Tk_CanvasTagsParseProc>;
32
33 Tk_OptionPrintProc *B<Tk_CanvasTagsPrintProc>;
34
35 =head1 ARGUMENTS
36
37 =over 4
38
39 =item Tk_Canvas canvas (in)
40
41 A token that identifies a canvas widget.
42
43 =item Tcl_Interp *interp (in/out)
44
45 Interpreter to use for error reporting.
46
47 =item char *string (in)
48
49 Textual description of a canvas coordinate.
50
51 =item double *doublePtr (out)
52
53 Points to place to store a converted coordinate.
54
55 =item double x (in)
56
57 An x coordinate in the space of the canvas.
58
59 =item double y (in)
60
61 A y coordinate in the space of the canvas.
62
63 =item short *drawableXPtr (out)
64
65 Pointer to a location in which to store an x coordinate in the space
66 of the drawable currently being used to redisplay the canvas.
67
68 =item short *drawableYPtr (out)
69
70 Pointer to a location in which to store a y coordinate in the space
71 of the drawable currently being used to redisplay the canvas.
72
73 =item GC gc (out)
74
75 Graphics context to modify.
76
77 =item short *screenXPtr (out)
78
79 Points to a location in which to store the screen coordinate in the
80 canvas window that corresponds to I<x>.
81
82 =item short *screenYPtr (out)
83
84 Points to a location in which to store the screen coordinate in the
85 canvas window that corresponds to I<y>.
86
87 =item int x1 (in)
88
89 Left edge of the region that needs redisplay. Only pixels at or to
90 the right of this coordinate need to be redisplayed.
91
92 =item int y1 (in)
93
94 Top edge of the region that needs redisplay. Only pixels at or below
95 this coordinate need to be redisplayed.
96
97 =item int x2 (in)
98
99 Right edge of the region that needs redisplay. Only pixels to
100 the left of this coordinate need to be redisplayed.
101
102 =item int y2 (in)
103
104 Bottom edge of the region that needs redisplay. Only pixels above
105 this coordinate need to be redisplayed.
106
107 =back
108
109 =head1 DESCRIPTION
110
111 These procedures are called by canvas type managers to perform various
112 utility functions.
113
114 B<Tk_CanvasTkwin> returns the Tk_Window associated with a particular
115 canvas.
116
117 B<Tk_CanvasGetCoord> translates a string specification of a
118 coordinate (such as B<2p> or B<1.6c>) into a double-precision
119 canvas coordinate.
120 If I<string> is a valid coordinate description then B<Tk_CanvasGetCoord>
121 stores the corresponding canvas coordinate at *I<doublePtr>
122 and returns TCL_OK.
123 Otherwise it stores an error message in I<interp-E<gt>result> and
124 returns TCL_ERROR.
125
126 B<Tk_CanvasDrawableCoords> is called by type managers during
127 redisplay to compute where to draw things.
128 Given I<x> and I<y> coordinates in the space of the
129 canvas, B<Tk_CanvasDrawableCoords> computes the corresponding
130 pixel in the drawable that is currently being used for redisplay;
131 it returns those coordinates in *I<drawableXPtr> and *I<drawableYPtr>.
132 This procedure should not be invoked except during redisplay.
133
134 B<Tk_CanvasSetStippleOrigin> is also used during redisplay.
135 It sets the stipple origin in I<gc> so that stipples drawn
136 with I<gc> in the current offscreen pixmap will line up
137 with stipples drawn with origin (0,0) in the canvas's actual
138 window.
139 B<Tk_CanvasSetStippleOrigin> is needed in order to guarantee
140 that stipple patterns line up properly when the canvas is
141 redisplayed in small pieces.
142 Redisplays are carried out in double-buffered fashion where a
143 piece of the canvas is redrawn in an offscreen pixmap and then
144 copied back onto the screen.
145 In this approach the stipple origins in graphics contexts need to
146 be adjusted during each redisplay to compensate for the position
147 of the off-screen pixmap relative to the window.
148 If an item is being drawn with stipples, its type manager typically
149 calls B<Tk_CanvasSetStippleOrigin> just before using I<gc>
150 to draw something; after it is finished drawing, the type manager
151 calls B<XSetTSOrigin> to restore the origin in I<gc> back to (0,0)
152 (the restore is needed because graphics contexts are shared, so
153 they cannot be modified permanently).
154
155 B<Tk_CanvasWindowCoords> is similar to B<Tk_CanvasDrawableCoords>
156 except that it returns coordinates in the canvas's window on the
157 screen, instead of coordinates in an off-screen pixmap.
158
159 B<Tk_CanvasEventuallyRedraw> may be invoked by a type manager
160 to inform Tk that a portion of a canvas needs to be redrawn.
161 The I<x1>, I<y1>, I<x2>, and I<y2> arguments
162 specify the region that needs to be redrawn, in canvas coordinates.
163 Type managers rarely need to invoke B<Tk_CanvasEventuallyRedraw>,
164 since Tk can normally figure out when an item has changed and make
165 the redisplay request on its behalf (this happens, for example
166 whenever Tk calls a I<configureProc> or I<scaleProc>).
167 The only time that a type manager needs to call
168 B<Tk_CanvasEventuallyRedraw> is if an item has changed on its own
169 without being invoked through one of the procedures in its Tk_ItemType;
170 this could happen, for example, in an image item if the image is
171 modified using image commands.
172
173 B<Tk_CanvasTagsParseProc> and B<Tk_CanvasTagsPrintProc> are
174 procedures that handle the B<-tags> option for canvas items.
175 The code of a canvas type manager won't call these procedures
176 directly, but will use their addresses to create a B<Tk_CustomOption>
177 structure for the B<-tags> option. The code typically looks
178 like this:
179
180 static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
181 Tk_CanvasTagsPrintProc, (ClientData) NULL
182 };
183
184 static Tk_ConfigSpec configSpecs[] = {
185 ...
186 {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
187 (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
188 ...
189 };
190
191 =head1 KEYWORDS
192
193 canvas, focus, item type, redisplay, selection, type manager