Debian Codegraph @

pod/pTk/GetImage.pod

raw
1 # Copyright (c) 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
8 =head1 NAME
9
10 Tk_GetImage, Tk_RedrawImage, Tk_SizeOfImage, Tk_FreeImage - use an image in a widget
11
12 =for category C Programming
13
14 =head1 SYNOPSIS
15
16 B<#include E<lt>tk.hE<gt>>
17
18 Tk_Image
19 B<Tk_GetImage>(I<interp, tkwin, name, changeProc, clientData>)
20
21 B<Tk_RedrawImage>(I<image, imageX, imageY, width, height, drawable, drawableX, drawableY>)
22
23 B<Tk_SizeOfImage>(I<image, widthPtr, heightPtr>)
24
25 B<Tk_FreeImage>(I<image>)
26
27 =head1 ARGUMENTS
28
29 =over 4
30
31 =item Tcl_Interp *interp (in)
32
33 Place to leave error message.
34
35 =item Tk_Window tkwin (in)
36
37 Window in which image will be used.
38
39 =item char *name (in)
40
41 Name of image.
42
43 =item Tk_ImageChangedProc *changeProc (in)
44
45 Procedure for Tk to invoke whenever image content or size changes.
46
47 =item ClientData clientData (in)
48
49 One-word value for Tk to pass to I<changeProc>.
50
51 =item Tk_Image image (in)
52
53 Token for image instance; must have been returned by a previous
54 call to B<Tk_GetImage>.
55
56 =item int imageX (in)
57
58 X-coordinate of upper-left corner of region of image to redisplay
59 (measured in pixels from the image's upper-left corner).
60
61 =item int imageY (in)
62
63 Y-coordinate of upper-left corner of region of image to redisplay
64 (measured in pixels from the image's upper-left corner).
65
66 =item "int" width ((in))
67
68 Width of region of image to redisplay.
69
70 =item "int" height ((in))
71
72 Height of region of image to redisplay.
73
74 =item Drawable drawable (in)
75
76 Where to display image. Must either be window specified to
77 B<Tk_GetImage> or a pixmap compatible with that window.
78
79 =item int drawableX (in)
80
81 Where to display image in I<drawable>: this is the x-coordinate
82 in I<drawable> where x-coordinate I<imageX> of the image
83 should be displayed.
84
85 =item int drawableY (in)
86
87 Where to display image in I<drawable>: this is the y-coordinate
88 in I<drawable> where y-coordinate I<imageY> of the image
89 should be displayed.
90
91 =item "int" widthPtr (out)
92
93 Store width of I<image> (in pixels) here.
94
95 =item "int" heightPtr (out)
96
97 Store height of I<image> (in pixels) here.
98
99 =back
100
101 =head1 DESCRIPTION
102
103 These procedures are invoked by widgets that wish to display images.
104 B<Tk_GetImage> is invoked by a widget when it first decides to
105 display an image.
106 I<name> gives the name of the desired image and I<tkwin>
107 identifies the window where the image will be displayed.
108 B<Tk_GetImage> looks up the image in the table of existing
109 images and returns a token for a new instance of the image.
110 If the image doesn't exist then B<Tk_GetImage> returns NULL
111 and leaves an error message in I<interp-E<gt>result>.
112
113 When a widget wishes to actually display an image it must
114 call B<Tk_RedrawWidget>, identifying the image (I<image>),
115 a region within the image to redisplay (I<imageX>, I<imageY>,
116 I<width>, and I<height>), and a place to display the
117 image (I<drawable>, I<drawableX>, and I<drawableY>).
118 Tk will then invoke the appropriate image manager, which will
119 display the requested portion of the image before returning.
120
121 A widget can find out the dimensions of an image by calling
122 B<Tk_SizeOfImage>: the width and height will be stored
123 in the locations given by I<widthPtr> and I<heightPtr>,
124 respectively.
125
126 When a widget is finished with an image (e.g., the widget is
127 being deleted or it is going to use a different image instead
128 of the current one), it must call B<Tk_FreeImage> to
129 release the image instance.
130 The widget should never again use the image token after passing
131 it to B<Tk_FreeImage>.
132 There must be exactly one call to B<Tk_FreeImage> for each
133 call to B<Tk_GetImage>.
134
135 If the contents or size of an image changes, then any widgets
136 using the image will need to find out about the changes so that
137 they can redisplay themselves.
138 The I<changeProc> and I<clientData> arguments to
139 B<Tk_GetImage> are used for this purpose.
140 I<changeProc> will be called by Tk whenever a change occurs
141 in the image; it must match the following prototype:
142
143 typedef void Tk_ImageChangedProc(
144 ClientData clientData,
145 int x,
146 int y,
147 int width,
148 int height,
149 int imageWidth,
150 int imageHeight);
151
152 The I<clientData> argument to I<changeProc> is the same as the
153 I<clientData> argument to B<Tk_GetImage>.
154 It is usually a pointer to the widget record for the widget or
155 some other data structure managed by the widget.
156 The arguments I<x>, I<y>, I<width>, and I<height>
157 identify a region within the image that must be redisplayed;
158 they are specified in pixels measured from the upper-left
159 corner of the image.
160 The arguments I<imageWidth> and I<imageHeight> give
161 the image's (new) size.
162
163 =head1 SEE ALSO
164
165 L<Tk::CrtImgType>
166
167 =head1 KEYWORDS
168
169 images, redisplay