OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / CELLLINUX64 / util / CELLLINUX64 / man / man3 / Tk_GetBitmapFromObj.3
1 '\"
2 '\" Copyright (c) 1990 The Regents of the University of California.
3 '\" Copyright (c) 1994-1998 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.5 2002/08/08 01:43:10 hobbs Exp $
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 '\" RCS: @(#) $Id: man.macros,v 1.4 2000/08/25 06:18:32 ericm Exp $
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 .ta \\n()Au \\n()Bu
85 .ie !"\\$3"" \{\
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 5.5c 11c
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_AllocBitmapFromObj 3 8.1 Tk "Tk Library Procedures"
247 .BS
248 .SH NAME
249 Tk_AllocBitmapFromObj, Tk_GetBitmap, Tk_GetBitmapFromObj, Tk_DefineBitmap, Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeBitmapFromObj, Tk_FreeBitmap \- maintain database of single-plane pixmaps
250 .SH SYNOPSIS
251 .nf
252 \fB#include <tk.h>\fR
253 .sp
254 .VS 8.1
255 Pixmap
256 \fBTk_GetBitmapFromObj(\fIinterp, tkwin, objPtr\fB)\fR
257 .sp
258 Pixmap
259 \fBTk_GetBitmap(\fIinterp, tkwin, info\fB)\fR
260 .sp
261 Pixmap
262 \fBTk_GetBitmapFromObj(\fItkwin, objPtr\fB)\fR
263 .VE
264 .sp
265 int
266 \fBTk_DefineBitmap(\fIinterp, name, source, width, height\fB)\fR
267 .sp
268 CONST char *
269 \fBTk_NameOfBitmap(\fIdisplay, bitmap\fB)\fR
270 .sp
271 \fBTk_SizeOfBitmap(\fIdisplay, bitmap, widthPtr, heightPtr\fB)\fR
272 .sp
273 .VS 8.1
274 \fBTk_FreeBitmapFromObj(\fItkwin, objPtr\fB)\fR
275 .VE
276 .sp
277 \fBTk_FreeBitmap(\fIdisplay, bitmap\fB)\fR
278 .SH ARGUMENTS
279 .AS "unsigned long" *pixelPtr
280 .AP Tcl_Interp *interp in
281 Interpreter to use for error reporting; if NULL then no error message
282 is left after errors.
283 .AP Tk_Window tkwin in
284 Token for window in which the bitmap will be used.
285 .VS 8.1 br
286 .AP Tcl_Obj *objPtr in/out
287 String value describes desired bitmap; internal rep will be
288 modified to cache pointer to corresponding Pixmap.
289 .AP "CONST char" *info in
290 Same as \fIobjPtr\fR except description of bitmap is passed as a string and
291 resulting Pixmap isn't cached.
292 .VE
293 .AP "CONST char" *name in
294 Name for new bitmap to be defined.
295 .AP "CONST char" *source in
296 Data for bitmap, in standard bitmap format.
297 Must be stored in static memory whose value will never change.
298 .AP "int" width in
299 Width of bitmap.
300 .AP "int" height in
301 Height of bitmap.
302 .AP "int" *widthPtr out
303 Pointer to word to fill in with \fIbitmap\fR's width.
304 .AP "int" *heightPtr out
305 Pointer to word to fill in with \fIbitmap\fR's height.
306 .AP Display *display in
307 Display for which \fIbitmap\fR was allocated.
308 .AP Pixmap bitmap in
309 Identifier for a bitmap allocated by \fBTk_AllocBitmapFromObj\fR or
310 \fBTk_GetBitmap\fR.
311 .BE
312
313 .SH DESCRIPTION
314 .PP
315 These procedures manage a collection of bitmaps (one-plane pixmaps)
316 being used by an application.  The procedures allow bitmaps to be
317 re-used efficiently, thereby avoiding server overhead, and also
318 allow bitmaps to be named with character strings.
319 .PP
320 .VS 8.1
321 \fBTk_AllocBitmapFromObj\fR returns a Pixmap identifier for a bitmap
322 that matches the description in \fIobjPtr\fR and is suitable for use
323 in \fItkwin\fR.  It re-uses an existing bitmap, if possible, and
324 creates a new one otherwise.  \fIObjPtr\fR's value must have one
325 of the following forms:
326 .VE
327 .TP 20
328 \fB@\fIfileName\fR
329 \fIFileName\fR must be the name of a file containing a bitmap
330 description in the standard X11 or X10 format.
331 .TP 20
332 \fIname\fR
333 \fIName\fR must be the name of a bitmap defined previously with
334 a call to \fBTk_DefineBitmap\fR.  The following names are pre-defined
335 by Tk:
336 .RS
337 .TP 12
338 \fBerror\fR
339 The international "don't" symbol:  a circle with a diagonal line
340 across it.
341 .VS "" br
342 .TP 12
343 \fBgray75\fR
344 75% gray: a checkerboard pattern where three out of four bits are on.
345 .VE
346 .TP 12
347 \fBgray50\fR
348 50% gray: a checkerboard pattern where every other bit is on.
349 .VS "" br
350 .TP 12
351 \fBgray25\fR
352 25% gray: a checkerboard pattern where one out of every four bits is on.
353 .VE
354 .TP 12
355 \fBgray12\fR
356 12.5% gray: a pattern where one-eighth of the bits are on, consisting of
357 every fourth pixel in every other row.
358 .TP 12
359 \fBhourglass\fR
360 An hourglass symbol.
361 .TP 12
362 \fBinfo\fR
363 A large letter ``i''.
364 .TP 12
365 \fBquesthead\fR
366 The silhouette of a human head, with a question mark in it.
367 .TP 12
368 \fBquestion\fR
369 A large question-mark.
370 .TP 12
371 \fBwarning\fR
372 A large exclamation point.
373 .PP
374 In addition, the following pre-defined names are available only on the
375 \fBMacintosh\fR platform:
376 .TP 12
377 \fBdocument\fR
378 A generic document.
379 .TP 12
380 \fBstationery\fR
381 Document stationery.
382 .TP 12
383 \fBedition\fR
384 The \fIedition\fR symbol.
385 .TP 12
386 \fBapplication\fR
387 Generic application icon.
388 .TP 12
389 \fBaccessory\fR
390 A desk accessory.
391 .TP 12
392 \fBfolder\fR
393 Generic folder icon.
394 .TP 12
395 \fBpfolder\fR
396 A locked folder.
397 .TP 12
398 \fBtrash\fR
399 A trash can.
400 .TP 12
401 \fBfloppy\fR
402 A floppy disk.
403 .TP 12
404 \fBramdisk\fR
405 A floppy disk with chip.
406 .TP 12
407 \fBcdrom\fR
408 A cd disk icon.
409 .TP 12
410 \fBpreferences\fR
411 A folder with prefs symbol.
412 .TP 12
413 \fBquerydoc\fR
414 A database document icon.
415 .TP 12
416 \fBstop\fR
417 A stop sign.
418 .TP 12
419 \fBnote\fR
420 A face with ballon words.
421 .TP 12
422 \fBcaution\fR
423 A triangle with an exclamation point.
424 .RE
425 .LP
426 .VS 8.1
427 Under normal conditions, \fBTk_AllocBitmapFromObj\fR
428 returns an identifier for the requested bitmap.  If an error
429 occurs in creating the bitmap, such as when \fIobjPtr\fR refers
430 to a non-existent file, then \fBNone\fR is returned and an error
431 message is left in \fIinterp\fR's result if \fIinterp\fR isn't
432 NULL. \fBTk_AllocBitmapFromObj\fR caches information about the return
433 value in \fIobjPtr\fR, which speeds up future calls to procedures
434 such as \fBTk_AllocBitmapFromObj\fR and \fBTk_GetBitmapFromObj\fR.
435 .PP
436 \fBTk_GetBitmap\fR is identical to \fBTk_AllocBitmapFromObj\fR except
437 that the description of the bitmap is specified with a string instead
438 of an object.  This prevents \fBTk_GetBitmap\fR from caching the
439 return value, so \fBTk_GetBitmap\fR is less efficient than
440 \fBTk_AllocBitmapFromObj\fR.
441 .PP
442 \fBTk_GetBitmapFromObj\fR returns the token for an existing bitmap, given
443 the window and description used to create the bitmap.
444 \fBTk_GetBitmapFromObj\fR doesn't actually create the bitmap; the bitmap
445 must already have been created with a previous call to
446 \fBTk_AllocBitmapFromObj\fR or \fBTk_GetBitmap\fR.  The return
447 value is cached in \fIobjPtr\fR, which speeds up
448 future calls to \fBTk_GetBitmapFromObj\fR with the same \fIobjPtr\fR
449 and \fItkwin\fR.
450 .VE
451 .PP
452 \fBTk_DefineBitmap\fR associates a name with
453 in-memory bitmap data so that the name can be used in later
454 calls to \fBTk_AllocBitmapFromObj\fR or \fBTk_GetBitmap\fR.  The \fInameId\fR
455 argument gives a name for the bitmap;  it must not previously
456 have been used in a call to \fBTk_DefineBitmap\fR.
457 The arguments \fIsource\fR, \fIwidth\fR, and \fIheight\fR
458 describe the bitmap.
459 \fBTk_DefineBitmap\fR normally returns TCL_OK;  if an error occurs
460 (e.g. a bitmap named \fInameId\fR has already been defined) then
461 TCL_ERROR is returned and an error message is left in
462 \fIinterp->result\fR.
463 Note:  \fBTk_DefineBitmap\fR expects the memory pointed to by
464 \fIsource\fR to be static:  \fBTk_DefineBitmap\fR doesn't make
465 a private copy of this memory, but uses the bytes pointed to
466 by \fIsource\fR later in calls to \fBTk_AllocBitmapFromObj\fR or
467 \fBTk_GetBitmap\fR.
468 .PP
469 Typically \fBTk_DefineBitmap\fR is used by \fB#include\fR-ing a
470 bitmap file directly into a C program and then referencing
471 the variables defined by the file.
472 For example, suppose there exists a file \fBstip.bitmap\fR,
473 which was created by the \fBbitmap\fR program and contains
474 a stipple pattern.
475 The following code uses \fBTk_DefineBitmap\fR to define a
476 new bitmap named \fBfoo\fR:
477 .VS
478 .CS
479 Pixmap bitmap;
480 #include "stip.bitmap"
481 Tk_DefineBitmap(interp, "foo", stip_bits,
482         stip_width, stip_height);
483 \&...
484 bitmap = Tk_GetBitmap(interp, tkwin, "foo");
485 .CE
486 .VE
487 This code causes the bitmap file to be read
488 at compile-time and incorporates the bitmap information into
489 the program's executable image.  The same bitmap file could be
490 read at run-time using \fBTk_GetBitmap\fR:
491 .VS
492 .CS
493 Pixmap bitmap;
494 bitmap = Tk_GetBitmap(interp, tkwin, "@stip.bitmap");
495 .CE
496 .VE
497 The second form is a bit more flexible (the file could be modified
498 after the program has been compiled, or a different string could be
499 provided to read a different file), but it is a little slower and
500 requires the bitmap file to exist separately from the program.
501 .PP
502 Tk maintains a database of all the bitmaps that are currently in use.
503 Whenever possible, it will return an existing bitmap rather
504 than creating a new one.
505 When a bitmap is no longer used, Tk will release it automatically.
506 This approach can substantially reduce server overhead, so
507 \fBTk_AllocBitmapFromObj\fR and \fBTk_GetBitmap\fR should generally
508 be used in preference to Xlib procedures like \fBXReadBitmapFile\fR.
509 .PP
510 The bitmaps returned by \fBTk_AllocBitmapFromObj\fR and \fBTk_GetBitmap\fR
511 are shared, so callers should never modify them.
512 If a bitmap must be modified dynamically, then it should be
513 created by calling Xlib procedures such as \fBXReadBitmapFile\fR
514 or \fBXCreatePixmap\fR directly.
515 .PP
516 The procedure \fBTk_NameOfBitmap\fR is roughly the inverse of
517 \fBTk_GetBitmap\fR.
518 Given an X Pixmap argument, it returns the textual description that was
519 passed to \fBTk_GetBitmap\fR when the bitmap was created.
520 \fIBitmap\fR must have been the return value from a previous
521 call to \fBTk_AllocBitmapFromObj\fR or \fBTk_GetBitmap\fR.
522 .PP
523 \fBTk_SizeOfBitmap\fR returns the dimensions of its \fIbitmap\fR
524 argument in the words pointed to by the \fIwidthPtr\fR and
525 \fIheightPtr\fR arguments.  As with \fBTk_NameOfBitmap\fR,
526 \fIbitmap\fR must have been created by \fBTk_AllocBitmapFromObj\fR or
527 \fBTk_GetBitmap\fR.
528 .PP
529 .VS 8.1
530 When a bitmap is no longer needed, \fBTk_FreeBitmapFromObj\fR or
531 \fBTk_FreeBitmap\fR should be called to release it.
532 For \fBTk_FreeBitmapFromObj\fR the bitmap to release is specified
533 with the same information used to create it; for
534 \fBTk_FreeBitmap\fR the bitmap to release is specified
535 with its Pixmap token.
536 There should be exactly one call to \fBTk_FreeBitmapFromObj\fR
537 or \fBTk_FreeBitmap\fR for each call to \fBTk_AllocBitmapFromObj\fR or
538 \fBTk_GetBitmap\fR.
539 .VE
540
541 .SH BUGS
542 In determining whether an existing bitmap can be used to satisfy
543 a new request, \fBTk_AllocBitmapFromObj\fR and \fBTk_GetBitmap\fR
544 consider only the immediate value of the string description.  For
545 example, when a file name is passed to \fBTk_GetBitmap\fR,
546 \fBTk_GetBitmap\fR will assume it is safe to re-use an existing
547 bitmap created from the same file name:  it will not check to
548 see whether the file itself has changed, or whether the current
549 directory has changed, thereby causing the name to refer to
550 a different file.
551
552 .SH KEYWORDS
553 bitmap, pixmap