OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [tk/] [doc/] [CrtImgType.3] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
2
'\" Copyright (c) 1994 The Regents of the University of California.
3
'\" Copyright (c) 1994-1997 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: CrtImgType.3,v 1.1.1.1 2002-01-16 10:25:48 markom Exp $
9
'\"
10
.so man.macros
11
.TH Tk_CreateImageType 3 8.0 Tk "Tk Library Procedures"
12
.BS
13
.SH NAME
14
Tk_CreateImageType, Tk_GetImageMasterData \- define new kind of image
15
.SH SYNOPSIS
16
.nf
17
\fB#include \fR
18
.sp
19
\fBTk_CreateImageType\fR(\fItypePtr\fR)
20
ClientData
21
.sp
22
.VS
23
\fBTk_GetImageMasterData\fR(\fIinterp, name, typePtrPtr\fR)
24
.SH ARGUMENTS
25
.AS Tk_ImageType *typePtrPtr
26
.AP Tk_ImageType *typePtr in
27
Structure that defines the new type of image.
28
Must be static: a
29
pointer to this structure is retained by the image code.
30
.AP Tcl_Interp *interp in
31
Interpreter in which image was created.
32
.AP char *name in
33
Name of existing image.
34
.AP Tk_ImageType **typePtrPtr out
35
Points to word in which to store a pointer to type information for
36
the given image, if it exists.
37
.VE
38
.BE
39
 
40
.SH DESCRIPTION
41
.PP
42
\fBTk_CreateImageType\fR is invoked to define a new kind of image.
43
An image type corresponds to a particular value of the \fItype\fR
44
argument for the \fBimage create\fR command.  There may exist
45
any number of different image types, and new types may be defined
46
dynamically by calling \fBTk_CreateImageType\fR.
47
For example, there might be one type for 2-color bitmaps,
48
another for multi-color images, another for dithered images,
49
another for video, and so on.
50
.PP
51
The code that implements a new image type is called an
52
\fIimage manager\fR.
53
It consists of a collection of procedures plus three different
54
kinds of data structures.
55
The first data structure is a Tk_ImageType structure, which contains
56
the name of the image type and pointers to five procedures provided
57
by the image manager to deal with images of this type:
58
.CS
59
typedef struct Tk_ImageType {
60
        char *\fIname\fR;
61
        Tk_ImageCreateProc *\fIcreateProc\fR;
62
        Tk_ImageGetProc *\fIgetProc\fR;
63
        Tk_ImageDisplayProc *\fIdisplayProc\fR;
64
        Tk_ImageFreeProc *\fIfreeProc\fR;
65
        Tk_ImageDeleteProc *\fIdeleteProc\fR;
66
} Tk_ImageType;
67
.CE
68
The fields of this structure will be described in later subsections
69
of this entry.
70
.PP
71
The second major data structure manipulated by an image manager
72
is called an \fIimage master\fR;  it contains overall information
73
about a particular image, such as the values of the configuration
74
options specified in an \fBimage create\fR command.
75
There will usually be one of these structures for each
76
invocation of the \fBimage create\fR command.
77
.PP
78
The third data structure related to images is an \fIimage instance\fR.
79
There will usually be one of these structures for each usage of an
80
image in a particular widget.
81
It is possible for a single image to appear simultaneously
82
in multiple widgets, or even multiple times in the same widget.
83
Furthermore, different instances may be on different screens
84
or displays.
85
The image instance data structure describes things that may
86
vary from instance to instance, such as colors and graphics
87
contexts for redisplay.
88
There is usually one instance structure for each \fB\-image\fR
89
option specified for a widget or canvas item.
90
.PP
91
The following subsections describe the fields of a Tk_ImageType
92
in more detail.
93
 
94
.SH NAME
95
.PP
96
\fItypePtr->name\fR provides a name for the image type.
97
Once \fBTk_CreateImageType\fR returns, this name may be used
98
in \fBimage create\fR commands to create images of the new
99
type.
100
If there already existed an image type by this name then
101
the new image type replaces the old one.
102
 
103
.SH CREATEPROC
104
\fItypePtr->createProc\fR provides the address of a procedure for
105
Tk to call whenever \fBimage create\fR is invoked to create
106
an image of the new type.
107
\fItypePtr->createProc\fR must match the following prototype:
108
.CS
109
typedef int Tk_ImageCreateProc(
110
        Tcl_Interp *\fIinterp\fR,
111
        char *\fIname\fR,
112
        int \fIargc\fR,
113
        char **\fIargv\fR,
114
        Tk_ImageType *\fItypePtr\fR,
115
        Tk_ImageMaster \fImaster\fR,
116
        ClientData *\fImasterDataPtr\fR);
117
.CE
118
The \fIinterp\fR argument is the interpreter in which the \fBimage\fR
119
command was invoked, and \fIname\fR is the name for the new image,
120
which was either specified explicitly in the \fBimage\fR command
121
or generated automatically by the \fBimage\fR command.
122
The \fIargc\fR and \fIargv\fR arguments describe all the configuration
123
options for the new image (everything after the name argument to
124
\fBimage\fR).
125
The \fImaster\fR argument is a token that refers to Tk's information
126
about this image;  the image manager must return this token to
127
Tk when invoking the \fBTk_ImageChanged\fR procedure.
128
Typically \fIcreateProc\fR will parse \fIargc\fR and \fIargv\fR
129
and create an image master data structure for the new image.
130
\fIcreateProc\fR may store an arbitrary one-word value at
131
*\fImasterDataPtr\fR, which will be passed back to the
132
image manager when other callbacks are invoked.
133
Typically the value is a pointer to the master data
134
structure for the image.
135
.PP
136
If \fIcreateProc\fR encounters an error, it should leave an error
137
message in \fIinterp->result\fR and return \fBTCL_ERROR\fR;  otherwise
138
it should return \fBTCL_OK\fR.
139
.PP
140
\fIcreateProc\fR should call \fBTk_ImageChanged\fR in order to set the
141
size of the image and request an initial redisplay.
142
 
