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

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [insight/] [tk/] [doc/] [listbox.n] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
'\"
2
'\" Copyright (c) 1990 The Regents of the University of California.
3
'\" Copyright (c) 1994-1997 Sun Microsystems, Inc.
4
'\"
5
'\" See the file "license.terms" for information on usage and redistribution
6
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7
'\"
8
'\" RCS: @(#) $Id: listbox.n,v 1.1.1.1 2002-01-16 10:25:49 markom Exp $
9
'\"
10
.so man.macros
11
.TH listbox n 8.0 Tk "Tk Built-In Commands"
12
.BS
13
'\" Note:  do not modify the .SH NAME line immediately below!
14
.SH NAME
15
listbox \- Create and manipulate listbox widgets
16
.SH SYNOPSIS
17
\fBlistbox\fR \fIpathName \fR?\fIoptions\fR?
18
.SO
19
\-background    \-foreground    \-relief        \-takefocus
20
\-borderwidth   \-height        \-selectbackground      \-width
21
\-cursor        \-highlightbackground   \-selectborderwidth     \-xscrollcommand
22
\-exportselection       \-highlightcolor        \-selectforeground      \-yscrollcommand
23
\-font  \-highlightthickness    \-setgrid
24
.SE
25
.SH "WIDGET-SPECIFIC OPTIONS"
26
.OP \-height height Height
27
Specifies the desired height for the window, in lines.
28
If zero or less, then the desired height for the window is made just
29
large enough to hold all the elements in the listbox.
30
.OP \-selectmode selectMode SelectMode
31
Specifies one of several styles for manipulating the selection.
32
The value of the option may be arbitrary, but the default bindings
33
expect it to be either \fBsingle\fR, \fBbrowse\fR, \fBmultiple\fR,
34
or \fBextended\fR;  the default value is \fBbrowse\fR.
35
.OP \-width width Width
36
Specifies the desired width for the window in characters.
37
If the font doesn't have a uniform width then the width of the
38
character ``0'' is used in translating from character units to
39
screen units.
40
If zero or less, then the desired width for the window is made just
41
large enough to hold all the elements in the listbox.
42
.BE
43
 
44
.SH DESCRIPTION
45
.PP
46
The \fBlistbox\fR command creates a new window (given by the
47
\fIpathName\fR argument) and makes it into a listbox widget.
48
Additional
49
options, described above, may be specified on the command line
50
or in the option database
51
to configure aspects of the listbox such as its colors, font,
52
text, and relief.  The \fBlistbox\fR command returns its
53
\fIpathName\fR argument.  At the time this command is invoked,
54
there must not exist a window named \fIpathName\fR, but
55
\fIpathName\fR's parent must exist.
56
.PP
57
A listbox is a widget that displays a list of strings, one per line.
58
When first created, a new listbox has no elements.
59
Elements may be added or deleted using widget commands described
60
below.  In addition, one or more elements may be selected as described
61
below.
62
If a listbox is exporting its selection (see \fBexportSelection\fR
63
option), then it will observe the standard X11 protocols
64
for handling the selection.
65
Listbox selections are available as type \fBSTRING\fR;
66
the value of the selection will be the text of the selected elements, with
67
newlines separating the elements.
68
.PP
69
It is not necessary for all the elements to be
70
displayed in the listbox window at once;  commands described below
71
may be used to change the view in the window.  Listboxes allow
72
scrolling in both directions using the standard \fBxScrollCommand\fR
73
and \fByScrollCommand\fR options.
74
They also support scanning, as described below.
75
 
76
.SH "INDICES"
77
.PP
78
Many of the widget commands for listboxes take one or more indices
79
as arguments.
80
An index specifies a particular element of the listbox, in any of
81
the following ways:
82
.TP 12
83
\fInumber\fR
84
Specifies the element as a numerical index, where 0 corresponds
85
to the first element in the listbox.
86
.TP 12
87
\fBactive\fR
88
Indicates the element that has the location cursor.  This element
89
will be displayed with an underline when the listbox has the
90
keyboard focus, and it is specified with the \fBactivate\fR
91
widget command.
92
.TP 12
93
\fBanchor\fR
94
Indicates the anchor point for the selection, which is set with the
95
\fBselection anchor\fR widget command.
96
.TP 12
97
\fBend\fR
98
Indicates the end of the listbox.
99
.VS 8.0
100
For most commands this refers to the last element in the listbox,
101
but for a few commands such as \fBindex\fR and \fBinsert\fR
102
it refers to the element just after the last one.
103
.VE
104
.TP 12
105
\fB@\fIx\fB,\fIy\fR
106
Indicates the element that covers the point in the listbox window
107
specified by \fIx\fR and \fIy\fR (in pixel coordinates).  If no
108
element covers that point, then the closest element to that
109
point is used.
110
.LP
111
In the widget command descriptions below, arguments named \fIindex\fR,
112
\fIfirst\fR, and \fIlast\fR always contain text indices in one of
113
the above forms.
114
 
