OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tk/] [doc/] [GetCursor.3] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
2
'\" Copyright (c) 1990 The Regents of the University of California.
3
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4
'\"
5
'\" See the file "license.terms" for information on usage and redistribution
6
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7
'\"
8
'\" RCS: @(#) $Id: GetCursor.3,v 1.1.1.1 2002-01-16 10:25:48 markom Exp $
9
'\"
10
.so man.macros
11
.TH Tk_GetCursor 3 4.1 Tk "Tk Library Procedures"
12
.BS
13
.SH NAME
14
Tk_GetCursor, Tk_GetCursorFromData, Tk_NameOfCursor, Tk_FreeCursor \- maintain database of cursors
15
.SH SYNOPSIS
16
.nf
17
\fB#include \fR
18
.sp
19
Tk_Cursor
20
\fBTk_GetCursor(\fIinterp, tkwin, nameId\fB)\fR
21
.sp
22
Tk_Cursor
23
\fBTk_GetCursorFromData(\fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bg\fB)\fR
24
.sp
25
char *
26
\fBTk_NameOfCursor(\fIdisplay, cursor\fB)\fR
27
.sp
28
\fBTk_FreeCursor(\fIdisplay, cursor\fB)\fR
29
.SH ARGUMENTS
30
.AS "unsigned long" *pixelPtr
31
.AP Tcl_Interp *interp in
32
Interpreter to use for error reporting.
33
.AP Tk_Window tkwin in
34
Token for window in which the cursor will be used.
35
.AP Tk_Uid nameId in
36
Description of cursor;  see below for possible values.
37
.AP char *source in
38
Data for cursor bitmap, in standard bitmap format.
39
.AP char *mask in
40
Data for mask bitmap, in standard bitmap format.
41
.AP "int" width in
42
Width of \fIsource\fR and \fImask\fR.
43
.AP "int" height in
44
Height of \fIsource\fR and \fImask\fR.
45
.AP "int" xHot in
46
X-location of cursor hot-spot.
47
.AP "int" yHot in
48
Y-location of cursor hot-spot.
49
.AP Tk_Uid fg in
50
Textual description of foreground color for cursor.
51
.AP Tk_Uid bg in
52
Textual description of background color for cursor.
53
.AP Display *display in
54
Display for which \fIcursor\fR was allocated.
55
.AP Tk_Cursor cursor in
56
Opaque Tk identifier for cursor.  If passed to\fBTk_FreeCursor\fR, must
57
have been returned by some previous call to \fBTk_GetCursor\fR or
58
\fBTk_GetCursorFromData\fR.
59
.BE
60
 
61
.SH DESCRIPTION
62
.PP
63
These procedures manage a collection of cursors
64
being used by an application.  The procedures allow cursors to be
65
re-used efficiently, thereby avoiding server overhead, and also
66
allow cursors to be named with character strings (actually Tk_Uids).
67
.PP
68
\fBTk_GetCursor\fR takes as argument a Tk_Uid describing a cursor,
69
and returns an opaque Tk identifier for a cursor corresponding to the
70
description.
71
It re-uses an existing cursor if possible and
72
creates a new one otherwise.  \fINameId\fR must be a standard Tcl
73
list with one of the following forms:
74
.TP
75
\fIname\fR\0[\fIfgColor\fR\0[\fIbgColor\fR]]
76
\fIName\fR is the name of a cursor in the standard X cursor font,
77
i.e., any of the names defined in \fBcursorfont.h\fR, without
78
the \fBXC_\fR.  Some example values are \fBX_cursor\fR, \fBhand2\fR,
79
or \fBleft_ptr\fR.  Appendix B of ``The X Window System''
80
by Scheifler & Gettys has illustrations showing what each of these
81
cursors looks like.  If \fIfgColor\fR and \fIbgColor\fR are both
82
specified, they give the foreground and background colors to use
83
for the cursor (any of the forms acceptable to \fBTk_GetColor\fR
84
may be used).  If only \fIfgColor\fR is specified, then there
85
will be no background color:  the background will be transparent.
86
If no colors are specified, then the cursor
87
will use black for its foreground color and white for its background
88
color.
89
 
