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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [tk/] [doc/] [GetBitmap.3] - Diff between revs 579 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 579 Rev 1765
'\"
'\"
'\" Copyright (c) 1990 The Regents of the University of California.
'\" Copyright (c) 1990 The Regents of the University of California.
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
'\"
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
'\"
'\" RCS: @(#) $Id: GetBitmap.3,v 1.1.1.1 2002-01-16 10:25:48 markom Exp $
'\" RCS: @(#) $Id: GetBitmap.3,v 1.1.1.1 2002-01-16 10:25:48 markom Exp $
'\"
'\"
.so man.macros
.so man.macros
.TH Tk_GetBitmap 3 8.0 Tk "Tk Library Procedures"
.TH Tk_GetBitmap 3 8.0 Tk "Tk Library Procedures"
.BS
.BS
.SH NAME
.SH NAME
Tk_GetBitmap, Tk_DefineBitmap, Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeBitmap, Tk_GetBitmapFromData \- maintain database of single-plane pixmaps
Tk_GetBitmap, Tk_DefineBitmap, Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeBitmap, Tk_GetBitmapFromData \- maintain database of single-plane pixmaps
.SH SYNOPSIS
.SH SYNOPSIS
.nf
.nf
\fB#include \fR
\fB#include \fR
.sp
.sp
Pixmap
Pixmap
\fBTk_GetBitmap(\fIinterp, tkwin, id\fB)\fR
\fBTk_GetBitmap(\fIinterp, tkwin, id\fB)\fR
.sp
.sp
int
int
\fBTk_DefineBitmap(\fIinterp, nameId, source, width, height\fB)\fR
\fBTk_DefineBitmap(\fIinterp, nameId, source, width, height\fB)\fR
.sp
.sp
Tk_Uid
Tk_Uid
\fBTk_NameOfBitmap(\fIdisplay, bitmap\fB)\fR
\fBTk_NameOfBitmap(\fIdisplay, bitmap\fB)\fR
.sp
.sp
\fBTk_SizeOfBitmap(\fIdisplay, bitmap, widthPtr, heightPtr\fB)\fR
\fBTk_SizeOfBitmap(\fIdisplay, bitmap, widthPtr, heightPtr\fB)\fR
.sp
.sp
\fBTk_FreeBitmap(\fIdisplay, bitmap\fB)\fR
\fBTk_FreeBitmap(\fIdisplay, bitmap\fB)\fR
.SH ARGUMENTS
.SH ARGUMENTS
.AS "unsigned long" *pixelPtr
.AS "unsigned long" *pixelPtr
.AP Tcl_Interp *interp in
.AP Tcl_Interp *interp in
Interpreter to use for error reporting.
Interpreter to use for error reporting.
.AP Tk_Window tkwin in
.AP Tk_Window tkwin in
Token for window in which the bitmap will be used.
Token for window in which the bitmap will be used.
.AP Tk_Uid id in
.AP Tk_Uid id in
Description of bitmap;  see below for possible values.
Description of bitmap;  see below for possible values.
.AP Tk_Uid nameId in
.AP Tk_Uid nameId in
Name for new bitmap to be defined.
Name for new bitmap to be defined.
.AP char *source in
.AP char *source in
Data for bitmap, in standard bitmap format.
Data for bitmap, in standard bitmap format.
Must be stored in static memory whose value will never change.
Must be stored in static memory whose value will never change.
.AP "int" width in
.AP "int" width in
Width of bitmap.
Width of bitmap.
.AP "int" height in
.AP "int" height in
Height of bitmap.
Height of bitmap.
.AP "int" *widthPtr out
.AP "int" *widthPtr out
Pointer to word to fill in with \fIbitmap\fR's width.
Pointer to word to fill in with \fIbitmap\fR's width.
.AP "int" *heightPtr out
.AP "int" *heightPtr out
Pointer to word to fill in with \fIbitmap\fR's height.
Pointer to word to fill in with \fIbitmap\fR's height.
.AP Display *display in
.AP Display *display in
Display for which \fIbitmap\fR was allocated.
Display for which \fIbitmap\fR was allocated.
.AP Pixmap bitmap in
.AP Pixmap bitmap in
Identifier for a bitmap allocated by \fBTk_GetBitmap\fR.
Identifier for a bitmap allocated by \fBTk_GetBitmap\fR.
.BE
.BE
.SH DESCRIPTION
.SH DESCRIPTION
.PP
.PP
These procedures manage a collection of bitmaps (one-plane pixmaps)
These procedures manage a collection of bitmaps (one-plane pixmaps)
being used by an application.  The procedures allow bitmaps to be
being used by an application.  The procedures allow bitmaps to be
re-used efficiently, thereby avoiding server overhead, and also
re-used efficiently, thereby avoiding server overhead, and also
allow bitmaps to be named with character strings.
allow bitmaps to be named with character strings.
.PP
.PP
\fBTk_GetBitmap\fR takes as argument a Tk_Uid describing a bitmap.
\fBTk_GetBitmap\fR takes as argument a Tk_Uid describing a bitmap.
It returns a Pixmap identifier for a bitmap corresponding to the
It returns a Pixmap identifier for a bitmap corresponding to the
description.  It re-uses an existing bitmap, if possible, and
description.  It re-uses an existing bitmap, if possible, and
creates a new one otherwise.  At present, \fIid\fR must have
creates a new one otherwise.  At present, \fIid\fR must have
one of the following forms:
one of the following forms:
.TP 20
.TP 20
\fB@\fIfileName\fR
\fB@\fIfileName\fR
\fIFileName\fR must be the name of a file containing a bitmap
\fIFileName\fR must be the name of a file containing a bitmap
description in the standard X11 or X10 format.
description in the standard X11 or X10 format.
.TP 20
.TP 20
\fIname\fR
\fIname\fR
\fIName\fR must be the name of a bitmap defined previously with
\fIName\fR must be the name of a bitmap defined previously with
a call to \fBTk_DefineBitmap\fR.  The following names are pre-defined
a call to \fBTk_DefineBitmap\fR.  The following names are pre-defined
by Tk:
by Tk:
.RS
.RS
.TP 12
.TP 12
\fBerror\fR
\fBerror\fR
The international "don't" symbol:  a circle with a diagonal line
The international "don't" symbol:  a circle with a diagonal line
across it.
across it.
.VS "" br
.VS "" br
.TP 12
.TP 12
\fBgray75\fR
\fBgray75\fR
75% gray: a checkerboard pattern where three out of four bits are on.
75% gray: a checkerboard pattern where three out of four bits are on.
.VE
.VE
.TP 12
.TP 12
\fBgray50\fR
\fBgray50\fR
50% gray: a checkerboard pattern where every other bit is on.
50% gray: a checkerboard pattern where every other bit is on.
.VS "" br
.VS "" br
.TP 12
.TP 12
\fBgray25\fR
\fBgray25\fR
25% gray: a checkerboard pattern where one out of every four bits is on.
25% gray: a checkerboard pattern where one out of every four bits is on.
.VE
.VE
.TP 12
.TP 12
\fBgray12\fR
\fBgray12\fR
12.5% gray: a pattern where one-eighth of the bits are on, consisting of
12.5% gray: a pattern where one-eighth of the bits are on, consisting of
every fourth pixel in every other row.
every fourth pixel in every other row.
.TP 12
.TP 12
\fBhourglass\fR
\fBhourglass\fR
An hourglass symbol.
An hourglass symbol.
.TP 12
.TP 12
\fBinfo\fR
\fBinfo\fR
A large letter ``i''.
A large letter ``i''.
.TP 12
.TP 12
\fBquesthead\fR
\fBquesthead\fR
The silhouette of a human head, with a question mark in it.
The silhouette of a human head, with a question mark in it.
.TP 12
.TP 12
\fBquestion\fR
\fBquestion\fR
A large question-mark.
A large question-mark.
.TP 12
.TP 12
\fBwarning\fR
\fBwarning\fR
A large exclamation point.
A large exclamation point.
.PP
.PP
In addition, the following pre-defined names are available only on the
In addition, the following pre-defined names are available only on the
\fBMacintosh\fR platform:
\fBMacintosh\fR platform:
.TP 12
.TP 12
\fBdocument\fR
\fBdocument\fR
A generic document.
A generic document.
.TP 12
.TP 12
\fBstationery\fR
\fBstationery\fR
Document stationery.
Document stationery.
.TP 12
.TP 12
\fBedition\fR
\fBedition\fR
The \fIedition\fR symbol.
The \fIedition\fR symbol.
.TP 12
.TP 12
\fBapplication\fR
\fBapplication\fR
Generic application icon.
Generic application icon.
.TP 12
.TP 12
\fBaccessory\fR
\fBaccessory\fR
A desk accessory.
A desk accessory.
.TP 12
.TP 12
\fBfolder\fR
\fBfolder\fR
Generic folder icon.
Generic folder icon.
.TP 12
.TP 12
\fBpfolder\fR
\fBpfolder\fR
A locked folder.
A locked folder.
.TP 12
.TP 12
\fBtrash\fR
\fBtrash\fR
A trash can.
A trash can.
.TP 12
.TP 12
\fBfloppy\fR
\fBfloppy\fR
A floppy disk.
A floppy disk.
.TP 12
.TP 12
\fBramdisk\fR
\fBramdisk\fR
A floppy disk with chip.
A floppy disk with chip.
.TP 12
.TP 12
\fBcdrom\fR
\fBcdrom\fR
A cd disk icon.
A cd disk icon.
.TP 12
.TP 12
\fBpreferences\fR
\fBpreferences\fR
A folder with prefs symbol.
A folder with prefs symbol.
.TP 12
.TP 12
\fBquerydoc\fR
\fBquerydoc\fR
A database document icon.
A database document icon.
.TP 12
.TP 12
\fBstop\fR
\fBstop\fR
A stop sign.
A stop sign.
.TP 12
.TP 12
\fBnote\fR
\fBnote\fR
A face with ballon words.
A face with ballon words.
.TP 12
.TP 12
\fBcaution\fR
\fBcaution\fR
A triangle with an exclamation point.
A triangle with an exclamation point.
.RE
.RE
.LP
.LP
Under normal conditions, \fBTk_GetBitmap\fR
Under normal conditions, \fBTk_GetBitmap\fR
returns an identifier for the requested bitmap.  If an error
returns an identifier for the requested bitmap.  If an error
occurs in creating the bitmap, such as when \fIid\fR refers
occurs in creating the bitmap, such as when \fIid\fR refers
to a non-existent file, then \fBNone\fR is returned and an error
to a non-existent file, then \fBNone\fR is returned and an error
message is left in \fIinterp->result\fR.
message is left in \fIinterp->result\fR.
.PP
.PP
\fBTk_DefineBitmap\fR associates a name with
\fBTk_DefineBitmap\fR associates a name with
in-memory bitmap data so that the name can be used in later
in-memory bitmap data so that the name can be used in later
calls to \fBTk_GetBitmap\fR.  The \fInameId\fR
calls to \fBTk_GetBitmap\fR.  The \fInameId\fR
argument gives a name for the bitmap;  it must not previously
argument gives a name for the bitmap;  it must not previously
have been used in a call to \fBTk_DefineBitmap\fR.
have been used in a call to \fBTk_DefineBitmap\fR.
The arguments \fIsource\fR, \fIwidth\fR, and \fIheight\fR
The arguments \fIsource\fR, \fIwidth\fR, and \fIheight\fR
describe the bitmap.
describe the bitmap.
\fBTk_DefineBitmap\fR normally returns TCL_OK;  if an error occurs
\fBTk_DefineBitmap\fR normally returns TCL_OK;  if an error occurs
(e.g. a bitmap named \fInameId\fR has already been defined) then
(e.g. a bitmap named \fInameId\fR has already been defined) then
TCL_ERROR is returned and an error message is left in
TCL_ERROR is returned and an error message is left in
\fIinterp->result\fR.
\fIinterp->result\fR.
Note:  \fBTk_DefineBitmap\fR expects the memory pointed to by
Note:  \fBTk_DefineBitmap\fR expects the memory pointed to by
\fIsource\fR to be static:  \fBTk_DefineBitmap\fR doesn't make
\fIsource\fR to be static:  \fBTk_DefineBitmap\fR doesn't make
a private copy of this memory, but uses the bytes pointed to
a private copy of this memory, but uses the bytes pointed to
by \fIsource\fR later in calls to \fBTk_GetBitmap\fR.
by \fIsource\fR later in calls to \fBTk_GetBitmap\fR.
.PP
.PP
Typically \fBTk_DefineBitmap\fR is used by \fB#include\fR-ing a
Typically \fBTk_DefineBitmap\fR is used by \fB#include\fR-ing a
bitmap file directly into a C program and then referencing
bitmap file directly into a C program and then referencing
the variables defined by the file.
the variables defined by the file.
For example, suppose there exists a file \fBstip.bitmap\fR,
For example, suppose there exists a file \fBstip.bitmap\fR,
which was created by the \fBbitmap\fR program and contains
which was created by the \fBbitmap\fR program and contains
a stipple pattern.
a stipple pattern.
The following code uses \fBTk_DefineBitmap\fR to define a
The following code uses \fBTk_DefineBitmap\fR to define a
new bitmap named \fBfoo\fR:
new bitmap named \fBfoo\fR:
.CS
.CS
Pixmap bitmap;
Pixmap bitmap;
#include "stip.bitmap"
#include "stip.bitmap"
Tk_DefineBitmap(interp, Tk_GetUid("foo"), stip_bits,
Tk_DefineBitmap(interp, Tk_GetUid("foo"), stip_bits,
        stip_width, stip_height);
        stip_width, stip_height);
