1 |
578 |
markom |
'\"
|
2 |
|
|
'\" Copyright (c) 1994 The Regents of the University of California.
|
3 |
|
|
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
|
4 |
|
|
'\"
|
5 |
|
|
'\" See the file "license.terms" for information on usage and redistribution
|
6 |
|
|
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
7 |
|
|
'\"
|
8 |
|
|
'\" RCS: @(#) $Id: GetImage.3,v 1.1.1.1 2002-01-16 10:25:48 markom Exp $
|
9 |
|
|
'\"
|
10 |
|
|
.so man.macros
|
11 |
|
|
.TH Tk_GetImage 3 4.0 Tk "Tk Library Procedures"
|
12 |
|
|
.BS
|
13 |
|
|
.SH NAME
|
14 |
|
|
Tk_GetImage, Tk_RedrawImage, Tk_SizeOfImage, Tk_FreeImage \- use an image in a widget
|
15 |
|
|
.SH SYNOPSIS
|
16 |
|
|
.nf
|
17 |
|
|
\fB#include \fR
|
18 |
|
|
.sp
|
19 |
|
|
Tk_Image
|
20 |
|
|
\fBTk_GetImage\fR(\fIinterp, tkwin, name, changeProc, clientData\fR)
|
21 |
|
|
.sp
|
22 |
|
|
\fBTk_RedrawImage\fR(\fIimage, imageX, imageY, width, height, drawable, drawableX, drawableY\fR)
|
23 |
|
|
.sp
|
24 |
|
|
\fBTk_SizeOfImage\fR(\fIimage, widthPtr, heightPtr\fR)
|
25 |
|
|
.sp
|
26 |
|
|
\fBTk_FreeImage\fR(\fIimage\fR)
|
27 |
|
|
.SH ARGUMENTS
|
28 |
|
|
.AS Tk_ImageChangedProc *changeProc
|
29 |
|
|
.AP Tcl_Interp *interp in
|
30 |
|
|
Place to leave error message.
|
31 |
|
|
.AP Tk_Window tkwin in
|
32 |
|
|
Window in which image will be used.
|
33 |
|
|
.AP char *name in
|
34 |
|
|
Name of image.
|
35 |
|
|
.AP Tk_ImageChangedProc *changeProc in
|
36 |
|
|
Procedure for Tk to invoke whenever image content or size changes.
|
37 |
|
|
.AP ClientData clientData in
|
38 |
|
|
One-word value for Tk to pass to \fIchangeProc\fR.
|
39 |
|
|
.AP Tk_Image image in
|
40 |
|
|
Token for image instance; must have been returned by a previous
|
41 |
|
|
call to \fBTk_GetImage\fR.
|
42 |
|
|
.AP int imageX in
|
43 |
|
|
X-coordinate of upper-left corner of region of image to redisplay
|
44 |
|
|
(measured in pixels from the image's upper-left corner).
|
45 |
|
|
.AP int imageY in
|
46 |
|
|
Y-coordinate of upper-left corner of region of image to redisplay
|
47 |
|
|
(measured in pixels from the image's upper-left corner).
|
48 |
|
|
.AP "int" width (in)
|
49 |
|
|
Width of region of image to redisplay.
|
50 |
|
|
.AP "int" height (in)
|
51 |
|
|
Height of region of image to redisplay.
|
52 |
|
|
.AP Drawable drawable in
|
53 |
|
|
Where to display image. Must either be window specified to
|
54 |
|
|
\fBTk_GetImage\fR or a pixmap compatible with that window.
|
55 |
|
|
.AP int drawableX in
|
56 |
|
|
Where to display image in \fIdrawable\fR: this is the x-coordinate
|
57 |
|
|
in \fIdrawable\fR where x-coordinate \fIimageX\fR of the image
|
58 |
|
|
should be displayed.
|
59 |
|
|
.AP int drawableY in
|
60 |
|
|
Where to display image in \fIdrawable\fR: this is the y-coordinate
|
61 |
|
|
in \fIdrawable\fR where y-coordinate \fIimageY\fR of the image
|
62 |
|
|
should be displayed.
|
63 |
|
|
.AP "int" widthPtr out
|
64 |
|
|
Store width of \fIimage\fR (in pixels) here.
|
65 |
|
|
.AP "int" heightPtr out
|
66 |
|
|
Store height of \fIimage\fR (in pixels) here.
|
67 |
|
|
.BE
|
68 |
|
|
|
69 |
|
|
.SH DESCRIPTION
|
70 |
|
|
.PP
|
71 |
|
|
These procedures are invoked by widgets that wish to display images.
|
72 |
|
|
\fBTk_GetImage\fR is invoked by a widget when it first decides to
|
73 |
|
|
display an image.
|
74 |
|
|
\fIname\fR gives the name of the desired image and \fItkwin\fR
|
75 |
|
|
identifies the window where the image will be displayed.
|
76 |
|
|
\fBTk_GetImage\fR looks up the image in the table of existing
|
77 |
|
|
images and returns a token for a new instance of the image.
|
78 |
|
|
If the image doesn't exist then \fBTk_GetImage\fR returns NULL
|
79 |
|
|
and leaves an error message in \fIinterp->result\fR.
|
80 |
|
|
.PP
|
81 |
|
|
When a widget wishes to actually display an image it must
|
82 |
|
|
call \fBTk_RedrawWidget\fR, identifying the image (\fIimage\fR),
|
83 |
|
|
a region within the image to redisplay (\fIimageX\fR, \fIimageY\fR,
|
84 |
|
|
\fIwidth\fR, and \fIheight\fR), and a place to display the
|
85 |
|
|
image (\fIdrawable\fR, \fIdrawableX\fR, and \fIdrawableY\fR).
|
86 |
|
|
Tk will then invoke the appropriate image manager, which will
|
87 |
|
|
display the requested portion of the image before returning.
|
88 |
|
|
.PP
|
89 |
|
|
A widget can find out the dimensions of an image by calling
|
90 |
|
|
\fBTk_SizeOfImage\fR: the width and height will be stored
|
91 |
|
|
in the locations given by \fIwidthPtr\fR and \fIheightPtr\fR,
|
92 |
|
|
respectively.
|
93 |
|
|
.PP
|
94 |
|
|
When a widget is finished with an image (e.g., the widget is
|
95 |
|
|
being deleted or it is going to use a different image instead
|
96 |
|
|
of the current one), it must call \fBTk_FreeImage\fR to
|
97 |
|
|
release the image instance.
|
98 |
|
|
The widget should never again use the image token after passing
|
99 |
|
|
it to \fBTk_FreeImage\fR.
|
100 |
|
|
There must be exactly one call to \fBTk_FreeImage\fR for each
|
101 |
|
|
call to \fBTk_GetImage\fR.
|
102 |
|
|
.PP
|
103 |
|
|
If the contents or size of an image changes, then any widgets
|
104 |
|
|
using the image will need to find out about the changes so that
|
105 |
|
|
they can redisplay themselves.
|
106 |
|
|
The \fIchangeProc\fR and \fIclientData\fR arguments to
|
107 |
|
|
\fBTk_GetImage\fR are used for this purpose.
|
108 |
|
|
\fIchangeProc\fR will be called by Tk whenever a change occurs
|
109 |
|
|
in the image; it must match the following prototype:
|
110 |
|
|
.CS
|
111 |
|
|
typedef void Tk_ImageChangedProc(
|
112 |
|
|
ClientData \fIclientData\fR,
|
113 |
|
|
int \fIx\fR,
|
114 |
|
|
int \fIy\fR,
|
115 |
|
|
int \fIwidth\fR,
|
116 |
|
|
int \fIheight\fR,
|
117 |
|
|
int \fIimageWidth\fR,
|
118 |
|
|
int \fIimageHeight\fR);
|
119 |
|
|
.CE
|
120 |
|
|
The \fIclientData\fR argument to \fIchangeProc\fR is the same as the
|
121 |
|
|
\fIclientData\fR argument to \fBTk_GetImage\fR.
|
122 |
|
|
It is usually a pointer to the widget record for the widget or
|
123 |
|
|
some other data structure managed by the widget.
|
124 |
|
|
The arguments \fIx\fR, \fIy\fR, \fIwidth\fR, and \fIheight\fR
|
125 |
|
|
identify a region within the image that must be redisplayed;
|
126 |
|
|
they are specified in pixels measured from the upper-left
|
127 |
|
|
corner of the image.
|
128 |
|
|
The arguments \fIimageWidth\fR and \fIimageHeight\fR give
|
129 |
|
|
the image's (new) size.
|
130 |
|
|
|
131 |
|
|
.SH "SEE ALSO"
|
132 |
|
|
Tk_CreateImageType
|
133 |
|
|
|
134 |
|
|
.SH KEYWORDS
|
135 |
|
|
images, redisplay
|