⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crtimgtype.3

📁 linux系统下的音频通信
💻 3
字号:
'\"'\" 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.'\" '\" SCCS: @(#) CrtImgType.3 1.9 97/08/08 15:43:15'\" .so man.macros.TH Tk_CreateImageType 3 8.0 Tk "Tk Library Procedures".BS.SH NAMETk_CreateImageType, Tk_GetImageMasterData \- define new kind of image.SH SYNOPSIS.nf\fB#include <tk.h>\fR.sp\fBTk_CreateImageType\fR(\fItypePtr\fR)ClientData.sp.VS\fBTk_GetImageMasterData\fR(\fIinterp, name, typePtrPtr\fR).SH ARGUMENTS.AS Tk_ImageType *typePtrPtr.AP Tk_ImageType *typePtr inStructure that defines the new type of image.Must be static: apointer to this structure is retained by the image code..AP Tcl_Interp *interp inInterpreter in which image was created..AP char *name inName of existing image..AP Tk_ImageType **typePtrPtr outPoints to word in which to store a pointer to type information forthe given image, if it exists..VE.BE.SH DESCRIPTION.PP\fBTk_CreateImageType\fR is invoked to define a new kind of image.An image type corresponds to a particular value of the \fItype\fRargument for the \fBimage create\fR command.  There may existany number of different image types, and new types may be defineddynamically by calling \fBTk_CreateImageType\fR.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..PPThe code that implements a new image type is called an\fIimage manager\fR.It consists of a collection of procedures plus three differentkinds of data structures.The first data structure is a Tk_ImageType structure, which containsthe name of the image type and pointers to five procedures providedby the image manager to deal with images of this type:.CStypedef struct Tk_ImageType {	char *\fIname\fR;	Tk_ImageCreateProc *\fIcreateProc\fR;	Tk_ImageGetProc *\fIgetProc\fR;	Tk_ImageDisplayProc *\fIdisplayProc\fR;	Tk_ImageFreeProc *\fIfreeProc\fR;	Tk_ImageDeleteProc *\fIdeleteProc\fR;} Tk_ImageType;.CEThe fields of this structure will be described in later subsectionsof this entry..PPThe second major data structure manipulated by an image manageris called an \fIimage master\fR;  it contains overall informationabout a particular image, such as the values of the configurationoptions specified in an \fBimage create\fR command.There will usually be one of these structures for eachinvocation of the \fBimage create\fR command..PPThe third data structure related to images is an \fIimage instance\fR.There will usually be one of these structures for each usage of animage in a particular widget.It is possible for a single image to appear simultaneouslyin multiple widgets, or even multiple times in the same widget.Furthermore, different instances may be on different screensor displays.The image instance data structure describes things that mayvary from instance to instance, such as colors and graphicscontexts for redisplay.There is usually one instance structure for each \fB\-image\fRoption specified for a widget or canvas item..PPThe following subsections describe the fields of a Tk_ImageTypein more detail..SH NAME.PP\fItypePtr->name\fR provides a name for the image type.Once \fBTk_CreateImageType\fR returns, this name may be usedin \fBimage create\fR commands to create images of the newtype.If there already existed an image type by this name thenthe new image type replaces the old one..SH CREATEPROC\fItypePtr->createProc\fR provides the address of a procedure forTk to call whenever \fBimage create\fR is invoked to createan image of the new type.\fItypePtr->createProc\fR must match the following prototype:.CStypedef int Tk_ImageCreateProc(	Tcl_Interp *\fIinterp\fR,	char *\fIname\fR,	int \fIargc\fR,	char **\fIargv\fR,	Tk_ImageType *\fItypePtr\fR,	Tk_ImageMaster \fImaster\fR,	ClientData *\fImasterDataPtr\fR);.CEThe \fIinterp\fR argument is the interpreter in which the \fBimage\fRcommand was invoked, and \fIname\fR is the name for the new image,which was either specified explicitly in the \fBimage\fR commandor generated automatically by the \fBimage\fR command.The \fIargc\fR and \fIargv\fR arguments describe all the configurationoptions for the new image (everything after the name argument to\fBimage\fR).The \fImaster\fR argument is a token that refers to Tk's informationabout this image;  the image manager must return this token toTk when invoking the \fBTk_ImageChanged\fR procedure.Typically \fIcreateProc\fR will parse \fIargc\fR and \fIargv\fRand create an image master data structure for the new image.\fIcreateProc\fR may store an arbitrary one-word value at*\fImasterDataPtr\fR, which will be passed back to theimage manager when other callbacks are invoked.Typically the value is a pointer to the master datastructure for the image..PPIf \fIcreateProc\fR encounters an error, it should leave an errormessage in \fIinterp->result\fR and return \fBTCL_ERROR\fR;  otherwiseit should return \fBTCL_OK\fR..PP\fIcreateProc\fR should call \fBTk_ImageChanged\fR in order to set thesize of the image and request an initial redisplay..SH GETPROC.PP\fItypePtr->getProc\fR is invoked by Tk whenever a widgetcalls \fBTk_GetImage\fR to use a particular image.This procedure must match the following prototype:.CStypedef ClientData Tk_ImageGetProc(	Tk_Window \fItkwin\fR,	ClientData \fImasterData\fR);.CEThe \fItkwin\fR argument identifies the window in which theimage will be used and \fImasterData\fR is the valuereturned by \fIcreateProc\fR when the image master was created.\fIgetProc\fR will usually create a data structure for the newinstance, including such things as the resources needed todisplay the image in the given window.\fIgetProc\fR returns a one-word token for the instance, whichis typically the address of the instance data structure.Tk will pass this value back to the image manager when invokingits \fIdisplayProc\fR and \fIfreeProc\fR procedures..SH DISPLAYPROC.PP\fItypePtr->displayProc\fR is invoked by Tk whenever an image needsto be displayed (i.e., whenever a widget calls \fBTk_RedrawImage\fR).\fIdisplayProc\fR must match the following prototype:.CStypedef void Tk_ImageDisplayProc(	ClientData \fIinstanceData\fR,	Display *\fIdisplay\fR,	Drawable \fIdrawable\fR,	int \fIimageX\fR,	int \fIimageY\fR,	int \fIwidth\fR,	int \fIheight\fR,	int \fIdrawableX\fR,	int \fIdrawableY\fR);.CEThe \fIinstanceData\fR will be the same as the value returned by\fIgetProc\fR when the instance was created.\fIdisplay\fR and \fIdrawable\fR indicate where to display theimage;  \fIdrawable\fR may be a pixmap rather thanthe window specified to \fIgetProc\fR (this is usually the case,since most widgets double-buffer their redisplay to get smoothervisual effects).\fIimageX\fR, \fIimageY\fR, \fIwidth\fR, and \fIheight\fRidentify the region of the image that must be redisplayed.This region will always be within the size of the imageas specified in the most recent call to \fBTk_ImageChanged\fR.\fIdrawableX\fR and \fIdrawableY\fR indicate where in \fIdrawable\fRthe image should be displayed;  \fIdisplayProc\fR should displaythe given region of the image so that point (\fIimageX\fR, \fIimageY\fR)in the image appears at (\fIdrawableX\fR, \fIdrawableY\fR) in \fIdrawable\fR..SH FREEPROC.PP\fItypePtr->freeProc\fR contains the address of a procedure thatTk will invoke when an image instance is released (i.e., when\fBTk_FreeImage\fR is invoked).This can happen, for example, when a widget is deleted or a image itemin a canvas is deleted, or when the image displayed in a widget orcanvas item is changed.\fIfreeProc\fR must match the following prototype:.CStypedef void Tk_ImageFreeProc(	ClientData \fIinstanceData\fR,	Display *\fIdisplay\fR);.CEThe \fIinstanceData\fR will be the same as the value returned by\fIgetProc\fR when the instance was created, and \fIdisplay\fRis the display containing the window for the instance.\fIfreeProc\fR should release any resources associated with theimage instance, since the instance will never be used again..SH DELETEPROC.PP\fItypePtr->deleteProc\fR is a procedure that Tk invokes when animage is being deleted (i.e. when the \fBimage delete\fR commandis invoked).Before invoking \fIdeleteProc\fR Tk will invoke \fIfreeProc\fR foreach of the image's instances.\fIdeleteProc\fR must match the following prototype:.CStypedef void Tk_ImageDeleteProc(	ClientData \fImasterData\fR);.CEThe \fImasterData\fR argument will be the same as the valuestored in \fI*masterDataPtr\fR by \fIcreateProc\fR when theimage was created.\fIdeleteProc\fR should release any resources associated withthe image..SH TK_GETIMAGEMASTERDATA.VS.PPThe procedure \fBTk_GetImageMasterData\fR may be invoked to retrieveinformation about an image.  For example, an image manager can use thisprocedure to locate its image master data for an image.If there exists an image named \fIname\fRin the interpreter given by \fIinterp\fR, then \fI*typePtrPtr\fR isfilled in with type information for the image (the \fItypePtr\fR valuepassed to \fBTk_CreateImageType\fR when the image type was registered)and the return value is the ClientData value returned by the\fIcreateProc\fR when the image was created (this is typically apointer to the image master data structure).  If no such image existsthen NULL is returned and NULL is stored at \fI*typePtrPtr\fR..VE.SH "SEE ALSO"Tk_ImageChanged, Tk_GetImage, Tk_FreeImage, Tk_RedrawImage, Tk_SizeOfImage.SH KEYWORDSimage manager, image type, instance, master

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -