[PD-cvs] SF.net SVN: pure-data:[10533] branches/pd-devel/0.41.4/src

eighthave at users.sourceforge.net eighthave at users.sourceforge.net
Tue Jan 13 18:57:25 CET 2009


Revision: 10533
          http://pure-data.svn.sourceforge.net/pure-data/?rev=10533&view=rev
Author:   eighthave
Date:     2009-01-13 17:57:25 +0000 (Tue, 13 Jan 2009)

Log Message:
-----------
- named variables after the Tk widgets they represent
   $mytoplevel = 'toplevel'
   $mymenubar = the 'menu' attached to the 'toplevel'
   $mymenu = 'menu' attached to the menubar 'menu'
   $menuitem = 'menu' item
   $mycanvas = 'canvas'
   $canvasitem = 'canvas' item

- replaced canvastosym/to_top with [winfo toplevel ...]


- reordered procs in pd_menus.tcl to go in order of creation

Modified Paths:
--------------
    branches/pd-devel/0.41.4/src/apple_events.tcl
    branches/pd-devel/0.41.4/src/pd.tk
    branches/pd-devel/0.41.4/src/pd_bindings.tcl
    branches/pd-devel/0.41.4/src/pd_menucommands.tcl
    branches/pd-devel/0.41.4/src/pd_menus.tcl
    branches/pd-devel/0.41.4/src/pdtk_canvas.tcl
    branches/pd-devel/0.41.4/src/pdtk_text.tcl

Modified: branches/pd-devel/0.41.4/src/apple_events.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/apple_events.tcl	2009-01-13 17:13:31 UTC (rev 10532)
+++ branches/pd-devel/0.41.4/src/apple_events.tcl	2009-01-13 17:57:25 UTC (rev 10533)
@@ -23,6 +23,9 @@
 
 #kAEShowPreferences
 proc ::tk::mac::ShowPreferences {} {
+ 	puts "apple prefs menu item callback"
+ 	puts "::tk::mac::ShowPreferences "
+# 	menu_preferences
 }
 
 #kAEQuitApplication

Modified: branches/pd-devel/0.41.4/src/pd.tk
===================================================================
--- branches/pd-devel/0.41.4/src/pd.tk	2009-01-13 17:13:31 UTC (rev 10532)
+++ branches/pd-devel/0.41.4/src/pd.tk	2009-01-13 17:57:25 UTC (rev 10533)
@@ -41,25 +41,31 @@
 #
 
 #
-# * when possible use "" doublequotes to delimit messages
+# - when possible use "" doublequotes to delimit messages
+# - instead of 'global myvar' use '$::myvar'
 #
 #
 #
-#
 ## Names for Common Variables
 #----------------------------
-# $name == window name
-# $canvasname == $name.c == canvas name
+#
+# variables named after the Tk widgets they represent
+#   $mytoplevel = 'toplevel'
+#   $mymenubar = the 'menu' attached to the 'toplevel'
+#   $mymenu = 'menu' attached to the menubar 'menu'
+#   $menuitem = 'menu' item
+#   $mycanvas = 'canvas'
+#   $canvasitem = 'canvas' item
 
 
 
-
 #------------------------------------------------------------------------------#
 # global variables
 
+
+# file types for Open/Save panels
 set filetypes ""
 
-
 # for the sake of clarity, I think there should not be any inline code,
 # everything should be in a procedure that is ultimately triggered from main()
 # -hans at eds.org