115
.SH "WIDGET COMMAND"
116
.PP
117
The \fBlistbox\fR command creates a new Tcl command whose
118
name is \fIpathName\fR.  This
119
command may be used to invoke various
120
operations on the widget.  It has the following general form:
121
.CS
122
\fIpathName option \fR?\fIarg arg ...\fR?
123
.CE
124
\fIOption\fR and the \fIarg\fRs
125
determine the exact behavior of the command.  The following
126
commands are possible for listbox widgets:
127
.TP
128
\fIpathName \fBactivate\fR \fIindex\fR
129
Sets the active element to the one indicated by \fIindex\fR.
130
.VS 8.0
131
If \fIindex\fR is outside the range of elements in the listbox
132
then the closest element is activated.
133
.VE
134
The active element is drawn with an underline when the widget
135
has the input focus, and its index may be retrieved with the
136
index \fBactive\fR.
137
.TP
138
\fIpathName \fBbbox\fR \fIindex\fR
139
Returns a list of four numbers describing the bounding box of
140
the text in the element given by \fIindex\fR.
141
The first two elements of the list give the x and y coordinates
142
of the upper-left corner of the screen area covered by the text
143
(specified in pixels relative to the widget) and the last two
144
elements give the width and height of the area, in pixels.
145
If no part of the element given by \fIindex\fR is visible on the
146
screen,
147
.VS 8.0
148
or if \fIindex\fR refers to a non-existent element,
149
.VE
150
then the result is an empty string;  if the element is
151
partially visible, the result gives the full area of the element,
152
including any parts that are not visible.
153
.TP
154
\fIpathName \fBcget\fR \fIoption\fR
155
Returns the current value of the configuration option given
156
by \fIoption\fR.
157
\fIOption\fR may have any of the values accepted by the \fBlistbox\fR
158
command.
159
.TP
160
\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
161
Query or modify the configuration options of the widget.
162
If no \fIoption\fR is specified, returns a list describing all of
163
the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
164
information on the format of this list).  If \fIoption\fR is specified
165
with no \fIvalue\fR, then the command returns a list describing the
166
one named option (this list will be identical to the corresponding
167
sublist of the value returned if no \fIoption\fR is specified).  If
168
one or more \fIoption\-value\fR pairs are specified, then the command
169
modifies the given widget option(s) to have the given value(s);  in
170
this case the command returns an empty string.
171
\fIOption\fR may have any of the values accepted by the \fBlistbox\fR
172
command.
173
.TP
174
\fIpathName \fBcurselection\fR
175
Returns a list containing the numerical indices of
176
all of the elements in the listbox that are currently selected.
177
If there are no elements selected in the listbox then an empty
178
string is returned.
179
.TP
180
\fIpathName \fBdelete \fIfirst \fR?\fIlast\fR?
181
Deletes one or more elements of the listbox.  \fIFirst\fR and \fIlast\fR
182
are indices specifying the first and last elements in the range
183
to delete.  If \fIlast\fR isn't specified it defaults to
184
\fIfirst\fR, i.e. a single element is deleted.
185
.TP
186
\fIpathName \fBget \fIfirst\fR ?\fIlast\fR?
187
If \fIlast\fR is omitted, returns the contents of the listbox
188
element indicated by \fIfirst\fR,
189
.VS 8.0
190
or an empty string if \fIfirst\fR refers to a non-existent element.
191
.VE
192
If \fIlast\fR is specified, the command returns a list whose elements
193
are all of the listbox elements between \fIfirst\fR and \fIlast\fR,
194
inclusive.
195
Both \fIfirst\fR and \fIlast\fR may have any of the standard
196
forms for indices.
197
.TP
198
\fIpathName \fBindex \fIindex\fR
199
Returns the integer index value that corresponds to \fIindex\fR.
200
.VS 8.0
201
If \fIindex\fR is \fBend\fR the return value is a count of the number
202
of elements in the listbox (not the index of the last element).
203
.VE
204
.TP
205
\fIpathName \fBinsert \fIindex \fR?\fIelement element ...\fR?
206
Inserts zero or more new elements in the list just before the
207
element given by \fIindex\fR.  If \fIindex\fR is specified as
208
\fBend\fR then the new elements are added to the end of the
209
list.  Returns an empty string.
210
.TP
211
\fIpathName \fBnearest \fIy\fR
212
Given a y-coordinate within the listbox window, this command returns
213
the index of the (visible) listbox element nearest to that y-coordinate.
214
.TP
215
\fIpathName \fBscan\fR \fIoption args\fR
216
This command is used to implement scanning on listboxes.  It has
217
two forms, depending on \fIoption\fR:
218
.RS
219
.TP
220
\fIpathName \fBscan mark \fIx y\fR
221
Records \fIx\fR and \fIy\fR and the current view in the listbox
222
window;  used in conjunction with later \fBscan dragto\fR commands.
223
Typically this command is associated with a mouse button press in
224
the widget.  It returns an empty string.
225
.TP
226
\fIpathName \fBscan dragto \fIx y\fR.
227
This command computes the difference between its \fIx\fR and \fIy\fR
228
arguments and the \fIx\fR and \fIy\fR arguments to the last
229
\fBscan mark\fR command for the widget.
230
It then adjusts the view by 10 times the
231
difference in coordinates.  This command is typically associated
232
with mouse motion events in the widget, to produce the effect of
233
dragging the list at high speed through the window.  The return
234
value is an empty string.
235
.RE
236
.TP
237
\fIpathName \fBsee \fIindex\fR
238
Adjust the view in the listbox so that the element given by \fIindex\fR
239
is visible.
240
If the element is already visible then the command has no effect;
241
if the element is near one edge of the window then the listbox
242
scrolls to bring the element into view at the edge;  otherwise
243
the listbox scrolls to center the element.
244
.TP
245
\fIpathName \fBselection \fIoption arg\fR
246
This command is used to adjust the selection within a listbox.  It
247
has several forms, depending on \fIoption\fR:
248
.RS
249
.TP
250
\fIpathName \fBselection anchor \fIindex\fR
251
Sets the selection anchor to the element given by \fIindex\fR.
252
.VS 8.0
253
If \fIindex\fR refers to a non-existent element, then the closest
254
element is used.
255
.VE
256
The selection anchor is the end of the selection that is fixed
257
while dragging out a selection with the mouse.
258
The index \fBanchor\fR may be used to refer to the anchor
259
element.
260
.TP
261
\fIpathName \fBselection clear \fIfirst \fR?\fIlast\fR?
262
If any of the elements between \fIfirst\fR and \fIlast\fR
263
(inclusive) are selected, they are deselected.
264
The selection state is not changed for elements outside
265
this range.
266
.TP
267
\fIpathName \fBselection includes \fIindex\fR
268
Returns 1 if the element indicated by \fIindex\fR is currently
269
selected, 0 if it isn't.
270
.TP
271
\fIpathName \fBselection set \fIfirst \fR?\fIlast\fR?
272
Selects all of the elements in the range between
273
\fIfirst\fR and \fIlast\fR, inclusive, without affecting
274
the selection state of elements outside that range.
275
.RE
276
.TP
277
\fIpathName \fBsize\fR
278
Returns a decimal string indicating the total number of elements
279
in the listbox.
280
.TP
281
\fIpathName \fBxview \fIargs\fR
282
This command is used to query and change the horizontal position of the
283
information in the widget's window.  It can take any of the following
284
forms:
285
.RS
286
.TP
287
\fIpathName \fBxview\fR
288
Returns a list containing two elements.
289
Each element is a real fraction between 0 and 1;  together they describe
290
the horizontal span that is visible in the window.
291
For example, if the first element is .2 and the second element is .6,
292
20% of the listbox's text is off-screen to the left, the middle 40% is visible
293
in the window, and 40% of the text is off-screen to the right.
294
These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR
295
option.
296
.TP
297
\fIpathName \fBxview\fR \fIindex\fR
298
Adjusts the view in the window so that the character position given by
299
\fIindex\fR is displayed at the left edge of the window.
300
Character positions are defined by the width of the character \fB0\fR.
301
.TP
302
\fIpathName \fBxview moveto\fI fraction\fR
303
Adjusts the view in the window so that \fIfraction\fR of the
304
total width of the listbox text is off-screen to the left.
305
\fIfraction\fR must be a fraction between 0 and 1.
306
.TP
307
\fIpathName \fBxview scroll \fInumber what\fR
308
This command shifts the view in the window left or right according to
309
\fInumber\fR and \fIwhat\fR.
310
\fINumber\fR must be an integer.
311
\fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation
312
of one of these.
313
If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by
314
\fInumber\fR character units (the width of the \fB0\fR character)
315
on the display;  if it is \fBpages\fR then the view adjusts by
316
\fInumber\fR screenfuls.
317
If \fInumber\fR is negative then characters farther to the left
318
become visible;  if it is positive then characters farther to the right
319
become visible.
320
.RE
321
.TP
322
\fIpathName \fByview \fI?args\fR?
323
This command is used to query and change the vertical position of the
324
text in the widget's window.
325
It can take any of the following forms:
326
.RS
327
.TP
328
\fIpathName \fByview\fR
329
Returns a list containing two elements, both of which are real fractions
330
between 0 and 1.
331
The first element gives the position of the listbox element at the
332
top of the window, relative to the listbox as a whole (0.5 means
333
it is halfway through the listbox, for example).
334
The second element gives the position of the listbox element just after
335
the last one in the window, relative to the listbox as a whole.
336
These are the same values passed to scrollbars via the \fB\-yscrollcommand\fR
337
option.
338
.TP
339
\fIpathName \fByview\fR \fIindex\fR
340
Adjusts the view in the window so that the element given by
341
\fIindex\fR is displayed at the top of the window.
342
.TP
343
\fIpathName \fByview moveto\fI fraction\fR
344
Adjusts the view in the window so that the element given by \fIfraction\fR
345
appears at the top of the window.
346
\fIFraction\fR is a fraction between 0 and 1;  0 indicates the first
347
element in the listbox, 0.33 indicates the element one-third the
348
way through the listbox, and so on.
349
.TP
350
\fIpathName \fByview scroll \fInumber what\fR
351
This command adjusts the view in the window up or down according to
352
\fInumber\fR and \fIwhat\fR.
353
\fINumber\fR must be an integer.
354
\fIWhat\fR must be either \fBunits\fR or \fBpages\fR.
355
If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by
356
\fInumber\fR lines;  if it is \fBpages\fR then
357
the view adjusts by \fInumber\fR screenfuls.
358
If \fInumber\fR is negative then earlier elements
359
become visible;  if it is positive then later elements
360
become visible.
361
.RE
362
 
