other versions
- wheezy 8.4.19-5
Tk_AllocCursorFromObj(3tk) | Tk Library Procedures | Tk_AllocCursorFromObj(3tk) |
NAME¶
Tk_AllocCursorFromObj, Tk_GetCursor, Tk_GetCursorFromObj, Tk_GetCursorFromData, Tk_NameOfCursor, Tk_FreeCursorFromObj, Tk_FreeCursor - maintain database of cursorsSYNOPSIS¶
#include <tk.h>Tk_Cursor Tk_AllocCursorFromObj(interp, tkwin, objPtr)Tk_Cursor Tk_GetCursor(interp, tkwin, name)Tk_Cursor Tk_GetCursorFromObj(tkwin, objPtr)Tk_Cursor Tk_GetCursorFromData(interp, tkwin, source, mask, width, height, xHot, yHot, fg, bg)CONST char * Tk_NameOfCursor(display, cursor)Tk_FreeCursorFromObj(tkwin, objPtr)Tk_FreeCursor(display, cursor)
ARGUMENTS¶
- Tcl_Interp *interp (in)
- Interpreter to use for error reporting.
- Tk_Window tkwin (in)
- Token for window in which the cursor will be used.
- 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.
- char *name (in)
- Same as objPtr except description of cursor is passed as a string and resulting Tk_Cursor isn't cached.
- CONST char *source (in)
- Data for cursor cursor, in standard cursor format.
- CONST char *mask (in)
- Data for mask cursor, in standard cursor format.
- int width (in)
- Width of source and mask.
- int height (in)
- Height of source and mask.
- int xHot (in)
- X-location of cursor hot-spot.
- int yHot (in)
- Y-location of cursor hot-spot.
- Tk_Uid fg (in)
- Textual description of foreground color for cursor.
- Tk_Uid bg (in)
- Textual description of background color for cursor.
- Display *display (in)
- Display for which cursor was allocated.
- Tk_Cursor cursor (in)
- Opaque Tk identifier for cursor. If passed to
Tk_FreeCursor, must have been returned by some previous call to
Tk_GetCursor or Tk_GetCursorFromData.
DESCRIPTION¶
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. Tk_AllocCursorFromObj 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. Tk_AllocCursorFromObj caches information about the return value in objPtr, which speeds up future calls to procedures such as Tk_AllocCursorFromObj and Tk_GetCursorFromObj. If an error occurs in creating the cursor, such as when objPtr refers to a non-existent file, then None is returned and an error message will be stored in interp's result if interp isn't NULL. ObjPtr must contain a standard Tcl list with one of the following forms:- name [fgColor [bgColor]]
- Name is the name of a cursor in the standard X cursor cursor, i.e., any of the names defined in cursorcursor.h, without the XC_. Some example values are X_cursor, hand2, or left_ptr. Appendix B of ``The X Window System'' by Scheifler & Gettys has illustrations showing what each of these cursors looks like. If fgColor and bgColor are both specified, they give the foreground and background colors to use for the cursor (any of the forms acceptable to Tk_GetColor may be used). If only fgColor 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.
The Macintosh version of Tk supports all of the X cursors and will also accept
any of the standard Mac cursors including ibeam, crosshair,
watch, plus, and arrow. In addition, Tk will load
Macintosh cursor resources of the types crsr (color) and CURS
(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.
- @sourceName maskName fgColor bgColor
- In this form, sourceName and maskName 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. FgColor and bgColor indicate the colors to use for the cursor, in any of the forms acceptable to Tk_GetColor. This form of the command will not work on Macintosh or Windows computers.
- @sourceName fgColor
- 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.
- @sourceName
- This form only works on Windows, and will load a Windows system cursor ( .ani or .cur) from the file specified in sourceName.
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"));
BUGS¶
In determining whether an existing cursor can be used to satisfy a new request, Tk_AllocCursorFromObj, Tk_GetCursor, and Tk_GetCursorFromData consider only the immediate values of their arguments. For example, when a file name is passed to Tk_GetCursor, Tk_GetCursor 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, Tk_GetCursorFromData assumes that if the same source 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.KEYWORDS¶
cursor8.1 | Tk |