Bwidget Source Code
Check-in [8860bd1e23]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:* listbox.tcl (ListBox::create et al) new feature: listbox option -listbox now read/write [Bug 1501874] reported by Stephen Huntley

* dynhelp.tcl (DynamicHelp::_show_help) fixed issue (as far as possible): Dynamic help baloon was on the main screen, if it touched the border on a windows multi screen configuration. The fix assumes, that all screens have same dimensions and no gaps in- between. This is necessary, because multi-screen configuration paramters may not be interrogated by tk (despite of coordinates out of the screen) [Bug 1499135] reported by Gregor

Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8860bd1e2319a2b38844eb2e7334c72a611863d0
User & Date: oehhar 2009-06-26 14:46:05
Context
2009-06-26
15:22
* notebook.tcl (NoteBook::delete) Deleted also state variables [Bug 1445219] reported by Eric Kemp-Benedict check-in: 886bbcdfee user: oehhar tags: trunk
14:46
* listbox.tcl (ListBox::create et al) new feature: listbox option -listbox now read/write [Bug 1501874] reported by Stephen Huntley

* dynhelp.tcl (DynamicHelp::_show_help) fixed issue (as far as possible): Dynamic help baloon was on the main screen, if it touched the border on a windows multi screen configuration. The fix assumes, that all screens have same dimensions and no gaps in- between. This is necessary, because multi-screen configuration paramters may not be interrogated by tk (despite of coordinates out of the screen) [Bug 1499135] reported by Gregor check-in: 8860bd1e23 user: oehhar tags: trunk

2009-06-25
16:48
* combobox.tcl (ComboBox::getvalue et al) fixed bug: getvalue returned first apearence of current data instead of clicked index, which may not be the same if values is not unique. Additional variable _index(path) added to hold click index [Bug 1610965] reported by Martin Lemburg check-in: a758127e75 user: oehhar tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to BWman/ListBox.html.

363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<DD>
    If true, the listbox will draw a selection rectangle that fills the
    listbox from left-to-right instead of just drawing a box around the
    selected item.  This more closely mimics the standard Tk listbox.
</DD>
</DL>

<DL><DT><A NAME="-selectmode"><B>-selectmode (read-only)</B></A></DT>
<DD>

Specifies the desired selection-mode for the listbox. Must be one of
<B>none</B>, <B>single</B> or <B>multiple</B>. <B>selectmode</B> <I>single</I>
allows to select 1 item by its text or image. <B>selectmode</B> <I>multiple</I>
allows to select multiple items by their text or image. For more info on
selectmodes <I>single</I> or <I>multiple</I>, see the Tk <B>listbox</B>






|







363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<DD>
    If true, the listbox will draw a selection rectangle that fills the
    listbox from left-to-right instead of just drawing a box around the
    selected item.  This more closely mimics the standard Tk listbox.
</DD>
</DL>

<DL><DT><A NAME="-selectmode"><B>-selectmode</B></A></DT>
<DD>

Specifies the desired selection-mode for the listbox. Must be one of
<B>none</B>, <B>single</B> or <B>multiple</B>. <B>selectmode</B> <I>single</I>
allows to select 1 item by its text or image. <B>selectmode</B> <I>multiple</I>
allows to select multiple items by their text or image. For more info on
selectmodes <I>single</I> or <I>multiple</I>, see the Tk <B>listbox</B>

Changes to ChangeLog.














1
2
3
4
5
6
7












2009-06-25 Harald Oehlmann  <[email protected]>

	* combobox.tcl (ComboBox::getvalue et al) fixed bug: getvalue returned
	first apearence of current data instead of clicked index, which may not
	be the same if values is not unique. Additional variable _index(path)
	added to hold click index [Bug 1610965] reported by Martin Lemburg

>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
2009-06-26 Harald Oehlmann  <[email protected]>

	* listbox.tcl (ListBox::create et al) new feature: listbox option
	-listbox now read/write [Bug 1501874] reported by Stephen Huntley
	
	* dynhelp.tcl (DynamicHelp::_show_help) fixed issue (as far as possible):
	Dynamic help baloon was on the main screen, if it touched the border on
	a windows multi screen configuration.
	The fix assumes, that all screens have same dimensions and no gaps in-
	between. This is necessary, because multi-screen configuration paramters
	may not be interrogated by tk (despite of coordinates out of the screen)
	[Bug 1499135] reported by Gregor

2009-06-25 Harald Oehlmann  <[email protected]>

	* combobox.tcl (ComboBox::getvalue et al) fixed bug: getvalue returned
	first apearence of current data instead of clicked index, which may not
	be the same if values is not unique. Additional variable _index(path)
	added to hold click index [Bug 1610965] reported by Martin Lemburg

Changes to dynhelp.tcl.

