summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Tk/Compound.pod
blob: 01f6e5f2639d4a696eab3659fa329b9f7109d9df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#  Copyright (c) 1996, Expert Interface Technologies
#  See the file "license.terms" for information on usage and redistribution
#  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
#  The file man.macros and some of the macros used by this file are
#  copyrighted: (c) 1990 The Regents of the University of California.
#               (c) 1994-1995 Sun Microsystems, Inc.
#  The license terms of the Tcl/Tk distrobution are in the file
#  license.tcl.

=head1 NAME

Tk::Compound - Create multi-line compound images.

=for category  Tk Image Classes

=head1 SYNOPSIS

    use Tk::Compound;
    $image = $widget->Compound(name,options);
    $image->Line(options);
    $image->Text(options);
    $image->Bitmap(options);
    $image->Image(options);
    $image->Space(options);

=for comment
This paragraph used to be written different, but perldoc 3.14 cannot
display this paragraph.
S<    >use Tk::Compound;
S<    >I<$image> = I<$widget>-E<gt>B<Compound>?(I<name>??,I<options>?)
S<    >I<$image>-E<gt>B<Line>?(I<options>?)
S<    >I<$image>-E<gt>B<Text>?(I<options>?)
S<    >I<$image>-E<gt>B<Bitmap>?(I<options>?)
S<    >I<$image>-E<gt>B<Image>?(I<options>?)
S<    >I<$image>-E<gt>B<Space>?(I<options>?)

=head1 DESCRIPTION

Compound image types can be used to create images that consists of
multiple horizontal lines; each line is composed of a series of items
(texts, bitmaps, images or spaces) arranged from left to
right. Compound images are mainly used to embed complex drawings into
widgets that support the B<-image> option. As shown in the EXAMPLE
section below, a compound image can be used to display a bitmap and a
text string simutaneously in a Tk B<Button> widget.

Compound images can only be used on windows on the same display as, and
with the same pixel depth and visual as the I<$widget> used to create them.

=head1 CREATING COMPOUND IMAGES

Compounds are created using I<$widget>-E<gt>B<Compound>.
Compounds support the following I<options>:

=over 4

=item B<-background> =E<gt> I<color>

Specifies the background color of the compound image. This color is
also used as the default background color for the bitmap items in the
compound image.

=item B<-borderwidth> =E<gt> I<pixels>

Specifies a non-negative value indicating the width of the 3-D border
drawn around the compound image.

=item B<-font> =E<gt> I<font>

Specifies the default font for the text items in the compound image.

=item B<-foreground> =E<gt> I<color>

Specifies the default foreground color for the bitmap and text items
in the compound image.

=item B<-padx> =E<gt> I<value>

Specifies a non-negative value indicating how much extra space to
request for the compound image in the X-direction. The I<value> may
have any of the forms acceptable to B<Tk_GetPixels(3)>.

=item B<-pady> =E<gt> I<value>

Specifies a non-negative value indicating how much extra space to
request for the compound image in the Y-direction.

=item B<-relief> =E<gt> I<value>

Specifies the 3-D effect desired for the background of the compound
image. Acceptable values are B<raised>, B<sunken>, B<flat>,
B<ridge>, and B<groove>.

=item B<-showbackground> =E<gt> I<value>

Specifies whether the background and the 3D borders should be drawn.
Must be a valid boolean value. By default the background is not drawn
and the compound image appears to have a transparent background.


=back

=head1 IMAGE COMMAND

When a compound image is created, Tk also creates a new object.
This object supports the B<configure> and B<cget> methods
described in L<Tk::options> which can be used to enquire and
modify the options described above.

The object also supports the following methods:

=over 4

=item I<$compound>-E<gt>B<Line>?(I<option => value ...>)?

Creates a new line at the bottom of the compound image. Lines support
the following I<options>:

=over 4

=item B<-anchor> value

Specifies how the line should be aligned along the horizontal axis.
When the values are B<w>, B<sw> or B<nw>, the line is aligned
to the left. When the values are B<c>, B<s> or B<n>, the line
is aligned to the middle.  When the values are B<e>, B<se> or
B<ne>, the line is aligned to the right.

=item B<-padx> =E<gt> I<value>

Specifies a non-negative value indicating how much extra space to
request for this line in the X-direction.

=back

