Revision: 10632 http://pure-data.svn.sourceforge.net/pure-data/?rev=10632&view=rev Author: eighthave Date: 2009-01-25 06:42:32 +0000 (Sun, 25 Jan 2009)
Log Message: ----------- - worked on font code started by mescalinum to make it receive the font family and weight from pd as well as standardizing variable and proc names
- created dummy font panel
- renamed pdtk_canvas_map/unmap to pdsend_map/unmap since it is not called from 'pd', it only send to 'pd'
- renamed enquote_filename to enquote_path for the sake of clarity
- updated version test to properly create Mac OS X preferences in Apple menu
- if a saved directory (pd_opendir, etc) has disappeared, use $HOME
Modified Paths: -------------- 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/s_main.c branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl
Modified: branches/pd-devel/0.41.4/src/pd.tk =================================================================== --- branches/pd-devel/0.41.4/src/pd.tk 2009-01-25 02:06:22 UTC (rev 10631) +++ branches/pd-devel/0.41.4/src/pd.tk 2009-01-25 06:42:32 UTC (rev 10632) @@ -25,13 +25,23 @@ # for testing which platform we are running on ("aqua", "win32", or "x11") set windowingsystem ""
-# FONT STUFF: -# default font family/weight, changed later in 'init' (if needed) -set font_family {Bitstream Vera Sans Mono} -set font_weight {normal} -# this contains the font metric that Pd expects (we have to respect those -# when creating fonts in proc pdtk_init_fonts) -set font_fixed_metrics {8 5 10 9 6 11 10 6 13 12 7 15 14 8 17 16 10 20 18 11 22 24 14 30 30 18 37 36 22 45} +# canvas font, received from pd in pdtk_pd_startup, set in s_main.c +set font_family "" +set font_weight "" +# sizes of chars for each of the Pd fixed font sizes: +# fontsize width(pixels) height(pixels) +set font_fixed_metrics { + 8 5 10 + 9 6 11 + 10 6 13 + 12 7 15 + 14 8 17 + 16 10 20 + 18 11 22 + 24 14 30 + 30 18 37 + 36 22 45 +}
set pd_opendir [pwd] set pd_untitleddir [pwd] @@ -115,7 +125,6 @@ {{Max Patch Files (.pat)} {.pat} } {{Max Text Files (.mxt)} {.mxt} } } - set ::font_family {Monaco} } "win32" { font create menufont -family Tahoma -size -11 @@ -137,24 +146,28 @@
# this proc creates all the needed fonts so that they fit # into the metrics given by $::font_fixed_metrics -proc pdtk_init_fonts {} { +proc fit_font_into_metrics {} { foreach {size width height} $::font_fixed_metrics { - set fnt [pdtk_font_name $size] - font create $fnt -family $::font_family -weight $::font_weight \ + set myfont [pdtk_font_name $size] + font create $myfont -family $::font_family -weight $::font_weight \ -size [expr {-$height}] - while {[font measure $fnt M] > $width} { + while {[font measure $myfont M] > $width} { incr height -1 - font configure $fnt -size [expr {-$height}] + font configure $myfont -size [expr {-$height}] } } }
proc pdtk_pd_startup {version {args ""}} { - pdtk_post "version: $version" - pdtk_post "args: $args" + pdtk_post "pdtk_pd_startup $version $args" + pdtk_post "\tversion: $version" + pdtk_post "\targs: $args" set oldtclversion 0 - pdtk_init_fonts - pdsend "pd init [enquote_filename [pwd]] $oldtclversion $::font_fixed_metrics" + pdsend "pd init [enquote_path [pwd]] $oldtclversion $::font_fixed_metrics" + set ::font_family [lindex $args 2] + set ::font_weight [lindex $args 3] + puts "setting font to: $::font_family $::font_weight" + fit_font_into_metrics # TODO what else is needed from the original? }
Modified: branches/pd-devel/0.41.4/src/pd_bindings.tcl =================================================================== --- branches/pd-devel/0.41.4/src/pd_bindings.tcl 2009-01-25 02:06:22 UTC (rev 10631) +++ branches/pd-devel/0.41.4/src/pd_bindings.tcl 2009-01-25 06:42:32 UTC (rev 10632) @@ -113,7 +113,7 @@ if {$::windowingsystem eq "aqua"} { bind $mytoplevel <$modifier-Key-m> "menu_minimize $mytoplevel" - bind $mytoplevel <$modifier-Key-t> "menu_font $mytoplevel" + bind $mytoplevel <$modifier-Key-t> "menu_font_panel $mytoplevel" bind $mytoplevel <$modifier-quoteleft> "menu_raisenextwindow" } else { bind $mytoplevel <$modifier-Key-m> "menu_message_panel" @@ -152,8 +152,8 @@ #TODO bind $mytoplevel <MouseWheel>
# event bindings ----------------------------------------------------------- - bind $mytoplevel <Map> "pdtk_canvas_map %W" - bind $mytoplevel <Unmap> "pdtk_canvas_unmap %W" + bind $mytoplevel <Map> "pdsend_map %W" + bind $mytoplevel <Unmap> "pdsend_unmap %W" #TODO bind $mytoplevel <Configure> "pdtk_canvas_getscroll %W"
# do window maintenance when entering a window (Window menu, scrollbars...)
Modified: branches/pd-devel/0.41.4/src/pd_menucommands.tcl =================================================================== --- branches/pd-devel/0.41.4/src/pd_menucommands.tcl 2009-01-25 02:06:22 UTC (rev 10631) +++ branches/pd-devel/0.41.4/src/pd_menucommands.tcl 2009-01-25 06:42:32 UTC (rev 10632) @@ -15,15 +15,15 @@
proc ::pd_menucommands::menu_new {} { variable untitled_number - if { ! [file isdirectory $::pd_untitleddir]} {set ::pd_untitleddir [pwd]} - pdsend "pd filename Untitled-$untitled_number [enquote_filename $::pd_untitleddir]" + if { ! [file isdirectory $::pd_untitleddir]} {set ::pd_untitleddir $::env(HOME)} + pdsend "pd filename Untitled-$untitled_number [enquote_path $::pd_untitleddir]" pdsend "#N canvas" pdsend "#X pop 1" - set untitled_number [expr $untitled_number + 1] + incr untitled_number }
proc ::pd_menucommands::menu_open {} { - if { ! [file isdirectory $::pd_opendir]} {set ::pd_opendir [pwd]} + if { ! [file isdirectory $::pd_opendir]} {set ::pd_opendir $::env(HOME)} set files [tk_getOpenFile -defaultextension .pd \ -multiple true \ -filetypes $::filetypes \ @@ -80,6 +80,20 @@ # console text. hmm that would be nice! }
+proc ::pd_menucommands::menu_font_panel {mytoplevel} { + if {[winfo exists .font]} { + raise .font + } else { + # TODO insert real preference panel here + toplevel .font + wm title .font "Font" + ::pd_bindings::panel_bindings .font + frame .font.frame + label .font.label -text "font" -width 30 -height 15 + pack .font.label .font.frame -side top -expand yes -fill both + } +} + proc ::pd_menucommands::menu_preferences_panel {} { if {[winfo exists .preferences]} { raise .preferences
Modified: branches/pd-devel/0.41.4/src/pd_menus.tcl =================================================================== --- branches/pd-devel/0.41.4/src/pd_menus.tcl 2009-01-25 02:06:22 UTC (rev 10631) +++ branches/pd-devel/0.41.4/src/pd_menus.tcl 2009-01-25 06:42:32 UTC (rev 10632) @@ -110,12 +110,12 @@ $mymenu add command -label [say "Text Editor"] \ -command "menu_texteditor $mytoplevel" $mymenu add command -label [say "Font"] -accelerator "$accelerator+T" \ - -command "menu_font $mytoplevel" + -command "menu_font_panel $mytoplevel" } else { $mymenu add command -label [say "Text Editor"] -accelerator "$accelerator+T"\ -command "menu_texteditor $mytoplevel" $mymenu add command -label [say "Font"] \ - -command "menu_font $mytoplevel" + -command "menu_font_panel $mytoplevel" } $mymenu add command -label [say "Tidy Up"] \ -command "pdsend "$mytoplevel tidy"" @@ -240,9 +240,10 @@ $mymenu add cascade -label "Apple" -menu $mymenu.apple $mymenu.apple add separator # starting in 8.4.14, this is created automatically - if {[regsub -- {[0-9].[0-9].([0-9][0-9]*)} [info patchlevel] {\1}] < 14} { + set patchlevel [split [info patchlevel] .] + if {[lindex $patchlevel 1] < 5 && [lindex $patchlevel 2] < 14} { $mymenu.apple add command -label [say "Preferences..."] \ - -command "menu_preferences" -accelerator "Cmd+," + -command "menu_preferences_panel" -accelerator "Cmd+," } }
Modified: branches/pd-devel/0.41.4/src/pdtk_canvas.tcl =================================================================== --- branches/pd-devel/0.41.4/src/pdtk_canvas.tcl 2009-01-25 02:06:22 UTC (rev 10631) +++ branches/pd-devel/0.41.4/src/pdtk_canvas.tcl 2009-01-25 06:42:32 UTC (rev 10632) @@ -44,7 +44,7 @@ }
proc pdtk_canvas_saveas {name initialfile initialdir} { - if { ! [file isdirectory $initialdir]} {set initialdir [pwd]} + if { ! [file isdirectory $initialdir]} {set initialdir $::env(HOME)} set filename [tk_getSaveFile -initialfile $initialfile -initialdir $initialdir \ -defaultextension .pd -filetypes $::filetypes] if {$filename eq ""} return; # they clicked cancel @@ -63,7 +63,7 @@ } set dirname [file dirname $filename] set basename [file tail $filename] - pdsend "$name savetofile [enquote_filename $basename] [enquote_filename $dirname]" + pdsend "$name savetofile [enquote_path $basename] [enquote_path $dirname]" set ::pd_untitleddir $dirname }
@@ -105,11 +105,13 @@ # "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 {mytoplevel} { +proc pdsend_map {mytoplevel} { pdsend "$mytoplevel map 1" + #[regsub -- "" [wm title $mytoplevel]] + #set ::pd_untitleddir $dirname }
-proc pdtk_canvas_unmap {mytoplevel} { +proc pdsend_unmap {mytoplevel} { pdsend "$mytoplevel map 0" }
Modified: branches/pd-devel/0.41.4/src/s_main.c =================================================================== --- branches/pd-devel/0.41.4/src/s_main.c 2009-01-25 02:06:22 UTC (rev 10631) +++ branches/pd-devel/0.41.4/src/s_main.c 2009-01-25 06:42:32 UTC (rev 10632) @@ -65,9 +65,9 @@ #ifdef MSW "Courier"; #else - "Courier"; + "Andale Mono"; #endif -char sys_fontweight[] = "bold "; /* currently only used for iemguis */ +char sys_fontweight[] = "normal "; /* currently only used for iemguis */ static int sys_main_srate; static int sys_main_advance; static int sys_main_callback;
Modified: branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl =================================================================== --- branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl 2009-01-25 02:06:22 UTC (rev 10631) +++ branches/pd-devel/0.41.4/src/wheredoesthisgo.tcl 2009-01-25 06:42:32 UTC (rev 10632) @@ -25,7 +25,7 @@ set directory [file dirname $filename] set basename [file tail $filename] if {[regexp -nocase -- ".(pd|pat|mxt)$" $filename]} { - pdsend "pd open [enquote_filename $basename] [enquote_filename $directory]" + pdsend "pd open [enquote_path $basename] [enquote_path $directory]" set ::pd_opendir $directory } } @@ -34,7 +34,7 @@ # quoting functions
# enquote a filename to send it to pd, " isn't handled properly tho... -proc enquote_filename {message} { +proc enquote_path {message} { string map {"," "\," ";" "\;" " " "\ "} $message }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.