Manual Pages for UNIX Darwin command on man Tk_GetCursor
MyWebUniversity

Manual Pages for UNIX Darwin command on man Tk_GetCursor

TkAllocCursorFromObj(3) Tk Library Procedures TkAllocCursorFromObj(3)

NAME

TkAllocCursorFromObj, TkGetCursor, TkGetCursorFromObj, TkGetCursor-

FromData, TkNameOfCursor, TkFreeCursorFromObj, TkFreeCursor - main-

tain database of cursors

SYNOPSIS

##iinncclluuddee <>

TkCursor | TTkkAAllllooccCCuurrssoorrFFrroommOObbjj((interp, tkwin, objPtr)) | TkCursor | TTkkGGeettCCuurrssoorr((interp, tkwin, name)) | TkCursor | TTkkGGeettCCuurrssoorrFFrroommOObbjj((tkwin, objPtr)) | TkCursor TTkkGGeettCCuurrssoorrFFrroommDDaattaa((interp, tkwin, source, mask, width, height, xHot, yHot, fg, bg)) CONST char * TTkkNNaammeeOOffCCuurrssoorr((display, cursor)) TTkkFFrreeeeCCuurrssoorrFFrroommOObbjj((tkwin, objPtr)) | TTkkFFrreeeeCCuurrssoorr((display, cursor)) AARRGGUUMMEENNTTSS TclInterp *interp (in) Interpreter to use for error reporting. TkWindow tkwin (in) Token for window in which the cursor will be used. TclObj *objPtr (in/out) || Description of cursor; see below | for possible values. Internal | rep will be modified to cache |

pointer to corresponding TkCur- |

sor. | char *name (in) || Same as objPtr except description | of cursor is passed as a string | and resulting TkCursor isn't | cached.

CONST char *source (in) Data for cursor cursor, in stan-

dard 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.

TkUid fg (in) Textual description of foreground color for cursor. TkUid bg (in) Textual description of background color for cursor. Display *display (in) Display for which cursor was allocated. TkCursor cursor (in) Opaque Tk identifier for cursor. If passed to TTkkFFrreeeeCCuurrssoorr, must

have been returned by some previ-

ous call to TTkkGGeettCCuurrssoorr or TTkkGGeettCCuurrssoorrFFrroommDDaattaa.

DESCRIPTION

These procedures manage a collection of cursors being used by an appli-

cation. The procedures allow cursors to be re-used efficiently,

thereby avoiding server overhead, and also allow cursors to be named with character strings. TTkkAAllllooccCCuurrssoorrFFrroommOObbjj 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. TTkkAAllllooccCCuurrssoorrFFrroommOObbjj caches information about the | return value in objPtr, which speeds up future calls to procedures such | as TTkkAAllllooccCCuurrssoorrFFrroommOObbjj and TTkkGGeettCCuurrssoorrFFrroommOObbjj. If an error occurs in |

creating the cursor, such as when objPtr refers to a non-existent file, |

then NNoonnee 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 ccuurrssoorrccuurrssoorr..hh, without the

XXCC. Some example values are XXccuurrssoorr, hhaanndd22, or lleeffttppttrr. Ap-

pendix 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 TTkkGGeettCCoolloorr may be used). If only fgColor is

specified, then there will be no background color: the back-

