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 Side-by-Side Diffs Ignore Whitespace Patch

Added windowlist/pkgIndex.tcl.

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

Added windowlist/windowlist.tcl.

            1  +#windowlist.tcl: provides routines for managing windows from menu, i.e. minimize, raise, bring all to front; standard menu item on Mac OS X. 
            2  +
            3  +#(c) 2011 WordTech Communications LLC. License: standard Tcl license, http://www.tcl.tk/software/tcltk/license.html
            4  +
            5  +#includes code from http://wiki.tcl.tk/1461
            6  +
            7  +##"cycle through windows" code courtesy of Tom Hennigan, tomhennigan@gmail.com, (c) 2009
            8  +
            9  +package provide windowlist 1.5
           10  +
           11  +namespace eval windowlist {
           12  +
           13  +    #make the window menu
           14  +    proc windowMenu {mainmenu} {
           15  +
           16  +	menu $mainmenu.windowlist
           17  +
           18  +	$mainmenu.windowlist add command -label "Minimize" -command [namespace current]::minimizeFrontWindow -accelerator Command-M
           19  +	$mainmenu.windowlist add separator
           20  +	$mainmenu.windowlist add command -label "Bring All to Front" -command [namespace current]::raiseAllWindows
           21  +	$mainmenu.windowlist add separator
           22  +	$mainmenu.windowlist add command -label "Cycle Through Windows" \
           23  +	    -command  {raise [lindex [wm stackorder .] 0]} \
           24  +	    -accelerator "Command-`"
           25  +       	bind all <Command-quoteleft> {raise [lindex [wm stackorder .] 0]}
           26  +	$mainmenu.windowlist add separator
           27  +	$mainmenu.windowlist add command -label "Main Window" -command ::tk::mac::ReopenApplication
           28  +	$mainmenu.windowlist add separator
           29  +	$mainmenu.windowlist add command -label [wm title .] -command ::tk::mac::ReopenApplication
           30  +	
           31  +	$mainmenu add cascade -label "Window" -menu $mainmenu.windowlist
           32  +	
           33  +        #bind the window menu to update whenever a new window is added, on menu selection
           34  +       	bind all <<MenuSelect>> +[list [namespace current]::updateWindowMenu $mainmenu.windowlist]
           35  +	bind all <Command-M>  [namespace current]::minimizeFrontWindow
           36  +	bind all <Command-m>  [namespace current]::minimizeFrontWindow
           37  +	bind . <Command-w> {wm state . withdrawn}
           38  +	bind .  <Command-W> {wm state . withdrawn}
           39  +	wm protocol . WM_DELETE_WINDOW {wm state . withdrawn}
           40  +
           41  +    }
           42  +
           43  +    
           44  +    #update the window menu with windows
           45  +    proc updateWindowMenu {windowmenu} {
           46  +
           47  +	set windowlist [wm stackorder .]
           48  +
           49  +	#search for drawer window first
           50  +	if {[lsearch $windowlist ".drawer"] >= 0 } {
           51  +	    set windowlist [lreplace $windowlist [lsearch $windowlist ".drawer"] [lsearch $windowlist ".drawer"]]
           52  +	    update
           53  +	}
           54  +	
           55  +	if {$windowlist == {}} {
           56  +	    return
           57  +	}
           58  +
           59  +	$windowmenu delete 8 end
           60  +	foreach item $windowlist {
           61  +	    $windowmenu add command -label "[wm title $item]"  -command [list raise $item]
           62  +
           63  +	}
           64  +    }
           65  +
           66  +
           67  +
           68  +    #make all windows visible
           69  +    proc raiseAllWindows {} {
           70  +
           71  +	#get list of mapped windows
           72  +
           73  +	if {![winfo ismapped .]} {
           74  +
           75  +	    wm deiconify .
           76  +
           77  +	}
           78  +
           79  +	set windowlist [wm stackorder .]
           80  +
           81  +	#do nothing if all windows are minimized
           82  +	if {$windowlist == {}} {
           83  +	    return
           84  +	}
           85  +
           86  +	#use [winfo children .] here to get windows that are minimized
           87  +	foreach item [winfo children .] {
           88  +	    
           89  +	    #get all toplevel windows, exclude menubar windows
           90  +	    if { [string equal [winfo toplevel $item] $item] && [catch {$item cget -tearoff}]} {
           91  +		wm deiconify $item
           92  +	    }
           93  +	}
           94  +	#be sure to deiconify ., since the above command only gets the child toplevels
           95  +	wm deiconify .
           96  +    }
           97  +
           98  +    #minimize the selected window
           99  +    proc minimizeFrontWindow {} {
          100  +
          101  +	#get list of mapped windows
          102  +	set windowlist [wm stackorder .]
          103  +
          104  +	#do nothing if all windows are minimized
          105  +	if {$windowlist == {}} {
          106  +	    return
          107  +	} else {
          108  +
          109  +	    #minimize topmost window
          110  +	    set topwindow [lindex $windowlist end]
          111  +	    wm iconify $topwindow
          112  +
          113  +	}
          114  +    }
          115  +    
          116  +    namespace export *
          117  +}
          118  +
          119  +#raise window if closed--dock click
          120  +proc ::tk::mac::ReopenApplication {} {
          121  +
          122  +    if { [wm state .] == "withdrawn"} {
          123  +	wm state . normal
          124  +	raise .
          125  +    } else {
          126  +	wm deiconify .
          127  +	raise .
          128  +    }
          129  +
          130  +    catch {fullscreen::fullscreen .}
          131  +
          132  +}
          133  +
          134  +
          135  +
          136  +
          137  +
          138  +