363
.SH "DEFAULT BINDINGS"
364
.PP
365
Tk automatically creates class bindings for listboxes that give them
366
Motif-like behavior.  Much of the behavior of a listbox is determined
367
by its \fBselectMode\fR option, which selects one of four ways
368
of dealing with the selection.
369
.PP
370
If the selection mode is \fBsingle\fR or \fBbrowse\fR, at most one
371
element can be selected in the listbox at once.
372
In both modes, clicking button 1 on an element selects
373
it and deselects any other selected item.
374
In \fBbrowse\fR mode it is also possible to drag the selection
375
with button 1.
376
.PP
377
If the selection mode is \fBmultiple\fR or \fBextended\fR,
378
any number of elements may be selected at once, including discontiguous
379
ranges.  In \fBmultiple\fR mode, clicking button 1 on an element
380
toggles its selection state without affecting any other elements.
381
In \fBextended\fR mode, pressing button 1 on an element selects
382
it, deselects everything else, and sets the anchor to the element
383
under the mouse;  dragging the mouse with button 1
384
down extends the selection to include all the elements between
385
the anchor and the element under the mouse, inclusive.
386
.PP
387
Most people will probably want to use \fBbrowse\fR mode for
388
single selections and \fBextended\fR mode for multiple selections;
389
the other modes appear to be useful only in special situations.
390
.PP
391
In addition to the above behavior, the following additional behavior
392
is defined by the default bindings:
393
.IP [1]
394
In \fBextended\fR mode, the selected range can be adjusted by pressing
395
button 1 with the Shift key down:  this modifies the selection to
396
consist of the elements between the anchor and the element under
397
the mouse, inclusive.
398
The un-anchored end of this new selection can also be dragged with
399
the button down.
400
.IP [2]
401
In \fBextended\fR mode, pressing button 1 with the Control key down
402
starts a toggle operation: the anchor is set to the element under
403
the mouse, and its selection state is reversed.  The selection state
404
of other elements isn't changed.
405
If the mouse is dragged with button 1 down, then the selection state
406
of all elements between the anchor and the element under the mouse
407
is set to match that of the anchor element;  the selection state of
408
all other elements remains what it was before the toggle operation
409
began.
410
.IP [3]
411
If the mouse leaves the listbox window with button 1 down, the window
412
scrolls away from the mouse, making information visible that used
413
to be off-screen on the side of the mouse.
414
The scrolling continues until the mouse re-enters the window, the
415
button is released, or the end of the listbox is reached.
416
.IP [4]
417
Mouse button 2 may be used for scanning.
418
If it is pressed and dragged over the listbox, the contents of
419
the listbox drag at high speed in the direction the mouse moves.
420
.IP [5]
421
If the Up or Down key is pressed, the location cursor (active
422
element) moves up or down one element.
423
If the selection mode is \fBbrowse\fR or \fBextended\fR then the
424
new active element is also selected and all other elements are
425
deselected.
426
In \fBextended\fR mode the new active element becomes the
427
selection anchor.
428
.IP [6]
429
In \fBextended\fR mode, Shift-Up and Shift-Down move the location
430
cursor (active element) up or down one element and also extend
431
the selection to that element in a fashion similar to dragging
432
with mouse button 1.
433
.IP [7]
434
The Left and Right keys scroll the listbox view left and right
435
by the width of the character \fB0\fR.
436
Control-Left and Control-Right scroll the listbox view left and
437
right by the width of the window.
438
Control-Prior and Control-Next also scroll left and right by
439
the width of the window.
440
.IP [8]
441
The Prior and Next keys scroll the listbox view up and down
442
by one page (the height of the window).
443
.IP [9]
444
The Home and End keys scroll the listbox horizontally to
445
the left and right edges, respectively.
446
.IP [10]
447
Control-Home sets the location cursor to the the first element in
448
the listbox, selects that element, and deselects everything else
449
in the listbox.
450
.IP [11]
451
Control-End sets the location cursor to the the last element in
452
the listbox, selects that element, and deselects everything else
453
in the listbox.
454
.IP [12]
455
In \fBextended\fR mode, Control-Shift-Home extends the selection
456
to the first element in the listbox and Control-Shift-End extends
457
the selection to the last element.
458
.IP [13]
459
In \fBmultiple\fR mode, Control-Shift-Home moves the location cursor
460
to the first element in the listbox and Control-Shift-End moves
461
the location cursor to the last element.
462
.IP [14]
463
The space and Select keys make a selection at the location cursor
464
(active element) just as if mouse button 1 had been pressed over
465
this element.
466
.IP [15]
467
In \fBextended\fR mode, Control-Shift-space and Shift-Select
468
extend the selection to the active element just as if button 1
469
had been pressed with the Shift key down.
470
.IP [16]
471
In \fBextended\fR mode, the Escape key cancels the most recent
472
selection and restores all the elements in the selected range
473
to their previous selection state.
474
.IP [17]
475
Control-slash selects everything in the widget, except in
476
\fBsingle\fR and \fBbrowse\fR modes, in which case it selects
477
the active element and deselects everything else.
478
.IP [18]
479
Control-backslash deselects everything in the widget, except in
480
\fBbrowse\fR mode where it has no effect.
481
.IP [19]
482
The F16 key (labelled Copy on many Sun workstations) or Meta-w
483
copies the selection in the widget to the clipboard, if there is
484
a selection.
485
 
486
.PP
487
The behavior of listboxes can be changed by defining new bindings for
488
individual widgets or by redefining the class bindings.
489
 
490
.SH KEYWORDS
491
listbox, widget

powered by: WebSVN 2.1.0

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