ground 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 iibbeeaamm, ccrroosssshhaaiirr, wwaattcchh, pplluuss, and aarrrrooww. In addition, Tk will load Macintosh cursor resources of the types ccrrssrr (color) and CCUURRSS (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 TTkkGGeettCCoolloorr. 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 Macin-

tosh or Windows computers. @@sourceName This form only works on Windows, and will load a Windows system cursor (..aannii or ..ccuurr) from the file specified in sourceName. TTkkGGeettCCuurrssoorr is identical to TTkkAAllllooccCCuurrssoorrFFrroommOObbjj except that the | description of the cursor is specified with a string instead of an | object. This prevents TTkkGGeettCCuurrssoorr from caching the return value, so | TTkkGGeettCCuurrssoorr is less efficient than TTkkAAllllooccCCuurrssoorrFFrroommOObbjj. | TTkkGGeettCCuurrssoorrFFrroommOObbjj returns the token for an existing cursor, given the | window and description used to create the cursor. TTkkGGeettCCuurrssoorrFFrroommOObbjj | doesn't actually create the cursor; the cursor must already have been | created with a previous call to TTkkAAllllooccCCuurrssoorrFFrroommOObbjj or TTkkGGeettCCuurrssoorr. | The return value is cached in objPtr, which speeds up future calls to | TTkkGGeettCCuurrssoorrFFrroommOObbjj with the same objPtr and tkwin.

TTkkGGeettCCuurrssoorrFFrroommDDaattaa allows cursors to be created from in-memory

descriptions of their source and mask cursors. Source points to stan-

dard cursor data for the cursor's source bits, and mask points to stan-

dard cursor data describing which pixels of source are to be drawn and which are to be considered transparent. Width and height give the dimensions of the cursor, xHot and yHot indicate the location of the

cursor's hot-spot (the point that is reported when an event occurs),

and fg and bg describe the cursor's foreground and background colors textually (any of the forms suitable for TTkkGGeettCCoolloorr may be used).

Typically, the arguments to TTkkGGeettCCuurrssoorrFFrroommDDaattaa are created by includ-

ing a cursor file directly into the source code for a program, as in the following example: TkCursor cursor;

#include "source.cursor"

#include "mask.cursor"

cursor = TkGetCursorFromData(interp, tkwin, sourcebits, maskbits, sourcewidth, sourceheight, sourcexhot, sourceyhot, TkGetUid("red"), TkGetUid("blue")); Under normal conditions TTkkGGeettCCuurrssoorrFFrroommDDaattaa will return an identifier for the requested cursor. If an error occurs in creating the cursor then NNoonnee is returned and an error message will be stored in interp's result. TTkkAAllllooccCCuurrssoorrFFrroommOObbjj, TTkkGGeettCCuurrssoorr, and TTkkGGeettCCuurrssoorrFFrroommDDaattaa maintain a database of all the cursors they have created. Whenever possible, a call to TTkkAAllllooccCCuurrssoorrFFrroommOObbjj, TTkkGGeettCCuurrssoorr, or TTkkGGeettCCuurrssoorrFFrroommDDaattaa 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 XXCCrreeaattee-

FFoonnttCCuurrssoorr or XXCCrreeaatteePPiixxmmaappCCuurrssoorr, which create a new cursor on each

call. The Tk procedures are also more portable than the lower-level X

procedures. The procedure TTkkNNaammeeOOffCCuurrssoorr is roughly the inverse of TTkkGGeettCCuurrssoorr. If its cursor argument was created by TTkkGGeettCCuurrssoorr, then the return value is the name argument that was passed to TTkkGGeettCCuurrssoorr to create the cursor. If cursor was created by a call to TTkkGGeettCCuurrssoorrFFrroommDDaattaa, 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 TTkkNNaammeeOOffCCuurrssoorr is only guaranteed to persist until the next call to TTkkNNaammeeOOffCCuurrssoorr. Also, this call is not portable except for cursors returned by TTkkGGeettCCuurrssoorr. When a cursor returned by TTkkAAllllooccCCuurrssoorrFFrroommOObbjj, TTkkGGeettCCuurrssoorr, or | TTkkGGeettCCuurrssoorrFFrroommDDaattaa is no longer needed, TTkkFFrreeeeCCuurrssoorrFFrroommOObbjj or | TTkkFFrreeeeCCuurrssoorr should be called to release it. For TTkkFFrreeeeCCuurrssoorrFFrroommOObbjj | the cursor to release is specified with the same information used to | create it; for TTkkFFrreeeeCCuurrssoorr the cursor to release is specified with | its TkCursor token. There should be exactly one call to TTkkFFrreeeeCCuurrssoorr |

for each call to TTkkAAllllooccCCuurrssoorrFFrroommOObbjj, TTkkGGeettCCuurrssoorr, or TTkkGGeettCCuurrssoorr- |

FFrroommDDaattaa.

BUGS

In determining whether an existing cursor can be used to satisfy a new request, TTkkAAllllooccCCuurrssoorrFFrroommOObbjj, TTkkGGeettCCuurrssoorr, and TTkkGGeettCCuurrssoorrFFrroommDDaattaa consider only the immediate values of their arguments. For example, when a file name is passed to TTkkGGeettCCuurrssoorr, TTkkGGeettCCuurrssoorr 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, TTkkGGeettCCuurrssoorrFFrroommDDaattaa 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. KKEEYYWWOORRDDSS cursor Tk 8.1 TkAllocCursorFromObj(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™