\&...
\&...
bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("foo"));
bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("foo"));
.CE
.CE
This code causes the bitmap file to be read
This code causes the bitmap file to be read
at compile-time and incorporates the bitmap information into
at compile-time and incorporates the bitmap information into
the program's executable image.  The same bitmap file could be
the program's executable image.  The same bitmap file could be
read at run-time using \fBTk_GetBitmap\fR:
read at run-time using \fBTk_GetBitmap\fR:
.CS
.CS
Pixmap bitmap;
Pixmap bitmap;
bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("@stip.bitmap"));
bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("@stip.bitmap"));
.CE
.CE
The second form is a bit more flexible (the file could be modified
The second form is a bit more flexible (the file could be modified
after the program has been compiled, or a different string could be
after the program has been compiled, or a different string could be
provided to read a different file), but it is a little slower and
provided to read a different file), but it is a little slower and
requires the bitmap file to exist separately from the program.
requires the bitmap file to exist separately from the program.
.PP
.PP
\fBTk_GetBitmap\fR maintains a
\fBTk_GetBitmap\fR maintains a
database of all the bitmaps that are currently in use.
database of all the bitmaps that are currently in use.
Whenever possible, it will return an existing bitmap rather
Whenever possible, it will return an existing bitmap rather
than creating a new one.
than creating a new one.
This approach can substantially reduce server overhead, so
This approach can substantially reduce server overhead, so
\fBTk_GetBitmap\fR should generally be used in preference to Xlib
\fBTk_GetBitmap\fR should generally be used in preference to Xlib
procedures like \fBXReadBitmapFile\fR.
procedures like \fBXReadBitmapFile\fR.
.PP
.PP
The bitmaps returned by \fBTk_GetBitmap\fR
The bitmaps returned by \fBTk_GetBitmap\fR
are shared, so callers should never modify them.
are shared, so callers should never modify them.
If a bitmap must be modified dynamically, then it should be
If a bitmap must be modified dynamically, then it should be
created by calling Xlib procedures such as \fBXReadBitmapFile\fR
created by calling Xlib procedures such as \fBXReadBitmapFile\fR
or \fBXCreatePixmap\fR directly.
or \fBXCreatePixmap\fR directly.
.PP
.PP
The procedure \fBTk_NameOfBitmap\fR is roughly the inverse of
The procedure \fBTk_NameOfBitmap\fR is roughly the inverse of
\fBTk_GetBitmap\fR.
\fBTk_GetBitmap\fR.
Given an X Pixmap argument, it returns the \fIid\fR that was
Given an X Pixmap argument, it returns the \fIid\fR that was
passed to \fBTk_GetBitmap\fR when the bitmap was created.
passed to \fBTk_GetBitmap\fR when the bitmap was created.
\fIBitmap\fR must have been the return value from a previous
\fIBitmap\fR must have been the return value from a previous
call to \fBTk_GetBitmap\fR.
call to \fBTk_GetBitmap\fR.
.PP
.PP
\fBTk_SizeOfBitmap\fR returns the dimensions of its \fIbitmap\fR
\fBTk_SizeOfBitmap\fR returns the dimensions of its \fIbitmap\fR
argument in the words pointed to by the \fIwidthPtr\fR and
argument in the words pointed to by the \fIwidthPtr\fR and
\fIheightPtr\fR arguments.  As with \fBTk_NameOfBitmap\fR,
\fIheightPtr\fR arguments.  As with \fBTk_NameOfBitmap\fR,
\fIbitmap\fR must have been created by \fBTk_GetBitmap\fR.
\fIbitmap\fR must have been created by \fBTk_GetBitmap\fR.
.PP
.PP
When a bitmap returned by \fBTk_GetBitmap\fR
When a bitmap returned by \fBTk_GetBitmap\fR
is no longer needed, \fBTk_FreeBitmap\fR should be called to release it.
is no longer needed, \fBTk_FreeBitmap\fR should be called to release it.
There should be exactly one call to \fBTk_FreeBitmap\fR for
There should be exactly one call to \fBTk_FreeBitmap\fR for
each call to \fBTk_GetBitmap\fR.
each call to \fBTk_GetBitmap\fR.
When a bitmap is no longer in use anywhere (i.e. it has been freed as
When a bitmap is no longer in use anywhere (i.e. it has been freed as
many times as it has been gotten) \fBTk_FreeBitmap\fR will release
many times as it has been gotten) \fBTk_FreeBitmap\fR will release
it to the X server and delete it from the database.
it to the X server and delete it from the database.
.SH BUGS
.SH BUGS
In determining whether an existing bitmap can be used to satisfy
In determining whether an existing bitmap can be used to satisfy
a new request, \fBTk_GetBitmap\fR
a new request, \fBTk_GetBitmap\fR
considers only the immediate value of its \fIid\fR argument.  For
considers only the immediate value of its \fIid\fR argument.  For
example, when a file name is passed to \fBTk_GetBitmap\fR,
example, when a file name is passed to \fBTk_GetBitmap\fR,
\fBTk_GetBitmap\fR will assume it is safe to re-use an existing
\fBTk_GetBitmap\fR will assume it is safe to re-use an existing
bitmap created from the same file name:  it will not check to
bitmap created from the same file name:  it will not check to
see whether the file itself has changed, or whether the current
see whether the file itself has changed, or whether the current
directory has changed, thereby causing the name to refer to
directory has changed, thereby causing the name to refer to
a different file.
a different file.
.SH KEYWORDS
.SH KEYWORDS
bitmap, pixmap
bitmap, pixmap
 
 

powered by: WebSVN 2.1.0

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