-
Notifications
You must be signed in to change notification settings - Fork 8
/
mclistbox.html
executable file
·552 lines (399 loc) · 18.1 KB
/
mclistbox.html
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
<HTML>
<HEAD>
<TITLE>NAME</TITLE>
<LINK REV="made" HREF="mailto:">
</HEAD>
<BODY>
<!-- INDEX BEGIN -->
<!--
<UL>
<UL>
<LI><A HREF="#NAME">NAME</A>
<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
<LI><A HREF="#EXPORTS">EXPORTS</A>
<LI><A HREF="#STANDARD_OPTIONS">STANDARD OPTIONS</A>
<LI><A HREF="#WIDGET_SPECIFIC_OPTIONS">WIDGET-SPECIFIC OPTIONS</A>
<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
<LI><A HREF="#WIDGET_COMMAND">WIDGET COMMAND</A>
<LI><A HREF="#EXAMPLE">EXAMPLE</A>
<LI><A HREF="#DEFAULT_BINDINGS">DEFAULT BINDINGS</A>
<LI><A HREF="#BUGS">BUGS</A>
</UL>
</UL>
-->
<!-- INDEX END -->
<P>
<H2><A NAME="NAME">NAME</A></H2>
<P>
mclistbox::mclistbox - Create and manipulate a multi-column listbox
<P>
<H2><A NAME="SYNOPSIS">SYNOPSIS</A></H2>
<P>
<STRONG>package require mclistbox ?1.02</STRONG>
<P>
<STRONG>mclistbox::mclistbox</STRONG> <EM>pathName</EM> <EM>?options?</EM>
<P>
<H2><A NAME="EXPORTS">EXPORTS</A></H2>
<P>
mclistbox
<P>
<H2><A NAME="STANDARD_OPTIONS">STANDARD OPTIONS</A></H2>
<P>
<STRONG>-background</STRONG>
<STRONG>-borderwidth</STRONG>
<STRONG>-cursor</STRONG>
<STRONG>-exportselection</STRONG>
<STRONG>-font</STRONG>
<STRONG>-foreground</STRONG>
<STRONG>-height</STRONG>
<STRONG>-highlightbackground</STRONG>
<STRONG>-highlightcolor</STRONG>
<STRONG>-highlightthickness</STRONG>
<STRONG>-relief</STRONG>
<STRONG>-selectbackground</STRONG>
<STRONG>-selectborderwidth</STRONG>
<STRONG>-selectforeground</STRONG>
<STRONG>-setgrid</STRONG>
<STRONG>-takefocus</STRONG>
<STRONG>-width</STRONG>
<STRONG>-xscrollcommand</STRONG>
<STRONG>-yscrollcommand</STRONG>
<P>
See the <EM>options</EM> manual entry for detailed descriptions of the above options.
<P>
<H2><A NAME="WIDGET_SPECIFIC_OPTIONS">WIDGET-SPECIFIC OPTIONS</A></H2>
<P>
Command-Line Name: <STRONG>-columnborderwidth</STRONG> <br>
Database Name: <STRONG>columnBorderWidth</STRONG><br>
Database Class: <STRONG>BorderWidth</STRONG>
<P>
Specifies a non-negative value indicating the width of the 3-D border to
draw around the outside of the column (if such a border is being drawn; the <STRONG>columnrelief</STRONG> option typically determines this). The value may also be used when drawing
3-D effects in the interior of the widget. The value may have any of the
forms acceptable to Tk_GetPixels.
<P>
Command-Line Name: <STRONG>-columnrelief</STRONG> <br>
Database Name: <STRONG>columnRelief</STRONG> <br>
Database Class: <STRONG>Relief</STRONG>
<P>
Specifies the 3-D effect desired for the column. Acceptable values are
raised, <STRONG>sunken</STRONG>, <STRONG>flat</STRONG>, <STRONG>ridge</STRONG>, <STRONG>solid</STRONG>, and <STRONG>groove</STRONG>. The value indicates how the interior of the column should appear relative
to its exterior; for example, raised means the interior of the column
should appear to protrude from the screen, relative to the exterior of the
column.
<P>
Command-Line Name: <STRONG>-fillcolumn</STRONG> <br>
Database Name: <STRONG>fillColumn</STRONG><br>
Database Class: <STRONG>FillColumn</STRONG>
<P>
Specifies which column should grow or shrink such that all columns exactly
fill the listbox widget.
<P>
Command-Line Name: <STRONG>-labelanchor</STRONG> <br>
Database Name: <STRONG>labelAnchor</STRONG><br>
Database Class: <STRONG>Anchor</STRONG>
<P>
Specifies how the information in the column label is to be displayed. Must
be one of the values <STRONG>n</STRONG>, <STRONG>ne</STRONG>, <STRONG>e</STRONG>, <STRONG>se</STRONG>,
<STRONG>s</STRONG>, <STRONG>sw</STRONG>, <STRONG>w</STRONG>, <STRONG>nw</STRONG>, or <STRONG>center</STRONG>. For example, nw means display the information such that its top-left
corner is at the top-left corner of the column label.
<P>
Command-Line Name: <STRONG>-labelbackground</STRONG> or <STRONG>-labelbg</STRONG><br>
Database Name: <STRONG>labelBackground</STRONG> <br>
Database Class: <STRONG>Background</STRONG>
<P>
Specifies the normal background color to use when displaying the label.
<P>
Command-Line Name: <STRONG>-labelborderwidth or -labelbd</STRONG> <br>
Database Name: <STRONG>labelBorderWidth</STRONG> <br>
Database Class: <STRONG>BorderWidth</STRONG>
<P>
Specifies a non-negative value indicating the width of the 3-D border to
draw around the outside of the column label (if such a border is being
drawn; the relief option typically determines this). The value may also be
used when drawing 3-D effects in the interior of the column label. The
value may have any of the forms acceptable to Tk_GetPixels.
<P>
Command-Line Name: <STRONG>-labelfont</STRONG> <br>
Database Name: <STRONG>labelFont</STRONG> <br>
Database Class: <STRONG>Font</STRONG>
<P>
Specifies the font to use when drawing text inside the column label.
<P>
Command-Line Name: <STRONG>-labelforeground</STRONG> <br>
Database Name: <STRONG>labelForeground</STRONG> <br>
Database Class: <STRONG>Foreground</STRONG>
<P>
Specifies the normal foreground color to use when displaying the column
label.
<P>
Command-Line Name: <STRONG>-labelheight</STRONG> <br>
Database Name: <STRONG>labelHeight</STRONG><br>
Database Class: <STRONG>Height</STRONG>
<P>
Specifies a desired height for the label. If an image or bitmap is being
displayed in the label then the value is in screen units (i.e. any of the
forms acceptable to Tk_GetPixels); for text it is in lines of text. If this
option isn't specified, the label's desired height is computed from the
size of the image or bitmap or text being displayed in it.
<P>
Command-Line Name: <STRONG>-labelrelief</STRONG> <br>
Database Name: <STRONG>labelRelief</STRONG><br>
Database Class: <STRONG>Relief</STRONG>
<P>
Specifies the 3-D effect desired for the column label. Acceptable values
are <STRONG>raised</STRONG>, <STRONG>sunken</STRONG>, <STRONG>flat</STRONG>, <STRONG>ridge</STRONG>, <STRONG>solid</STRONG>, and
<STRONG>groove</STRONG>. The value indicates how the interior of the column label should appear
relative to its exterior; for example, raised means the interior of the
column label should appear to protrude from the screen, relative to the
exterior of the column label.
<P>
Command-Line Name: <STRONG>-labels</STRONG> <br>
Database Name: <STRONG>labels</STRONG><br>
Database Class: <STRONG>Labels</STRONG>
<P>
A boolean value which determines whether column labels are shown or not.
<P>
Command-Line Name: <STRONG>-selectcommand</STRONG> <EM>command</EM> <br>
Database Name: <STRONG>selectCommand</STRONG><br>
Database Class: <STRONG>Command</STRONG>
<P>
Specifies a Tcl command to be run whenever the selection in the mclistbox
changes. The command will be called with the result of the curselection
command.
<P>
Command-Line Name: <STRONG>-resizablecolumns</STRONG> <br>
Database Name: <STRONG>resizableColumns</STRONG> <br>
Database Class: <STRONG>ResizableColumns</STRONG>
<P>
Specifies whether the columns can be resized interactively. If set to true,
mouse bindings will be defined to allow the columns to be resized. See <STRONG>DEFAULT BINDINGS</STRONG> for more information.
<P>
Command-Line Name: <STRONG>-selectmode</STRONG> <br>
Database Name: <STRONG>selectMode</STRONG><br>
Database Class: <STRONG>SelectMode</STRONG>
<P>
Specifies one of several styles for manipulating the selection. The value
of the option may be arbitrary, but the default bindings expect it to be
either <STRONG>single</STRONG>, <STRONG>browse</STRONG>, <STRONG>multiple</STRONG>, or <STRONG>extended</STRONG>; the default value is browse.
<P>
<H2><A NAME="DESCRIPTION">DESCRIPTION</A></H2>
<P>
The <STRONG>mclistbox</STRONG> command creates a new window (given by the
<EM>pathName</EM> argument) and makes it into a mclistbox widget. Additional options,
described above, may be specified on the command line to configure aspects
of the mclistbox such as its colors, font, text, and relief. The mclistbox
command returns its pathName argument. At the time this command is invoked,
there must not exist a window named pathName, but pathName's parent must
exist.
<P>
A mclistbox is a widget that displays a list of strings, one per line. When
first created, a new mclistbox has no elements and no columns. Columns and
elementd may be added or deleted using widget commands described below. In
addition, one or more elements may be selected as described below. When an
element in one column is selected, the elements in all columns are
selected.
<P>
It is not necessary for all the elements to be displayed in the mclistbox
window at once; commands described below may be used to change the view in
the window. Mclistboxes allow scrolling in both directions using the
standard xScrollCommand and yScrollCommand options. They also support
scanning, as described below.
<P>
<H2><A NAME="WIDGET_COMMAND">WIDGET COMMAND</A></H2>
<P>
The widget command accepts many of the same arguments as the standard
listbox command. The following commands behave identically to the standard
listbox commands:
<P>
<STRONG>activate</STRONG>
<STRONG>bbox</STRONG>
<STRONG>cget</STRONG>
<STRONG>configure</STRONG>
<STRONG>curselection</STRONG>
<STRONG>delete</STRONG>
<STRONG>index</STRONG>
<STRONG>nearest</STRONG>
<STRONG>scan</STRONG>
<STRONG>see</STRONG>
<STRONG>selection</STRONG>
<STRONG>size</STRONG>
<STRONG>xview</STRONG>
<STRONG>yview</STRONG>
<P>
In addition, there are a few commands unique to the mclistbox:
<DL>
<P><DT><STRONG><A NAME="item_pathName">pathName column option args</A></STRONG><DD>
<DL>
<P><DT><STRONG>pathName column add name options</STRONG><DD>
<P>
Adds a new column with the specified <EM>name</EM>. <EM>options</EM> may be any of the valid column configuration options.
<P><DT><STRONG>pathName column cget name option</STRONG><DD>
<P>
Returns the value for the named <EM>option</EM>
<P><DT><STRONG>pathName column configure name options</STRONG><DD>
<P>
Configures or queries attributes of the <EM>named</EM> column.
<P>
Columns may be configured with the standard listbox options (-background,
-font, etc). In addition, the following options are available:
<DL>
<P><DT><STRONG><A NAME="item__background">-background</A></STRONG><DD>
<P>
Specifies the background color for this column. If the value is an empty
string the column will be configured with the default background color.
<P><DT><STRONG><A NAME="item__bitmap">-bitmap</A></STRONG><DD>
<P>
Specifies a bitmap to display in the column label. If the bitmap option is
specified then it overrides the -label option. the bitmap option may be
reset to an empty string to re-enable a text display.
<P><DT><STRONG><A NAME="item__font">-font</A></STRONG><DD>
<P>
Specifies the font for this column. If the value is an empty string the
column will be configured with the default font. Note that if fonts with
different line heights are used for separate columns, the data in each
column will not line up properly.
<P><DT><STRONG><A NAME="item__foreground">-foreground</A></STRONG><DD>
<P>
Specifies the foreground color for this column. If the value is an empty
string the column will be configured with the default foreground color.
<P><DT><STRONG><A NAME="item__image">-image</A></STRONG><DD>
<P>
Specifies an image to display in the column label. If the image option is
specified then it overrides other options that specify a bitmap or textual
value to display in the column label; the image option may be reset to an
empty string to re-enable a bitmap or text display.
<P><DT><STRONG><A NAME="item__label">-label</A></STRONG><DD>
<P>
Specifies the desired text to be used in the column label.
<P><DT><STRONG><A NAME="item__position">-position</A></STRONG><DD>
<P>
Specifies the position of the column. 0 (zero) is the first column, 1 (one)
is the second and so on.
<P><DT><STRONG><A NAME="item__resizable">-resizable</A></STRONG><DD>
<P>
Specifies whether the column is resizable. This only takes effect if the
global option <STRONG>-resizablecolumns</STRONG> is true.
<P><DT><STRONG><A NAME="item__visible">-visible</A></STRONG><DD>
<P>
Specifies whether the column is visible or not.
<P><DT><STRONG><A NAME="item__width">-width</A></STRONG><DD>
<P>
Specifies the desired width of the column in characters. If the font
doesn't have a uniform width then the width of the character ``0'' is used
in translating from character units to screen units. If zero or less, then
the desired width for the window is made just large enough to hold all the
elements in the listbox.
</DL>
<P><DT><STRONG>pathName column delete name</STRONG><DD>
<P>
Deletes the column identified by <EM>name</EM>
<P><DT><STRONG>pathName column names</STRONG><DD>
<P>
Returns a list containing all of the column <EM>names</EM>. The order of the list is the same as the visual order of the columns, and
is the same as the order the data is returned by the get command.
<P><DT><STRONG>pathName column nearext x</STRONG><DD>
<P>
Given a x-coordinate within the mclistbox window, this command returns the
name of the column nearest to that x-coordinate.
</DL>
<P><DT><STRONG>pathName get first ?last?</STRONG><DD>
<P>
If last is omitted, returns a list containing the element from each column
of the listbox element indicated by <EM>first</EM>, or an empty list if first refers to a non-existent element. If <EM>last</EM> is specified, the command returns a list of lists. Each of the sublists
will contain an element from each column of the mclistbox element. Both
first and last may have any of the standard forms for indices.
<P>
The data will be returned in the order that the columns appear visually,
and is the same order as reported by the <STRONG>column names</STRONG>
command.
<P><DT><STRONG>pathName insert index list ?list ...?</STRONG><DD>
<P>
Inserts zero or more new elements in the mclistbox just before the element
given by index. If index is specified as end then the new elements are
added to the end of the list. Returns an empty string. Each
<EM>list</EM> argument becomes one row in the mclistbox. If there are not enough elements
to fill all of the columns, blank values will be used to fill in the
missing columns.
<P><DT><STRONG>pathName label bind name sequence command</STRONG><DD>
<P>
This command associates <EM>command</EM> with a column label such that whenever the event sequence given by <EM>sequence</EM> occurs over the label for the column named <EM>name</EM> the <EM>command</EM> will be invoked. This widget command is similar to the bind command except
that it operates on column labels rather than the entire widget. See the
bind manual entry for complete details on the syntax of <EM>sequence</EM> and the substitutions performed on <EM>command</EM> before invoking it.
</DL>
<P>
<H2><A NAME="EXAMPLE">EXAMPLE</A></H2>
<P>
The following example creates a listbox with three columns:
<P>
<PRE> mclistbox .listbox -width 55
</PRE>
<P>
<PRE> .listbox column add name -label "First Name" -width 20
.listbox column add size -label "Last Name" -width 20
.listbox column add mod -label "Organization" -width 15
</PRE>
<P>
To add items to the list, do the following:
<P>
<PRE> .listbox insert end [list "Bryan" "Oakley" "ChannelPoint"]
.listbox insert end [list "John" "Ousterhout" "Ajuba Solutions"]
</PRE>
<P>
... or more concisely:
<P>
<PRE> .listbox insert end \
[list "Bryan" "Oakley" "ChannelPoint"] \
[list "John" "Ousterhout" "Ajuba Solutions"]
</PRE>
<P>
To cause a proc to be called when the user clicks on the column label of
the column named ``date'', use ``label bind'' as in the following example:
<P>
<PRE> .listbox label bind date <ButtonPress-1> "sortByDate %W"
</PRE>
<P>
<PRE> proc sortByDate {w} {
# code to sort the contents of the mclistbox named $w
}
</PRE>
<P>
<H2><A NAME="DEFAULT_BINDINGS">DEFAULT BINDINGS</A></H2>
<P>
Bindings in the mclistbox widget are the same as for a standard listbox
widget. In addition, if <STRONG>-resizableColumns</STRONG> is set to true, the following additional bindings are set:
<P>
<STRONG>ButtonPress-1</STRONG> starts a column resize if the cursor is over a column header and within a
few pixels of the left or right edge of the label. <STRONG>B1-Motion</STRONG> causes the columns on either side of the cursor to be resized based on the
amount the cursor has moved. <STRONG>ButtonRelease-1</STRONG>
ends the column resize.
<P>
If a binding is set on a label via the <STRONG>label bind</STRONG> command and
<STRONG>-resizablecolumns</STRONG> is set, the binding will not fire the event happens in the few pixels
inside the left and right edges of the label where a resize can occur. This
is to prevent both the label bindings and resize events to happen with a
single button press.
<P>
<H2><A NAME="BUGS">BUGS</A></H2>
<P>
If you use different fonts for different columns, the data will not line up
properly if those fonts don't have the same line height. There is currently
no workaround other than to use fonts with the same line height.
<P>
Mixing labels and images in column headers can produce unevenly sized
headers, which in turn will cause the data in the columns not to line up
properly.
<P>
Event bindings that fire while the mouse cursor is over a column return
wrong values for %W, <CODE>%x</CODE> and %y. The returned values represent
the internal widgets clicked over rather than relative to the mclistbox
widget (there's no way to work around this in tk as of 8.1b2). To convert a
value returned for the <CODE>%W</CODE> keyword, use the function
::mclistbox::convert. Sorry, no real documentation here; see the example
(example.tcl) that comes with this distribution
<P>
The command ``<pathName> xview index'' doesn't work.
<P>
I'm sure there are others...
</BODY>
</HTML>