GetCursor.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:10k
- '"
- '" Copyright (c) 1990 The Regents of the University of California.
- '" Copyright (c) 1994-1998 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: GetCursor.3,v 1.5 2002/08/05 04:30:38 dgp Exp $
- '"
- .so man.macros
- .TH Tk_AllocCursorFromObj 3 8.1 Tk "Tk Library Procedures"
- .BS
- .SH NAME
- Tk_AllocCursorFromObj, Tk_GetCursor, Tk_GetCursorFromObj, Tk_GetCursorFromData, Tk_NameOfCursor, Tk_FreeCursorFromObj, Tk_FreeCursor - maintain database of cursors
- .SH SYNOPSIS
- .nf
- fB#include <tk.h>fR
- .sp
- .VS 8.1
- Tk_Cursor
- fBTk_AllocCursorFromObj(fIinterp, tkwin, objPtrfB)fR
- .sp
- Tk_Cursor
- fBTk_GetCursor(fIinterp, tkwin, namefB)fR
- .sp
- Tk_Cursor
- fBTk_GetCursorFromObj(fItkwin, objPtrfB)fR
- .VE
- .sp
- Tk_Cursor
- fBTk_GetCursorFromData(fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bgfB)fR
- .sp
- CONST char *
- fBTk_NameOfCursor(fIdisplay, cursorfB)fR
- .sp
- .VS 8.1
- fBTk_FreeCursorFromObj(fItkwin, objPtrfB)fR
- .VE
- .sp
- fBTk_FreeCursor(fIdisplay, cursorfB)fR
- .SH ARGUMENTS
- .AS "unsigned long" *pixelPtr
- .AP Tcl_Interp *interp in
- Interpreter to use for error reporting.
- .AP Tk_Window tkwin in
- Token for window in which the cursor will be used.
- .VS 8.1 br
- .AP Tcl_Obj *objPtr in/out
- Description of cursor; see below for possible values. Internal rep will be
- modified to cache pointer to corresponding Tk_Cursor.
- .AP char *name in
- Same as fIobjPtrfR except description of cursor is passed as a string and
- resulting Tk_Cursor isn't cached.
- .VE
- .AP "CONST char" *source in
- Data for cursor cursor, in standard cursor format.
- .AP "CONST char" *mask in
- Data for mask cursor, in standard cursor format.
- .AP "int" width in
- Width of fIsourcefR and fImaskfR.
- .AP "int" height in
- Height of fIsourcefR and fImaskfR.
- .AP "int" xHot in
- X-location of cursor hot-spot.
- .AP "int" yHot in
- Y-location of cursor hot-spot.
- .AP Tk_Uid fg in
- Textual description of foreground color for cursor.
- .AP Tk_Uid bg in
- Textual description of background color for cursor.
- .AP Display *display in
- Display for which fIcursorfR was allocated.
- .AP Tk_Cursor cursor in
- Opaque Tk identifier for cursor. If passed to fBTk_FreeCursorfR, must
- have been returned by some previous call to fBTk_GetCursorfR or
- fBTk_GetCursorFromDatafR.
- .BE
- .SH DESCRIPTION
- .PP
- These procedures manage a collection of cursors
- being used by an application. The procedures allow cursors to be
- re-used efficiently, thereby avoiding server overhead, and also
- allow cursors to be named with character strings.
- .PP
- .VS 8.1
- fBTk_AllocCursorFromObjfR takes as argument an object describing a
- cursor, and returns an opaque Tk identifier for a cursor corresponding
- to the description. It re-uses an existing cursor if possible and
- creates a new one otherwise. fBTk_AllocCursorFromObjfR caches
- information about the return value in fIobjPtrfR, which speeds up
- future calls to procedures such as fBTk_AllocCursorFromObjfR and
- fBTk_GetCursorFromObjfR. If an error occurs in creating the cursor,
- such as when fIobjPtrfR refers to a non-existent file, then fBNonefR
- is returned and an error message will be stored in fIinterpfR's result
- if fIinterpfR isn't NULL. fIObjPtrfR must contain a standard Tcl
- list with one of the following forms:
- .VE
- .TP
- fInamefR [fIfgColorfR [fIbgColorfR]]
- fINamefR is the name of a cursor in the standard X cursor cursor,
- i.e., any of the names defined in fBcursorcursor.hfR, without
- the fBXC_fR. Some example values are fBX_cursorfR, fBhand2fR,
- or fBleft_ptrfR. Appendix B of ``The X Window System''
- by Scheifler & Gettys has illustrations showing what each of these
- cursors looks like. If fIfgColorfR and fIbgColorfR are both
- specified, they give the foreground and background colors to use
- for the cursor (any of the forms acceptable to fBTk_GetColorfR
- may be used). If only fIfgColorfR is specified, then there
- will be no background color: the background will be transparent.
- If no colors are specified, then the cursor
- will use black for its foreground color and white for its background
- color.
- .RS
- .PP
- The Macintosh version of Tk supports all of the X cursors and
- will also accept any of the standard Mac cursors
- including fBibeamfR, fBcrosshairfR, fBwatchfR, fBplusfR, and
- fBarrowfR. In addition, Tk will load Macintosh cursor resources of
- the types fBcrsrfR (color) and fBCURSfR (black and white) by the
- name of the of the resource. The application and all its open
- dynamic library's resource files will be searched for the named
- cursor. If there are conflicts color cursors will always be loaded
- in preference to black and white cursors.
- .RE
- .TP
- fB@fIsourceName maskName fgColor bgColorfR
- In this form, fIsourceNamefR and fImaskNamefR are the names of
- files describing cursors for the cursor's source bits and mask.
- Each file must be in standard X11 or X10 cursor format.
- fIFgColorfR and fIbgColorfR
- indicate the colors to use for the
- cursor, in any of the forms acceptable to fBTk_GetColorfR. This
- form of the command will not work on Macintosh or Windows computers.
- .TP
- fB@fIsourceName fgColorfR
- This form is similar to the one above, except that the source is
- used as mask also. This means that the cursor's background is
- transparent. This form of the command will not work on Macintosh
- or Windows computers.
- .TP
- fB@fIsourceNamefR
- This form only works on Windows, and will load a Windows system
- cursor (fB.anifR or fB.curfR) from the file specified in
- fIsourceNamefR.
- .PP
- .VS 8.1
- fBTk_GetCursorfR is identical to fBTk_AllocCursorFromObjfR except
- that the description of the cursor is specified with a string instead
- of an object. This prevents fBTk_GetCursorfR from caching the
- return value, so fBTk_GetCursorfR is less efficient than
- fBTk_AllocCursorFromObjfR.
- .PP
- fBTk_GetCursorFromObjfR returns the token for an existing cursor, given
- the window and description used to create the cursor.
- fBTk_GetCursorFromObjfR doesn't actually create the cursor; the cursor
- must already have been created with a previous call to
- fBTk_AllocCursorFromObjfR or fBTk_GetCursorfR. The return
- value is cached in fIobjPtrfR, which speeds up
- future calls to fBTk_GetCursorFromObjfR with the same fIobjPtrfR
- and fItkwinfR.
- .VE
- .PP
- fBTk_GetCursorFromDatafR allows cursors to be created from
- in-memory descriptions of their source and mask cursors. fISourcefR
- points to standard cursor data for the cursor's source bits, and
- fImaskfR points to standard cursor data describing
- which pixels of fIsourcefR are to be drawn and which are to be
- considered transparent. fIWidthfR and fIheightfR give the
- dimensions of the cursor, fIxHotfR and fIyHotfR indicate the
- location of the cursor's hot-spot (the point that is reported when
- an event occurs), and fIfgfR and fIbgfR describe the cursor's
- foreground and background colors textually (any of the forms
- suitable for fBTk_GetColorfR may be used). Typically, the
- arguments to fBTk_GetCursorFromDatafR are created by including
- a cursor file directly into the source code for a program, as in
- the following example:
- .CS
- Tk_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
- .PP
- Under normal conditions fBTk_GetCursorFromDatafR
- will return an identifier for the requested cursor. If an error
- occurs in creating the cursor then fBNonefR is returned and an error
- message will be stored in fIinterpfR's result.
- .PP
- fBTk_AllocCursorFromObjfR, fBTk_GetCursorfR, and
- fBTk_GetCursorFromDatafR maintain a
- database of all the cursors they have created. Whenever possible,
- a call to fBTk_AllocCursorFromObjfR, fBTk_GetCursorfR, or
- fBTk_GetCursorFromDatafR will
- return an existing cursor rather than creating a new one. This
- approach can substantially reduce server overhead, so the Tk
- procedures should generally be used in preference to Xlib procedures
- like fBXCreateFontCursorfR or fBXCreatePixmapCursorfR, which
- create a new cursor on each call. The Tk procedures are also more
- portable than the lower-level X procedures.
- .PP
- The procedure fBTk_NameOfCursorfR is roughly the inverse of
- fBTk_GetCursorfR. If its fIcursorfR argument was created
- by fBTk_GetCursorfR, then the return value is the fInamefR
- argument that was passed to fBTk_GetCursorfR to create the
- cursor. If fIcursorfR was created by a call to fBTk_GetCursorFromDatafR,
- or by any other mechanism, then the return value is a hexadecimal string
- giving the X identifier for the cursor.
- Note: the string returned by fBTk_NameOfCursorfR is
- only guaranteed to persist until the next call to
- fBTk_NameOfCursorfR. Also, this call is not portable except for
- cursors returned by fBTk_GetCursorfR.
- .PP
- .VS 8.1
- When a cursor returned by fBTk_AllocCursorFromObjfR, fBTk_GetCursorfR,
- or fBTk_GetCursorFromDatafR
- is no longer needed, fBTk_FreeCursorFromObjfR or
- fBTk_FreeCursorfR should be called to release it.
- For fBTk_FreeCursorFromObjfR the cursor to release is specified
- with the same information used to create it; for
- fBTk_FreeCursorfR the cursor to release is specified
- with its Tk_Cursor token.
- There should be exactly one call to fBTk_FreeCursorfR for
- each call to fBTk_AllocCursorFromObjfR, fBTk_GetCursorfR,
- or fBTk_GetCursorFromDatafR.
- .VE
- .SH BUGS
- In determining whether an existing cursor can be used to satisfy
- a new request, fBTk_AllocCursorFromObjfR, fBTk_GetCursorfR,
- and fBTk_GetCursorFromDatafR
- consider only the immediate values of their arguments. For
- example, when a file name is passed to fBTk_GetCursorfR,
- fBTk_GetCursorfR will assume it is safe to re-use an existing
- cursor created from the same file name: it will not check to
- see whether the file itself has changed, or whether the current
- directory has changed, thereby causing the name to refer to
- a different file. Similarly, fBTk_GetCursorFromDatafR assumes
- that if the same fIsourcefR pointer is used in two different calls,
- then the pointers refer to the same data; it does not check to
- see if the actual data values have changed.
- .SH KEYWORDS
- cursor