OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / SGI / util / SGI / man / man3 / GetBitmap.3
1 '\"
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 '\" SCCS: @(#) GetBitmap.3 1.27 97/08/22 18:52:11
9 '\" 
10 '\" The definitions below are for supplemental macros used in Tcl/Tk
11 '\" manual entries.
12 '\"
13 '\" .AP type name in/out ?indent?
14 '\"     Start paragraph describing an argument to a library procedure.
15 '\"     type is type of argument (int, etc.), in/out is either "in", "out",
16 '\"     or "in/out" to describe whether procedure reads or modifies arg,
17 '\"     and indent is equivalent to second arg of .IP (shouldn't ever be
18 '\"     needed;  use .AS below instead)
19 '\"
20 '\" .AS ?type? ?name?
21 '\"     Give maximum sizes of arguments for setting tab stops.  Type and
22 '\"     name are examples of largest possible arguments that will be passed
23 '\"     to .AP later.  If args are omitted, default tab stops are used.
24 '\"
25 '\" .BS
26 '\"     Start box enclosure.  From here until next .BE, everything will be
27 '\"     enclosed in one large box.
28 '\"
29 '\" .BE
30 '\"     End of box enclosure.
31 '\"
32 '\" .CS
33 '\"     Begin code excerpt.
34 '\"
35 '\" .CE
36 '\"     End code excerpt.
37 '\"
38 '\" .VS ?version? ?br?
39 '\"     Begin vertical sidebar, for use in marking newly-changed parts
40 '\"     of man pages.  The first argument is ignored and used for recording
41 '\"     the version when the .VS was added, so that the sidebars can be
42 '\"     found and removed when they reach a certain age.  If another argument
43 '\"     is present, then a line break is forced before starting the sidebar.
44 '\"
45 '\" .VE
46 '\"     End of vertical sidebar.
47 '\"
48 '\" .DS
49 '\"     Begin an indented unfilled display.
50 '\"
51 '\" .DE
52 '\"     End of indented unfilled display.
53 '\"
54 '\" .SO
55 '\"     Start of list of standard options for a Tk widget.  The
56 '\"     options follow on successive lines, in four columns separated
57 '\"     by tabs.
58 '\"
59 '\" .SE
60 '\"     End of list of standard options for a Tk widget.
61 '\"
62 '\" .OP cmdName dbName dbClass
63 '\"     Start of description of a specific option.  cmdName gives the
64 '\"     option's name as specified in the class command, dbName gives
65 '\"     the option's name in the option database, and dbClass gives
66 '\"     the option's class in the option database.
67 '\"
68 '\" .UL arg1 arg2
69 '\"     Print arg1 underlined, then print arg2 normally.
70 '\"
71 '\" SCCS: @(#) man.macros 1.9 97/08/22 18:50:59
72 '\"
73 '\"     # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
74 .if t .wh -1.3i ^B
75 .nr ^l \n(.l
76 .ad b
77 '\"     # Start an argument description
78 .de AP
79 .ie !"\\$4"" .TP \\$4
80 .el \{\
81 .   ie !"\\$2"" .TP \\n()Cu
82 .   el          .TP 15
83 .\}
84 .ie !"\\$3"" \{\
85 .ta \\n()Au \\n()Bu
86 \&\\$1  \\fI\\$2\\fP    (\\$3)
87 .\".b
88 .\}
89 .el \{\
90 .br
91 .ie !"\\$2"" \{\
92 \&\\$1  \\fI\\$2\\fP
93 .\}
94 .el \{\
95 \&\\fI\\$1\\fP
96 .\}
97 .\}
98 ..
99 '\"     # define tabbing values for .AP
100 .de AS
101 .nr )A 10n
102 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
103 .nr )B \\n()Au+15n
104 .\"
105 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
106 .nr )C \\n()Bu+\\w'(in/out)'u+2n
107 ..
108 .AS Tcl_Interp Tcl_CreateInterp in/out
109 '\"     # BS - start boxed text
110 '\"     # ^y = starting y location
111 '\"     # ^b = 1
112 .de BS
113 .br
114 .mk ^y
115 .nr ^b 1u
116 .if n .nf
117 .if n .ti 0
118 .if n \l'\\n(.lu\(ul'
119 .if n .fi
120 ..
121 '\"     # BE - end boxed text (draw box now)
122 .de BE
123 .nf
124 .ti 0
125 .mk ^t
126 .ie n \l'\\n(^lu\(ul'
127 .el \{\
128 .\"     Draw four-sided box normally, but don't draw top of
129 .\"     box if the box started on an earlier page.
130 .ie !\\n(^b-1 \{\
131 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
132 .\}
133 .el \}\
134 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
135 .\}
136 .\}
137 .fi
138 .br
139 .nr ^b 0
140 ..
141 '\"     # VS - start vertical sidebar
142 '\"     # ^Y = starting y location
143 '\"     # ^v = 1 (for troff;  for nroff this doesn't matter)
144 .de VS
145 .if !"\\$2"" .br
146 .mk ^Y
147 .ie n 'mc \s12\(br\s0
148 .el .nr ^v 1u
149 ..
150 '\"     # VE - end of vertical sidebar
151 .de VE
152 .ie n 'mc
153 .el \{\
154 .ev 2
155 .nf
156 .ti 0
157 .mk ^t
158 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
159 .sp -1
160 .fi
161 .ev
162 .\}
163 .nr ^v 0
164 ..
165 '\"     # Special macro to handle page bottom:  finish off current
166 '\"     # box/sidebar if in box/sidebar mode, then invoked standard
167 '\"     # page bottom macro.
168 .de ^B
169 .ev 2
170 'ti 0
171 'nf
172 .mk ^t
173 .if \\n(^b \{\
174 .\"     Draw three-sided box if this is the box's first page,
175 .\"     draw two sides but no top otherwise.
176 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
177 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
178 .\}
179 .if \\n(^v \{\
180 .nr ^x \\n(^tu+1v-\\n(^Yu
181 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
182 .\}
183 .bp
184 'fi
185 .ev
186 .if \\n(^b \{\
187 .mk ^y
188 .nr ^b 2
189 .\}
190 .if \\n(^v \{\
191 .mk ^Y
192 .\}
193 ..
194 '\"     # DS - begin display
195 .de DS
196 .RS
197 .nf
198 .sp
199 ..
200 '\"     # DE - end display
201 .de DE
202 .fi
203 .RE
204 .sp
205 ..
206 '\"     # SO - start of list of standard options
207 .de SO
208 .SH "STANDARD OPTIONS"
209 .LP
210 .nf
211 .ta 4c 8c 12c
212 .ft B
213 ..
214 '\"     # SE - end of list of standard options
215 .de SE
216 .fi
217 .ft R
218 .LP
219 See the \\fBoptions\\fR manual entry for details on the standard options.
220 ..
221 '\"     # OP - start of full description for a single option
222 .de OP
223 .LP
224 .nf
225 .ta 4c
226 Command-Line Name:      \\fB\\$1\\fR
227 Database Name:  \\fB\\$2\\fR
228 Database Class: \\fB\\$3\\fR
229 .fi
230 .IP
231 ..
232 '\"     # CS - begin code excerpt
233 .de CS
234 .RS
235 .nf
236 .ta .25i .5i .75i 1i
237 ..
238 '\"     # CE - end code excerpt
239 .de CE
240 .fi
241 .RE
242 ..
243 .de UL
244 \\$1\l'|0\(ul'\\$2
245 ..
246 .TH Tk_GetBitmap 3 8.0 Tk "Tk Library Procedures"
247 .BS
248 .SH NAME
249 Tk_GetBitmap, Tk_DefineBitmap, Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeBitmap, Tk_GetBitmapFromData \- maintain database of single-plane pixmaps
250 .SH SYNOPSIS
251 .nf
252 \fB#include <tk.h>\fR
253 .sp
254 Pixmap
255 \fBTk_GetBitmap(\fIinterp, tkwin, id\fB)\fR
256 .sp
257 int
258 \fBTk_DefineBitmap(\fIinterp, nameId, source, width, height\fB)\fR
259 .sp
260 Tk_Uid
261 \fBTk_NameOfBitmap(\fIdisplay, bitmap\fB)\fR
262 .sp
263 \fBTk_SizeOfBitmap(\fIdisplay, bitmap, widthPtr, heightPtr\fB)\fR
264 .sp
265 \fBTk_FreeBitmap(\fIdisplay, bitmap\fB)\fR
266 .SH ARGUMENTS
267 .AS "unsigned long" *pixelPtr
268 .AP Tcl_Interp *interp in
269 Interpreter to use for error reporting.
270 .AP Tk_Window tkwin in
271 Token for window in which the bitmap will be used.
272 .AP Tk_Uid id in
273 Description of bitmap;  see below for possible values.
274 .AP Tk_Uid nameId in
275 Name for new bitmap to be defined.
276 .AP char *source in
277 Data for bitmap, in standard bitmap format.
278 Must be stored in static memory whose value will never change.
279 .AP "int" width in
280 Width of bitmap.
281 .AP "int" height in
282 Height of bitmap.
283 .AP "int" *widthPtr out
284 Pointer to word to fill in with \fIbitmap\fR's width.
285 .AP "int" *heightPtr out
286 Pointer to word to fill in with \fIbitmap\fR's height.
287 .AP Display *display in
288 Display for which \fIbitmap\fR was allocated.
289 .AP Pixmap bitmap in
290 Identifier for a bitmap allocated by \fBTk_GetBitmap\fR.
291 .BE
292
293 .SH DESCRIPTION
294 .PP
295 These procedures manage a collection of bitmaps (one-plane pixmaps)
296 being used by an application.  The procedures allow bitmaps to be
297 re-used efficiently, thereby avoiding server overhead, and also
298 allow bitmaps to be named with character strings.
299 .PP
300 \fBTk_GetBitmap\fR takes as argument a Tk_Uid describing a bitmap.
301 It returns a Pixmap identifier for a bitmap corresponding to the
302 description.  It re-uses an existing bitmap, if possible, and
303 creates a new one otherwise.  At present, \fIid\fR must have
304 one of the following forms:
305 .TP 20
306 \fB@\fIfileName\fR
307 \fIFileName\fR must be the name of a file containing a bitmap
308 description in the standard X11 or X10 format.
309 .TP 20
310 \fIname\fR
311 \fIName\fR must be the name of a bitmap defined previously with
312 a call to \fBTk_DefineBitmap\fR.  The following names are pre-defined
313 by Tk:
314 .RS
315 .TP 12
316 \fBerror\fR
317 The international "don't" symbol:  a circle with a diagonal line
318 across it.
319 .VS "" br
320 .TP 12
321 \fBgray75\fR
322 75% gray: a checkerboard pattern where three out of four bits are on.
323 .VE
324 .TP 12
325 \fBgray50\fR
326 50% gray: a checkerboard pattern where every other bit is on.
327 .VS "" br
328 .TP 12
329 \fBgray25\fR
330 25% gray: a checkerboard pattern where one out of every four bits is on.
331 .VE
332 .TP 12
333 \fBgray12\fR
334 12.5% gray: a pattern where one-eighth of the bits are on, consisting of
335 every fourth pixel in every other row.
336 .TP 12
337 \fBhourglass\fR
338 An hourglass symbol.
339 .TP 12
340 \fBinfo\fR
341 A large letter ``i''.
342 .TP 12
343 \fBquesthead\fR
344 The silhouette of a human head, with a question mark in it.
345 .TP 12
346 \fBquestion\fR
347 A large question-mark.
348 .TP 12
349 \fBwarning\fR
350 A large exclamation point.
351 .PP
352 In addition, the following pre-defined names are available only on the
353 \fBMacintosh\fR platform:
354 .TP 12
355 \fBdocument\fR
356 A generic document.
357 .TP 12
358 \fBstationery\fR
359 Document stationery.
360 .TP 12
361 \fBedition\fR
362 The \fIedition\fR symbol.
363 .TP 12
364 \fBapplication\fR
365 Generic application icon.
366 .TP 12
367 \fBaccessory\fR
368 A desk accessory.
369 .TP 12
370 \fBfolder\fR
371 Generic folder icon.
372 .TP 12
373 \fBpfolder\fR
374 A locked folder.
375 .TP 12
376 \fBtrash\fR
377 A trash can.
378 .TP 12
379 \fBfloppy\fR
380 A floppy disk.
381 .TP 12
382 \fBramdisk\fR
383 A floppy disk with chip.
384 .TP 12
385 \fBcdrom\fR
386 A cd disk icon.
387 .TP 12
388 \fBpreferences\fR
389 A folder with prefs symbol.
390 .TP 12
391 \fBquerydoc\fR
392 A database document icon.
393 .TP 12
394 \fBstop\fR
395 A stop sign.
396 .TP 12
397 \fBnote\fR
398 A face with ballon words.
399 .TP 12
400 \fBcaution\fR
401 A triangle with an exclamation point.
402 .RE
403 .LP
404 Under normal conditions, \fBTk_GetBitmap\fR
405 returns an identifier for the requested bitmap.  If an error
406 occurs in creating the bitmap, such as when \fIid\fR refers
407 to a non-existent file, then \fBNone\fR is returned and an error
408 message is left in \fIinterp->result\fR.
409 .PP
410 \fBTk_DefineBitmap\fR associates a name with
411 in-memory bitmap data so that the name can be used in later
412 calls to \fBTk_GetBitmap\fR.  The \fInameId\fR
413 argument gives a name for the bitmap;  it must not previously
414 have been used in a call to \fBTk_DefineBitmap\fR.
415 The arguments \fIsource\fR, \fIwidth\fR, and \fIheight\fR
416 describe the bitmap.
417 \fBTk_DefineBitmap\fR normally returns TCL_OK;  if an error occurs
418 (e.g. a bitmap named \fInameId\fR has already been defined) then
419 TCL_ERROR is returned and an error message is left in
420 \fIinterp->result\fR.
421 Note:  \fBTk_DefineBitmap\fR expects the memory pointed to by
422 \fIsource\fR to be static:  \fBTk_DefineBitmap\fR doesn't make
423 a private copy of this memory, but uses the bytes pointed to
424 by \fIsource\fR later in calls to \fBTk_GetBitmap\fR.
425 .PP
426 Typically \fBTk_DefineBitmap\fR is used by \fB#include\fR-ing a
427 bitmap file directly into a C program and then referencing
428 the variables defined by the file.
429 For example, suppose there exists a file \fBstip.bitmap\fR,
430 which was created by the \fBbitmap\fR program and contains
431 a stipple pattern.
432 The following code uses \fBTk_DefineBitmap\fR to define a
433 new bitmap named \fBfoo\fR:
434 .CS
435 Pixmap bitmap;
436 #include "stip.bitmap"
437 Tk_DefineBitmap(interp, Tk_GetUid("foo"), stip_bits,
438         stip_width, stip_height);
439 \&...
440 bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("foo"));
441 .CE
442 This code causes the bitmap file to be read
443 at compile-time and incorporates the bitmap information into
444 the program's executable image.  The same bitmap file could be
445 read at run-time using \fBTk_GetBitmap\fR:
446 .CS
447 Pixmap bitmap;
448 bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("@stip.bitmap"));
449 .CE
450 The second form is a bit more flexible (the file could be modified
451 after the program has been compiled, or a different string could be
452 provided to read a different file), but it is a little slower and
453 requires the bitmap file to exist separately from the program.
454 .PP
455 \fBTk_GetBitmap\fR maintains a
456 database of all the bitmaps that are currently in use.
457 Whenever possible, it will return an existing bitmap rather
458 than creating a new one.
459 This approach can substantially reduce server overhead, so
460 \fBTk_GetBitmap\fR should generally be used in preference to Xlib
461 procedures like \fBXReadBitmapFile\fR.
462 .PP
463 The bitmaps returned by \fBTk_GetBitmap\fR
464 are shared, so callers should never modify them.
465 If a bitmap must be modified dynamically, then it should be
466 created by calling Xlib procedures such as \fBXReadBitmapFile\fR
467 or \fBXCreatePixmap\fR directly.
468 .PP
469 The procedure \fBTk_NameOfBitmap\fR is roughly the inverse of
470 \fBTk_GetBitmap\fR.
471 Given an X Pixmap argument, it returns the \fIid\fR that was
472 passed to \fBTk_GetBitmap\fR when the bitmap was created.
473 \fIBitmap\fR must have been the return value from a previous
474 call to \fBTk_GetBitmap\fR.
475 .PP
476 \fBTk_SizeOfBitmap\fR returns the dimensions of its \fIbitmap\fR
477 argument in the words pointed to by the \fIwidthPtr\fR and
478 \fIheightPtr\fR arguments.  As with \fBTk_NameOfBitmap\fR,
479 \fIbitmap\fR must have been created by \fBTk_GetBitmap\fR.
480 .PP
481 When a bitmap returned by \fBTk_GetBitmap\fR
482 is no longer needed, \fBTk_FreeBitmap\fR should be called to release it.
483 There should be exactly one call to \fBTk_FreeBitmap\fR for
484 each call to \fBTk_GetBitmap\fR.
485 When a bitmap is no longer in use anywhere (i.e. it has been freed as
486 many times as it has been gotten) \fBTk_FreeBitmap\fR will release
487 it to the X server and delete it from the database.
488
489 .SH BUGS
490 In determining whether an existing bitmap can be used to satisfy
491 a new request, \fBTk_GetBitmap\fR
492 considers only the immediate value of its \fIid\fR argument.  For
493 example, when a file name is passed to \fBTk_GetBitmap\fR,
494 \fBTk_GetBitmap\fR will assume it is safe to re-use an existing
495 bitmap created from the same file name:  it will not check to
496 see whether the file itself has changed, or whether the current
497 directory has changed, thereby causing the name to refer to
498 a different file.
499
500 .SH KEYWORDS
501 bitmap, pixmap