1<TITLE>iwidgets::scrolledlistbox - Create and manipulate scrolled listbox widgets</TITLE> 2<H1>iwidgets::scrolledlistbox - Create and manipulate scrolled listbox widgets</H1> 3 4</pre><H2>SYNOPSIS</H2> 5<B>iwidgets::scrolledlistbox<I> <I>pathName </I>?<I>options</I>? 6</pre><H2>INHERITANCE</H2> 7itk::Widget <- iwidgets::Labeledwidget <- iwidgets::Scrolledwidget <- iwidgets::Scrolledlistbox 8</pre><H2>STANDARD OPTIONS</H2> 9<P> 10<table cellpadding=5> 11<td valign=top> 12<B><br> 13cursor<br> 14highlightThickness<br> 15selectForeground</B></I><br> 16</td> 17<td valign=top> 18activeBackground<br> 19exportSelection<br> 20relief<br> 21</td> 22<td valign=top> 23background<br> 24foreground<br> 25selectBackground<br> 26</td> 27<td valign=top> 28borderWidth<br> 29highlightColor<br> 30selectBorderWidth<br> 31</td> 32</table> 33<P> 34See the <A HREF="http://www.sco.com/Technology/tcl/man/tk_man/options.n.html"> "options" </A> manual entry for details on the standard options. 35</pre><H2>ASSOCIATED OPTIONS</H2> 36<P> 37<table cellpadding=5> 38<td valign=top> 39<B>selectMode</B><br> 40</td> 41<td valign=top> 42<B>listvariable</B><br> 43</td> 44<td valign=top> 45</td> 46<td valign=top> 47</td> 48</table> 49<P> 50See the <A HREF="http://www.sco.com/Technology/tcl/man/tk_man/listbox.n.html"> "listbox" </A> widget manual entry for details on the above 51associated options. 52<P> 53<table cellpadding=5> 54<td valign=top> 55<B>activeRelief</B><br> 56</td> 57<td valign=top> 58<B>elementBorderwidth</B><br> 59</td> 60<td valign=top> 61<B>jump</B><br> 62</td> 63<td valign=top> 64<B>troughColor</B><br> 65</td> 66</table> 67<P> 68See the <A HREF="http://www.sco.com/Technology/tcl/man/tk_man/scrollbar.n.html"> "scrollbar" </A> widget manual entry for details on the above 69associated options. 70</pre><H2>INHERITED OPTIONS</H2> 71<P> 72<table cellpadding=5> 73<td valign=top> 74<B>disabledForeground</B><br> 75<B>labelMargin</B><br> 76<B>state</B><br> 77</td> 78<td valign=top> 79<B>labelBitmap</B><br> 80<B>labelPos</B><br> 81<B>sticky</B><br> 82</td> 83<td valign=top> 84<B>labelFont</B><br> 85<B>labelText</B><br> 86</td> 87<td valign=top> 88<B>labelImage</B><br> 89<B>labelVariable</B><br> 90</td> 91</table> 92<P> 93See the <A HREF="labeledwidget.n.html"> "labeledwidget" </A> class manual entry for details on the inherited 94options. 95</pre><H2>WIDGET-SPECIFIC OPTIONS</H2> 96<P> 97<pre> 98Name: <B>dblClickCommand</B> 99Class: <B>Command</B> 100Command-Line Switch: <B>-dblclickcommand</B> 101</pre> 102<UL> 103Specifies a Tcl command procedure which is called when an item is 104double clicked. Typically this occurs when mouse button 1 is double 105clicked over an item. Selection policy does not matter. 106</UL> 107<P> 108<pre> 109Name: <B>height</B> 110Class: <B>Height</B> 111Command-Line Switch: <B>-height</B> 112</pre> 113<UL> 114Specifies the height of the scrolled list box as an entire unit. 115The value may be specified in any of the forms acceptable to 116<B>Tk_GetPixels</B>. Any additional space needed to display the other 117components such as labels, margins, and scrollbars force the listbox 118to be compressed. A value of zero along with the same value for 119the width causes the value given for the visibleitems option 120to be applied which administers geometry constraints in a different 121manner. The default height is zero. 122</UL> 123<P> 124<pre> 125Name: <B>hscrollMode</B> 126Class: <B>ScrollMode</B> 127Command-Line Switch: <B>-hscrollmode</B> 128</pre> 129<UL> 130Specifies the the display mode to be used for the horizontal 131scrollbar: <B>static, dynamic,</B> or <B>none</B>. In static mode, the 132scroll bar is displayed at all times. Dynamic mode displays the 133scroll bar as required, and none disables the scroll bar display. The 134default is static. 135</UL> 136<P> 137<pre> 138Name: <B>sbWidth</B> 139Class: <B>Width</B> 140Command-Line Switch: <B>-sbwidth</B> 141</pre> 142<UL> 143Specifies the width of the scrollbar in any of the forms acceptable 144to <B>Tk_GetPixels</B>. The default width is 15 pixels.. 145</UL> 146<P> 147<pre> 148Name: <B>scrollMargin</B> 149Class: <B>Margin</B> 150Command-Line Switch: <B>-scrollmargin</B> 151</pre> 152<UL> 153Specifies the distance between the listbox and scrollbar in any of the 154forms acceptable to <B>Tk_GetPixels</B>. The default is 3 pixels. 155</UL> 156<P> 157<pre> 158Name: <B>selectionCommand</B> 159Class: <B>Command</B> 160Command-Line Switch: <B>-selectioncommand</B> 161</pre> 162<UL> 163Specifies a Tcl command procedure which is called when an item is 164selected. Selection policy does not matter. 165</UL> 166<P> 167<pre> 168Name: <B>state</B> 169Class: <B>State</B> 170Command-Line Switch: <B>-state</B> 171</pre> 172<UL> 173Specifies one of two states for the listbox: <B>normal</B> or <B>disabled</B>. 174If the listbox is disabled then selection is ignored. The default is 175normal. 176</UL> 177<P> 178<pre> 179Name: <B>textBackground</B> 180Class: <B>Background</B> 181Command-Line Switch <B>-textbackground</B> 182</pre> 183<UL> 184Specifies the background color for the listbox. This allows the background 185within the listbox to be different from the normal background color. 186</UL> 187<P> 188<pre> 189Name: <B>textFont</B> 190Class: <B>Font</B> 191Command-Line Switch: <B>-textfont</B> 192</pre> 193<UL> 194Specifies the font to be used for text in the listbox. This allows for 195the font associated with text internal to the scrolled listbox to be 196different than the font for labels. 197</UL> 198<P> 199<pre> 200Name: <B>visibleitems</B> 201Class: <B>VisibleItems</B> 202Command-Line Switch: <B>-visibleitems</B> 203</pre> 204<UL> 205Specifies the widthxheight in characters and lines for the listbox. 206This option is only administered if the width and height options 207are both set to zero, otherwise they take precedence. The default value 208is 20x10. With the visibleitems option engaged, geometry constraints 209are maintained only on the listbox. The size of the other components such as 210labels, margins, and scroll bars, are additive and independent, 211effecting the overall size of the scrolled list box. In contrast, 212should the width and height options have non zero values, they 213are applied to the scrolled list box as a whole. The listbox 214is compressed or expanded to maintain the geometry constraints. 215</UL> 216<P> 217<pre> 218Name: <B>vscrollMode</B> 219Class: <B>ScrollMode</B> 220Command-Line Switch: <B>-vscrollmode</B> 221</pre> 222<UL> 223Specifies the the display mode to be used for the vertical 224scrollbar: <B>static, dynamic,</B> or <B>none</B>. In static mode, the 225scroll bar is displayed at all times. Dynamic mode displays the 226scroll bar as required, and none disables the scroll bar display. The 227default is static. 228</UL> 229<P> 230<pre> 231Name: <B>width</B> 232Class: <B>Width</B> 233Command-Line Switch: <B>-width</B> 234</pre> 235<UL> 236Specifies the width of the scrolled list box as an entire unit. 237The value may be specified in any of the forms acceptable to 238<B>Tk_GetPixels</B>. Any additional space needed to display the other 239components such as labels, margins, and scrollbars force the listbox 240to be compressed. A value of zero along with the same value for 241the height causes the value given for the visibleitems option 242to be applied which administers geometry constraints in a different 243manner. The default width is zero. 244</UL> 245</pre><HR> 246 247</pre><H2>DESCRIPTION</H2> 248<P> 249The <B>iwidgets::scrolledlistbox</B> command creates 250a scrolled listbox with additional options to manage 251horizontal and vertical scrollbars. This includes options to control 252which scrollbars are displayed and the method, i.e. statically or 253dynamically. 254 255</pre><H2>METHODS</H2> 256<P> 257The <B>iwidgets::scrolledlistbox</B> command creates a new Tcl command whose 258name is <I>pathName</I>. This 259command may be used to invoke various 260operations on the widget. It has the following general form: 261<pre> 262<I>pathName option </I>?<I>arg arg ...</I>? 263</pre> 264<I>Option</I> and the <I>arg</I>s 265determine the exact behavior of the command. 266<P> 267Many of the widget commands for a scrolledlistbox take as one argument an 268indicator of which entry of the list box to operate on. These 269indicators are called <I>index</I>es and may be specified in 270any of the following forms: 271<DL> 272<DT> <I>number</I> 273</I></B> 274<DD> Specifies the element as a numerical index, where 0 corresponds 275to the first element in the listbox. 276</DL> 277<DL> 278<DT> <B>active</B> 279</I></B> 280<DD> Indicates the element that has the location cursor. This element 281will be displayed with an underline when the listbox has the 282keyboard focus, and it is specified with the <B>activate</B> 283widget command. 284</DL> 285<DL> 286<DT> <B>anchor</B> 287</I></B> 288<DD> Indicates the anchor point for the selection, which is set with the 289<B>selection anchor</B> widget command. 290</DL> 291<DL> 292<DT> <B>end</B> 293</I></B> 294<DD> Indicates the end of the listbox. 295For some commands this means just after the last element; 296for other commands it means the last element. 297</DL> 298<DL> 299<DT> <B>@<I>x<B>,<I>y</I> 300</I></B> 301<DD> Indicates the element that covers the point in the listbox window 302specified by <I>x</I> and <I>y</I> (in pixel coordinates). If no 303element covers that point, then the closest element to that 304point is used. 305</DL> 306<DL> 307<DT> <I>pattern</I> 308</I></B> 309<DD> If the index doesn't satisfy one of the above forms then this 310form is used. <I>Pattern</I> is pattern-matched against the items in 311the list box, in order from the top down, until a matching entry is found. 312The rules of <B>Tcl_StringMatch</B> are used. 313</DL> 314<P> 315The following widget commands are possible for scrolledlistbox widgets: 316 317</pre><H2>ASSOCIATED METHODS</H2> 318<P> 319<table cellpadding=5> 320<td valign=top> 321<B>activate</B><br> 322<B>get</B><br> 323<B>nearest</B><br> 324<B>size</B><br> 325</td> 326<td valign=top> 327<B>bbox</B><br> 328<B>index</B><br> 329<B>scan</B><br> 330<B>xview</B><br> 331</td> 332<td valign=top> 333<B>curselection</B><br> 334<B>insert</B><br> 335<B>see</B><br> 336<B>yview</B><br> 337</td> 338<td valign=top> 339<B>delete</B><br> 340<B>itemconfigure</B><br> 341<B>selection</B><br> 342</td> 343</table> 344<P> 345See the <A HREF="http://www.sco.com/Technology/tcl/man/tk_man/listbox.n.html"> "listbox" </A> manual entry for details on the associated methods. 346 347</pre><H2>WIDGET-SPECIFIC METHODS</H2> 348<DL> 349<DT> <I>pathName <B>cget</B> <I>option</I> 350</I></B> 351<DD> Returns the current value of the configuration option given 352by <I>option</I>. 353<I>Option</I> may have any of the values accepted by the <B>iwidgets::scrolledlistbox</B> 354command. 355</DL> 356<DL> 357<DT> <I>pathName <B>clear</B> 358</I></B> 359<DD> Clears the listbox of all items. 360</DL> 361<DL> 362<DT> <I>pathName</I> <B>configure</B> ?<I>option</I>? ?<I>value option value ...</I>? 363</I></B> 364<DD> Query or modify the configuration options of the widget. 365If no <I>option</I> is specified, returns a list describing all of 366the available options for <I>pathName</I> (see <B>Tk_ConfigureInfo</B> for 367information on the format of this list). If <I>option</I> is specified 368with no <I>value</I>, then the command returns a list describing the 369one named option (this list will be identical to the corresponding 370sublist of the value returned if no <I>option</I> is specified). If 371one or more <I>option-value</I> pairs are specified, then the command 372modifies the given widget option(s) to have the given value(s); in 373this case the command returns an empty string. 374<I>Option</I> may have any of the values accepted by the <B>iwidgets::scrolledlistbox</B> 375command. 376</DL> 377<DL> 378<DT> <I>pathName <B>getcurselection</B> 379</I></B> 380<DD> Returns the contents of the listbox element indicated by the current 381selection indexes. Short cut version of get and curselection command 382combination. 383</DL> 384<DL> 385<DT> <I>pathName <B>justify <I>direction</I> 386</I></B> 387<DD> Justifies the list contents via teh scroll bars in one of four directions: 388<B>left</B>, <B>right</B>, <B>top</B>, or <B>bottom</B>. 389</DL> 390<DL> 391<DT> <I>pathName <B>selecteditemcount</B> 392</I></B> 393<DD> Returns the number of items currently selected in the list. 394</DL> 395<DL> 396<DT> <I>pathName <B>sort</B> <I>order</I> 397</I></B> 398<DD> Sort the current list in any of the forms accepted by Tcl's lsort command. 399Also accepts either <B>ascending</B> or <B>descending</B> order. 400 401</DL> 402</pre><H2>COMPONENTS</H2> 403<P> 404<pre> 405Name: <B>listbox</B> 406Class: <B>listbox</B> 407</pre> 408<UL> 409The listbox component is the listbox widget. See the "listbox" widget 410manual entry for details on the listbox component item. 411</UL> 412<P> 413<pre> 414Name: <B>horizsb</B> 415Class: <B>Scrollbar</B> 416</pre> 417<UL> 418The horizsb component is the horizontal scroll bar. See the "scrollbar" 419widget manual entry for details on the horizsb component item. 420</UL> 421<P> 422<pre> 423Name: <B>vertsb</B> 424Class: <B>Scrollbar</B> 425</pre> 426<UL> 427The vertsb component is the vertical scroll bar. See the "scrollbar" widget 428manual entry for details on the vertsb component item. 429</UL> 430</table> 431 432</pre><H2>EXAMPLE</H2> 433<pre> 434 package require Iwidgets 4.0 435 option add *textBackground white 436 proc selCmd {} { 437 puts stdout "[.slb getcurselection]" 438 } 439 proc defCmd {} { 440 puts stdout "Double Click" 441 return [selCmd] 442 } 443 iwidgets::scrolledlistbox .slb -selection single \\ 444 -vscrollmode static -hscrollmode dynamic -labeltext "List" \\ 445 -selectioncommand selCmd -dblclickcommand defCmd 446 pack .slb -padx 10 -pady 10 -fill both -expand yes 447 .slb insert end {Hello {Out There} World} 448</pre> 449</pre><H2>AUTHOR</H2> 450<A HREF="mailto:mulferts@spd.dsccc.com">Mark L. Ulferts</A> 451</pre><H2>KEYWORDS</H2> 452scrolledlistbox, listbox, widget 453