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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [tk/] [doc/] [GetBitmap.3] - Blame information for rev 1765

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: GetBitmap.3,v 1.1.1.1 2002-01-16 10:25:48 markom Exp $
9
'\"
10
.so man.macros
11
.TH Tk_GetBitmap 3 8.0 Tk "Tk Library Procedures"
12
.BS
13
.SH NAME
14
Tk_GetBitmap, Tk_DefineBitmap, Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeBitmap, Tk_GetBitmapFromData \- maintain database of single-plane pixmaps
15
.SH SYNOPSIS
16
.nf
17
\fB#include \fR
18
.sp
19
Pixmap
20
\fBTk_GetBitmap(\fIinterp, tkwin, id\fB)\fR
21
.sp
22
int
23
\fBTk_DefineBitmap(\fIinterp, nameId, source, width, height\fB)\fR
24
.sp
25
Tk_Uid
26
\fBTk_NameOfBitmap(\fIdisplay, bitmap\fB)\fR
27
.sp
28
\fBTk_SizeOfBitmap(\fIdisplay, bitmap, widthPtr, heightPtr\fB)\fR
29
.sp
30
\fBTk_FreeBitmap(\fIdisplay, bitmap\fB)\fR
31
.SH ARGUMENTS
32
.AS "unsigned long" *pixelPtr
33
.AP Tcl_Interp *interp in
34
Interpreter to use for error reporting.
35
.AP Tk_Window tkwin in
36
Token for window in which the bitmap will be used.
37
.AP Tk_Uid id in
38
Description of bitmap;  see below for possible values.
39
.AP Tk_Uid nameId in
40
Name for new bitmap to be defined.
41
.AP char *source in
42
Data for bitmap, in standard bitmap format.
43
Must be stored in static memory whose value will never change.
44
.AP "int" width in
45
Width of bitmap.
46
.AP "int" height in
47
Height of bitmap.
48
.AP "int" *widthPtr out
49
Pointer to word to fill in with \fIbitmap\fR's width.
50
.AP "int" *heightPtr out
51
Pointer to word to fill in with \fIbitmap\fR's height.
52
.AP Display *display in
53
Display for which \fIbitmap\fR was allocated.
54
.AP Pixmap bitmap in
55
Identifier for a bitmap allocated by \fBTk_GetBitmap\fR.
56
.BE
57
 
58
.SH DESCRIPTION
59
.PP
60
These procedures manage a collection of bitmaps (one-plane pixmaps)
61
being used by an application.  The procedures allow bitmaps to be
62
re-used efficiently, thereby avoiding server overhead, and also
63
allow bitmaps to be named with character strings.
64
.PP
65
\fBTk_GetBitmap\fR takes as argument a Tk_Uid describing a bitmap.
66
It returns a Pixmap identifier for a bitmap corresponding to the
67
description.  It re-uses an existing bitmap, if possible, and
68
creates a new one otherwise.  At present, \fIid\fR must have
69
one of the following forms:
70
.TP 20
71
\fB@\fIfileName\fR
72
\fIFileName\fR must be the name of a file containing a bitmap
73
description in the standard X11 or X10 format.
74
.TP 20
75
\fIname\fR
76
\fIName\fR must be the name of a bitmap defined previously with
77
a call to \fBTk_DefineBitmap\fR.  The following names are pre-defined
78
by Tk:
79
.RS
80
.TP 12
81
\fBerror\fR
82
The international "don't" symbol:  a circle with a diagonal line
83
across it.
84
.VS "" br
85
.TP 12
86
\fBgray75\fR
87
75% gray: a checkerboard pattern where three out of four bits are on.
88
.VE
89
.TP 12
90
\fBgray50\fR
91
50% gray: a checkerboard pattern where every other bit is on.
92
.VS "" br
93
.TP 12
94
\fBgray25\fR
95
25% gray: a checkerboard pattern where one out of every four bits is on.
96
.VE
97
.TP 12
98
\fBgray12\fR
99
12.5% gray: a pattern where one-eighth of the bits are on, consisting of
100
every fourth pixel in every other row.
101
.TP 12
102
\fBhourglass\fR
103
An hourglass symbol.
104
.TP 12
105
\fBinfo\fR
106
A large letter ``i''.
107
.TP 12
108
\fBquesthead\fR
109
The silhouette of a human head, with a question mark in it.
110
.TP 12
111
\fBquestion\fR
112
A large question-mark.
113
.TP 12
114
\fBwarning\fR
115
A large exclamation point.
116
.PP
117
In addition, the following pre-defined names are available only on the
118
\fBMacintosh\fR platform:
119
.TP 12
120
\fBdocument\fR
121
A generic document.
122
.TP 12
123
\fBstationery\fR
124
Document stationery.
125
.TP 12
126
\fBedition\fR
127
The \fIedition\fR symbol.
128
.TP 12
129
\fBapplication\fR
130
Generic application icon.
131
.TP 12
132
\fBaccessory\fR
133
A desk accessory.
134
.TP 12
135
\fBfolder\fR
136
Generic folder icon.
137
.TP 12
138
\fBpfolder\fR
139
A locked folder.
140
.TP 12
141
\fBtrash\fR
142
A trash can.
143
.TP 12
144
\fBfloppy\fR
145
A floppy disk.
146
.TP 12
147
\fBramdisk\fR
148
A floppy disk with chip.
149
.TP 12
150
\fBcdrom\fR
151
A cd disk icon.
152
.TP 12
153
\fBpreferences\fR
154
A folder with prefs symbol.
155
.TP 12
156
\fBquerydoc\fR
157
A database document icon.
158
.TP 12
159
\fBstop\fR
160
A stop sign.
161
.TP 12
162
\fBnote\fR
163
A face with ballon words.
164
.TP 12
165
\fBcaution\fR
166
A triangle with an exclamation point.
167
.RE
168
.LP
169
Under normal conditions, \fBTk_GetBitmap\fR
170
returns an identifier for the requested bitmap.  If an error
171
occurs in creating the bitmap, such as when \fIid\fR refers
172
to a non-existent file, then \fBNone\fR is returned and an error
173
message is left in \fIinterp->result\fR.
174
.PP
175
\fBTk_DefineBitmap\fR associates a name with
176
in-memory bitmap data so that the name can be used in later
177
calls to \fBTk_GetBitmap\fR.  The \fInameId\fR
178
argument gives a name for the bitmap;  it must not previously
179
have been used in a call to \fBTk_DefineBitmap\fR.
180
The arguments \fIsource\fR, \fIwidth\fR, and \fIheight\fR
181
describe the bitmap.
182
\fBTk_DefineBitmap\fR normally returns TCL_OK;  if an error occurs
183
(e.g. a bitmap named \fInameId\fR has already been defined) then
184
TCL_ERROR is returned and an error message is left in
185
\fIinterp->result\fR.
186
Note:  \fBTk_DefineBitmap\fR expects the memory pointed to by
187
\fIsource\fR to be static:  \fBTk_DefineBitmap\fR doesn't make
188
a private copy of this memory, but uses the bytes pointed to
189
by \fIsource\fR later in calls to \fBTk_GetBitmap\fR.
190
.PP
191
Typically \fBTk_DefineBitmap\fR is used by \fB#include\fR-ing a
192
bitmap file directly into a C program and then referencing
193
the variables defined by the file.
194
For example, suppose there exists a file \fBstip.bitmap\fR,
195
which was created by the \fBbitmap\fR program and contains
196
a stipple pattern.
197
The following code uses \fBTk_DefineBitmap\fR to define a
198
new bitmap named \fBfoo\fR:
199
.CS
200
Pixmap bitmap;
201
#include "stip.bitmap"
202
Tk_DefineBitmap(interp, Tk_GetUid("foo"), stip_bits,
203
        stip_width, stip_height);