143
.SH GETPROC
144
.PP
145
\fItypePtr->getProc\fR is invoked by Tk whenever a widget
146
calls \fBTk_GetImage\fR to use a particular image.
147
This procedure must match the following prototype:
148
.CS
149
typedef ClientData Tk_ImageGetProc(
150
        Tk_Window \fItkwin\fR,
151
        ClientData \fImasterData\fR);
152
.CE
153
The \fItkwin\fR argument identifies the window in which the
154
image will be used and \fImasterData\fR is the value
155
returned by \fIcreateProc\fR when the image master was created.
156
\fIgetProc\fR will usually create a data structure for the new
157
instance, including such things as the resources needed to
158
display the image in the given window.
159
\fIgetProc\fR returns a one-word token for the instance, which
160
is typically the address of the instance data structure.
161
Tk will pass this value back to the image manager when invoking
162
its \fIdisplayProc\fR and \fIfreeProc\fR procedures.
163
 
164
.SH DISPLAYPROC
165
.PP
166
\fItypePtr->displayProc\fR is invoked by Tk whenever an image needs
167
to be displayed (i.e., whenever a widget calls \fBTk_RedrawImage\fR).
168
\fIdisplayProc\fR must match the following prototype:
169
.CS
170
typedef void Tk_ImageDisplayProc(
171
        ClientData \fIinstanceData\fR,
172
        Display *\fIdisplay\fR,
173
        Drawable \fIdrawable\fR,
174
        int \fIimageX\fR,
175
        int \fIimageY\fR,
176
        int \fIwidth\fR,
177
        int \fIheight\fR,
178
        int \fIdrawableX\fR,
179
        int \fIdrawableY\fR);
180
.CE
181
The \fIinstanceData\fR will be the same as the value returned by
182
\fIgetProc\fR when the instance was created.
183
\fIdisplay\fR and \fIdrawable\fR indicate where to display the
184
image;  \fIdrawable\fR may be a pixmap rather than
185
the window specified to \fIgetProc\fR (this is usually the case,
186
since most widgets double-buffer their redisplay to get smoother
187
visual effects).
188
\fIimageX\fR, \fIimageY\fR, \fIwidth\fR, and \fIheight\fR
189
identify the region of the image that must be redisplayed.
190
This region will always be within the size of the image
191
as specified in the most recent call to \fBTk_ImageChanged\fR.
192
\fIdrawableX\fR and \fIdrawableY\fR indicate where in \fIdrawable\fR
193
the image should be displayed;  \fIdisplayProc\fR should display
194
the given region of the image so that point (\fIimageX\fR, \fIimageY\fR)
195
in the image appears at (\fIdrawableX\fR, \fIdrawableY\fR) in \fIdrawable\fR.
196
 
197
.SH FREEPROC
198
.PP
199
\fItypePtr->freeProc\fR contains the address of a procedure that
200
Tk will invoke when an image instance is released (i.e., when
201
\fBTk_FreeImage\fR is invoked).
202
This can happen, for example, when a widget is deleted or a image item
203
in a canvas is deleted, or when the image displayed in a widget or
204
canvas item is changed.
205
\fIfreeProc\fR must match the following prototype:
206
.CS
207
typedef void Tk_ImageFreeProc(
208
        ClientData \fIinstanceData\fR,
209
        Display *\fIdisplay\fR);
210
.CE
211
The \fIinstanceData\fR will be the same as the value returned by
212
\fIgetProc\fR when the instance was created, and \fIdisplay\fR
213
is the display containing the window for the instance.
214
\fIfreeProc\fR should release any resources associated with the
215
image instance, since the instance will never be used again.
216
 
217
.SH DELETEPROC
218
.PP
219
\fItypePtr->deleteProc\fR is a procedure that Tk invokes when an
220
image is being deleted (i.e. when the \fBimage delete\fR command
221
is invoked).
222
Before invoking \fIdeleteProc\fR Tk will invoke \fIfreeProc\fR for
223
each of the image's instances.
224
\fIdeleteProc\fR must match the following prototype:
225
.CS
226
typedef void Tk_ImageDeleteProc(
227
        ClientData \fImasterData\fR);
228
.CE
229
The \fImasterData\fR argument will be the same as the value
230
stored in \fI*masterDataPtr\fR by \fIcreateProc\fR when the
231
image was created.
232
\fIdeleteProc\fR should release any resources associated with
233
the image.
234
 
235
.SH TK_GETIMAGEMASTERDATA
236
.VS
237
.PP
238
The procedure \fBTk_GetImageMasterData\fR may be invoked to retrieve
239
information about an image.  For example, an image manager can use this
240
procedure to locate its image master data for an image.
241
If there exists an image named \fIname\fR
242
in the interpreter given by \fIinterp\fR, then \fI*typePtrPtr\fR is
243
filled in with type information for the image (the \fItypePtr\fR value
244
passed to \fBTk_CreateImageType\fR when the image type was registered)
245
and the return value is the ClientData value returned by the
246
\fIcreateProc\fR when the image was created (this is typically a
247
pointer to the image master data structure).  If no such image exists
248
then NULL is returned and NULL is stored at \fI*typePtrPtr\fR.
249
.VE
250
 
251
.SH "SEE ALSO"
252
Tk_ImageChanged, Tk_GetImage, Tk_FreeImage, Tk_RedrawImage, Tk_SizeOfImage
253
 
254
.SH KEYWORDS
255
image manager, image type, instance, master

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.