📄 getcursor.3
字号:
'\"'\" Copyright (c) 1990 The Regents of the University of California.'\" Copyright (c) 1994-1996 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: @(#) GetCursor.3 1.23 96/08/27 13:21:26'\" .so man.macros.TH Tk_GetCursor 3 4.1 Tk "Tk Library Procedures".BS.SH NAMETk_GetCursor, Tk_GetCursorFromData, Tk_NameOfCursor, Tk_FreeCursor \- maintain database of cursors.SH SYNOPSIS.nf\fB#include <tk.h>\fR.spTk_Cursor\fBTk_GetCursor(\fIinterp, tkwin, nameId\fB)\fR.spTk_Cursor\fBTk_GetCursorFromData(\fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bg\fB)\fR.spchar *\fBTk_NameOfCursor(\fIdisplay, cursor\fB)\fR.sp\fBTk_FreeCursor(\fIdisplay, cursor\fB)\fR.SH ARGUMENTS.AS "unsigned long" *pixelPtr.AP Tcl_Interp *interp inInterpreter to use for error reporting..AP Tk_Window tkwin inToken for window in which the cursor will be used..AP Tk_Uid nameId inDescription of cursor; see below for possible values..AP char *source inData for cursor bitmap, in standard bitmap format..AP char *mask inData for mask bitmap, in standard bitmap format..AP "int" width inWidth of \fIsource\fR and \fImask\fR..AP "int" height inHeight of \fIsource\fR and \fImask\fR..AP "int" xHot inX-location of cursor hot-spot..AP "int" yHot inY-location of cursor hot-spot..AP Tk_Uid fg inTextual description of foreground color for cursor..AP Tk_Uid bg inTextual description of background color for cursor..AP Display *display inDisplay for which \fIcursor\fR was allocated..AP Tk_Cursor cursor inOpaque Tk identifier for cursor. If passed to\fBTk_FreeCursor\fR, musthave been returned by some previous call to \fBTk_GetCursor\fR or\fBTk_GetCursorFromData\fR..BE.SH DESCRIPTION.PPThese procedures manage a collection of cursorsbeing used by an application. The procedures allow cursors to bere-used efficiently, thereby avoiding server overhead, and alsoallow cursors to be named with character strings (actually Tk_Uids)..PP\fBTk_GetCursor\fR takes as argument a Tk_Uid describing a cursor,and returns an opaque Tk identifier for a cursor corresponding to thedescription. It re-uses an existing cursor if possible andcreates a new one otherwise. \fINameId\fR must be a standard Tcllist with one of the following forms:.TP\fIname\fR\0[\fIfgColor\fR\0[\fIbgColor\fR]]\fIName\fR is the name of a cursor in the standard X cursor font,i.e., any of the names defined in \fBcursorfont.h\fR, withoutthe \fBXC_\fR. Some example values are \fBX_cursor\fR, \fBhand2\fR,or \fBleft_ptr\fR. Appendix B of ``The X Window System''by Scheifler & Gettys has illustrations showing what each of thesecursors looks like. If \fIfgColor\fR and \fIbgColor\fR are bothspecified, they give the foreground and background colors to usefor the cursor (any of the forms acceptable to \fBTk_GetColor\fRmay be used). If only \fIfgColor\fR is specified, then therewill be no background color: the background will be transparent.If no colors are specified, then the cursorwill use black for its foreground color and white for its backgroundcolor.The Macintosh version of Tk also supports all of the X cursors.Tk on the Mac will also accept any of the standard Mac cursorsincluding \fBibeam\fR, \fBcrosshair\fR, \fBwatch\fR, \fBplus\fR, and\fBarrow\fR. In addition, Tk will load Macintosh cursor resources ofthe types \fBcrsr\fR (color) and \fBCURS\fR (black and white) by thename of the of the resource. The application and all its opendynamic library's resource files will be searched for the namedcursor. If there are conflicts color cursors will always be loadedin preference to black and white cursors..TP\fB@\fIsourceName\0maskName\0fgColor\0bgColor\fRIn this form, \fIsourceName\fR and \fImaskName\fR are the names offiles describing bitmaps for the cursor's source bits and mask.Each file must be in standard X11 or X10 bitmap format.\fIFgColor\fR and \fIbgColor\fR indicate the colors to use for thecursor, in any of the forms acceptable to \fBTk_GetColor\fR. Thisform of the command will not work on Macintosh or Windows computers..TP\fB@\fIsourceName\0fgColor\fRThis form is similar to the one above, except that the source isused as mask also. This means that the cursor's background istransparent. This form of the command will not work on Macintoshor Windows computers..PP\fBTk_GetCursorFromData\fR allows cursors to be created fromin-memory descriptions of their source and mask bitmaps. \fISource\fRpoints to standard bitmap data for the cursor's source bits, and\fImask\fR points to standard bitmap data describingwhich pixels of \fIsource\fR are to be drawn and which are to beconsidered transparent. \fIWidth\fR and \fIheight\fR give thedimensions of the cursor, \fIxHot\fR and \fIyHot\fR indicate thelocation of the cursor's hot-spot (the point that is reported whenan event occurs), and \fIfg\fR and \fIbg\fR describe the cursor'sforeground and background colors textually (any of the formssuitable for \fBTk_GetColor\fR may be used). Typically, thearguments to \fBTk_GetCursorFromData\fR are created by includinga cursor file directly into the source code for a program, as inthe following example:.CSTk_Cursor cursor;#include "source.cursor"#include "mask.cursor"cursor = Tk_GetCursorFromData(interp, tkwin, source_bits, mask_bits, source_width, source_height, source_x_hot, source_y_hot, Tk_GetUid("red"), Tk_GetUid("blue"));.CE.PPUnder normal conditions, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fRwill return an identifier for the requested cursor. If an erroroccurs in creating the cursor, such as when \fInameId\fR refersto a non-existent file, then \fBNone\fR is returned and an errormessage will be stored in \fIinterp->result\fR..PP\fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR maintain adatabase of all the cursors they have created. Whenever possible,a call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR willreturn an existing cursor rather than creating a new one. Thisapproach can substantially reduce server overhead, so the Tkprocedures should generally be used in preference to Xlib procedureslike \fBXCreateFontCursor\fR or \fBXCreatePixmapCursor\fR, whichcreate a new cursor on each call..PPThe procedure \fBTk_NameOfCursor\fR is roughly the inverse of\fBTk_GetCursor\fR. If its \fIcursor\fR argument was createdby \fBTk_GetCursor\fR, then the return value is the \fInameId\fRargument that was passed to \fBTk_GetCursor\fR to create thecursor. If \fIcursor\fR was created by a call to \fBTk_GetCursorFromData\fR,or by any other mechanism, then the return value is a hexadecimal stringgiving the X identifier for the cursor.Note: the string returned by \fBTk_NameOfCursor\fR isonly guaranteed to persist until the next call to\fBTk_NameOfCursor\fR. Also, this call is not portable except forcursors returned by \fBTk_GetCursor\fR..PPWhen a cursor returned by \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fRis no longer needed, \fBTk_FreeCursor\fR should be called to release it.There should be exactly one call to \fBTk_FreeCursor\fR foreach call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR.When a cursor is no longer in use anywhere (i.e. it has been freed asmany times as it has been gotten) \fBTk_FreeCursor\fR will releaseit to the X server and remove it from the database..SH BUGSIn determining whether an existing cursor can be used to satisfya new request, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fRconsider only the immediate values of their arguments. Forexample, when a file name is passed to \fBTk_GetCursor\fR,\fBTk_GetCursor\fR will assume it is safe to re-use an existingcursor created from the same file name: it will not check tosee whether the file itself has changed, or whether the currentdirectory has changed, thereby causing the name to refer toa different file. Similarly, \fBTk_GetCursorFromData\fR assumesthat if the same \fIsource\fR pointer is used in two different calls,then the pointers refer to the same data; it does not check tosee if the actual data values have changed..SH KEYWORDScursor
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -