Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / perl-5.8.0 / lib / site_perl / 5.8.0 / sun4-solaris / Tk / TList.pod
CommitLineData
86530b38
AT
1# Copyright (c) 1996, Expert Interface Technologies
2# See the file "license.terms" for information on usage and redistribution
3# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
4#
5# The file man.macros and some of the macros used by this file are
6# copyrighted: (c) 1990 The Regents of the University of California.
7# (c) 1994-1995 Sun Microsystems, Inc.
8# The license terms of the Tcl/Tk distribution are in the file
9# license.tcl.
10
11=head1 NAME
12
13Tk::TList - Create and manipulate Tix Tabular List widgets
14
15=for category Tix Extensions
16
17=head1 SYNOPSIS
18
19S< >I<$tlist> = I<$parent>-E<gt>B<TList>(?I<options>?);
20
21=head1 SUPER-CLASS
22
23None.
24
25=head1 STANDARD OPTIONS
26
27B<-background> B<-borderwidth> B<-class> B<-cursor> B<-foreground>
28B<-font> B<-height> B<-highlightcolor> B<-highlightthickness>
29B<-relief> B<-selectbackground> B<-selectforeground>
30B<-xscrollcommand> B<-yscrollcommand> B<-width>
31
32See L<Tk::options> for details of the standard options.
33
34=head1 WIDGET-SPECIFIC OPTIONS
35
36=over 4
37
38=item Name: B<browsecmd>
39
40=item Class: B<BrowseCmd>
41
42=item Switch: B<-browsecmd>
43
44Specifies a perl/Tk B<callback> to be executed when the user browses through the
45entries in the TList widget.
46
47=item Name: B<command>
48
49=item Class: B<Command>
50
51=item Switch: B<-command>
52
53Specifies the perl/Tk B<callback> to be executed when the user invokes a list
54entry in the TList widget. Normally the user invokes a list
55entry by double-clicking it or pressing the Return key.
56
57=item Name: B<foreground>
58
59=item Class: B<Foreground>
60
61=item Switch: B<-foreground>
62
63=item Alias: B<-fg>
64
65Specifies the default foreground color for the list entries.
66
67=item Name: B<height>
68
69=item Class: B<Height>
70
71=item Switch: B<-height>
72
73Specifies the desired height for the window in number of characters.
74
75=item Name: B<itemType>
76
77=item Class: B<ItemType>
78
79=item Switch: B<-itemtype>
80
81Specifies the default type of display item for this TList widget. When
82you call the B<insert> methods, display items of this
83type will be created if the B<-itemtype> option is not specified.
84
85=item Name: B<orient>
86
87=item Class: B<Orient>
88
89=item Switch: B<-orient>
90
91Specifies the order of tabularizing the list entries. When set to
92"B<vertical>", the entries are arranged in a column, from top to
93bottom. If the entries cannot be contained in one column, the
94remaining entries will go to the next column, and so on. When set to
95"B<horizontal>", the entries are arranged in a row, from left to
96right. If the entries cannot be contained in one row, the remaining
97entries will go to the next row, and so on.
98
99=item Name: B<padX>
100
101=item Class: B<Pad>
102
103=item Switch: B<-padx>
104
105The default horizontal padding for list entries.
106
107=item Name: B<padY>
108
109=item Class: B<Pad>
110
111=item Switch: B<-padx>
112
113The default vertical padding for list entries.
114
115=item Name: B<selectBackground>
116
117=item Class: B<SelectBackground>
118
119=item Switch: B<-selectbackground>
120
121Specifies the background color for the selected list entries.
122
123=item Name: B<selectBorderWidth>
124
125=item Class: B<BorderWidth>
126
127=item Switch: B<-selectborderwidth>
128
129Specifies a non-negative value indicating the width of the 3-D border
130to draw around selected items. The value may have any of the forms
131acceptable to B<Tk_GetPixels>.
132
133=item Name: B<selectForeground>
134
135=item Class: B<SelectForeground>
136
137=item Switch: B<-selectforeground>
138
139Specifies the foreground color for the selected list entries.
140
141=item Name: B<selectMode>
142
143=item Class: B<SelectMode>
144
145=item Switch: B<-selectmode>
146
147Specifies one of several styles for manipulating the selection. The
148value of the option may be arbitrary, but the default bindings expect
149it to be either B<single>, B<browse>, B<multiple>, or
150B<extended>; the default value is B<single>.
151
152=item Name: B<sizeCmd>
153
154=item Class: B<SizeCmd>
155
156=item Switch: B<-sizecmd>
157
158Specifies a perl/Tk B<callback> to be called whenever the TList widget
159changes its size. This command can be useful to implement "user scroll
160bars when needed" features.
161
162=item Name: B<state>
163
164=item Class: B<State>
165
166=item Switch: B<-state>
167
168Specifies whether the TList command should react to user actions. When
169set to "B<normal>", the TList reacts to user actions in the normal
170way. When set to "B<disabled>", the TList can only be scrolled, but
171its entries cannot be selected or activated.
172
173=item Name: B<width>
174
175=item Class: B<Width>
176
177=item Switch: B<-width>
178
179Specifies the desired width for the window in characters.
180
181=back
182
183=head1 DESCRIPTION
184
185The B<TList> method creates a new window (given by the
186$widget argument) and makes it into a TList widget.
187Additional options, described above, may be specified on the command
188line or in the option database to configure aspects of the
189TList widget such as its cursor and relief.
190
191The TList widget can be used to display data in a tabular format. The
192list entries of a TList widget are similar to the entries in the Tk
193listbox widget. The main differences are (1) the TList widget can
194display the list entries in a two dimensional format and (2) you can
195use graphical images as well as multiple colors and fonts for
196the list entries.
197
198Each list entry is identified by an B<index>, which can be in the
199following forms:
200
201=over 4
202
203=item I<number>
204
205An integer that indicates the position of the entry in the list. 0
206means the first position, 1 means the second position, and so on.
207
208=item B<end>
209
210Indicates the end of the listbox. For some commands this means just
211after the last entry; for other commands it means the last entry.
212
213=item B<@>I<x>,I<y>
214
215Indicates the element that covers the point in the listbox window
216specified by x and y (in pixel coordinates). If no element covers that
217point, then the closest element to that point is used.
218
219=back
220
221=head1 DISPLAY ITEMS
222
223Each list entry in an TList widget is associated with a B<display>
224item. The display item determines what visual information should
225be displayed for this list entry. Please see L<Tk::DItem>
226for a list of all display items.
227
228When a list entry is created by the B<insert> command, the type of
229its display item is determined by the B<-itemtype> option passed
230to these commands. If the B<-itemtype> is omitted, then by default
231the type specified by this TList widget's B<-itemtype> option is
232used.
233
234=head1 WIDGET METHODS
235
236The B<TList> method creates a widget object.
237
238This object supports the B<configure> and B<cget> methods
239described in L<Tk::options> which can be used to enquire and
240modify the options described above.
241The widget also inherits all the methods provided by the generic
242L<Tk::Widget|Tk::Widget> class.
243
244The following additional methods are available for TList widgets:
245
246=over 4
247
248=item I<$tlist>-E<gt>B<anchorSet>(I<index>)
249
250Sets the anchor to the list entry identified by I<index>. The
251anchor is the end of the selection that is fixed while dragging out a
252selection with the mouse.
253
254=item I<$tlist>-E<gt>B<anchorClear>
255
256Removes the anchor, if any, from this TList widget. This only removes
257the surrounding highlights of the anchor entry and does not affect its
258selection status.
259
260=item I<$tlist>-E<gt>B<delete>(I<from, >?I<to>?)
261
262Deletes one or more list entries between the two entries specified by
263the indices I<from> and I<to>. If I<to> is not specified, deletes
264the single entry specified by I<from>.
265
266=item I<$tlist>-E<gt>B<dragsiteSet>(I<index>)
267
268Sets the dragsite to the list entry identified by
269I<index>. The dragsite is used to indicate the source of a
270drag-and-drop action. Currently drag-and-drop functionality has not
271been implemented in Tix yet.
272
273=item I<$tlist>-E<gt>B<dragsiteClear>
274
275Remove the dragsite, if any, from the this TList widget. This only
276removes the surrounding highlights of the dragsite entry and does not
277affect its selection status.
278
279=item I<$tlist>-E<gt>B<dropsiteSet>(I<index>)
280
281Sets the dropsite to the list entry identified by I<index>. The
282dropsite is used to indicate the target of a drag-and-drop
283action. Currently drag-and-drop functionality has not been implemented
284in Tix yet.
285
286=item I<$tlist>-E<gt>B<dropsiteClear>
287
288Remove the dropsite, if any, from the this TList widget. This only
289removes the surrounding highlights of the dropsite entry and does not
290affect its selection status.
291
292=item I<$tlist>-E<gt>B<entrycget>(I<index, option>)
293
294Returns the current value of the configuration option given by
295I<option> for the entry indentfied by I<index>. I<Option> may
296have any of the values accepted by the B<insert> method.
297
298=item I<$tlist>-E<gt>B<entryconfigure>(I<index, >?I<option>?, I<?value, option, value, ...>?)
299
300Query or modify the configuration options of the list entry identified
301by I<index>. If no I<option> is specified, returns a list
302describing all of the available options for I<index> (see
303B<Tk_ConfigureInfo> for information on the format of this list). If
304I<option> is specified with no I<value>, then the method
305returns a list describing the one named option (this list will be
306identical to the corresponding sublist of the value returned if no
307I<option> is specified). If one or more I<option-value> pairs
308are specified, then the command modifies the given option(s) to have
309the given value(s); in this case the method returns an empty string.
310I<Option> may have any of the values accepted by the B<insert>
311method. The exact set of options depends on the
312value of the B<-itemtype> option passed to the the B<insert>
313method when this list entry is created.
314
315=item I<$tlist>-E<gt>B<insert>(I<index, >?I<option, value, ...>?)
316
317Creates a new list entry at the position indicated by I<index>. The
318following configuration options can be given to configure the list
319entry:
320
321=over 8
322
323=item B<-itemtype> => I<type>
324
325Specifies the type of display item to be display for the new list
326entry. I<type> must be a valid display item type. Currently the
327available display item types are B<image>, B<imagetext>,
328B<text>, and I<$widget>. If this option is not specified, then by
329default the type specified by this TList widget's B<-itemtype>
330option is used.
331
332=item B<-state> => I<state>
333
334Specifies whether this entry can be selected or invoked by the user.
335Must be either B<normal> or B<disabled>.
336
337=item B<-data> => I<data>
338
339Arbitrary data to be associated with the entry (a perl scalar value).
340
341=back
342
343The B<insert> method accepts additional configuration options
344to configure the display item associated with this list entry. The set
345of additional configuration options depends on the type of the display
346item given by the B<-itemtype> option. Please see
347L<Tk::DItem> for a list of the configuration options for
348each of the display item types.
349
350=item I<$tlist>-E<gt>B<info>(I<option, >I<arg, ...>)
351
352Query information about the TList widget. I<option> can be one
353of the following:
354
355=over 8
356
357=item I<$tlist>-E<gt>B<info>(B<anchor, >I<index>)
358
359Returns the index of the current anchor, if any, of the TList
360widget. If the anchor is not set, returns the empty string.
361
362=item I<$tlist>-E<gt>B<info>(B<dragsite, >I<index>)
363
364Returns the index of the current dragsite, if any, of the TList
365widget. If the dragsite is not set, returns the empty string.
366
367=item I<$tlist>-E<gt>B<info>(B<dropsite, >I<index>)
368
369Returns the index of the current dropsite, if any, of the TList
370widget. If the dropsite is not set, returns the empty string.
371
372=item I<$tlist>-E<gt>B<info>(B<selection>)
373
374Returns a list of selected elements in the TList widget. If no entries
375are selected, returns an empty string.
376
377=back
378
379=item I<$tlist>-E<gt>B<nearest>(I<x, y>)
380
381Given an I<(x,y)> coordinate within the TList window, this command
382returns the index of the TList element nearest to that coordinate.
383
384=item I<$tlist>-E<gt>B<see>(I<index>)
385
386Adjust the view in the TList so that the entry given by I<index> is
387visible. If the entry is already visible then the command has no
388effect; otherwise TList scrolls to bring the element into view at the edge
389to which it is nearest.
390
391=item I<$tlist>-E<gt>B<selection>(I<option, >I<arg, ...>)
392
393This command is used to adjust the selection within a TList widget. It
394has several forms, depending on I<option>:
395
396=over 8
397
398=item I<$tlist>-E<gt>B<selectionClear>(?I<from>?, ?I<to>?)
399
400When no extra arguments are given, deselects all of the list entrie(s)
401in this TList widget. When only I<from> is given, only the list
402entry identified by I<from> is deselected. When both I<from> and
403I<to> are given, deselects all of the list entrie(s) between
404between I<from> and I<to>, inclusive, without affecting the
405selection state of entries outside that range.
406
407=item I<$tlist>-E<gt>B<selectionIncludes>(I<index>)
408
409Returns 1 if the list entry indicated by I<index> is currently
410selected; returns 0 otherwise.
411
412=item I<$tlist>-E<gt>B<selectionSet>(I<from, >?I<to>?)
413
414Selects all of the list entrie(s) between between I<from> and
415I<to>, inclusive, without affecting the selection state of entries
416outside that range. When only I<from> is given, only the list entry
417identified by I<from> is selected.
418
419=back
420
421=item I<$tlist>-E<gt>B<xview>(I<args>)
422
423This command is used to query and change the horizontal position of the
424information in the widget's window. It can take any of the following
425forms:
426
427=over 8
428
429=item I<$tlist>-E<gt>B<xview>
430
431Returns a list containing two elements. Each element is a real
432fraction between 0 and 1; together they describe the horizontal span
433that is visible in the window. For example, if the first element is
4340.2 and the second element is 0.6, 20% of the TList entry is
435off-screen to the left, the middle 40% is visible in the window, and
43640% of the entry is off-screen to the right. These are the same values
437passed to scrollbars via the B<-xscrollcommand> option.
438
439=item I<$tlist>-E<gt>B<xview>(I<index>)
440
441Adjusts the view in the window so that the list entry identified by
442I<index> is aligned to the left edge of the window.
443
444=item I<$tlist>-E<gt>B<xviewMoveto>(I<fraction>)
445
446Adjusts the view in the window so that I<fraction> of the total
447width of the TList is off-screen to the left. I<fraction> must be
448a fraction between 0 and 1.
449
450=item I<$tlist>-E<gt>B<xviewScroll>(I<number, what>)
451
452This command shifts the view in the window left or right according to
453I<number> and I<what>. I<Number> must be an integer.
454I<What> must be either B<units> or B<pages> or an
455abbreviation of one of these. If I<what> is B<units>, the view
456adjusts left or right by I<number> character units (the width of
457the B<0> character) on the display; if it is B<pages> then the
458view adjusts by I<number> screenfuls. If I<number> is negative
459then characters farther to the left become visible; if it is positive
460then characters farther to the right become visible.
461
462=back
463
464=item I<$tlist>-E<gt>B<yview>(I<?args>?)
465
466This command is used to query and change the vertical position of the
467entries in the widget's window. It can take any of the following forms:
468
469=over 8
470
471=item I<$tlist>-E<gt>B<yview>
472
473Returns a list containing two elements, both of which are real
474fractions between 0 and 1. The first element gives the position of
475the list element at the top of the window, relative to the TList as a
476whole (0.5 means it is halfway through the TList, for example). The
477second element gives the position of the list entry just after the
478last one in the window, relative to the TList as a whole. These are
479the same values passed to scrollbars via the B<-yscrollcommand>
480option.
481
482=item I<$tlist>-E<gt>B<yview>(I<index>)
483
484Adjusts the view in the window so that the list entry given by
485I<index> is displayed at the top of the window.
486
487=item I<$tlist>-E<gt>B<yviewMoveto>(I<fraction>)
488
489Adjusts the view in the window so that the list entry given by
490I<fraction> appears at the top of the window. I<Fraction> is a
491fraction between 0 and 1; 0 indicates the first entry in the TList,
4920.33 indicates the entry one-third the way through the TList, and so
493on.
494
495=item I<$tlist>-E<gt>B<yviewScroll>(I<number, what>)
496
497This command adjust the view in the window up or down according to
498I<number> and I<what>. I<Number> must be an integer.
499I<What> must be either B<units> or B<pages>. If I<what>
500is B<units>, the view adjusts up or down by I<number> lines; if
501it is B<pages> then the view adjusts by I<number> screenfuls.
502If I<number> is negative then earlier entries become visible; if
503it is positive then later entries become visible.
504
505=back
506
507=back
508
509=head1 BINDINGS
510
511=over 4
512
513=item [1]
514
515If the B<-selectmode> is "browse", when the user drags the mouse
516pointer over the list entries, the entry under the pointer will be
517highlighted and the B<-browsecmd> procedure will be called with
518one parameter, the index of the highlighted entry. Only one entry
519can be highlighted at a time. The B<-command> procedure will be
520called when the user double-clicks on a list entry.
521
522=item [2]
523
524If the B<-selectmode> is "single", the entries will only be
525highlighted by mouse E<lt>ButtonRelease-1E<gt> events. When a new list entry
526is highlighted, the B<-browsecmd> procedure will be called with
527one parameter indicating the highlighted list entry. The
528B<-command> procedure will be called when the user double-clicks
529on a list entry.
530
531=item [3]
532
533If the B<-selectmode> is "multiple", when the user drags the mouse
534pointer over the list entries, all the entries under the pointer will
535be highlighted. However, only a contiguous region of list entries can
536be selected. When the highlighted area is changed, the
537B<-browsecmd> procedure will be called with an undefined
538parameter. It is the responsibility of the B<-browsecmd> procedure
539to find out the exact highlighted selection in the TList. The
540B<-command> procedure will be called when the user double-clicks
541on a list entry.
542
543=item [4]
544
545If the B<-selectmode> is "extended", when the user drags the mouse
546pointer over the list entries, all the entries under the pointer will
547be highlighted. The user can also make disjointed selections using
548E<lt>Control-ButtonPress-1E<gt>. When the highlighted area is changed, the
549B<-browsecmd> procedure will be called with an undefined
550parameter. It is the responsibility of the B<-browsecmd> procedure
551to find out the exact highlighted selection in the TList. The
552B<-command> procedure will be called when the user double-clicks
553on a list entry.
554
555=back
556
557=cut
558
559# BUG:
560# click on 'one' in example below does not make
561# it 'active' item (didn't GBARR reported this before!?)
562
563=head1 EXAMPLE
564
565This example demonstrates how to use an TList to store a list of
566numbers:
567
568 use strict;
569 use Tk ();
570 use Tk::TList;
571
572 my $mw = Tk::MainWindow->new();
573 my $image = $mw->Getimage('folder');
574 my $tlist = $mw->TList(-orient => 'vertical');
575 for my $text ( qw/one two three four five six seven eight nine/ ) {
576 $tlist->insert('end',
577 -itemtype=>'imagetext', -image=>$image, -text=>$text);
578 }
579
580 $tlist->pack(-expand=>'yes', -fill=>'both');
581
582 Tk::MainLoop;
583
584=head1 SEE ALSO
585
586L<Tk::options|Tk::options>
587L<Tk::Widget|Tk::Widget>
588L<Tk::DItem|Tk::DItem>
589L<Tk::HList|Tk::HList>
590L<Tk::TixGrid|Tk::TixGrid>
591
592=head1 KEYWORDS
593
594Tix(n), Tabular Listbox, Display Items
595
596=cut
597