1
2
3
4
5
6
7
8
9
10
11
...
680
681
682
683
684
685
686









687
688
689
690
691



692
693
694


695
696
697
698
699
700
701
# ----------------------------------------------------------------------------
#  dynhelp.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: dynhelp.tcl,v 1.16 2006/11/10 19:58:49 dev_null42a Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - DynamicHelp::configure
#     - DynamicHelp::include
#     - DynamicHelp::sethelp
#     - DynamicHelp::register
#     - DynamicHelp::_motion_balloon
................................................................................

	if {![winfo exists $_top]} {return}

        set  scrwidth  [winfo vrootwidth  .]
        set  scrheight [winfo vrootheight .]
        set  width     [winfo reqwidth  $_top]
        set  height    [winfo reqheight $_top]









        incr y 12
        incr x 8

        if { $x+$width > $scrwidth } {
            set x [expr {$scrwidth - $width}]



        }
        if { $y+$height > $scrheight } {
            set y [expr {$y - 12 - $height}]


        }

        wm geometry  $_top "+$x+$y"
        update idletasks

	if {![winfo exists $_top]} { return }
        wm deiconify $_top


|







 







>
>
>
>
>
>
>
>
>
|
|
|
|
<
>
>
>

|
|
>
>







1
2
3
4
5
6
7
8
9
10
11
...
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699

700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
# ----------------------------------------------------------------------------
#  dynhelp.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: dynhelp.tcl,v 1.17 2009/06/26 14:46:05 oehhar Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - DynamicHelp::configure
#     - DynamicHelp::include
#     - DynamicHelp::sethelp
#     - DynamicHelp::register
#     - DynamicHelp::_motion_balloon
................................................................................

	if {![winfo exists $_top]} {return}

        set  scrwidth  [winfo vrootwidth  .]
        set  scrheight [winfo vrootheight .]
        set  width     [winfo reqwidth  $_top]
        set  height    [winfo reqheight $_top]

        # On windows multi screen configurations, coordinates may get outside
        # the main screen. We suppose that all screens have the same size
        # because it is not possible to query the size of the other screens.
        
        set screenx [expr {$x % $scrwidth} ]
        set screeny [expr {$y % $scrheight} ]
        
        # Increment the required size by the deplacement from the passed point
        incr width 8
        incr height 12
        
        if { $screenx+$width > $scrwidth } {

            set x [expr {$x + ($scrwidth - $screenx) - ($width - 8)}]
        } else {
            incr x 8
        }
        if { $screeny+$height > $scrheight } {
            set y [expr {$y - $height}]
        } else {
            incr y 12
        }

        wm geometry  $_top "+$x+$y"
        update idletasks

	if {![winfo exists $_top]} { return }
        wm deiconify $_top

Changes to listbox.tcl.

1
2
3
4
5
6
7
8
9
10
11
..
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
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
# ----------------------------------------------------------------------------
#  listbox.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: listbox.tcl,v 1.27 2009/06/10 08:48:06 oehhar Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - ListBox::create
#     - ListBox::configure
#     - ListBox::cget
#     - ListBox::insert
#     - ListBox::itemconfigure
................................................................................
        {-selectforeground TkResource "" 0 listbox}
        {-font             TkResource "" 0 listbox}
        {-width            TkResource "" 0 listbox}
        {-height           TkResource "" 0 listbox}
        {-redraw           Boolean 1  0}
        {-multicolumn      Boolean 0  0}
        {-dropovermode     Flag    "wpi" 0 "wpi"}
	{-selectmode       Enum none 1 {none single multiple}}
        {-fg               Synonym -foreground}
        {-bg               Synonym -background}
        {-dropcmd          String  "ListBox::_drag_and_drop" 0}
        {-autofocus        Boolean  1  1}
        {-selectfill       Boolean  0  1}
    }

................................................................................
    bindtags $path.c $bindtags

    # Add slightly modified up/down bindings to the canvas, in case
    # it gets the focus (like with -autofocus).
    bind $path.c <Key-Up> {ListBox::_keyboard_navigation [winfo parent %W] -1}
    bind $path.c <Key-Down> {ListBox::_keyboard_navigation [winfo parent %W] 1}

    switch -exact -- [Widget::getoption $path -selectmode] {












	single {
















	    $path bindText  <Button-1> [list ListBox::_mouse_select $path set]
	    $path bindImage <Button-1> [list ListBox::_mouse_select $path set]


	}

	multiple {
	    set cmd ListBox::_multiple_select
	    $path bindText <Button-1>          [list $cmd $path n %x %y]
	    $path bindText <Shift-Button-1>    [list $cmd $path s %x %y]
	    $path bindText <Control-Button-1>  [list $cmd $path c %x %y]

	    $path bindImage <Button-1>         [list $cmd $path n %x %y]
	    $path bindImage <Shift-Button-1>   [list $cmd $path s %x %y]
	    $path bindImage <Control-Button-1> [list $cmd $path c %x %y]
	}



    }

    return $path
}


