OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / SGI / util / SGI / man / man3 / Tk_GetImageMasterData.3
1 '\"
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 '\" SCCS: @(#) CrtImgType.3 1.9 97/08/08 15:43:15
9 '\" 
10 '\" The definitions below are for supplemental macros used in Tcl/Tk
11 '\" manual entries.
12 '\"
13 '\" .AP type name in/out ?indent?
14 '\"     Start paragraph describing an argument to a library procedure.
15 '\"     type is type of argument (int, etc.), in/out is either "in", "out",
16 '\"     or "in/out" to describe whether procedure reads or modifies arg,
17 '\"     and indent is equivalent to second arg of .IP (shouldn't ever be
18 '\"     needed;  use .AS below instead)
19 '\"
20 '\" .AS ?type? ?name?
21 '\"     Give maximum sizes of arguments for setting tab stops.  Type and
22 '\"     name are examples of largest possible arguments that will be passed
23 '\"     to .AP later.  If args are omitted, default tab stops are used.
24 '\"
25 '\" .BS
26 '\"     Start box enclosure.  From here until next .BE, everything will be
27 '\"     enclosed in one large box.
28 '\"
29 '\" .BE
30 '\"     End of box enclosure.
31 '\"
32 '\" .CS
33 '\"     Begin code excerpt.
34 '\"
35 '\" .CE
36 '\"     End code excerpt.
37 '\"
38 '\" .VS ?version? ?br?
39 '\"     Begin vertical sidebar, for use in marking newly-changed parts
40 '\"     of man pages.  The first argument is ignored and used for recording
41 '\"     the version when the .VS was added, so that the sidebars can be
42 '\"     found and removed when they reach a certain age.  If another argument
43 '\"     is present, then a line break is forced before starting the sidebar.
44 '\"
45 '\" .VE
46 '\"     End of vertical sidebar.
47 '\"
48 '\" .DS
49 '\"     Begin an indented unfilled display.
50 '\"
51 '\" .DE
52 '\"     End of indented unfilled display.
53 '\"
54 '\" .SO
55 '\"     Start of list of standard options for a Tk widget.  The
56 '\"     options follow on successive lines, in four columns separated
57 '\"     by tabs.
58 '\"
59 '\" .SE
60 '\"     End of list of standard options for a Tk widget.
61 '\"
62 '\" .OP cmdName dbName dbClass
63 '\"     Start of description of a specific option.  cmdName gives the
64 '\"     option's name as specified in the class command, dbName gives
65 '\"     the option's name in the option database, and dbClass gives
66 '\"     the option's class in the option database.
67 '\"
68 '\" .UL arg1 arg2
69 '\"     Print arg1 underlined, then print arg2 normally.
70 '\"
71 '\" SCCS: @(#) man.macros 1.9 97/08/22 18:50:59
72 '\"
73 '\"     # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
74 .if t .wh -1.3i ^B
75 .nr ^l \n(.l
76 .ad b
77 '\"     # Start an argument description
78 .de AP
79 .ie !"\\$4"" .TP \\$4
80 .el \{\
81 .   ie !"\\$2"" .TP \\n()Cu
82 .   el          .TP 15
83 .\}
84 .ie !"\\$3"" \{\
85 .ta \\n()Au \\n()Bu
86 \&\\$1  \\fI\\$2\\fP    (\\$3)
87 .\".b
88 .\}
89 .el \{\
90 .br
91 .ie !"\\$2"" \{\
92 \&\\$1  \\fI\\$2\\fP
93 .\}
94 .el \{\
95 \&\\fI\\$1\\fP
96 .\}
97 .\}
98 ..
99 '\"     # define tabbing values for .AP
100 .de AS
101 .nr )A 10n
102 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
103 .nr )B \\n()Au+15n
104 .\"
105 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
106 .nr )C \\n()Bu+\\w'(in/out)'u+2n
107 ..
108 .AS Tcl_Interp Tcl_CreateInterp in/out
109 '\"     # BS - start boxed text
110 '\"     # ^y = starting y location
111 '\"     # ^b = 1
112 .de BS
113 .br
114 .mk ^y
115 .nr ^b 1u
116 .if n .nf
117 .if n .ti 0
118 .if n \l'\\n(.lu\(ul'
119 .if n .fi
120 ..
121 '\"     # BE - end boxed text (draw box now)
122 .de BE
123 .nf
124 .ti 0
125 .mk ^t
126 .ie n \l'\\n(^lu\(ul'
127 .el \{\
128 .\"     Draw four-sided box normally, but don't draw top of
129 .\"     box if the box started on an earlier page.
130 .ie !\\n(^b-1 \{\
131 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
132 .\}
133 .el \}\
134 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
135 .\}
136 .\}
137 .fi
138 .br
139 .nr ^b 0
140 ..
141 '\"     # VS - start vertical sidebar
142 '\"     # ^Y = starting y location
143 '\"     # ^v = 1 (for troff;  for nroff this doesn't matter)
144 .de VS
145 .if !"\\$2"" .br
146 .mk ^Y
147 .ie n 'mc \s12\(br\s0
148 .el .nr ^v 1u
149 ..
150 '\"     # VE - end of vertical sidebar
151 .de VE
152 .ie n 'mc
153 .el \{\
154 .ev 2
155 .nf
156 .ti 0
157 .mk ^t
158 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
159 .sp -1
160 .fi
161 .ev
162 .\}
163 .nr ^v 0
164 ..
165 '\"     # Special macro to handle page bottom:  finish off current
166 '\"     # box/sidebar if in box/sidebar mode, then invoked standard
167 '\"     # page bottom macro.
168 .de ^B
169 .ev 2
170 'ti 0
171 'nf
172 .mk ^t
173 .if \\n(^b \{\
174 .\"     Draw three-sided box if this is the box's first page,
175 .\"     draw two sides but no top otherwise.
176 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
177 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
178 .\}
179 .if \\n(^v \{\
180 .nr ^x \\n(^tu+1v-\\n(^Yu
181 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
182 .\}
183 .bp
184 'fi
185 .ev
186 .if \\n(^b \{\
187 .mk ^y
188 .nr ^b 2
189 .\}
190 .if \\n(^v \{\
191 .mk ^Y
192 .\}
193 ..
194 '\"     # DS - begin display
195 .de DS
196 .RS
197 .nf
198 .sp
199 ..
200 '\"     # DE - end display
201 .de DE
202 .fi
203 .RE
204 .sp
205 ..
206 '\"     # SO - start of list of standard options
207 .de SO
208 .SH "STANDARD OPTIONS"
209 .LP
210 .nf
211 .ta 4c 8c 12c
212 .ft B
213 ..
214 '\"     # SE - end of list of standard options
215 .de SE
216 .fi
217 .ft R
218 .LP
219 See the \\fBoptions\\fR manual entry for details on the standard options.
220 ..
221 '\"     # OP - start of full description for a single option
222 .de OP
223 .LP
224 .nf
225 .ta 4c
226 Command-Line Name:      \\fB\\$1\\fR
227 Database Name:  \\fB\\$2\\fR
228 Database Class: \\fB\\$3\\fR
229 .fi
230 .IP
231 ..
232 '\"     # CS - begin code excerpt
233 .de CS
234 .RS
235 .nf
236 .ta .25i .5i .75i 1i
237 ..
238 '\"     # CE - end code excerpt
239 .de CE
240 .fi
241 .RE
242 ..
243 .de UL
244 \\$1\l'|0\(ul'\\$2
245 ..
246 .TH Tk_CreateImageType 3 8.0 Tk "Tk Library Procedures"
247 .BS
248 .SH NAME
249 Tk_CreateImageType, Tk_GetImageMasterData \- define new kind of image
250 .SH SYNOPSIS
251 .nf
252 \fB#include <tk.h>\fR
253 .sp
254 \fBTk_CreateImageType\fR(\fItypePtr\fR)
255 ClientData
256 .sp
257 .VS
258 \fBTk_GetImageMasterData\fR(\fIinterp, name, typePtrPtr\fR)
259 .SH ARGUMENTS
260 .AS Tk_ImageType *typePtrPtr
261 .AP Tk_ImageType *typePtr in
262 Structure that defines the new type of image.
263 Must be static: a
264 pointer to this structure is retained by the image code.
265 .AP Tcl_Interp *interp in
266 Interpreter in which image was created.
267 .AP char *name in
268 Name of existing image.
269 .AP Tk_ImageType **typePtrPtr out
270 Points to word in which to store a pointer to type information for
271 the given image, if it exists.
272 .VE
273 .BE
274
275 .SH DESCRIPTION
276 .PP
277 \fBTk_CreateImageType\fR is invoked to define a new kind of image.
278 An image type corresponds to a particular value of the \fItype\fR
279 argument for the \fBimage create\fR command.  There may exist
280 any number of different image types, and new types may be defined
281 dynamically by calling \fBTk_CreateImageType\fR.
282 For example, there might be one type for 2-color bitmaps,
283 another for multi-color images, another for dithered images,
284 another for video, and so on.
285 .PP
286 The code that implements a new image type is called an
287 \fIimage manager\fR.
288 It consists of a collection of procedures plus three different
289 kinds of data structures.
290 The first data structure is a Tk_ImageType structure, which contains
291 the name of the image type and pointers to five procedures provided
292 by the image manager to deal with images of this type:
293 .CS
294 typedef struct Tk_ImageType {
295         char *\fIname\fR;
296         Tk_ImageCreateProc *\fIcreateProc\fR;
297         Tk_ImageGetProc *\fIgetProc\fR;
298         Tk_ImageDisplayProc *\fIdisplayProc\fR;
299         Tk_ImageFreeProc *\fIfreeProc\fR;
300         Tk_ImageDeleteProc *\fIdeleteProc\fR;
301 } Tk_ImageType;
302 .CE
303 The fields of this structure will be described in later subsections
304 of this entry.
305 .PP
306 The second major data structure manipulated by an image manager
307 is called an \fIimage master\fR;  it contains overall information
308 about a particular image, such as the values of the configuration
309 options specified in an \fBimage create\fR command.
310 There will usually be one of these structures for each
311 invocation of the \fBimage create\fR command.
312 .PP
313 The third data structure related to images is an \fIimage instance\fR.
314 There will usually be one of these structures for each usage of an
315 image in a particular widget.
316 It is possible for a single image to appear simultaneously
317 in multiple widgets, or even multiple times in the same widget.
318 Furthermore, different instances may be on different screens
319 or displays.
320 The image instance data structure describes things that may
321 vary from instance to instance, such as colors and graphics
322 contexts for redisplay.
323 There is usually one instance structure for each \fB\-image\fR
324 option specified for a widget or canvas item.
325 .PP
326 The following subsections describe the fields of a Tk_ImageType
327 in more detail.
328
329 .SH NAME
330 .PP
331 \fItypePtr->name\fR provides a name for the image type.
332 Once \fBTk_CreateImageType\fR returns, this name may be used
333 in \fBimage create\fR commands to create images of the new
334 type.
335 If there already existed an image type by this name then
336 the new image type replaces the old one.
337
338 .SH CREATEPROC
339 \fItypePtr->createProc\fR provides the address of a procedure for
340 Tk to call whenever \fBimage create\fR is invoked to create
341 an image of the new type.
342 \fItypePtr->createProc\fR must match the following prototype:
343 .CS
344 typedef int Tk_ImageCreateProc(
345         Tcl_Interp *\fIinterp\fR,
346         char *\fIname\fR,
347         int \fIargc\fR,
348         char **\fIargv\fR,
349         Tk_ImageType *\fItypePtr\fR,
350         Tk_ImageMaster \fImaster\fR,
351         ClientData *\fImasterDataPtr\fR);
352 .CE
353 The \fIinterp\fR argument is the interpreter in which the \fBimage\fR
354 command was invoked, and \fIname\fR is the name for the new image,
355 which was either specified explicitly in the \fBimage\fR command
356 or generated automatically by the \fBimage\fR command.
357 The \fIargc\fR and \fIargv\fR arguments describe all the configuration
358 options for the new image (everything after the name argument to
359 \fBimage\fR).
360 The \fImaster\fR argument is a token that refers to Tk's information
361 about this image;  the image manager must return this token to
362 Tk when invoking the \fBTk_ImageChanged\fR procedure.
363 Typically \fIcreateProc\fR will parse \fIargc\fR and \fIargv\fR
364 and create an image master data structure for the new image.
365 \fIcreateProc\fR may store an arbitrary one-word value at
366 *\fImasterDataPtr\fR, which will be passed back to the
367 image manager when other callbacks are invoked.
368 Typically the value is a pointer to the master data
369 structure for the image.
370 .PP
371 If \fIcreateProc\fR encounters an error, it should leave an error
372 message in \fIinterp->result\fR and return \fBTCL_ERROR\fR;  otherwise
373 it should return \fBTCL_OK\fR.
374 .PP
375 \fIcreateProc\fR should call \fBTk_ImageChanged\fR in order to set the
376 size of the image and request an initial redisplay.
377
378 .SH GETPROC
379 .PP
380 \fItypePtr->getProc\fR is invoked by Tk whenever a widget
381 calls \fBTk_GetImage\fR to use a particular image.
382 This procedure must match the following prototype:
383 .CS
384 typedef ClientData Tk_ImageGetProc(
385         Tk_Window \fItkwin\fR,
386         ClientData \fImasterData\fR);
387 .CE
388 The \fItkwin\fR argument identifies the window in which the
389 image will be used and \fImasterData\fR is the value
390 returned by \fIcreateProc\fR when the image master was created.
391 \fIgetProc\fR will usually create a data structure for the new
392 instance, including such things as the resources needed to
393 display the image in the given window.
394 \fIgetProc\fR returns a one-word token for the instance, which
395 is typically the address of the instance data structure.
396 Tk will pass this value back to the image manager when invoking
397 its \fIdisplayProc\fR and \fIfreeProc\fR procedures.
398
399 .SH DISPLAYPROC
400 .PP
401 \fItypePtr->displayProc\fR is invoked by Tk whenever an image needs
402 to be displayed (i.e., whenever a widget calls \fBTk_RedrawImage\fR).
403 \fIdisplayProc\fR must match the following prototype:
404 .CS
405 typedef void Tk_ImageDisplayProc(
406         ClientData \fIinstanceData\fR,
407         Display *\fIdisplay\fR,
408         Drawable \fIdrawable\fR,
409         int \fIimageX\fR,
410         int \fIimageY\fR,
411         int \fIwidth\fR,
412         int \fIheight\fR,
413         int \fIdrawableX\fR,
414         int \fIdrawableY\fR);
415 .CE
416 The \fIinstanceData\fR will be the same as the value returned by
417 \fIgetProc\fR when the instance was created.
418 \fIdisplay\fR and \fIdrawable\fR indicate where to display the
419 image;  \fIdrawable\fR may be a pixmap rather than
420 the window specified to \fIgetProc\fR (this is usually the case,
421 since most widgets double-buffer their redisplay to get smoother
422 visual effects).
423 \fIimageX\fR, \fIimageY\fR, \fIwidth\fR, and \fIheight\fR
424 identify the region of the image that must be redisplayed.
425 This region will always be within the size of the image
426 as specified in the most recent call to \fBTk_ImageChanged\fR.
427 \fIdrawableX\fR and \fIdrawableY\fR indicate where in \fIdrawable\fR
428 the image should be displayed;  \fIdisplayProc\fR should display
429 the given region of the image so that point (\fIimageX\fR, \fIimageY\fR)
430 in the image appears at (\fIdrawableX\fR, \fIdrawableY\fR) in \fIdrawable\fR.
431
432 .SH FREEPROC
433 .PP
434 \fItypePtr->freeProc\fR contains the address of a procedure that
435 Tk will invoke when an image instance is released (i.e., when
436 \fBTk_FreeImage\fR is invoked).
437 This can happen, for example, when a widget is deleted or a image item
438 in a canvas is deleted, or when the image displayed in a widget or
439 canvas item is changed.
440 \fIfreeProc\fR must match the following prototype:
441 .CS
442 typedef void Tk_ImageFreeProc(
443         ClientData \fIinstanceData\fR,
444         Display *\fIdisplay\fR);
445 .CE
446 The \fIinstanceData\fR will be the same as the value returned by
447 \fIgetProc\fR when the instance was created, and \fIdisplay\fR
448 is the display containing the window for the instance.
449 \fIfreeProc\fR should release any resources associated with the
450 image instance, since the instance will never be used again.
451
452 .SH DELETEPROC
453 .PP
454 \fItypePtr->deleteProc\fR is a procedure that Tk invokes when an
455 image is being deleted (i.e. when the \fBimage delete\fR command
456 is invoked).
457 Before invoking \fIdeleteProc\fR Tk will invoke \fIfreeProc\fR for
458 each of the image's instances.
459 \fIdeleteProc\fR must match the following prototype:
460 .CS
461 typedef void Tk_ImageDeleteProc(
462         ClientData \fImasterData\fR);
463 .CE
464 The \fImasterData\fR argument will be the same as the value
465 stored in \fI*masterDataPtr\fR by \fIcreateProc\fR when the
466 image was created.
467 \fIdeleteProc\fR should release any resources associated with
468 the image.
469
470 .SH TK_GETIMAGEMASTERDATA
471 .VS
472 .PP
473 The procedure \fBTk_GetImageMasterData\fR may be invoked to retrieve
474 information about an image.  For example, an image manager can use this
475 procedure to locate its image master data for an image.
476 If there exists an image named \fIname\fR
477 in the interpreter given by \fIinterp\fR, then \fI*typePtrPtr\fR is
478 filled in with type information for the image (the \fItypePtr\fR value
479 passed to \fBTk_CreateImageType\fR when the image type was registered)
480 and the return value is the ClientData value returned by the
481 \fIcreateProc\fR when the image was created (this is typically a
482 pointer to the image master data structure).  If no such image exists
483 then NULL is returned and NULL is stored at \fI*typePtrPtr\fR.
484 .VE
485
486 .SH "SEE ALSO"
487 Tk_ImageChanged, Tk_GetImage, Tk_FreeImage, Tk_RedrawImage, Tk_SizeOfImage
488
489 .SH KEYWORDS
490 image manager, image type, instance, master