Debian Codegraph @

man/bitmap.mann

raw ◀ ▶
1 Debian patch touch this file
1 '\"
2 '\" Copyright 1991-2001 by Bell Labs Innovations for Lucent Technologies.
3 '\"
4 '\" Permission to use, copy, modify, and distribute this software and its
5 '\" documentation for any purpose and without fee is hereby granted, provided
6 '\" that the above copyright notice appear in all copies and that both that the
7 '\" copyright notice and warranty disclaimer appear in supporting documentation,
8 '\" and that the names of Lucent Technologies any of their entities not be used
9 '\" in advertising or publicity pertaining to distribution of the software
10 '\" without specific, written prior permission.
11 '\"
12 '\" Lucent Technologies disclaims all warranties with regard to this software,
13 '\" including all implied warranties of merchantability and fitness. In no event
14 '\" shall Lucent Technologies be liable for any special, indirect or
15 '\" consequential damages or any damages whatsoever resulting from loss of use,
16 '\" data or profits, whether in an action of contract, negligence or other
17 '\" tortuous action, arising out of or in connection with the use or performance
18 '\" of this software.
19 '\"
20 '\" Bitmap command created by George Howlett.
21 '\"
22 .so man.macros
23 .TH bitmap n BLT_VERSION BLT "BLT Built-In Commands"
24 .BS
25 '\" Note: do not modify the .SH NAME line immediately below!
26 .SH NAME
27 bitmap \- Define a new bitmap from a Tcl script
28 .SH SYNOPSIS
29 \fBbitmap define \fIbitmapName data\fR ?\fIoption value\fR?...
30 .sp
31 \fBbitmap compose \fIbitmapName text\fR ?\fIoption value\fR?...
32 .sp
33 \fBbitmap exists \fIbitmapName\fR
34 .sp
35 \fBbitmap source \fIbitmapName\fR
36 .sp
37 \fBbitmap data \fIbitmapName\fR
38 .sp
39 \fBbitmap height \fIbitmapName\fR
40 .sp
41 \fBbitmap width \fIbitmapName\fR
42 .BE
43 .SH DESCRIPTION
44 The \fBbitmap\fR command lets you create new bitmaps directly from your
45 Tcl script. The bitmap can be specified as a list of data or a text string
46 which is converted into a bitmap. You can arbitrarily scale
47 or rotate the bitmap too.
48 .SH INTRODUCTION
49 Bitmaps are commonly used within Tk. In label and button widgets, you
50 display bitmaps them instead of text strings and in the canvas and
51 text widgets, they're used for stippling. But Tk let's you can create
52 new bitmaps only by reading the bitmap data from a file. This makes
53 bitmaps cumbersome to manage, especially in packaging the program as a
54 \fBwish\fR script, since each bitmap must be its own file. It would
55 be nicer if you could create new bitmaps directly from your Tcl script.
56 .PP
57 The \fBbitmap\fR command lets you do just that. You can specify the
58 bitmap as in various formats (such as the X11 bitmap format). You can
59 also compose a bitmap from a text string. The \fBbitmap\fR command
60 also lets you and arbitrarily rotate or scale the bitmap. For example, you
61 could use this to create button widgets with the text label rotated 90
62 degrees.
63 .SH EXAMPLE
64 <<<<<<< bitmap.mann
65 You can define a new bitmap with the \fBdefine\fR operation. For
66 example, let's say you are using the X11 bitmap "gray1". Normally to
67 use it, you would specify the location of the file.
68 .CS
69 label .l -bitmap @/usr/X11R6/include/X11/bitmaps/gray1
70 .CE
71 But you can simply cut and paste the contents of "gray1" into the
72 \fBbitmap\fR command.
73 .CS
74 bitmap define gray1 {
75 #define gray1_width 2
76 #define gray1_height 2
77 static char gray1_bits[] = {
78 0x01, 0x02};
79 }
80 label .l -bitmap gray1
81 .CE
82 Tk will recognize "gray1" as a bitmap which can now be used with any
83 widget that accepts bitmaps.
84 .CS
•85 \&.barchart element configure elem1 -stipple gray1
86 .CE
•87 The bitmap data can be specified in a multitude of forms.
88 The following commands are all equivalent.
89 .CS
90 bitmap define gray1 {
91 #define gray1_width 2
92 #define gray1_height 2
93 static char gray1_bits[] = {
94 0x01, 0x02};
95 }
96 bitmap define gray1 { { 2 2 } { 0x01, 0x02 } }
97 bitmap define gray1 { { 2 2 } { 0x01 0x02 } }
98 bitmap define gray1 { { 2 2 } { 1 2 } }
99 .CE
100 Either the data is in the standard X11 bitmap form, or it's a list of
101 two lists. The first list contains the height and width of the bitmap.
102 The second list is the bitmap source data. Each element of that list
103 is an hexadecimal number specifying which pixels are foreground (1)
104 and which are background (0) of the bitmap. Note that the format of
105 the source data is exactly that of the XBM format.
106 .P
107 You can scale or rotate the bitmap as you create it, by using the
108 \fB-scale\fR or\fB-rotate\fR options.
109 .CS
110 bitmap define gray1 {
111 #define gray1_width 2
112 #define gray1_height 2
113 static char gray1_bits[] = {
114 0x01, 0x02};
115 } -scale 2.0 -rotate 90.0
116 .CE
117 In addition, you can compose bitmaps from text strings. This makes it
118 easy to create rotated buttons or labels. The text string can have
119 multi-line.
120 .CS
121 bitmap compose rot_text "This is rotated\\ntext" \\
122 -rotate 90.0 -font fixed
123 .CE
124 There are also a number of ways to query bitmaps. This isn't limited
125 to bitmaps that you create, but any bitmap.
126 .CS
127 bitmap exists rot_text
128 bitmap width rot_text
129 bitmap height rot_text
130 bitmap data rot_text
131 bitmap source rot_text
132 .CE
133 The \fBexists\fR operation indicates if a bitmap by that name is
134 defined. You can query the dimensions of the bitmap using the
135 \fBwidth\fR and \fBheight\fR operations. The \fBdata\fR operation
136 returns the list of the data used to create the bitmap.
137 For example, you could query the data of a bitmap and \fBsend\fR
138 it across the network to another Tk application.
139 .CS
140 set data [bitmap data @/usr/X11R6/include/X11/bitmaps/ghost.xbm]
141 send {wish #2} bitmap define ghost $data
142 .CE
143 .SH OPERATIONS
144 The following operations are available for \fBbitmap\fR:
145 .TP
146 \fBbitmap compose \fIbitmapName text \fR?\fIoption value\fR?...
147 Creates a bitmap \fIbitmapName\fR from the text string \fItext\fR.
148 A bitmap \fIbitmapName\fR can not already exist.
149 The following options are available.
150 .RS
151 .TP
152 \fB\-font \fIfontName\fR
153 Specifies a font to use when drawing text into the bitmap.
154 If this option isn't specified then \fIfontName\fR defaults to
155 \fB*-Helvetica-Bold-R-Normal-*-140-*\fR.
156 .TP
157 \fB\-rotate \fItheta\fR
158 Specifies the angle of rotation of the text in the bitmap.
159 \fITheta\fR is a real number representing the angle in degrees.
160 It defaults to \fB0.0\fR degrees.
161 .TP
162 \fB\-scale \fIvalue\fR
163 Specifies the scale of the bitmap.
164 \fIValue\fR is a real number representing the scale. A scale
165 of 1.0 indicates no scaling is necessary, while 2.0 would
166 double the size of the bitmap. There is no way to specify
167 differents scales for the width and height of the bitmap.
168 The default scale is \fB1.0\fR.
169 .RE
170 .TP
171 \fBbitmap data \fIbitmapName\fR
172 Returns a list of both the
173 dimensions of the bitmap \fIbitmapName\fR and its source data.
174 .TP
175 \fBbitmap define \fIbitmapName data\fR \fR?\fIoption value\fR?...
176 Associates \fIbitmapName\fR with in-memory bitmap data so that
177 \fIbitmapName\fR can be used in later calls to \fBTk_GetBitmap\fR.
178 The \fIbitmapName\fR argument is the name of the bitmap; it must not
179 previously have been defined in either a call to Tk_DefineBitmap or
180 \fBbitmap\fR. The argument \fIdata\fP describes the bitmap to
181 be created. It is either the X11 bitmap format (a C structure) or
182 a list of two lists: the dimensions and source data. The dimensions
183 are a list of two numbers which are the width
184 and height of the bitmap. The source data is a list of hexadecimal
185 values in a format similar to the X11 or X10 bitmap format. The
186 values may be optionally separated by commas and do not need to be
187 prefixed with "0x". The following options are available.
188 .RS
189 .TP
190 \fB\-rotate \fItheta\fR
191 Specifies how many degrees to rotate the bitmap.
192 \fITheta\fR is a real number representing the angle.
193 The default is \fB0.0\fR degrees.
194 .TP
195 \fB\-scale \fIvalue\fR
196 Specifies how to scale the bitmap.
197 \fIValue\fR is a real number representing the scale. A scale
198 of 1.0 indicates no scaling is necessary, while 2.0 would
199 double the size of the bitmap. There is no way to specify
200 differents scales for the width and height of the bitmap.
201 The default scale is \fB1.0\fR.
202 .RE
203 .TP
204 \fBbitmap exists \fIbitmapName\fR
205 Returns \fB1\fR if a bitmap \fIbitmapName\fR exists, otherwise \fB0\fR.
206 .TP
207 \fBbitmap height \fIbitmapName\fR
208 Returns the height in pixels of the bitmap \fIbitmapName\fR.
209 .TP
210 \fBbitmap source \fIbitmapName\fR
211 Returns the source data of the bitmap \fIbitmapName\fR. The source data is a
212 list of the hexadecimal values.
213 .TP
214 \fBbitmap width \fIbitmapName\fR
215 Returns the width in pixels of the bitmap \fIbitmapName\fR.
216 .SH LIMITATIONS
217 Tk currently offers no way of destroying bitmaps. Once a bitmap is
218 created, it exists until the application terminates.
219 .SH KEYWORDS
220 bitmap