cbklib

Check-in [5362800858]
Login

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

Overview
Comment:Add more libs
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:5362800858731247246ae6b7b8cddcb8220b1c85
User & Date: admin 2015-06-28 21:10:53
Context
2015-06-29
00:57
add appname pkg check-in: 975bb1035a user: admin tags: trunk
2015-06-28
21:10
Add more libs check-in: 5362800858 user: admin tags: trunk
20:59
Add more libs check-in: d779a931b1 user: admin tags: trunk
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Added windowlist/pkgIndex.tcl.























>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
# Tcl package index file, version 1.1
# This file is generated by the "pkg_mkIndex" command
# and sourced either when an application starts up or
# by a "package unknown" script.  It invokes the
# "package ifneeded" command to set up package-related
# information so that packages will be loaded automatically
# in response to "package require" commands.  When this
# script is sourced, the variable $dir must contain the
# full path name of this file's directory.

package ifneeded windowlist 1.5 [list source [file join $dir windowlist.tcl]]

Added windowlist/windowlist.tcl.





















































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
#windowlist.tcl: provides routines for managing windows from menu, i.e. minimize, raise, bring all to front; standard menu item on Mac OS X. 

#(c) 2011 WordTech Communications LLC. License: standard Tcl license, http://www.tcl.tk/software/tcltk/license.html

#includes code from http://wiki.tcl.tk/1461

##"cycle through windows" code courtesy of Tom Hennigan, tomhennigan@gmail.com, (c) 2009

package provide windowlist 1.5

namespace eval windowlist {

    #make the window menu
    proc windowMenu {mainmenu} {

	menu $mainmenu.windowlist

	$mainmenu.windowlist add command -label "Minimize" -command [namespace current]::minimizeFrontWindow -accelerator Command-M
	$mainmenu.windowlist add separator
	$mainmenu.windowlist add command -label "Bring All to Front" -command [namespace current]::raiseAllWindows
	$mainmenu.windowlist add separator
	$mainmenu.windowlist add command -label "Cycle Through Windows" \
	    -command  {raise [lindex [wm stackorder .] 0]} \
	    -accelerator "Command-`"
       	bind all <Command-quoteleft> {raise [lindex [wm stackorder .] 0]}
	$mainmenu.windowlist add separator
	$mainmenu.windowlist add command -label "Main Window" -command ::tk::mac::ReopenApplication
	$mainmenu.windowlist add separator
	$mainmenu.windowlist add command -label [wm title .] -command ::tk::mac::ReopenApplication
	
	$mainmenu add cascade -label "Window" -menu $mainmenu.windowlist
	
        #bind the window menu to update whenever a new window is added, on menu selection
       	bind all <<MenuSelect>> +[list [namespace current]::updateWindowMenu $mainmenu.windowlist]
	bind all <Command-M>  [namespace current]::minimizeFrontWindow
	bind all <Command-m>  [namespace current]::minimizeFrontWindow
	bind . <Command-w> {wm state . withdrawn}
	bind .  <Command-W> {wm state . withdrawn}
	wm protocol . WM_DELETE_WINDOW {wm state . withdrawn}

    }

    
    #update the window menu with windows
    proc updateWindowMenu {windowmenu} {

	set windowlist [wm stackorder .]

	#search for drawer window first
	if {[lsearch $windowlist ".drawer"] >= 0 } {
	    set windowlist [lreplace $windowlist [lsearch $windowlist ".drawer"] [lsearch $windowlist ".drawer"]]
	    update
	}
	
	if {$windowlist == {}} {
	    return
	}

	$windowmenu delete 8 end
	foreach item $windowlist {
	    $windowmenu add command -label "[wm title $item]"  -command [list raise $item]

	}
    }



    #make all windows visible
    proc raiseAllWindows {} {

	#get list of mapped windows

	if {![winfo ismapped .]} {

	    wm deiconify .

	}

	set windowlist [wm stackorder .]

	#do nothing if all windows are minimized
	if {$windowlist == {}} {
	    return
	}

	#use [winfo children .] here to get windows that are minimized
	foreach item [winfo children .] {
	    
	    #get all toplevel windows, exclude menubar windows
	    if { [string equal [winfo toplevel $item] $item] && [catch {$item cget -tearoff}]} {
		wm deiconify $item
	    }
	}
	#be sure to deiconify ., since the above command only gets the child toplevels
	wm deiconify .
    }

    #minimize the selected window
    proc minimizeFrontWindow {} {

	#get list of mapped windows
	set windowlist [wm stackorder .]

	#do nothing if all windows are minimized
	if {$windowlist == {}} {
	    return
	} else {

	    #minimize topmost window
	    set topwindow [lindex $windowlist end]
	    wm iconify $topwindow

	}
    }
    
    namespace export *
}

#raise window if closed--dock click
proc ::tk::mac::ReopenApplication {} {

    if { [wm state .] == "withdrawn"} {
	wm state . normal
	raise .
    } else {
	wm deiconify .
	raise .
    }

    catch {fullscreen::fullscreen .}

}