90
The Macintosh version of Tk also supports all of the X cursors.
91
Tk on the Mac will also accept any of the standard Mac cursors
92
including \fBibeam\fR, \fBcrosshair\fR, \fBwatch\fR, \fBplus\fR, and
93
\fBarrow\fR.  In addition, Tk will load Macintosh cursor resources of
94
the types \fBcrsr\fR (color) and \fBCURS\fR (black and white) by the
95
name of the of the resource.  The application and all its open
96
dynamic library's resource files will be searched for the named
97
cursor.  If there are conflicts color cursors will always be loaded
98
in preference to black and white cursors.
99
.TP
100
\fB@\fIsourceName\0maskName\0fgColor\0bgColor\fR
101
In this form, \fIsourceName\fR and \fImaskName\fR are the names of
102
files describing bitmaps for the cursor's source bits and mask.
103
Each file must be in standard X11 or X10 bitmap format.
104
\fIFgColor\fR and \fIbgColor\fR
105
indicate the colors to use for the
106
cursor, in any of the forms acceptable to \fBTk_GetColor\fR.  This
107
form of the command will not work on Macintosh or Windows computers.
108
.TP
109
\fB@\fIsourceName\0fgColor\fR
110
This form is similar to the one above, except that the source is
111
used as mask also.  This means that the cursor's background is
112
transparent.  This form of the command will not work on Macintosh
113
or Windows computers.
114
.PP
115
\fBTk_GetCursorFromData\fR allows cursors to be created from
116
in-memory descriptions of their source and mask bitmaps.  \fISource\fR
117
points to standard bitmap data for the cursor's source bits, and
118
\fImask\fR points to standard bitmap data describing
119
which pixels of \fIsource\fR are to be drawn and which are to be
120
considered transparent.  \fIWidth\fR and \fIheight\fR give the
121
dimensions of the cursor, \fIxHot\fR and \fIyHot\fR indicate the
122
location of the cursor's hot-spot (the point that is reported when
123
an event occurs), and \fIfg\fR and \fIbg\fR describe the cursor's
124
foreground and background colors textually (any of the forms
125
suitable for \fBTk_GetColor\fR may be used).  Typically, the
126
arguments to \fBTk_GetCursorFromData\fR are created by including
127
a cursor file directly into the source code for a program, as in
128
the following example:
129
.CS
130
Tk_Cursor cursor;
131
#include "source.cursor"
132
#include "mask.cursor"
133
cursor = Tk_GetCursorFromData(interp, tkwin, source_bits,
134
        mask_bits, source_width, source_height, source_x_hot,
135
        source_y_hot, Tk_GetUid("red"), Tk_GetUid("blue"));
136
.CE
137
.PP
138
Under normal conditions, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR
139
will return an identifier for the requested cursor.  If an error
140
occurs in creating the cursor, such as when \fInameId\fR refers
141
to a non-existent file, then \fBNone\fR is returned and an error
142
message will be stored in \fIinterp->result\fR.
143
.PP
144
\fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR maintain a
145
database of all the cursors they have created.  Whenever possible,
146
a call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR will
147
return an existing cursor rather than creating a new one.  This
148
approach can substantially reduce server overhead, so the Tk
149
procedures should generally be used in preference to Xlib procedures
150
like \fBXCreateFontCursor\fR or \fBXCreatePixmapCursor\fR, which
151
create a new cursor on each call.
152
.PP
153
The procedure \fBTk_NameOfCursor\fR is roughly the inverse of
154
\fBTk_GetCursor\fR.  If its \fIcursor\fR argument was created
155
by \fBTk_GetCursor\fR, then the return value is the \fInameId\fR
156
argument that was passed to \fBTk_GetCursor\fR to create the
157
cursor.  If \fIcursor\fR was created by a call to \fBTk_GetCursorFromData\fR,
158
or by any other mechanism, then the return value is a hexadecimal string
159
giving the X identifier for the cursor.
160
Note:  the string returned by \fBTk_NameOfCursor\fR is
161
only guaranteed to persist until the next call to
162
\fBTk_NameOfCursor\fR.  Also, this call is not portable except for
163
cursors returned by \fBTk_GetCursor\fR.
164
.PP
165
When a cursor returned by \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR
166
is no longer needed, \fBTk_FreeCursor\fR should be called to release it.
167
There should be exactly one call to \fBTk_FreeCursor\fR for
168
each call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR.
169
When a cursor is no longer in use anywhere (i.e. it has been freed as
170
many times as it has been gotten) \fBTk_FreeCursor\fR will release
171
it to the X server and remove it from the database.
172
 
173
.SH BUGS
174
In determining whether an existing cursor can be used to satisfy
175
a new request, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR
176
consider only the immediate values of their arguments.  For
177
example, when a file name is passed to \fBTk_GetCursor\fR,
178
\fBTk_GetCursor\fR will assume it is safe to re-use an existing
179
cursor created from the same file name:  it will not check to
180
see whether the file itself has changed, or whether the current
181
directory has changed, thereby causing the name to refer to
182
a different file.  Similarly, \fBTk_GetCursorFromData\fR assumes
183
that if the same \fIsource\fR pointer is used in two different calls,
184
then the pointers refer to the same data;  it does not check to
185
see if the actual data values have changed.
186
 
187
.SH KEYWORDS
188
cursor

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.