Bwidget Source Code
Check-in [8cb3726ece]
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:BWidget::bindMiddleMouseMovement added
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8cb3726eceed019d6eb9ad9da74c13f0911a05f1
User & Date: oberdorfer 2009-09-08 20:46:40
Context
2009-09-08
20:50
ttk style related mod's done check-in: 1d04512fc7 user: oberdorfer tags: trunk
20:46
BWidget::bindMiddleMouseMovement added check-in: 8cb3726ece user: oberdorfer tags: trunk
20:33
ttk style related change done check-in: eaa66ce996 user: oberdorfer tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to tree.tcl.

1
2
3
4
5
6
7
8
9
10
11
..
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
..
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
...
134
135
136
137
138
139
140




141
142
143
144
145
146
147
...
194
195
196
197
198
199
200

201
202
203
204
205
206
207
...
231
232
233
234
235
236
237



238
239
240
241
242
243
244
....
2237
2238
2239
2240
2241
2242
2243
















































# ----------------------------------------------------------------------------
#  tree.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: tree.tcl,v 1.61 2009/08/04 16:39:06 oehhar Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - Tree::create
#     - Tree::configure
#     - Tree::cget
#     - Tree::insert
#     - Tree::itemconfigure
................................................................................
#     - Tree::_redraw_selection
#     - Tree::_redraw_idle
#     - Tree::_drag_cmd
#     - Tree::_drop_cmd
#     - Tree::_over_cmd
#     - Tree::_auto_scroll
#     - Tree::_scroll

# ----------------------------------------------------------------------------

namespace eval Tree {
    Widget::define Tree tree DragSite DropSite DynamicHelp

    namespace eval Node {
        Widget::declare Tree::Node {
            {-text       String     ""      0}
            {-font       TkResource ""      0 listbox}
            {-image      TkResource ""      0 label}
            {-window     String     ""      0}
            {-fill       TkResource black   0 {listbox -foreground}}
            {-data       String     ""      0}
            {-open       Boolean    0       0}
	    {-selectable Boolean    1       0}
            {-drawcross  Enum       auto    0 {auto always never allways}}
	    {-padx       Int        -1      0 "%d >= -1"}
	    {-deltax     Int        -1      0 "%d >= -1"}
	    {-anchor     String     "w"     0 ""}
................................................................................
	-highlightthickness 1 -width 200
    }

    Widget::declare Tree {
        {-deltax           Int 10 0 "%d >= 0"}
        {-deltay           Int 15 0 "%d >= 0"}
        {-padx             Int 20 0 "%d >= 0"}
        {-background       TkResource "" 0 listbox}
        {-selectbackground TkResource "" 0 listbox}
        {-selectforeground TkResource "" 0 listbox}
	{-selectcommand    String     "" 0}
        {-width            TkResource "" 0 listbox}
        {-height           TkResource "" 0 listbox}
        {-selectfill       Boolean 0  0}
        {-showlines        Boolean 1  0}
        {-linesfill        TkResource black  0 {listbox -foreground}}
        {-linestipple      TkResource ""     0 {label -bitmap}}
	{-crossfill        TkResource black  0 {listbox -foreground}}
        {-redraw           Boolean 1  0}
        {-opencmd          String  "" 0}
        {-closecmd         String  "" 0}
        {-dropovermode     Flag    "wpn" 0 "wpn"}
        {-bg               Synonym -background}

        {-crossopenimage    String  ""  0}
................................................................................
    }

    bind TreeSentinalEnd <Button-1> {
	set ::Tree::sentinal(%W) 0
    }

    bind TreeFocus <Button-1> [list focus %W]





    variable _edit
}


# ----------------------------------------------------------------------------
#  Command Tree::create
................................................................................
    bind $path.c <Control-KeyPress-Up>    [list $path.c yview scroll -1 units]
    bind $path.c <Control-KeyPress-Down>  [list $path.c yview scroll  1 units]
    bind $path.c <Control-KeyPress-Left>  [list $path.c xview scroll -1 units]
    bind $path.c <Control-KeyPress-Right> [list $path.c xview scroll  1 units]
    # [email protected]

    BWidget::bindMouseWheel $path.c


    DragSite::setdrag $path $path.c Tree::_init_drag_cmd \
	    [Widget::cget $path -dragendcmd] 1
    DropSite::setdrop $path $path.c Tree::_over_cmd Tree::_drop_cmd 1

    Widget::create Tree $path

................................................................................
    # canvas (which can happen if the double-button on the item causes some
    # other event to be handled in between when the button clicks are examined
    # for the canvas)
    $path.c bind TreeItemSentinal <Double-Button-1> \
	[list set ::Tree::sentinal($path.c) 1]
    # ericm




    return $path
}


# ----------------------------------------------------------------------------
#  Command Tree::configure
# ----------------------------------------------------------------------------
................................................................................
    if { $data(dnd,afterid) != "" } {
        after cancel $data(dnd,afterid)
    }
    _subdelete $path [lrange $data(root) 1 end]
    Widget::destroy $path
    unset data
}


















































|







 







>








|


|







 







|
|
|





|

|







 







>
>
>
>







 







>







 







>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
..
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
..
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
...
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
...
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
...
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
....
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
# ----------------------------------------------------------------------------
#  tree.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: tree.tcl,v 1.62 2009/09/08 20:46:40 oberdorfer Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - Tree::create
#     - Tree::configure
#     - Tree::cget
#     - Tree::insert
#     - Tree::itemconfigure
................................................................................
#     - Tree::_redraw_selection
#     - Tree::_redraw_idle
#     - Tree::_drag_cmd
#     - Tree::_drop_cmd
#     - Tree::_over_cmd
#     - Tree::_auto_scroll
#     - Tree::_scroll
#     - Tree::_themechanged
# ----------------------------------------------------------------------------