@@ -95,7 +101,6 @@
 # init functions
 
 proc init {} {
-	global filetypes
 	switch -- [tk windowingsystem] {
 		"x11" {
 			# add control to show/hide hidden files in the open panel (load
@@ -104,14 +109,14 @@
 			set ::tk::dialog::file::showHiddenBtn 1
 			set ::tk::dialog::file::showHiddenVar 0
 			# set file types that open/save recognize
-			set filetypes {
+			set ::filetypes {
 				{{pd files}         {.pd}  }
 				{{max text files}   {.pat} }
 			}
 		}
 		"aqua" {
 			# set file types that open/save recognize
-			set filetypes {
+			set ::filetypes {
 				{{Pd Files}               {.pd}  }
 				{{Max Text Files (.pat)}  {.pat} }
 			}
@@ -119,7 +124,7 @@
 		"win32" {
 			font create menufont -family Tahoma -size -11
 			# set file types that open/save recognize
-			set filetypes {
+			set ::filetypes {
 				{{Pd Files}         {.pd}  }
 				{{Max Text Files}   {.pat} }
 			}
@@ -159,32 +164,34 @@
 	puts stderr "Running pdtk_fixwindowmenu"
 }
 
-# TODO rename "name" to "topname" to be clear
-proc pdtk_canvas_new {name width height geometry editable} {
+proc pdtk_canvas_new {mytoplevel width height geometry editable} {
 	# TODO check size of window
-	toplevel $name -width $width -height $height
-	::pd_menus::create_menubar $name.menubar
-	$name configure -menu $name.menubar
+	toplevel $mytoplevel -width $width -height $height
+	::pd_menus::create_menubar $mytoplevel.menubar
+	$mytoplevel configure -menu $mytoplevel.menubar
 
 	# TODO slide off screen windows into view
-	wm geometry $name $geometry
+	wm geometry $mytoplevel $geometry
 	if {[tk windowingsystem] eq "aqua"} {
-		wm minsize $name 50 20
+		wm minsize $mytoplevel 50 20
 	} else { # leave room for the menubar
-		wm minsize $name 310 30
+		wm minsize $mytoplevel 310 30
 	}
-	canvas $name.c -width $width -height $height -background white \
+	canvas $mytoplevel.c -width $width -height $height -background white \
 		-highlightthickness 0
 	# TODO add scrollbars here
-    pack $name.c -side left -expand 1 -fill both
+    pack $mytoplevel.c -side left -expand 1 -fill both
 
-	::pd_bindings::canvas_bindings $name
+	::pd_bindings::canvas_bindings $mytoplevel
 
 	# the popup menu for the canvas
-    menu $name.popup -tearoff false
-    $name.popup add command -label "Properties" -command "popup_action $name 0"
-    $name.popup add command -label "Open"       -command "popup_action $name 1"
-    $name.popup add command -label "Help"       -command "popup_action $name 2"
+    menu $mytoplevel.popup -tearoff false
+    $mytoplevel.popup add command -label "Properties" \
+		-command "popup_action $mytoplevel 0"
+    $mytoplevel.popup add command -label "Open"       \
+		-command "popup_action $mytoplevel 1"
+    $mytoplevel.popup add command -label "Help"       \
+		-command "popup_action $mytoplevel 2"
 }
 
 proc check_font {$fontname} {

Modified: branches/pd-devel/0.41.4/src/pd_bindings.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pd_bindings.tcl	2009-01-13 17:13:31 UTC (rev 10532)
+++ branches/pd-devel/0.41.4/src/pd_bindings.tcl	2009-01-13 17:57:25 UTC (rev 10533)
@@ -18,133 +18,140 @@
 	}
 }
 
-proc ::pd_bindings::window_bindings {name} {
+proc ::pd_bindings::window_bindings {mytoplevel} {
 	variable modifier
 
 	# File menu
-	bind $name <$modifier-Key-b>        "menu_helpbrowser"
-	bind $name <$modifier-Key-n>        "menu_new"
-	bind $name <$modifier-Key-o>        "menu_open"
-	bind $name <$modifier-Key-p>        "menu_print $name"
-	bind $name <$modifier-Key-q>        "pdsend \"pd verifyquit ;\""
-	bind $name <$modifier-Key-r>        "menu_raiseconsole"
-	bind $name <$modifier-Key-w>        "pdsend \"$name menuclose 0 ;\""
-	bind $name <$modifier-Shift-Key-L>  "menu_clear_console"
-	bind $name <$modifier-Shift-Key-Q>  "pdsend \"pd quit ;\""
-	bind $name <$modifier-Shift-Key-R>  "menu_toggle_console"
-	bind $name <$modifier-Shift-Key-W>  "pdsend \"$name menuclose 1 ;\""
+	bind $mytoplevel <$modifier-Key-b>        "menu_helpbrowser"
+	bind $mytoplevel <$modifier-Key-n>        "menu_new"
+	bind $mytoplevel <$modifier-Key-o>        "menu_open"
+	bind $mytoplevel <$modifier-Key-p>        "menu_print $mytoplevel"
+	bind $mytoplevel <$modifier-Key-q>        "pdsend \"pd verifyquit ;\""
+	bind $mytoplevel <$modifier-Key-r>        "menu_raiseconsole"
+	bind $mytoplevel <$modifier-Key-w>        "pdsend \"$mytoplevel menuclose 0 ;\""
+	bind $mytoplevel <$modifier-Shift-Key-L>  "menu_clear_console"
+	bind $mytoplevel <$modifier-Shift-Key-Q>  "pdsend \"pd quit ;\""
+	bind $mytoplevel <$modifier-Shift-Key-R>  "menu_toggle_console"
+	bind $mytoplevel <$modifier-Shift-Key-W>  "pdsend \"$mytoplevel menuclose 1 ;\""
 
 	# DSP control
-	bind $name <$modifier-Key-slash>    "pdsend \"pd dsp 1 ;\""
-	bind $name <$modifier-Key-period>   "pdsend \"pd dsp 0 ;\""
+	bind $mytoplevel <$modifier-Key-slash>    "pdsend \"pd dsp 1 ;\""
+	bind $mytoplevel <$modifier-Key-period>   "pdsend \"pd dsp 0 ;\""
 }
 
-proc ::pd_bindings::pdwindow_bindings {name} {
+proc ::pd_bindings::pdwindow_bindings {mytoplevel} {
 	variable modifier
 
-	window_bindings $name
+	window_bindings $mytoplevel
 
 	# TODO update this to work with the console, if it is used
-	bind . <$modifier-Key-a> ".printout.text tag add sel 1.0 end"
-	bind . <$modifier-Key-x> "tk_textCut .printout.text"
-	bind . <$modifier-Key-c> "tk_textCopy .printout.text"
-	bind . <$modifier-Key-v> "tk_textPaste .printout.text"
-	bind . <$modifier-Key-w> {::pd_post::pdtk_post "Can't close Pd window, ignored.\n"}
+	bind $mytoplevel <$modifier-Key-a> ".printout.text tag add sel 1.0 end"
+	bind $mytoplevel <$modifier-Key-x> "tk_textCut .printout.text"
+	bind $mytoplevel <$modifier-Key-c> "tk_textCopy .printout.text"
+	bind $mytoplevel <$modifier-Key-v> "tk_textPaste .printout.text"
+	bind $mytoplevel <$modifier-Key-w> {
+		::pd_post::pdtk_post "Can't close Pd window, ignored.\n"
+	}
 
 	# Tcl event bindings
-	wm protocol . WM_DELETE_WINDOW "pdsend \"pd verifyquit ;\""
+	wm protocol $mytoplevel WM_DELETE_WINDOW "pdsend \"pd verifyquit ;\""
 
 	# do window maintenance when entering the Pd window (Window menu, scrollbars, etc)
-	#bind $name <FocusIn> {pdtk_pdwindowmaintenance}
+	#bind $mytoplevel <FocusIn> {pdtk_pdwindowmaintenance}
 }
 
-proc ::pd_bindings::panel_bindings {name} {
+proc ::pd_bindings::panel_bindings {mytoplevel} {
 	variable modifier
 
-	window_bindings $name
+	window_bindings $mytoplevel
 
-#    bind $name <KeyPress-Escape> [format "%s_cancel %s" $panelname $name]
-#    bind $name <KeyPress-Return> [format "%s_ok %s" $panelname $name]
-#    bind $name <$modifier_key-Key-w> [format "%s_cancel %s" $panelname $name]
+#    bind $mytoplevel <KeyPress-Escape> [format "%s_cancel %s" $panelname $mytoplevel]
+#    bind $mytoplevel <KeyPress-Return> [format "%s_ok %s" $panelname $mytoplevel]
+#    bind $mytoplevel <$modifier_key-Key-w> [format "%s_cancel %s" $panelname $mytoplevel]
 
-#	wm protocol $name WM_DELETE_WINDOW "$panelname_cancel"
+#	wm protocol $mytoplevel WM_DELETE_WINDOW "$panelname_cancel"
 }
 
-proc ::pd_bindings::canvas_bindings {name} {
+proc ::pd_bindings::canvas_bindings {mytoplevel} {
 	variable modifier
 
-	window_bindings $name
-
+	window_bindings $mytoplevel
+	set mycanvas $mytoplevel.c
+	
 	# key bindings -------------------------------------------------------------
-	bind $name <$modifier-Key-1>        "pdsend \"$name obj ;\""
-	bind $name <$modifier-Key-2>        "pdsend \"$name msg ;\""
-	bind $name <$modifier-Key-3>        "pdsend \"$name floatatom ;\""
-	bind $name <$modifier-Key-4>        "pdsend \"$name symbolatom ;\""
-	bind $name <$modifier-Key-5>        "pdsend \"$name text ;\""
-	bind $name <$modifier-Key-a>        "pdsend \"$name selectall ;\""
-	bind $name <$modifier-Key-c>        "pdsend \"$name copy ;\""
-	bind $name <$modifier-Key-d>        "pdsend \"$name duplicate ;\""
-	bind $name <$modifier-Key-e>        "pdsend \"$name editmode 0 ;\""
-	bind $name <$modifier-Key-f>        "menu_findobject $name"
-	bind $name <$modifier-Key-g>        "pdsend \"$name findagain ;\""
-	bind $name <$modifier-Key-s>        "pdsend \"$name menusave ;\""
-	bind $name <$modifier-Key-v>        "pdsend \"$name paste ;\""
-	bind $name <$modifier-Key-x>        "pdsend \"$name cut ;\""
-	bind $name <$modifier-Key-z>        "menu_undo $name"
-	bind $name <$modifier-Key-slash>    "pdsend \"pd dsp 1 ;\""
-	bind $name <$modifier-Key-period>   "pdsend \"pd dsp 0 ;\""
+	bind $mytoplevel <$modifier-Key-1>        "pdsend \"$mytoplevel obj ;\""
+	bind $mytoplevel <$modifier-Key-2>        "pdsend \"$mytoplevel msg ;\""
+	bind $mytoplevel <$modifier-Key-3>        "pdsend \"$mytoplevel floatatom ;\""
+	bind $mytoplevel <$modifier-Key-4>        "pdsend \"$mytoplevel symbolatom ;\""
+	bind $mytoplevel <$modifier-Key-5>        "pdsend \"$mytoplevel text ;\""
+	bind $mytoplevel <$modifier-Key-a>        "pdsend \"$mytoplevel selectall ;\""
+	bind $mytoplevel <$modifier-Key-c>        "pdsend \"$mytoplevel copy ;\""
+	bind $mytoplevel <$modifier-Key-d>        "pdsend \"$mytoplevel duplicate ;\""
+	bind $mytoplevel <$modifier-Key-e>        "pdsend \"$mytoplevel editmode 0 ;\""
+	bind $mytoplevel <$modifier-Key-f>        "menu_findobject $mytoplevel"
+	bind $mytoplevel <$modifier-Key-g>        "pdsend \"$mytoplevel findagain ;\""
+	bind $mytoplevel <$modifier-Key-s>        "pdsend \"$mytoplevel menusave ;\""
+	bind $mytoplevel <$modifier-Key-v>        "pdsend \"$mytoplevel paste ;\""
+	bind $mytoplevel <$modifier-Key-x>        "pdsend \"$mytoplevel cut ;\""
+	bind $mytoplevel <$modifier-Key-z>        "menu_undo $mytoplevel"
+	bind $mytoplevel <$modifier-Key-slash>    "pdsend \"pd dsp 1 ;\""
+	bind $mytoplevel <$modifier-Key-period>   "pdsend \"pd dsp 0 ;\""
 
 	# annoying, but Tk's bind needs uppercase letter to get the Shift
-	bind $name <$modifier-Shift-Key-B>  "pdsend \"$name bng 1 ;\""
-	bind $name <$modifier-Shift-Key-C>  "pdsend \"$name mycnv 1 ;\""
-	bind $name <$modifier-Shift-Key-D>  "pdsend \"$name vradio 1 ;\""
-	bind $name <$modifier-Shift-Key-H>  "pdsend \"$name hslider 1 ;\""
-	bind $name <$modifier-Shift-Key-I>  "pdsend \"$name hradio 1 ;\""
-	bind $name <$modifier-Shift-Key-N>  "pdsend \"$name numbox 1 ;\""
-	bind $name <$modifier-Shift-Key-S>  "pdsend \"$name menusaveas ;\""
-	bind $name <$modifier-Shift-Key-T>  "pdsend \"$name toggle 1 ;\""
-	bind $name <$modifier-Shift-Key-U>  "pdsend \"$name vumeter 1 ;\""
-	bind $name <$modifier-Shift-Key-V>  "pdsend \"$name vslider 1 ;\""
-	bind $name <$modifier-Shift-Key-Z>  "menu_redo $name"
+	bind $mytoplevel <$modifier-Shift-Key-B> "pdsend \"$mytoplevel bng 1 ;\""
+	bind $mytoplevel <$modifier-Shift-Key-C> "pdsend \"$mytoplevel mycnv 1 ;\""
+	bind $mytoplevel <$modifier-Shift-Key-D> "pdsend \"$mytoplevel vradio 1 ;\""
+	bind $mytoplevel <$modifier-Shift-Key-H> "pdsend \"$mytoplevel hslider 1 ;\""
+	bind $mytoplevel <$modifier-Shift-Key-I> "pdsend \"$mytoplevel hradio 1 ;\""
+	bind $mytoplevel <$modifier-Shift-Key-N> "pdsend \"$mytoplevel numbox 1 ;\""
+	bind $mytoplevel <$modifier-Shift-Key-S> "pdsend \"$mytoplevel menusaveas ;\""
+	bind $mytoplevel <$modifier-Shift-Key-T> "pdsend \"$mytoplevel toggle 1 ;\""
+	bind $mytoplevel <$modifier-Shift-Key-U> "pdsend \"$mytoplevel vumeter 1 ;\""
+	bind $mytoplevel <$modifier-Shift-Key-V> "pdsend \"$mytoplevel vslider 1 ;\""
+	bind $mytoplevel <$modifier-Shift-Key-Z> "menu_redo $mytoplevel"
 	
 	if {[tk windowingsystem] eq "aqua"} {
-		bind $name <$modifier-Key-m>    "menu_minimize $name"
-		bind $name <$modifier-Key-t>    "menu_font $name"
-        bind $name <$modifier-quoteleft> "menu_raisenextwindow"
+		bind $mytoplevel <$modifier-Key-m>   "menu_minimize $mytoplevel"
+		bind $mytoplevel <$modifier-Key-t>   "menu_font $mytoplevel"
+        bind $mytoplevel <$modifier-quoteleft> "menu_raisenextwindow"
 	} else {
-		bind $name <$modifier-Key-m>    "menu_send"
-		bind $name <$modifier-Key-t>    "menu_texteditor"
+		bind $mytoplevel <$modifier-Key-m>    "menu_send"
+		bind $mytoplevel <$modifier-Key-t>    "menu_texteditor"
 	}
 
 	# mouse bindings -----------------------------------------------------------
-	# these need to be bound to $name.c because %W will return $name for
-	# events over the window frame and $name.c for events over the canvas
-    bind $name.c <Motion>                 "pdtk_canvas_motion %W %x %y 0"
-    bind $name.c <Button>                 "pdtk_canvas_mouse %W %x %y %b 0"
-    bind $name.c <ButtonRelease>          "pdtk_canvas_mouseup %W %x %y %b"
-	bind $name.c <$modifier-Button>       "pdtk_canvas_mouse %W %x %y %b 0"
+	# these need to be bound to $mytoplevel.c because %W will return $mytoplevel for
+	# events over the window frame and $mytoplevel.c for events over the canvas
+    bind $mycanvas <Motion>               "pdtk_canvas_motion %W %x %y 0"
+    bind $mycanvas <Button>               "pdtk_canvas_mouse %W %x %y %b 0"
+    bind $mycanvas <ButtonRelease>        "pdtk_canvas_mouseup %W %x %y %b"
+	bind $mycanvas <$modifier-Button>     "pdtk_canvas_mouse %W %x %y %b 0"
 	# TODO look into "virtual events' for a means for getting Shift-Button, etc.
 	switch {[tk windowingsystem]} { 
 		"aqua" {
 			# on Mac OS X, emulate a rightclick with Ctrl-click
-			bind.c $name <Ctrl-Button>    "pdtk_canvas_rightclick %W %x %y %b"
+			bind $mycanvas <Ctrl-Button>  "pdtk_canvas_rightclick %W %x %y %b"
+			# TODO try replacing the above with this (and making it global by binding to "."
+			#bind all <Control-ButtonPress-1> {event generate %W <ButtonPress-2> \
+			#									  -x %x -y %y -rootx %X -rooty %Y \
+			#									  -button 2 -time %t}
 		} "x11" {
 			# on X11, button 2 "pastes" from the X windows clipboard
-			bind.c $name <Button-2>       "pdtk_canvas_clickpaste %W %x %y %b"
+			bind $mycanvas <Button-2>     "pdtk_canvas_clickpaste %W %x %y %b"
 		}
 	}
-	#TODO bind $name <MouseWheel>
+	#TODO bind $mytoplevel <MouseWheel>
 
 	# event bindings -----------------------------------------------------------
-    bind $name <Map>                    "pdtk_canvas_map %W"
-    bind $name <Unmap>                  "pdtk_canvas_unmap %W"
-	#TODO bind $name <Configure>             "pdtk_canvas_getscroll %W"
+    bind $mytoplevel <Map>                    "pdtk_canvas_map %W"
+    bind $mytoplevel <Unmap>                  "pdtk_canvas_unmap %W"
+	#TODO bind $mytoplevel <Configure>             "pdtk_canvas_getscroll %W"
 
 	# do window maintenance when entering a window (Window menu, scrollbars...)
 	# maybe use WM_TAKE_FOCUS for this?
-	#bind $name <FocusIn> {pdtk_canvaswindowmaintenance}
+	#bind $mytoplevel <FocusIn> {pdtk_canvaswindowmaintenance}
 
 	# window protocol bindings
-    wm protocol $name WM_DELETE_WINDOW "pdsend \"$name menuclose 0 ;\""
+    wm protocol $mytoplevel WM_DELETE_WINDOW "pdsend \"$mytoplevel menuclose 0 ;\""
 }
 

Modified: branches/pd-devel/0.41.4/src/pd_menucommands.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pd_menucommands.tcl	2009-01-13 17:13:31 UTC (rev 10532)
+++ branches/pd-devel/0.41.4/src/pd_menucommands.tcl	2009-01-13 17:57:25 UTC (rev 10533)
@@ -55,12 +55,12 @@
 	# TODO insert real send panel here
 }
 
-proc ::pd_menucommands::menu_print {name} {
+proc ::pd_menucommands::menu_print {mytoplevel} {
     set filename [tk_getSaveFile -initialfile pd.ps \
                       -defaultextension .ps \
                       -filetypes { {{postscript} {.ps}} }]
     if {$filename != ""} {
-        $name.c postscript -file $filename 
+        $mytoplevel.c postscript -file $filename 
     }
 }
 
@@ -85,7 +85,7 @@
 	}
 }
 
-proc ::pd_menucommands::menu_maximize {window} {
-	wm state $window zoomed
+proc ::pd_menucommands::menu_maximize {mytoplevel} {
+	wm state $mytoplevel zoomed
 }
 

Modified: branches/pd-devel/0.41.4/src/pd_menus.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pd_menus.tcl	2009-01-13 17:13:31 UTC (rev 10532)
+++ branches/pd-devel/0.41.4/src/pd_menus.tcl	2009-01-13 17:57:25 UTC (rev 10533)
@@ -38,32 +38,89 @@
 	option add *tearOff 0
 }
 
+proc ::pd_menus::create_menubar {mymenubar} {
+	menu $mymenubar
+	set menulist "file edit put find media window help"
+	if { [tk windowingsystem] eq "aqua" } {make_apple_menu $mymenubar}
+	if { [tk windowingsystem] eq "win32" } {make_system_menu $mymenubar}
+	foreach mymenu $menulist {	
+		menu $mymenubar.$mymenu
+		$mymenubar add cascade -label [string totitle $mymenu] \
+			-menu $mymenubar.$mymenu
+		[format create_%s_menu $mymenu] $mymenubar.$mymenu PLACEHOLDER
+		if {[tk windowingsystem] eq "win32"} {
+			# fix menu font size on Windows with tk scaling = 1
+			$mymenubar.$mymenu configure -font menufont
+		}
+	}
+}
+
+proc ::pd_menus::configure_pdwindow {mymenubar} {
+	# these are meaningless for the Pd window, so disable them
+	set file_items_to_disable {"Save" "Save As..." "Print..." "Close"}
+	foreach menuitem $file_items_to_disable {
+		$mymenubar.file entryconfigure $menuitem -state disabled
+	}
+	set edit_items_to_disable {"Undo" "Redo" "Duplicate" "Tidy Up" "Edit Mode"}
+	foreach menuitem $edit_items_to_disable {
+		$mymenubar.edit entryconfigure $menuitem -state disabled
+	}
+	# disable everything on the Put menu
+	for {set i 0} {$i <= [$mymenubar.put index end]} {incr i} {
+		# catch errors by trying to disable separators
+		catch {$mymenubar.put entryconfigure $i -state disabled }
+	}
+}
+
+# for Mac OS X only
+proc ::pd_menus::make_apple_menu {mymenu} {
+	puts stderr CREATE_APPLE_MENU
+	# TODO this should open a Pd patch called about.pd
+	menu $mymenu.apple
+	$mymenu.apple add command -label [say "About Pd"] \
+		-command "menu_doc_open doc/1.manual 1.introduction.txt" 
+    $mymenu add cascade -label "Apple" -menu $mymenu.apple
+	# starting in 8.4.14, this is created automatically
+	if {[regsub -- {[0-9]\.[0-9]\.([0-9][0-9]*)} [info patchlevel] {\1}] < 14} {
+		$mymenu.apple add separator
+		$mymenu.apple add command -label [say "Preferences..."] \
+			-command "menu_preferences" -accelerator "Cmd+,"
+	}
+}
+
+# for Windows only
+proc ::pd_menus::make_system_menu {mymenu} {
+	$mymenu add cascade -menu [menu $mymenu.system]
+	# TODO add Close, Minimize, etc and whatever else is on the little menu
+	# that is on the top left corner of the window frame
+}
+
 # ------------------------------------------------------------------------------
 # menu building functions for Mac OS X/aqua
 
-proc ::pd_menus::create_file_menu_aqua {rootmenu} {
+proc ::pd_menus::create_file_menu_aqua {mymenu} {
 	variable accelerator
-	$rootmenu add command -label [say "new_file"]  -accelerator "$accelerator+N"
-	$rootmenu add command -label [say "Open"]      -accelerator "$accelerator+O"
-	$rootmenu add cascade -label [say "Open Recent"]
-	$rootmenu add  separator
-	$rootmenu add command -label [say "Close"]     -accelerator "$accelerator+W"
-	$rootmenu add command -label [say "Save"]      -accelerator "$accelerator+S"
-	$rootmenu add command -label [say "Save As..."] -accelerator "$accelerator+Shift+S"
-	#$rootmenu add command -label [say "Save All"]
-	$rootmenu add command -label [say "Revert to Saved"]
-	$rootmenu add  separator
-	$rootmenu add command -label [say "Message"]
-	$rootmenu add  separator
-	$rootmenu add command -label [say "Print..."]   -accelerator "$accelerator+P"
+	$mymenu add command -label [say "new_file"]  -accelerator "$accelerator+N"
+	$mymenu add command -label [say "Open"]      -accelerator "$accelerator+O"
+	$mymenu add cascade -label [say "Open Recent"]
+	$mymenu add  separator
+	$mymenu add command -label [say "Close"]     -accelerator "$accelerator+W"
+	$mymenu add command -label [say "Save"]      -accelerator "$accelerator+S"
+	$mymenu add command -label [say "Save As..."] -accelerator "$accelerator+Shift+S"
+	#$mymenu add command -label [say "Save All"]
+	$mymenu add command -label [say "Revert to Saved"]
+	$mymenu add  separator
+	$mymenu add command -label [say "Message"]
+	$mymenu add  separator
+	$mymenu add command -label [say "Print..."]   -accelerator "$accelerator+P"
 }
 
 # the "Edit", "Put", and "Find" menus do not have cross-platform differences
 
-proc ::pd_menus::create_media_menu_aqua {rootmenu} {
+proc ::pd_menus::create_media_menu_aqua {mymenu} {
 }
 
-proc ::pd_menus::create_window_menu_aqua {rootmenu} {
+proc ::pd_menus::create_window_menu_aqua {mymenu} {
 }
 
 # the "Help" does not have cross-platform differences
@@ -71,29 +128,29 @@
 # ------------------------------------------------------------------------------
 # menu building functions for UNIX/X11
 
-proc ::pd_menus::create_file_menu_x11 {rootmenu} {
+proc ::pd_menus::create_file_menu_x11 {mymenu} {
 	variable accelerator
-	$rootmenu add command -label [say "new_file"]        -accelerator "$accelerator+N"
-	$rootmenu add command -label [say "Open"]       -accelerator "$accelerator+O"
-	$rootmenu add  separator
-	$rootmenu add command -label [say "Save"]       -accelerator "$accelerator+S"
-	$rootmenu add command -label [say "Save As..."] -accelerator "Shift+$accelerator+S"
-	#	$rootmenu add command -label "Revert"
-	$rootmenu add  separator
-	$rootmenu add command -label [say "Message"]    -accelerator "$accelerator+M"
-	$rootmenu add command -label [say "Print..."]   -accelerator "$accelerator+P"
-	$rootmenu add  separator
-	$rootmenu add command -label [say "Close"]      -accelerator "$accelerator+W"
-	$rootmenu add command -label [say "Quit"]       -accelerator "$accelerator+Q" \
+	$mymenu add command -label [say "new_file"]        -accelerator "$accelerator+N"
+	$mymenu add command -label [say "Open"]       -accelerator "$accelerator+O"
+	$mymenu add  separator
+	$mymenu add command -label [say "Save"]       -accelerator "$accelerator+S"
+	$mymenu add command -label [say "Save As..."] -accelerator "Shift+$accelerator+S"
+	#	$mymenu add command -label "Revert"
+	$mymenu add  separator
+	$mymenu add command -label [say "Message"]    -accelerator "$accelerator+M"
+	$mymenu add command -label [say "Print..."]   -accelerator "$accelerator+P"
+	$mymenu add  separator
+	$mymenu add command -label [say "Close"]      -accelerator "$accelerator+W"
+	$mymenu add command -label [say "Quit"]       -accelerator "$accelerator+Q" \
 		-command "pdsend \"pd verifyquit ;\""
 }
 
 # the "Edit", "Put", and "Find" menus do not have cross-platform differences
 
-proc ::pd_menus::create_media_menu_x11 {rootmenu} {
+proc ::pd_menus::create_media_menu_x11 {mymenu} {
 }
 
-proc ::pd_menus::create_window_menu_x11 {rootmenu} {
+proc ::pd_menus::create_window_menu_x11 {mymenu} {
 }
 
 # the "Help" does not have cross-platform differences
@@ -101,29 +158,29 @@
 # ------------------------------------------------------------------------------
 # menu building functions for Windows/Win32
 
-proc ::pd_menus::create_file_menu_win32 {rootmenu} {
+proc ::pd_menus::create_file_menu_win32 {mymenu} {
 	variable accelerator
-	$rootmenu add command -label [say "new_file"] -accelerator "$accelerator+N"
-	$rootmenu add command -label [say "Open"]     -accelerator "$accelerator+O"
-	$rootmenu add  separator
-	$rootmenu add command -label [say "Save"]      -accelerator "$accelerator+S"
-	$rootmenu add command -label [say "Save As..."] -accelerator "Shift+$accelerator+S"
-	#	$rootmenu add command -label "Revert"
-	$rootmenu add  separator
-	$rootmenu add command -label [say "Message"]  -accelerator "$accelerator+M"
-	$rootmenu add command -label [say "Print..."] -accelerator "$accelerator+P"
-	$rootmenu add  separator
-	$rootmenu add command -label [say "Close"]    -accelerator "$accelerator+W"
-	$rootmenu add command -label [say "Quit"]     -accelerator "$accelerator+Q"\
+	$mymenu add command -label [say "new_file"] -accelerator "$accelerator+N"
+	$mymenu add command -label [say "Open"]     -accelerator "$accelerator+O"
+	$mymenu add  separator
+	$mymenu add command -label [say "Save"]      -accelerator "$accelerator+S"
+	$mymenu add command -label [say "Save As..."] -accelerator "Shift+$accelerator+S"
+	#	$mymenu add command -label "Revert"
+	$mymenu add  separator
+	$mymenu add command -label [say "Message"]  -accelerator "$accelerator+M"
+	$mymenu add command -label [say "Print..."] -accelerator "$accelerator+P"
+	$mymenu add  separator
+	$mymenu add command -label [say "Close"]    -accelerator "$accelerator+W"
+	$mymenu add command -label [say "Quit"]     -accelerator "$accelerator+Q"\
 		-command "pdsend \"pd verifyquit ;\""
 }
 
 # the "Edit", "Put", and "Find" menus do not have cross-platform differences
 
-proc ::pd_menus::create_media_menu_win32 {rootmenu} {
+proc ::pd_menus::create_media_menu_win32 {mymenu} {
 }
 
-proc ::pd_menus::create_window_menu_win32 {rootmenu} {
+proc ::pd_menus::create_window_menu_win32 {mymenu} {
 }
 
 # the "Help" does not have cross-platform differences
@@ -131,214 +188,148 @@
 
 # ------------------------------------------------------------------------------
 # menu building functions
-proc ::pd_menus::create_file_menu {rootmenu name} {
-	[format create_file_menu_%s [tk windowingsystem]] $rootmenu
-	$rootmenu entryconfigure [say "new_file"]   -command "menu_new"
-	$rootmenu entryconfigure [say "Open"]       -command "menu_open"
-	$rootmenu entryconfigure [say "Save"]       -command "pdsend \"$name menusave ;\""
-	$rootmenu entryconfigure [say "Save As..."] -command "pdsend \"$name menusaveas ;\""
-	#	$rootmenu entryconfigure "Revert*"    -command "menu_revert $name"
-	$rootmenu entryconfigure [say "Close"]      -command "pdsend \"$name menuclose 0 ;\""
-	$rootmenu entryconfigure [say "Message"]    -command "menu_send"
-	$rootmenu entryconfigure [say "Print..."]   -command "menu_print $name"
+proc ::pd_menus::create_file_menu {mymenu mytoplevel} {
+	[format create_file_menu_%s [tk windowingsystem]] $mymenu
+	$mymenu entryconfigure [say "new_file"]   -command "menu_new"
+	$mymenu entryconfigure [say "Open"]       -command "menu_open"
+	$mymenu entryconfigure [say "Save"]       -command "pdsend \"$mytoplevel menusave ;\""
+	$mymenu entryconfigure [say "Save As..."] -command "pdsend \"$mytoplevel menusaveas ;\""
+	#	$mymenu entryconfigure "Revert*"    -command "menu_revert $mytoplevel"
+	$mymenu entryconfigure [say "Close"]      -command "pdsend \"$mytoplevel menuclose 0 ;\""
+	$mymenu entryconfigure [say "Message"]    -command "menu_send"
+	$mymenu entryconfigure [say "Print..."]   -command "menu_print $mytoplevel"
 }
 
-proc ::pd_menus::create_edit_menu {rootmenu name} {
+proc ::pd_menus::create_edit_menu {mymenu mytoplevel} {
 	variable accelerator
-	$rootmenu add command -label [say "Undo"]       -accelerator "$accelerator+Z" \
-		-command "menu_undo $name"
-	$rootmenu add command -label [say "Redo"]       -accelerator "Shift+$accelerator+Z" \
-		-command "menu_redo $name"
-	$rootmenu add  separator
-	$rootmenu add command -label [say "Cut"]        -accelerator "$accelerator+X" \
-		-command "pdsend \"$name cut ;\""
-	$rootmenu add command -label [say "Copy"]       -accelerator "$accelerator+C" \
-		-command "pdsend \"$name copy ;\""
-	$rootmenu add command -label [say "Paste"]      -accelerator "$accelerator+V" \
-		-command "pdsend \"$name paste ;\""
-	$rootmenu add command -label [say "Duplicate"]  -accelerator "$accelerator+D" \
-		-command "pdsend \"$name duplicate ;\""
-	$rootmenu add command -label [say "Select All"] -accelerator "$accelerator+A" \
-		-command "pdsend \"$name selectall ;\""
-	$rootmenu add  separator
+	$mymenu add command -label [say "Undo"]       -accelerator "$accelerator+Z" \
+		-command "menu_undo $mytoplevel"
+	$mymenu add command -label [say "Redo"]       -accelerator "Shift+$accelerator+Z" \
+		-command "menu_redo $mytoplevel"
+	$mymenu add  separator
+	$mymenu add command -label [say "Cut"]        -accelerator "$accelerator+X" \
+		-command "pdsend \"$mytoplevel cut ;\""
+	$mymenu add command -label [say "Copy"]       -accelerator "$accelerator+C" \
+		-command "pdsend \"$mytoplevel copy ;\""
+	$mymenu add command -label [say "Paste"]      -accelerator "$accelerator+V" \
+		-command "pdsend \"$mytoplevel paste ;\""
+	$mymenu add command -label [say "Duplicate"]  -accelerator "$accelerator+D" \
+		-command "pdsend \"$mytoplevel duplicate ;\""
+	$mymenu add command -label [say "Select All"] -accelerator "$accelerator+A" \
+		-command "pdsend \"$mytoplevel selectall ;\""
+	$mymenu add  separator
 	if {[tk windowingsystem] eq "aqua"} {
-		$rootmenu add command -label [say "Text Editor"] \
-			-command "menu_texteditor $name"
-		$rootmenu add command -label [say "Font"]  -accelerator "$accelerator+T" \
-			-command "menu_font $name"
+		$mymenu add command -label [say "Text Editor"] \
+			-command "menu_texteditor $mytoplevel"
+		$mymenu add command -label [say "Font"]  -accelerator "$accelerator+T" \
+			-command "menu_font $mytoplevel"
 	} else {
-		$rootmenu add command -label [say "Text Editor"] -accelerator "$accelerator+T"\
-			-command "menu_texteditor $name"
-		$rootmenu add command -label [say "Font"] \
-			-command "menu_font $name"
+		$mymenu add command -label [say "Text Editor"] -accelerator "$accelerator+T"\
+			-command "menu_texteditor $mytoplevel"
+		$mymenu add command -label [say "Font"] \
+			-command "menu_font $mytoplevel"
 	}
-	$rootmenu add command -label [say "Tidy Up"] \
-		-command "pdsend \"$name tidy ;\""
-	$rootmenu add command -label [say "Toggle Console"] -accelerator "Shift+$accelerator+R" \
+	$mymenu add command -label [say "Tidy Up"] \
+		-command "pdsend \"$mytoplevel tidy ;\""
+	$mymenu add command -label [say "Toggle Console"] -accelerator "Shift+$accelerator+R" \
 		-command {.controls.switches.console invoke}
-	$rootmenu add command -label [say "Clear Console"] -accelerator "Shift+$accelerator+L" \
+	$mymenu add command -label [say "Clear Console"] -accelerator "Shift+$accelerator+L" \
 		-command "menu_clear_console"
-	$rootmenu add  separator
-	$rootmenu add radiobutton -label [say "Edit Mode"] -accelerator "$accelerator+E" \
+	$mymenu add  separator
+	$mymenu add radiobutton -label [say "Edit Mode"] -accelerator "$accelerator+E" \
 		-indicatoron true -selectcolor grey85 \
-		-command "pdsend \"$name editmode ;\"" \
-		
+		-command "pdsend \"$mytoplevel editmode 0 ;\""
 	#    if { $editable == 0 } {
-	#        $name.m.edit entryconfigure "Edit mode" -indicatoron false 
+	#        $mymenu entryconfigure "Edit Mode" -indicatoron false 
 	#    }
+
 	if {[tk windowingsystem] ne "aqua"} {
-		$rootmenu add  separator
-		$rootmenu add command -label [say "Preferences"] \
+		$mymenu add  separator
+		$mymenu add command -label [say "Preferences"] \
 			-command "menu_preferences"
 	}
 }
 
-proc ::pd_menus::create_put_menu {rootmenu name} {
+proc ::pd_menus::create_put_menu {mymenu mytoplevel} {
 	variable accelerator
-	$rootmenu add command -label [say "Object"] -accelerator "$accelerator+1" \
-		-command "pdsend \"$name obj 0;\"" 
-	$rootmenu add command -label [say "Message"] -accelerator "$accelerator+2" \
-		-command "pdsend \"$name msg 0;\""
-	$rootmenu add command -label [say "Number"] -accelerator "$accelerator+3" \
-		-command "pdsend \"$name floatatom  0;\""
-	$rootmenu add command -label [say "Symbol"] -accelerator "$accelerator+4" \
-		-command "pdsend \"$name symbolatom  0;\""
-	$rootmenu add command -label [say "Comment"] -accelerator "$accelerator+5" \
-		-command "pdsend \"$name text  0;\""
-	$rootmenu add  separator
-	$rootmenu add command -label [say "Bang"]    -accelerator "Shift+$accelerator+B" \
-		-command "pdsend \"$name bng  0;\""
-	$rootmenu add command -label [say "Toggle"]  -accelerator "Shift+$accelerator+T" \
-		-command "pdsend \"$name toggle  0;\""
-	$rootmenu add command -label [say "Number2"] -accelerator "Shift+$accelerator+N" \
-		-command "pdsend \"$name numbox  0;\""
-	$rootmenu add command -label [say "Vslider"] -accelerator "Shift+$accelerator+V" \
-		-command "pdsend \"$name vslider  0;\""
-	$rootmenu add command -label [say "Hslider"] -accelerator "Shift+$accelerator+H" \
-		-command "pdsend \"$name hslider  0;\""
-	$rootmenu add command -label [say "Vradio"]  -accelerator "Shift+$accelerator+D" \
-		-command "pdsend \"$name vradio  0;\""
-	$rootmenu add command -label [say "Hradio"]  -accelerator "Shift+$accelerator+I" \
-		-command "pdsend \"$name hradio  0;\""
-	$rootmenu add command -label [say "VU Meter"] -accelerator "Shift+$accelerator+U"\
-		-command "pdsend \"$name vumeter  0;\""
-	$rootmenu add command -label [say "Canvas"]  -accelerator "Shift+$accelerator+C" \
-		-command "pdsend \"$name mycnv  0;\""
-	$rootmenu add  separator
-	$rootmenu add command -label Graph -command "pdsend \"$name graph ;\"" 
-	$rootmenu add command -label Array -command "pdsend \"$name menuarray ;\""
+	$mymenu add command -label [say "Object"] -accelerator "$accelerator+1" \
+		-command "pdsend \"$mytoplevel obj 0;\"" 
+	$mymenu add command -label [say "Message"] -accelerator "$accelerator+2" \
+		-command "pdsend \"$mytoplevel msg 0;\""
+	$mymenu add command -label [say "Number"] -accelerator "$accelerator+3" \
+		-command "pdsend \"$mytoplevel floatatom  0;\""
+	$mymenu add command -label [say "Symbol"] -accelerator "$accelerator+4" \
+		-command "pdsend \"$mytoplevel symbolatom  0;\""
+	$mymenu add command -label [say "Comment"] -accelerator "$accelerator+5" \
+		-command "pdsend \"$mytoplevel text  0;\""
+	$mymenu add  separator
+	$mymenu add command -label [say "Bang"]    -accelerator "Shift+$accelerator+B" \
+		-command "pdsend \"$mytoplevel bng  0;\""
+	$mymenu add command -label [say "Toggle"]  -accelerator "Shift+$accelerator+T" \
+		-command "pdsend \"$mytoplevel toggle  0;\""
+	$mymenu add command -label [say "Number2"] -accelerator "Shift+$accelerator+N" \
+		-command "pdsend \"$mytoplevel numbox  0;\""
+	$mymenu add command -label [say "Vslider"] -accelerator "Shift+$accelerator+V" \
+		-command "pdsend \"$mytoplevel vslider  0;\""
+	$mymenu add command -label [say "Hslider"] -accelerator "Shift+$accelerator+H" \
+		-command "pdsend \"$mytoplevel hslider  0;\""
+	$mymenu add command -label [say "Vradio"]  -accelerator "Shift+$accelerator+D" \
+		-command "pdsend \"$mytoplevel vradio  0;\""
+	$mymenu add command -label [say "Hradio"]  -accelerator "Shift+$accelerator+I" \
+		-command "pdsend \"$mytoplevel hradio  0;\""
+	$mymenu add command -label [say "VU Meter"] -accelerator "Shift+$accelerator+U"\
+		-command "pdsend \"$mytoplevel vumeter  0;\""
+	$mymenu add command -label [say "Canvas"]  -accelerator "Shift+$accelerator+C" \
+		-command "pdsend \"$mytoplevel mycnv  0;\""
+	$mymenu add  separator
+	$mymenu add command -label Graph -command "pdsend \"$mytoplevel graph ;\"" 
+	$mymenu add command -label Array -command "pdsend \"$mytoplevel menuarray ;\""
 }
 
-proc ::pd_menus::create_find_menu {rootmenu name} {
+proc ::pd_menus::create_find_menu {mymenu mytoplevel} {
 	variable accelerator
-	$rootmenu add command -label [say "Find..."]    -accelerator "$accelerator+F" \
-		-command "menu_findobject $name"
-	$rootmenu add command -label [say "Find Again"] -accelerator "$accelerator+G" \
-		-command "pdsend \"$name findagain ;\""
-	$rootmenu add command -label [say "Find last error"] \
-		-command "pdsend \"$name finderror ;\"" 
+	$mymenu add command -label [say "Find..."]    -accelerator "$accelerator+F" \
+		-command "menu_findobject $mytoplevel"
+	$mymenu add command -label [say "Find Again"] -accelerator "$accelerator+G" \
+		-command "pdsend \"$mytoplevel findagain ;\""
+	$mymenu add command -label [say "Find last error"] \
+		-command "pdsend \"$mytoplevel finderror ;\"" 
 }
 
-proc ::pd_menus::create_media_menu {rootmenu name} {
+proc ::pd_menus::create_media_menu {mymenu mytoplevel} {
 	variable accelerator
-	$rootmenu add radiobutton -label [say "Compute Audio On"] -accelerator "$accelerator+/" \
+	$mymenu add radiobutton -label [say "Compute Audio On"] -accelerator "$accelerator+/" \
 		-command "pdsend \"pd dsp 1 ;\""
-	$rootmenu add radiobutton -label [say "Compute Audio Off"] -accelerator "$accelerator+." \
+	$mymenu add radiobutton -label [say "Compute Audio Off"] -accelerator "$accelerator+." \
 		-command "pdsend \"pd dsp 0 ;\"" -indicatoron true 
-	$rootmenu add  separator    
-	$rootmenu add command -label [say "Test Audio and MIDI"] \
+	$mymenu add  separator    
+	$mymenu add command -label [say "Test Audio and MIDI"] \
 		-command "menu_doc_open doc/7.stuff/tools testtone.pd" 
-	$rootmenu add command -label [say "Load Meter"] \
+	$mymenu add command -label [say "Load Meter"] \
 		-command "menu_doc_open doc/7.stuff/tools load-meter.pd" 
 }
 
-proc ::pd_menus::create_window_menu {rootmenu name} {
+proc ::pd_menus::create_window_menu {mymenu mytoplevel} {
 	variable accelerator
 	if {[tk windowingsystem] eq "aqua"} {
-		$rootmenu add command -label [say "Minimize"] -command "menu_minimize ." \
+		$mymenu add command -label [say "Minimize"] -command "menu_minimize ." \
 			-accelerator "$accelerator+M"
-		$rootmenu add command -label [say "Zoom"] -command "menu_zoom ."
-		$rootmenu add  separator
+		$mymenu add command -label [say "Zoom"] -command "menu_zoom ."
+		$mymenu add  separator
 	}
-	$rootmenu add command -label [say "Parent Window"] -state disabled
-	$rootmenu add command -label [say "Pd window"] -command "menu_raise_console" \
+	$mymenu add command -label [say "Parent Window"] -state disabled
+	$mymenu add command -label [say "Pd window"] -command "menu_raise_console" \
 		-accelerator "$accelerator+R" -state disabled
-	$rootmenu add  separator
+	$mymenu add  separator
 }
 
-proc ::pd_menus::create_help_menu {rootmenu name} {
+proc ::pd_menus::create_help_menu {mymenu mytoplevel} {
 	if {[tk windowingsystem] ne "aqua"} {
-		$rootmenu add command -label {About Pd} \
+		$mymenu add command -label {About Pd} \
 			-command "placeholder menu_doc_open doc/1.manual 1.introduction.txt" 
 	}
-	$rootmenu add command -label {HTML ...} \
+	$mymenu add command -label {HTML ...} \
 		-command "placeholder menu_doc_open doc/1.manual index.htm"
-	$rootmenu add command -label {Browser ...} \
+	$mymenu add command -label {Browser ...} \
 		-command "placeholder menu_helpbrowser \$help_top_directory" 
 }
-
-
-# for the Apple application menu on Mac OS X
-# proc ::tk::mac::ShowPreferences {} {
-# 	puts stderr "apple prefs menu item callback"
-# 	puts stderr "::tk::mac::ShowPreferences "
-# 	menu_preferences
-# }
-
-# for Mac OS X only
-proc ::pd_menus::make_apple_menu {rootmenu} {
-	puts stderr CREATE_APPLE_MENU
-	# TODO this should open a Pd patch called about.pd
-	menu $rootmenu.apple
-	$rootmenu.apple add command -label [say "About Pd"] \
-		-command "menu_doc_open doc/1.manual 1.introduction.txt" 
-    $rootmenu add cascade -label "Apple" -menu $rootmenu.apple
-	# starting in 8.4.14, this is created automatically
-	if {[regsub -- {[0-9]\.[0-9]\.([0-9][0-9]*)} [info patchlevel] {\1}] < 14} {
-		$rootmenu.apple add separator
-		$rootmenu.apple add command -label [say "Preferences..."] \
-			-command "menu_preferences" -accelerator "Cmd+,"
-	}
-}
-
-# for Windows only
-proc ::pd_menus::make_system_menu {rootmenu} {
-	$rootmenu add cascade -menu [menu $rootmenu.system]
-	# TODO add Close, Minimize, etc and whatever else is on the little menu
-	# that is on the top left corner of the window frame
-}
-
-proc ::pd_menus::create_menubar {rootmenu} {
-	menu $rootmenu
-	set menulist "file edit put find media window help"
-	if { [tk windowingsystem] eq "aqua" } {make_apple_menu $rootmenu}
-	if { [tk windowingsystem] eq "win32" } {make_system_menu $rootmenu}
-	foreach menuitem $menulist {	
-		menu $rootmenu.$menuitem
-		$rootmenu add cascade -label [string totitle $menuitem] \
-			-menu $rootmenu.$menuitem
-		[format create_%s_menu $menuitem] $rootmenu.$menuitem PLACEHOLDER
-		if {[tk windowingsystem] eq "win32"} {
-			# fix menu font size on Windows with tk scaling = 1
-			$rootmenu.$menuitem configure -font menufont
-		}
-	}
-}
-
-proc ::pd_menus::configure_pdwindow {menubar} {
-	# these are meaningless for the Pd window, so disable them
-	set file_items_to_disable {"Save" "Save As..." "Print..." "Close"}
-	foreach item $file_items_to_disable {
-		$menubar.file entryconfigure $item -state disabled
-	}
-	set edit_items_to_disable {"Undo" "Redo" "Duplicate" "Tidy Up" "Edit Mode"}
-	foreach item $edit_items_to_disable {
-		$menubar.edit entryconfigure $item -state disabled
-	}
-	# disable everything on the Put menu
-	for {set i 0} {$i <= [$menubar.put index end]} {incr i} {
-		# catch errors by trying to disable separators
-		catch {$menubar.put entryconfigure $i -state disabled }
-	}
-}
-

Modified: branches/pd-devel/0.41.4/src/pdtk_canvas.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pdtk_canvas.tcl	2009-01-13 17:13:31 UTC (rev 10532)
+++ branches/pd-devel/0.41.4/src/pdtk_canvas.tcl	2009-01-13 17:57:25 UTC (rev 10533)
@@ -6,14 +6,7 @@
 namespace eval ::pdtk_canvas:: {
 }
 
-
-# get the name of the toplevel window for a canvas; this is also the name of
-# the canvas object in Pd.  It would probably make more sense if bind's %W returned the window name ($name) rather than the canvas name
-proc to_top {canvasname} {
-    string range $canvasname 0 [expr [string length $canvasname] - 3]
-}
-
-proc pdtk_canvas_checkgeometry {topname} {
+proc pdtk_canvas_checkgeometry {mytoplevel} {
 	# TODO check and relocate window accordingly
 }
 
@@ -21,28 +14,32 @@
 #------------------------------------------------------------------------------#
 # mouse usage
 
-proc pdtk_canvas_motion {canvasname x y mods} {
-    pdsend "[to_top $canvasname] motion [$canvasname canvasx $x] [$canvasname canvasy $y] $mods;"
+proc pdtk_canvas_motion {mycanvas x y mods} {
+	set mytoplevel [winfo toplevel $mycanvas]
+    pdsend "$mytoplevel motion [$mycanvas canvasx $x] [$mycanvas canvasy $y] $mods;"
 }
 
-proc pdtk_canvas_mouse {canvasname x y b f} {
+proc pdtk_canvas_mouse {mycanvas x y b f} {
 	# TODO perhaps the Tcl/C function names should match "mouse" message
 	# rather than "mousedown" function
-    pdsend "[to_top $canvasname] mouse [$canvasname canvasx $x] [$canvasname canvasy $y] $b $f;"
+	set mytoplevel [winfo toplevel $mycanvas]
+    pdsend "$mytoplevel mouse [$mycanvas canvasx $x] [$mycanvas canvasy $y] $b $f;"
 }
 
-proc pdtk_canvas_mouseup {canvasname x y b} {
-    pdsend "[to_top $canvasname] mouseup [$canvasname canvasx $x] [$canvasname canvasy $y] $b;"
+proc pdtk_canvas_mouseup {mycanvas x y b} {
+	set mytoplevel [winfo toplevel $mycanvas]
+    pdsend "$mytoplevel mouseup [$mycanvas canvasx $x] [$mycanvas canvasy $y] $b;"
 }
 
-proc pdtk_canvas_rightclick {canvasname x y b} {
-    pdsend "[to_top $canvasname] mouse [$canvasname canvasx $x] [$canvasname canvasy $y] $b 8;"
+proc pdtk_canvas_rightclick {mycanvas x y b} {
+	set mytoplevel [winfo toplevel $mycanvas]
+    pdsend "$mytoplevel mouse [$mycanvas canvasx $x] [$mycanvas canvasy $y] $b 8;"
 }
 
-# on X11, button 2 "pastes" from the X windows clipboard
-proc pdtk_canvas_clickpaste {canvasname x y b} {
-	pdtk_canvas_click $canvasname $x $y $b 0
-	pdtk_canvas_mouseup $canvasname $x $y $b
+# on X11, button 2 pastes from X11 clipboard, so simulate normal paste actions
+proc pdtk_canvas_clickpaste {mycanvas x y b} {
+	pdtk_canvas_mouse $mycanvas $x $y $b 0
+	pdtk_canvas_mouseup $mycanvas $x $y $b
 	pdtk_pastetext
 }
 
@@ -52,19 +49,19 @@
 # "map" event tells us when the canvas becomes visible (arg is "0") or
 # invisible (arg is "").  Invisibility means the Window Manager has minimized
 # us.  We don't get a final "unmap" event when we destroy the window.
-proc pdtk_canvas_map {name} {
-    pdsend "$name map 1 ;"
+proc pdtk_canvas_map {mytoplevel} {
+    pdsend "$mytoplevel map 1 ;"
 }
 
-proc pdtk_canvas_unmap {name} {
-    pdsend "$name map 0 ;"
+proc pdtk_canvas_unmap {mytoplevel} {
+    pdsend "$mytoplevel map 0 ;"
 }
 
 # check or uncheck the "edit" menu item
-proc pdtk_canvas_editval {name value} {
-	$name.m.edit entryconfigure "Edit mode" -indicatoron $value
+proc pdtk_canvas_editval {mytoplevel value} {
+	# TODO make this work
 }
 
-proc pdtk_canvas_getscroll {name} {
+proc pdtk_canvas_getscroll {mytoplevel} {
 	# TODO make this work
 }

Modified: branches/pd-devel/0.41.4/src/pdtk_text.tcl
===================================================================
--- branches/pd-devel/0.41.4/src/pdtk_text.tcl	2009-01-13 17:13:31 UTC (rev 10532)
+++ branches/pd-devel/0.41.4/src/pdtk_text.tcl	2009-01-13 17:57:25 UTC (rev 10533)
@@ -8,20 +8,19 @@
 # TODO use a Tk 'font' as the main font
 
 ############ pdtk_text_new -- create a new text object #2###########
-proc pdtk_text_new {canvasname itemname x y text font_size color} {
-	global font_family font_weight
-    $canvasname create text $x $y -font "$font_family $font_size $font_weight" \
-        -tags $itemname -text $text -fill $color -anchor nw 
-	$canvasname bind $itemname <Home> "$canvasname icursor $itemname 0"
-	$canvasname bind $itemname <End> "$canvasname icursor $itemname end"
+proc pdtk_text_new {mycanvas canvasitem x y text font_size color} {
+    $mycanvas create text $x $y -tags $canvasitem -text $text -fill $color \
+		-anchor nw -font "$::font_family $font_size $::font_weight"
+	$mycanvas bind $canvasitem <Home> "$mycanvas icursor $canvasitem 0"
+	$mycanvas bind $canvasitem <End> "$mycanvas icursor $canvasitem end"
 	if {[tk windowingsystem] eq "aqua"} { # emacs bindings for Mac OS X
-		$canvasname bind $itemname <Control-a> "$canvasname icursor $itemname 0"
-		$canvasname bind $itemname <Control-e> "$canvasname icursor $itemname end"
+		$mycanvas bind $canvasitem <Control-a> "$mycanvas icursor $canvasitem 0"
+		$mycanvas bind $canvasitem <Control-e> "$mycanvas icursor $canvasitem end"
 	}
 }
 
 ################ pdtk_text_set -- change the text ##################
-proc pdtk_text_set {canvasname itemname text} {
-    $canvasname itemconfig $itemname -text $text
+proc pdtk_text_set {mycanvas canvasitem text} {
+    $mycanvas itemconfig $canvasitem -text $text
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Pd-cvs mailing list