=item I<$compound>-E<gt>I<Itemtype>?(I<option => value ...>)?

Creates a new item of the type I<Itemtype> at the end of the last
line of the compound image. All types of items support
these following common I<options>:

=over 4

=item B<-anchor> value

Specifies how the item should be aligned along the vertical axis. When
the values are B<n>, B<nw> or B<ne>, the item is aligned to
the top of the line. When the values are B<c>, B<w> or B<e>,
the item is aligned to the middle of the line.  When the values are
B<s>, B<se> or B<sw>, the item is aligned to the bottom of
the line.

=item B<-padx> =E<gt> I<value>

Specifies a non-negative value indicating how much extra space to
request for this item in the X-direction.

=item B<-pady> =E<gt> I<value>

Specifies a non-negative value indicating how much extra space to
request for this item in the Y-direction.

=item I<item-type> can be any of the following:

=back

=item I<$compound>-E<gt>B<Bitmap>?(I<option => value ...>)?

Creates a new bitmap item of at the end of the last
line of the compound image. Additional I<options> accepted by the
bitmap type are:

=over 4

=item B<-background> =E<gt> I<color>

Specifies the background color of the bitmap item.

=item B<-bitmap> =E<gt> I<name>

Specifies a bitmap to display in this item, in any of the forms
acceptable to B<Tk_GetBitmap(3)>.

=item B<-foreground> =E<gt> I<color>

Specifies the foreground color of the bitmap item.

=back

=item I<$compound>-E<gt>B<Image>?(I<option => value ...>)?

Creates a new image item of at the end of the last
line of the compound image. Additional I<options> accepted by the
image type are:

=over 4

=item B<-image> =E<gt> I<name>

Specifies an image to display in this item. I<name>
must have been created with the B<image create> command.

=back

=item I<$compound>-E<gt>B<Space>?(I<option => value ...>)?

Creates a new space item of at the end of the last line of the
compound image. Space items do not display anything. They just acts as
space holders that add additional spaces between items inside a
compound image. Additional I<options> accepted by the image type
are:

=over 4

=item B<-width> =E<gt> I<value>

Specifies the width of this space. The I<value> may have any of the
forms acceptable to B<Tk_GetPixels(3)>.

=item B<-height> =E<gt> I<value>

Specifies the height of this space. The I<value> may have any of
the forms acceptable to B<Tk_GetPixels(3)>.

=back

=item I<$compound>-E<gt>B<Text>?(I<option => value ...>)?

Creates a new text item of at the end of the last line of the compound
image. Additional I<options> accepted by the text type are:

=over 4

=item B<-background> =E<gt> I<color>

Specifies the background color of the text item.

=item B<-font> =E<gt> I<name>

Specifies the font to be used for this text item.

=item B<-foreground> =E<gt> I<color>

Specifies the foreground color of the text item.

=item B<-justify> I<value>

When there are multiple lines of text displayed in a text item, this
option determines how the lines line up with each other. I<value>
must be one of B<left>, B<center>, or B<right>.  B<Left>
means that the lines' left edges all line up, B<center> means that
the lines' centers are aligned, and B<right> means that the lines'
right edges line up.

=item B<-text> =E<gt> I<string>

Specifies a text string to display in this text item.

=item B<-underline> I<value>

Specifies the integer index of a character to underline in the text
item. 0 corresponds to the first character of the text displayed in
the text item, 1 to the next character, and so on.

=item B<-wraplength> I<value>

This option specifies the maximum line length of the label string on
this text item. If the line length of the label string exceeds this
length, it is wrapped onto the next line, so that no line is longer
than the specified length. The value may be specified in any of the
standard forms for screen distances. If this value is less than or
equal to 0 then no wrapping is done: lines will break only at newline
characters in the text.

=back

=back

=head1 EXAMPLE

The following example creates a compound image with a bitmap and a
text string and places this image into a B<Button(n)>
widget. Notice that the image must be created using the widget
that it resides in.

  my $b = $parent->Button;
  my $c = $b->Compound;
  $b->configure(-image => $c);
  $c->Line;
  $c->Bitmap(-bitmap => 'warning');
  $c->Space(-width => 8);
  $c->Text(-text => "Warning", -underline => 0);
  $b->pack;

=head1 KEYWORDS

image(n), Tix(n)