# ----------------------------------------------------------------------------
#  Command ListBox::configure
# ----------------------------------------------------------------------------
proc ListBox::configure { path args } {

    set res [Widget::configure $path $args]





    set ch1 [expr {[Widget::hasChanged $path -deltay dy]  |
                   [Widget::hasChanged $path -padx val]   |
                   [Widget::hasChanged $path -multicolumn val]}]

    set ch2 [expr {[Widget::hasChanged $path -selectbackground val] |
                   [Widget::hasChanged $path -selectforeground val]}]


|







 







|







 







|
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|
>
>
|
>
|
|
|
|
|

|
|
|
|
>
>
>
|
|
<
|
|
<




>

>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
..
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
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
# ----------------------------------------------------------------------------
#  listbox.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: listbox.tcl,v 1.28 2009/06/26 14:46:05 oehhar Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - ListBox::create
#     - ListBox::configure
#     - ListBox::cget
#     - ListBox::insert
#     - ListBox::itemconfigure
................................................................................
        {-selectforeground TkResource "" 0 listbox}
        {-font             TkResource "" 0 listbox}
        {-width            TkResource "" 0 listbox}
        {-height           TkResource "" 0 listbox}
        {-redraw           Boolean 1  0}
        {-multicolumn      Boolean 0  0}
        {-dropovermode     Flag    "wpi" 0 "wpi"}
        {-selectmode       Enum none 0 {none single multiple}}
        {-fg               Synonym -foreground}
        {-bg               Synonym -background}
        {-dropcmd          String  "ListBox::_drag_and_drop" 0}
        {-autofocus        Boolean  1  1}
        {-selectfill       Boolean  0  1}
    }

................................................................................
    bindtags $path.c $bindtags

    # Add slightly modified up/down bindings to the canvas, in case
    # it gets the focus (like with -autofocus).
    bind $path.c <Key-Up> {ListBox::_keyboard_navigation [winfo parent %W] -1}
    bind $path.c <Key-Down> {ListBox::_keyboard_navigation [winfo parent %W] 1}

    _configureSelectmode $path [Widget::getoption $path -selectmode]

    return $path
}


# ----------------------------------------------------------------------------
#  Command ListBox::_configureSelectmode
# ----------------------------------------------------------------------------
# Configure the selectmode
proc ListBox::_configureSelectmode { path selectmode {previous none} } {
    # clear current binding
    switch -exact -- $previous {
        single {
            $path bindText  <Button-1> ""
            $path bindImage <Button-1> ""
        }
        multiple {
            $path bindText <Button-1>          ""
            $path bindText <Shift-Button-1>    ""
            $path bindText <Control-Button-1>  ""

            $path bindImage <Button-1>         ""
            $path bindImage <Shift-Button-1>   ""
            $path bindImage <Control-Button-1> ""
        }
    }
    # set new bindings
    switch -exact -- $selectmode {
        single {
            $path bindText  <Button-1> [list ListBox::_mouse_select $path set]
            $path bindImage <Button-1> [list ListBox::_mouse_select $path set]
            if {1 < [llength [ListBox::selection $path get]]} {
                ListBox::selection $path clear
            }
        }
        multiple {
            set cmd ListBox::_multiple_select
            $path bindText <Button-1>          [list $cmd $path n %x %y]
            $path bindText <Shift-Button-1>    [list $cmd $path s %x %y]
            $path bindText <Control-Button-1>  [list $cmd $path c %x %y]

            $path bindImage <Button-1>         [list $cmd $path n %x %y]
            $path bindImage <Shift-Button-1>   [list $cmd $path s %x %y]
            $path bindImage <Control-Button-1> [list $cmd $path c %x %y]
        }
        default {
            if {0 < [llength [ListBox::selection $path get]]} {
                ListBox::selection $path clear
            }
        }

    }
}

# ----------------------------------------------------------------------------
#  Command ListBox::configure
# ----------------------------------------------------------------------------
proc ListBox::configure { path args } {
    set selectmodePrevious [Widget::getoption $path -selectmode]
    set res [Widget::configure $path $args]

    if { [Widget::hasChanged $path -selectmode selectmode] } {
        _configureSelectmode $path $selectmode $selectmodePrevious
    }

    set ch1 [expr {[Widget::hasChanged $path -deltay dy]  |
                   [Widget::hasChanged $path -padx val]   |
                   [Widget::hasChanged $path -multicolumn val]}]

    set ch2 [expr {[Widget::hasChanged $path -selectbackground val] |
                   [Widget::hasChanged $path -selectforeground val]}]