CrtImgType.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:11k
- '"
- '" Copyright (c) 1994 The Regents of the University of California.
- '" Copyright (c) 1994-1997 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: CrtImgType.3,v 1.6.2.1 2003/12/10 09:40:43 dkf Exp $
- '"
- .so man.macros
- .TH Tk_CreateImageType 3 8.3 Tk "Tk Library Procedures"
- .BS
- .SH NAME
- Tk_CreateImageType, Tk_GetImageMasterData, Tk_InitImageArgs - define new kind of image
- .SH SYNOPSIS
- .nf
- fB#include <tk.h>fR
- .sp
- fBTk_CreateImageTypefR(fItypePtrfR)
- .sp
- .VS
- ClientData
- fBTk_GetImageMasterDatafR(fIinterp, name, typePtrPtrfR)
- .sp
- fBTk_InitImageArgsfR(fIinterp, argc, argvPtrfR)
- .SH ARGUMENTS
- .AS Tk_ImageType *typePtrPtr
- .AP Tk_ImageType *typePtr in
- Structure that defines the new type of image.
- Must be static: a
- pointer to this structure is retained by the image code.
- .AP Tcl_Interp *interp in
- Interpreter in which image was created.
- .AP "CONST char" *name in
- Name of existing image.
- .AP Tk_ImageType **typePtrPtr out
- Points to word in which to store a pointer to type information for
- the given image, if it exists.
- .AP int argc in
- Number of arguments
- .AP char ***argvPtr in/out
- Pointer to argument list
- .VE
- .BE
- .SH DESCRIPTION
- .PP
- fBTk_CreateImageTypefR is invoked to define a new kind of image.
- An image type corresponds to a particular value of the fItypefR
- argument for the fBimage createfR command. There may exist
- any number of different image types, and new types may be defined
- dynamically by calling fBTk_CreateImageTypefR.
- For example, there might be one type for 2-color bitmaps,
- another for multi-color images, another for dithered images,
- another for video, and so on.
- .PP
- The code that implements a new image type is called an
- fIimage managerfR.
- It consists of a collection of procedures plus three different
- kinds of data structures.
- The first data structure is a Tk_ImageType structure, which contains
- the name of the image type and pointers to five procedures provided
- by the image manager to deal with images of this type:
- .CS
- typedef struct Tk_ImageType {
- char *fInamefR;
- Tk_ImageCreateProc *fIcreateProcfR;
- Tk_ImageGetProc *fIgetProcfR;
- Tk_ImageDisplayProc *fIdisplayProcfR;
- Tk_ImageFreeProc *fIfreeProcfR;
- Tk_ImageDeleteProc *fIdeleteProcfR;
- } Tk_ImageType;
- .CE
- The fields of this structure will be described in later subsections
- of this entry.
- .PP
- The second major data structure manipulated by an image manager
- is called an fIimage masterfR; it contains overall information
- about a particular image, such as the values of the configuration
- options specified in an fBimage createfR command.
- There will usually be one of these structures for each
- invocation of the fBimage createfR command.
- .PP
- The third data structure related to images is an fIimage instancefR.
- There will usually be one of these structures for each usage of an
- image in a particular widget.
- It is possible for a single image to appear simultaneously
- in multiple widgets, or even multiple times in the same widget.
- Furthermore, different instances may be on different screens
- or displays.
- The image instance data structure describes things that may
- vary from instance to instance, such as colors and graphics
- contexts for redisplay.
- There is usually one instance structure for each fB-imagefR
- option specified for a widget or canvas item.
- .PP
- The following subsections describe the fields of a Tk_ImageType
- in more detail.
- .SH NAME
- .PP
- fItypePtr->namefR provides a name for the image type.
- Once fBTk_CreateImageTypefR returns, this name may be used
- in fBimage createfR commands to create images of the new
- type.
- If there already existed an image type by this name then
- the new image type replaces the old one.
- .SH PORTABILITY
- .PP
- In Tk 8.2 and earlier, the createProc below had a different
- signature. If you want to compile an image type using the
- old interface which should still run on all Tcl/Tk versions,
- compile it with the flag -DUSE_OLD_IMAGE. Further on, if
- you are using Stubs, you need to call the function
- Tk_InitImageArgs(interp, argc, &argv) first in your
- createProc. See below for a description of this function.
- .SH CREATEPROC
- fItypePtr->createProcfR provides the address of a procedure for
- Tk to call whenever fBimage createfR is invoked to create
- an image of the new type.
- fItypePtr->createProcfR must match the following prototype:
- .CS
- typedef int Tk_ImageCreateProc(
- Tcl_Interp *fIinterpfR,
- char *fInamefR,
- int fIobjcfR,
- Tcl_Obj *CONST fIobjvfR[],
- Tk_ImageType *fItypePtrfR,
- Tk_ImageMaster fImasterfR,
- ClientData *fImasterDataPtrfR);
- .CE
- The fIinterpfR argument is the interpreter in which the fBimagefR
- command was invoked, and fInamefR is the name for the new image,
- which was either specified explicitly in the fBimagefR command
- or generated automatically by the fBimagefR command.
- The fIobjcfR and fIobjvfR arguments describe all the configuration
- options for the new image (everything after the name argument to
- fBimagefR).
- The fImasterfR argument is a token that refers to Tk's information
- about this image; the image manager must return this token to
- Tk when invoking the fBTk_ImageChangedfR procedure.
- Typically fIcreateProcfR will parse fIobjcfR and fIobjvfR
- and create an image master data structure for the new image.
- fIcreateProcfR may store an arbitrary one-word value at
- *fImasterDataPtrfR, which will be passed back to the
- image manager when other callbacks are invoked.
- Typically the value is a pointer to the master data
- structure for the image.
- .PP
- If fIcreateProcfR encounters an error, it should leave an error
- message in fIinterp->resultfR and return fBTCL_ERRORfR; otherwise
- it should return fBTCL_OKfR.
- .PP
- fIcreateProcfR should call fBTk_ImageChangedfR in order to set the
- size of the image and request an initial redisplay.
- .SH GETPROC
- .PP
- fItypePtr->getProcfR is invoked by Tk whenever a widget
- calls fBTk_GetImagefR to use a particular image.
- This procedure must match the following prototype:
- .CS
- typedef ClientData Tk_ImageGetProc(
- Tk_Window fItkwinfR,
- ClientData fImasterDatafR);
- .CE
- The fItkwinfR argument identifies the window in which the
- image will be used and fImasterDatafR is the value
- returned by fIcreateProcfR when the image master was created.
- fIgetProcfR will usually create a data structure for the new
- instance, including such things as the resources needed to
- display the image in the given window.
- fIgetProcfR returns a one-word token for the instance, which
- is typically the address of the instance data structure.
- Tk will pass this value back to the image manager when invoking
- its fIdisplayProcfR and fIfreeProcfR procedures.
- .SH DISPLAYPROC
- .PP
- fItypePtr->displayProcfR is invoked by Tk whenever an image needs
- to be displayed (i.e., whenever a widget calls fBTk_RedrawImagefR).
- fIdisplayProcfR must match the following prototype:
- .CS
- typedef void Tk_ImageDisplayProc(
- ClientData fIinstanceDatafR,
- Display *fIdisplayfR,
- Drawable fIdrawablefR,
- int fIimageXfR,
- int fIimageYfR,
- int fIwidthfR,
- int fIheightfR,
- int fIdrawableXfR,
- int fIdrawableYfR);
- .CE
- The fIinstanceDatafR will be the same as the value returned by
- fIgetProcfR when the instance was created.
- fIdisplayfR and fIdrawablefR indicate where to display the
- image; fIdrawablefR may be a pixmap rather than
- the window specified to fIgetProcfR (this is usually the case,
- since most widgets double-buffer their redisplay to get smoother
- visual effects).
- fIimageXfR, fIimageYfR, fIwidthfR, and fIheightfR
- identify the region of the image that must be redisplayed.
- This region will always be within the size of the image
- as specified in the most recent call to fBTk_ImageChangedfR.
- fIdrawableXfR and fIdrawableYfR indicate where in fIdrawablefR
- the image should be displayed; fIdisplayProcfR should display
- the given region of the image so that point (fIimageXfR, fIimageYfR)
- in the image appears at (fIdrawableXfR, fIdrawableYfR) in fIdrawablefR.
- .SH FREEPROC
- .PP
- fItypePtr->freeProcfR contains the address of a procedure that
- Tk will invoke when an image instance is released (i.e., when
- fBTk_FreeImagefR is invoked).
- This can happen, for example, when a widget is deleted or a image item
- in a canvas is deleted, or when the image displayed in a widget or
- canvas item is changed.
- fIfreeProcfR must match the following prototype:
- .CS
- typedef void Tk_ImageFreeProc(
- ClientData fIinstanceDatafR,
- Display *fIdisplayfR);
- .CE
- The fIinstanceDatafR will be the same as the value returned by
- fIgetProcfR when the instance was created, and fIdisplayfR
- is the display containing the window for the instance.
- fIfreeProcfR should release any resources associated with the
- image instance, since the instance will never be used again.
- .SH DELETEPROC
- .PP
- fItypePtr->deleteProcfR is a procedure that Tk invokes when an
- image is being deleted (i.e. when the fBimage deletefR command
- is invoked).
- Before invoking fIdeleteProcfR Tk will invoke fIfreeProcfR for
- each of the image's instances.
- fIdeleteProcfR must match the following prototype:
- .CS
- typedef void Tk_ImageDeleteProc(
- ClientData fImasterDatafR);
- .CE
- The fImasterDatafR argument will be the same as the value
- stored in fI*masterDataPtrfR by fIcreateProcfR when the
- image was created.
- fIdeleteProcfR should release any resources associated with
- the image.
- .SH TK_GETIMAGEMASTERDATA
- .VS
- .PP
- The procedure fBTk_GetImageMasterDatafR may be invoked to retrieve
- information about an image. For example, an image manager can use this
- procedure to locate its image master data for an image.
- If there exists an image named fInamefR
- in the interpreter given by fIinterpfR, then fI*typePtrPtrfR is
- filled in with type information for the image (the fItypePtrfR value
- passed to fBTk_CreateImageTypefR when the image type was registered)
- and the return value is the ClientData value returned by the
- fIcreateProcfR when the image was created (this is typically a
- pointer to the image master data structure). If no such image exists
- then NULL is returned and NULL is stored at fI*typePtrPtrfR.
- .VE
- .SH TK_INITIMAGEARGS
- .VS
- .PP
- The function fBTk_InitImageArgsfR converts the arguments of the
- fBcreateProcfR from objects to strings when necessary. When
- not using stubs, not using the old interface, or running
- under an older (pre-8.3) Tk version, this function has no
- effect. This function makes porting older image handlers to
- the new interface a lot easier: After running this function,
- the arguments are guaranteed to be in string format, no
- matter how Tk deliverd them.
- .SH "SEE ALSO"
- Tk_ImageChanged, Tk_GetImage, Tk_FreeImage, Tk_RedrawImage, Tk_SizeOfImage
- .SH KEYWORDS
- image manager, image type, instance, master