204
\&...
205
bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("foo"));
206
.CE
207
This code causes the bitmap file to be read
208
at compile-time and incorporates the bitmap information into
209
the program's executable image.  The same bitmap file could be
210
read at run-time using \fBTk_GetBitmap\fR:
211
.CS
212
Pixmap bitmap;
213
bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("@stip.bitmap"));
214
.CE
215
The second form is a bit more flexible (the file could be modified
216
after the program has been compiled, or a different string could be
217
provided to read a different file), but it is a little slower and
218
requires the bitmap file to exist separately from the program.
219
.PP
220
\fBTk_GetBitmap\fR maintains a
221
database of all the bitmaps that are currently in use.
222
Whenever possible, it will return an existing bitmap rather
223
than creating a new one.
224
This approach can substantially reduce server overhead, so
225
\fBTk_GetBitmap\fR should generally be used in preference to Xlib
226
procedures like \fBXReadBitmapFile\fR.
227
.PP
228
The bitmaps returned by \fBTk_GetBitmap\fR
229
are shared, so callers should never modify them.
230
If a bitmap must be modified dynamically, then it should be
231
created by calling Xlib procedures such as \fBXReadBitmapFile\fR
232
or \fBXCreatePixmap\fR directly.
233
.PP
234
The procedure \fBTk_NameOfBitmap\fR is roughly the inverse of
235
\fBTk_GetBitmap\fR.
236
Given an X Pixmap argument, it returns the \fIid\fR that was
237
passed to \fBTk_GetBitmap\fR when the bitmap was created.
238
\fIBitmap\fR must have been the return value from a previous
239
call to \fBTk_GetBitmap\fR.
240
.PP
241
\fBTk_SizeOfBitmap\fR returns the dimensions of its \fIbitmap\fR
242
argument in the words pointed to by the \fIwidthPtr\fR and
243
\fIheightPtr\fR arguments.  As with \fBTk_NameOfBitmap\fR,
244
\fIbitmap\fR must have been created by \fBTk_GetBitmap\fR.
245
.PP
246
When a bitmap returned by \fBTk_GetBitmap\fR
247
is no longer needed, \fBTk_FreeBitmap\fR should be called to release it.
248
There should be exactly one call to \fBTk_FreeBitmap\fR for
249
each call to \fBTk_GetBitmap\fR.
250
When a bitmap is no longer in use anywhere (i.e. it has been freed as
251
many times as it has been gotten) \fBTk_FreeBitmap\fR will release
252
it to the X server and delete it from the database.
253
 
254
.SH BUGS
255
In determining whether an existing bitmap can be used to satisfy
256
a new request, \fBTk_GetBitmap\fR
257
considers only the immediate value of its \fIid\fR argument.  For
258
example, when a file name is passed to \fBTk_GetBitmap\fR,
259
\fBTk_GetBitmap\fR will assume it is safe to re-use an existing
260
bitmap created from the same file name:  it will not check to
261
see whether the file itself has changed, or whether the current
262
directory has changed, thereby causing the name to refer to
263
a different file.
264
 
265
.SH KEYWORDS
266
bitmap, pixmap

powered by: WebSVN 2.1.0

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