namespace eval Tree {
    Widget::define Tree tree DragSite DropSite DynamicHelp

    namespace eval Node {
        Widget::declare Tree::Node {
            {-text       String     ""      0}
 	    {-font       String     "TkTextFont" 0}
            {-image      TkResource ""      0 label}
            {-window     String     ""      0}
            {-fill       Color      "SystemWindowText" 0}
            {-data       String     ""      0}
            {-open       Boolean    0       0}
	    {-selectable Boolean    1       0}
            {-drawcross  Enum       auto    0 {auto always never allways}}
	    {-padx       Int        -1      0 "%d >= -1"}
	    {-deltax     Int        -1      0 "%d >= -1"}
	    {-anchor     String     "w"     0 ""}
................................................................................
	-highlightthickness 1 -width 200
    }

    Widget::declare Tree {
        {-deltax           Int 10 0 "%d >= 0"}
        {-deltay           Int 15 0 "%d >= 0"}
        {-padx             Int 20 0 "%d >= 0"}
        {-background       Color      "SystemWindow"  0}
        {-selectbackground Color      "SystemHighlight"  0}
        {-selectforeground Color      "SystemHighlightText" 0}
	{-selectcommand    String     "" 0}
        {-width            TkResource "" 0 listbox}
        {-height           TkResource "" 0 listbox}
        {-selectfill       Boolean 0  0}
        {-showlines        Boolean 1  0}
        {-linesfill        Color      "SystemWindowText"  0}
        {-linestipple      TkResource ""     0 {label -bitmap}}
	{-crossfill        Color      "SystemWindowText"  0} 
        {-redraw           Boolean 1  0}
        {-opencmd          String  "" 0}
        {-closecmd         String  "" 0}
        {-dropovermode     Flag    "wpn" 0 "wpn"}
        {-bg               Synonym -background}

        {-crossopenimage    String  ""  0}
................................................................................
    }

    bind TreeSentinalEnd <Button-1> {
	set ::Tree::sentinal(%W) 0
    }

    bind TreeFocus <Button-1> [list focus %W]

    if {[lsearch [bindtags .] TreeThemeChanged] < 0} {
        bindtags . [linsert [bindtags .] 1 TreeThemeChanged]
    }

    variable _edit
}


# ----------------------------------------------------------------------------
#  Command Tree::create
................................................................................
    bind $path.c <Control-KeyPress-Up>    [list $path.c yview scroll -1 units]
    bind $path.c <Control-KeyPress-Down>  [list $path.c yview scroll  1 units]
    bind $path.c <Control-KeyPress-Left>  [list $path.c xview scroll -1 units]
    bind $path.c <Control-KeyPress-Right> [list $path.c xview scroll  1 units]
    # [email protected]

    BWidget::bindMouseWheel $path.c
    BWidget::bindMiddleMouseMovement $path.c

    DragSite::setdrag $path $path.c Tree::_init_drag_cmd \
	    [Widget::cget $path -dragendcmd] 1
    DropSite::setdrop $path $path.c Tree::_over_cmd Tree::_drop_cmd 1

    Widget::create Tree $path

................................................................................
    # canvas (which can happen if the double-button on the item causes some
    # other event to be handled in between when the button clicks are examined
    # for the canvas)
    $path.c bind TreeItemSentinal <Double-Button-1> \
	[list set ::Tree::sentinal($path.c) 1]
    # ericm

    bind TreeThemeChanged <<ThemeChanged>> \
	   "+ [namespace current]::_themechanged $path"

    return $path
}


# ----------------------------------------------------------------------------
#  Command Tree::configure
# ----------------------------------------------------------------------------
................................................................................
    if { $data(dnd,afterid) != "" } {
        after cancel $data(dnd,afterid)
    }
    _subdelete $path [lrange $data(root) 1 end]
    Widget::destroy $path
    unset data
}


proc Tree::_getnodes {path {node "root"}} {
    set nodes [$path nodes $node]
    foreach node $nodes {
        set nodes [concat $nodes [_getnodes $path $node]]
    }
    return $nodes
}


# ----------------------------------------------------------------------------
#  Command Tree::_themechanged
# ----------------------------------------------------------------------------
proc Tree::_themechanged { path } {

    if { ![winfo exists $path] } { return }
    BWidget::set_themedefaults
    
    $path configure \
           -background $BWidget::colors(SystemWindow) \
           -selectbackground $BWidget::colors(SystemHighlight) \
           -selectforeground $BWidget::colors(SystemHighlightText) \
           -linesfill $BWidget::colors(SystemWindowText) \
           -crossfill $BWidget::colors(SystemWindowText)

    # make sure, existing items appear in the same color as well:
    set res [$path nodes "root"]

    # res(ult) might be either a string or a list...
    if {[llength $res] == 0 && [string length $res] > 0} {

        foreach node [_getnodes $path $res] {
            $path itemconfigure $node \
	             -fill $BWidget::colors(SystemWindowText)
        }
    } elseif { [llength $res] > 0 } {

        foreach n $res {
            foreach node [_getnodes $path $n] {
                $path itemconfigure $node \
	                 -fill $BWidget::colors(SystemWindowText)
            }
	}
    }
    
    _redraw_idle $path 3
}