#!/usr/bin/wish # Copyright (c) 1997-1999 Miller Puckette. # For information on usage and redistribution, and for a DISCLAIMER OF ALL # WARRANTIES, see the file, "LICENSE.txt," in this distribution. # changed by Thomas Musil 09.2001 # between "pdtk_graph_dialog -- dialog window for graphs" # and "pdtk_array_dialog -- dialog window for arrays" # a new dialogbox was inserted, named: # "pdtk_iemgui_dialog -- dialog window for iem guis" # # all these changes are labeled with #######iemlib######## # set pd_nt (bad name) 0 for unix, 1 for microsoft, and 2 for Mac OSX. #May 22 2009 #GUI improvements and dynamic runtime 8.5 widget upgrade for Linux by Ivica Ico Bukvic #http://ico.bukvic.net # Mathieu's way of listing all defined procs #rename proc proque #proque proc {name args body} { # puts "proc $name" # uplevel 1 [list proque $name $args $body] #} #puts stderr [info tclversion] ##--moo: force default system and stdio encoding to UTF-8 encoding system utf-8 fconfigure stderr -encoding utf-8 fconfigure stdout -encoding utf-8 ##--/moo set appname [tk appname] tk appname $appname-startup #puts stderr "APPNAME [tk appname]" if { [info tclversion] >= 8.5 } { # EDIT THIS PART TO CUSTOMIZE LINUX THEME # match gnome colors # Ubuntu Human # set linux_wm_bgcolor "#3e3d39" set linux_wm_bgcolor "#e5e5e5" # set linux_wm_hlcolor "#fdbf69" # set linux_wm_hlcolor "#f9ba81" # set linux_wm_hlcolor "#ffaa16" set linux_wm_hlcolor "#eb5f28" # ttk colors # -frame, -lighter, and -selectbg are automatically # replaced by theme colors specified above variable colors array set colors { -frame "#e5e5e5" -window "#ffffff" -darkest "#999999" -darker "#709970" #-dark "#a8e6a8" -dark "#bcbcbc" -light "#d2ffd2" -lighter "#e5e5e5" -disabledfg "#a3a3a3" -selectbg "#fdbf69" -selectfg "#000000" } # STOP EDITING BEYOND THIS POINT #sync ttk with theme choice above it set colors(-frame) $linux_wm_bgcolor set colors(-lighter) $linux_wm_bgcolor set colors(-selectbg) $linux_wm_hlcolor ttk::style theme create purty_linux -parent clam -settings { ttk::style configure "." \ -background $colors(-frame) \ -foreground black \ -bordercolor $colors(-darkest) \ -selectbackground $colors(-selectbg) \ -selectforeground $colors(-selectfg) \ -troughcolor $colors(-dark) \ -arrowcolor $colors(-darkest) \ -font TkDefaultFont \ ; ttk::style map "." -background \ [list disabled $colors(-frame) active $colors(-lighter)] ; ttk::style map "." -foreground [list disabled $colors(-disabledfg)] ; ttk::style map "." -embossed [list disabled 0] ; ttk::style configure TButton \ -anchor center -width -11 -padding "1 1" \ -relief raised -shiftrelief 1 \ -highlightthickness 1 -highlightcolor $colors(-selectbg) ttk::style map TButton -relief { {pressed !disabled} sunken {active !disabled} raised } -highlightcolor {alternate black} ttk::style configure TCheckbutton \ -indicatorcolor $colors(-window) -padding 2 ttk::style configure TRadiobutton \ -indicatorcolor $colors(-window) -padding 2 ttk::style map TCheckbutton -indicatorcolor \ [list disabled $colors(-frame) pressed $colors(-frame)] ttk::style map TRadiobutton -indicatorcolor \ [list disabled $colors(-frame) pressed $colors(-frame)] ttk::style configure TMenubutton \ -width -11 -padding "3 3" -relief raised ttk::style configure TEntry \ -padding 1 -fieldbackground $colors(-window) ; ttk::style map TEntry -fieldbackground \ [list readonly $colors(-frame) disabled $colors(-frame)] ttk::style configure TCombobox \ -padding 1 -fieldbackground $colors(-window) ; ttk::style map TCombobox -fieldbackground \ [list readonly $colors(-frame) disabled $colors(-frame)] ttk::style configure Toolbutton -relief flat -padding 2 ttk::style map Toolbutton -relief \ {disabled flat selected sunken pressed sunken active raised} ttk::style map Toolbutton -background \ [list pressed $colors(-dark) active $colors(-light)] ttk::style configure TScrollbar -relief raised ttk::style configure TScale \ -groovewidth 4 -troughrelief sunken \ -sliderwidth raised -borderwidth 2 ttk::style configure TProgressbar \ -background $colors(-selectbg) -borderwidth 0 ttk::style configure TLabelframe -relief groove -borderwidth 2 ttk::style configure TNotebook -tabmargins {2 2 1 0} ttk::style configure TNotebook.Tab \ -padding {4 2} -background $colors(-dark) ttk::style map TNotebook.Tab \ -background [list selected $colors(-frame)] \ -expand [list selected {2 2 1 0}] \ ; ttk::style configure Treeview -fieldbackground $colors(-window) ttk::style configure Heading -font TkHeadingFont -relief raised ttk::style configure Row -background $colors(-window) ttk::style map Row \ -background [list selected $colors(-selectbg)] ttk::style map Item \ -foreground [list selected $colors(-selectfg)] ttk::style map Cell \ -foreground [list selected $colors(-selectfg)] } } # Automate matching of the linux wm and use ttk where possible # As of right now it is only enabled if system is Linux/Unix using tcl >= 8.5 proc match_linux_wm {list} { global pd_nt linux_wm_bgcolor linux_wm_hlcolor if { [info tclversion] >= 8.5 && $pd_nt == 0 } { if {[lsearch -regexp $list ::] != 0} { #puts stderr [lindex $list 0] if {[lindex $list 0] != "button" \ && [lindex $list 0] != "checkbutton" \ && [lindex $list 0] != "radiobutton" \ && [lindex $list 0] != "entry" \ && [lindex $list 0] != "scrollbar" \ && [lindex $list 1] != "add"} { lappend list -bg $linux_wm_bgcolor } if {[lindex $list 0] == "listbox" \ || [lindex $list 0] == "text"} { lappend list -bg white -highlightcolor $linux_wm_hlcolor } if {[lindex $list 1] == "add"} { #lappend list -background "#000000" set newlist [list [lindex $list 0] add command -label {} -state disabled] } if {[lindex $list 0] == "menu"} { lappend list -activebackground $linux_wm_hlcolor -bg "#3c3b37" -fg "#dddddd" -bd 0 -activeborderwidth 0 -relief flat -disabledforeground "#777777" } #convert non-ttk objects to ttk objects if {[lindex $list 0] == "button" \ || [lindex $list 0] == "checkbutton" \ || [lindex $list 0] == "radiobutton" \ || [lindex $list 0] == "entry" \ || [lindex $list 0] == "scrollbar"} { set newlist [lreplace $list 0 0 ttk::[lindex $list 0]] } } } if {[info exists newlist]} { eval $newlist } else { #puts stderr "[lsearch -regexp $list ::]:::::[lindex $list 0]::::::$list" eval $list } } if { $tcl_platform(platform) == "windows" } { set pd_nt 1 set ctrl_key "Control" # fontsc set defaultFontFamily {DejaVu Sans Mono} font create menuFont -family Tahoma -size 10 # mouse cursors set cursor_runmode_nothing "arrow" set cursor_runmode_clickme "right_ptr" set cursor_runmode_thicken "sb_v_double_arrow" set cursor_runmode_addpoint "plus" set cursor_editmode_nothing "hand2" set cursor_editmode_connect "circle" set cursor_editmode_disconnect "X_cursor" set cursor_editmode_resize "sb_h_double_arrow" set cursor_editmode_resize_bottom_right "bottom_right_corner" set cursor_scroll "fleur" # set file types that open/save recognize set filetypes { {{Pd Files} {.pd} } {{Max Patch Files} {.pat} } {{Max Text Files} {.mxt} } {{Max Binary Files} {.mxb} } {{Max Help Files} {.help} } } # use CommonProgramFiles by default instead because its a lot easier to # find. Microsoft seems to have carefully hidden the AppData folder from # all but the most determined users. #set externalsdir "$::env(AppData)/Pd" set externalsdir "$::env(CommonProgramFiles)/Pd" } elseif { $tcl_platform(os) == "Darwin" } { set pd_nt 2 set ctrl_key "Mod1" # fonts set defaultFontFamily Monaco # mouse cursors set cursor_runmode_nothing "arrow" set cursor_runmode_clickme "center_ptr" set cursor_runmode_thicken "sb_v_double_arrow" set cursor_runmode_addpoint "plus" set cursor_editmode_nothing "hand2" set cursor_editmode_connect "circle" set cursor_editmode_disconnect "X_cursor" set cursor_editmode_resize "sb_h_double_arrow" set cursor_editmode_resize_bottom_right "bottom_right_corner" set cursor_scroll "fleur" # set file types that open/save recognize set filetypes { {{Pd Files} {.pd} } {{Max Patch Files (.pat)} {.pat} } {{Max Text Files (.mxt)} {.mxt} } {{Max Binary Files (.mxb)} {.mxb} } {{Max Help Files (.help)} {.help} } } set externalsdir "$::env(HOME)/Library/Pd" } else { # set nicer theme ttk::style theme use purty_linux clipboard clear set window_prefs {} set pd_nt 0 set ctrl_key "Control" # Shift modifier set shift_l_down 0 set shift_r_down 0 # Ctrl modifier set ctrl_l_down 0 set ctrl_r_down 0 # fonts set defaultFontFamily {DejaVu Sans Mono} # mouse cursors set cursor_runmode_nothing "left_ptr" set cursor_runmode_clickme "right_ptr" set cursor_runmode_thicken "sb_v_double_arrow" set cursor_runmode_addpoint "plus" set cursor_editmode_nothing "hand2" set cursor_editmode_connect "target" set cursor_editmode_disconnect "X_cursor" set cursor_editmode_resize "sb_h_double_arrow" set cursor_editmode_resize_bottom_right "bottom_right_corner" set cursor_scroll "fleur" # set file types that open/save recognize set filetypes { {{pd files} {.pd} } {{max patch files} {.pat} } {{max text files} {.mxt} } {{max binary files} {.mxb} } {{max help files} {.help} } } set externalsdir "$::env(HOME)/pd-l2ork-externals" } #proc bgerror {message} { # pdtk_post "\ntcl error: $message" #puts "\033\[0;1;33mtcl error: $::errorInfo\033\[0m" #} # make sure the user folder for installing externals exists #catch { # if { ! [file exists $externalsdir] && [file exists [file dirname $externalsdir]] } { # puts stderr "Creating folder for user-installed externals: \n\t$externalsdir" # file mkdir $externalsdir # } #} # make sure the user folder for settings exists catch { if { ! [file exists $::env(HOME)/.pd-l2ork] } { puts stderr "Creating settings folder: $::env(HOME)/.pd-l2ork" file mkdir $::env(HOME)/.pd-l2ork } } # namespace for general-purpose functions proc pdtk_encode { listdata } { set outlist {} foreach this_path $listdata { if {0==[string match "" $this_path]} { lappend outlist [pdtk_encodedialog $this_path] } } return $outlist } # args is a list of length 1 or 2, # specifying optional additional x, y offsets for the window proc center_window { w args } { set offx 0 set offy 0 if { [llength $args] >= 2 } { set offx [lindex $args 0] set offy [lindex $args 1] } set x [expr [winfo screenwidth $w]/2 - [winfo reqwidth $w]/2 \ - [winfo vrootx [winfo parent $w]] + $offx] set y [expr [winfo screenheight $w]/2 - [winfo reqheight $w]/2 \ - [winfo vrooty [winfo parent $w]] + $offy] wm geom $w +$x+$y } # backported workaround for pdsend #proc pdsend { args } { # #puts stderr "===============pdsend pdtk $args" # pd [concat pd $args \;] #} proc ::pdsend {args} { #puts stderr "===============[join $args { }]" pd "[join $args { }] ;" } # start Pd-extended font hacks ----------------------------- # Pd-0.39.2-extended hacks to make font/box sizes the same across platform #puts stderr "tk scaling is [tk scaling]" tk scaling 1 # this font is for the Pd Window console text font create console_font -family $defaultFontFamily -size 9 -weight normal # this font is for text in Pd windows font create text_font -family $defaultFontFamily -size 9 -weight normal # for text in Properties Panels and other panes font create highlight_font -family $defaultFontFamily -size 9 -weight bold if { $pd_nt == 0 } { font create menufont -family $defaultFontFamily -size 9 -weight normal } # end Pd-extended font hacks ----------------------------- # K-12 version global variable (enabled through -k12, disabled by default) set k12_mode 0 set k12_saveas_on_new 0 # Only can be enabled at startup (cannot be toggled afterwards) proc pdtk_enable_k12_mode {extra_dir} { global k12_mode # global signal_cord_width global autotips # global signal_cord_highlight # global signal_cord global highlight_width set k12_mode 1 # set signal_cord_width 5 set ::pd_colors(signal_cord_width) 5 set autotips 1 # set signal_cord_highlight "#474" set ::pd_colors(signal_cord) "#2ca7d4" set ::pd_colors(signal_nlet) "#2ca7d4" # set signal_cord "#2ca7d4" set highlight_width 7 image create photo i.wii_connect -file $extra_dir/K12/icons/wii_connect_on.png image create photo i.wii_buttons -file $extra_dir/K12/icons/wii_buttons.png image create photo i.wii_speed_xry -file $extra_dir/K12/icons/wii_speed_xry.png image create photo i.wii_speed -file $extra_dir/K12/icons/wii_speed.png image create photo i.wii_hit -file $extra_dir/K12/icons/wii_hit.png image create photo i.wii_accelerometer -file $extra_dir/K12/icons/wii_accelerometer.png image create photo i.wii_nunchuk_buttons -file $extra_dir/K12/icons/wii_nunchuk_buttons.png image create photo i.wii_nunchuk_hit -file $extra_dir/K12/icons/wii_nunchuk_hit.png image create photo i.wii_nunchuk_accelerometer -file $extra_dir/K12/icons/wii_nunchuk_accelerometer.png image create photo i.wii_nunchuk_stick -file $extra_dir/K12/icons/wii_nunchuk_stick.png image create photo i.sarcduino -file $extra_dir/K12/icons/sarcduino_on.png image create photo i.sarcduino_digital -file $extra_dir/K12/icons/sarcduino_digital.png image create photo i.sarcduino_analog -file $extra_dir/K12/icons/sarcduino_analog.png image create photo i.sarcduino_hit -file $extra_dir/K12/icons/sarcduino_hit.png image create photo i.sarcduino_piezo -file $extra_dir/K12/icons/sarcduino_piezo.png #image create photo i.sarcduino_net -file $extra_dir/K12/icons/sarcduino_net.png image create photo i.raspberry_digital -file $extra_dir/K12/icons/raspberrypi_gpio_digital_on.png image create photo i.raspberry_analog_out -file $extra_dir/K12/icons/raspberrypi_gpio_analog_out_on.png image create photo i.raspberry_analog_in -file $extra_dir/K12/icons/raspberrypi_3008_analog_in_on.png image create photo i.math_number -file $extra_dir/K12/icons/math_number.png image create photo i.math_netsend -file $extra_dir/K12/icons/math_netsend.png image create photo i.math_netreceive -file $extra_dir/K12/icons/math_netreceive.png image create photo i.math_tag -file $extra_dir/K12/icons/math_tag.png image create photo i.math_routebytag -file $extra_dir/K12/icons/math_routebytag.png image create photo i.math_average -file $extra_dir/K12/icons/math_average.png image create photo i.math_random -file $extra_dir/K12/icons/math_random.png image create photo i.math_add -file $extra_dir/K12/icons/math_add.png image create photo i.math_subtract -file $extra_dir/K12/icons/math_subtract.png image create photo i.math_multiply -file $extra_dir/K12/icons/math_multiply.png image create photo i.math_divide -file $extra_dir/K12/icons/math_divide.png image create photo i.math_scale -file $extra_dir/K12/icons/math_scale.png image create photo i.logic_compare -file $extra_dir/K12/icons/logic_compare.png image create photo i.logic_mapper -file $extra_dir/K12/icons/logic_mapper.png image create photo i.logic_metronome -file $extra_dir/K12/icons/logic_metronome.png image create photo i.logic_counter -file $extra_dir/K12/icons/logic_counter.png image create photo i.logic_sequencer -file $extra_dir/K12/icons/logic_sequencer.png image create photo i.preset -file $extra_dir/K12/icons/preset.png image create photo i.comment -file $extra_dir/K12/icons/comment.png image create photo i.signal_microphone -file $extra_dir/K12/icons/signal_microphone.png image create photo i.signal_netsend -file $extra_dir/K12/icons/signal_netsend.png image create photo i.signal_netreceive -file $extra_dir/K12/icons/signal_netreceive.png image create photo i.signal_sampler -file $extra_dir/K12/icons/signal_sampler.png image create photo i.signal_player -file $extra_dir/K12/icons/signal_player.png image create photo i.signal_sine -file $extra_dir/K12/icons/signal_sine.png image create photo i.signal_saw -file $extra_dir/K12/icons/signal_saw.png image create photo i.signal_square -file $extra_dir/K12/icons/signal_square.png image create photo i.signal_triangle -file $extra_dir/K12/icons/signal_triangle.png image create photo i.signal_envelope -file $extra_dir/K12/icons/signal_envelope.png image create photo i.signal_noise -file $extra_dir/K12/icons/signal_noise.png image create photo i.signal_pink -file $extra_dir/K12/icons/signal_pink.png image create photo i.signal_add -file $extra_dir/K12/icons/signal_add.png image create photo i.signal_multiply -file $extra_dir/K12/icons/signal_multiply.png image create photo i.instr_short1 -file $extra_dir/K12/icons/instr_short1.png image create photo i.instr_short2 -file $extra_dir/K12/icons/instr_short2.png image create photo i.instr_sustained1 -file $extra_dir/K12/icons/instr_sustained1.png image create photo i.instr_sustained2 -file $extra_dir/K12/icons/instr_sustained2.png image create photo i.fx_filter -file $extra_dir/K12/icons/fx_filter.png image create photo i.fx_multitap -file $extra_dir/K12/icons/fx_multitap.png image create photo i.fx_reverb -file $extra_dir/K12/icons/fx_reverb.png image create photo i.output -file $extra_dir/K12/icons/audio_on.png image create photo i.edit -file $extra_dir/K12/icons/edit.png image create photo i.perform -file $extra_dir/K12/icons/perform.png image create photo i.data -file $extra_dir/K12/icons/data.png image create photo i.sound -file $extra_dir/K12/icons/sound.png image create photo i.data_on -file $extra_dir/K12/icons/data_on.png image create photo i.sound_on -file $extra_dir/K12/icons/sound_on.png .mbar.file insert 2 command -label {K12 Demos} -command {menu_k12_open_demos} #pack forget .controls.switches.audiobutton #pack forget .controls.inout #.mbar.audio delete 0 2 } # calculate offset on a movable canvas set tmp_xpix 0 set tmp_ypix 0 set popup_xpix 0 set popup_ypix 0 # monitor pointer position set pointer_x_local 0 set pointer_y_local 0 set pointer_x_virtual 0 set pointer_y_virtual 0 set pointer_x_global 0 set pointer_y_global 0 # text pasting global set copytexttocanvas 0 set global_clipboard 0 # used for comparison to avoid redundant copyfromexternalbuffer set last_clipboard 0 set global_selection 0 #TOOLTIPS PATCH #TODO: make a separate tcl file for tooltips and put #afterid in its scope variable afterid 0 variable duplicate_tags -1 variable current_window 0 variable nlet_color 0 variable autotips 0 #variable magicglass 0 variable tooltip_visible 0 # x:y location tooltip during dragging set tooltip [toplevel .tooltip -bd 1 -bg black] wm attributes $tooltip -topmost 1 wm overrideredirect $tooltip 1 pack [label $tooltip.label -bg lightyellow -fg black -text aaa -justify left] wm withdraw $tooltip # timeout for the tooltip proc pdtk_toggle_xy_tooltip {name num} { global tooltip if {$num == 0} { wm withdraw $tooltip } else { wm deiconify $tooltip } } proc pdtk_update_xy_tooltip {name x y} { global tooltip global pointer_x_virtual pointer_y_virtual pointer_x_global pointer_y_global wm geometry $tooltip +[expr $pointer_x_global+15]+[expr $pointer_y_global-2] $tooltip.label configure -text [concat x: $x\ny: $y] set pointer_x_virtual $x set pointer_y_virtual $y } # begin hack to hide hidden files/folder in tk browser on unix ---------- if {$pd_nt == 0} { # load the dialog once, otherwise setting the vars will not work catch {tk_getOpenFile -with-invalid-argument} # change the environment variables namespace eval ::tk::dialog::file { variable showHiddenBtn 1 variable showHiddenVar 0 } } # end hidden files/folder hack ------------------ # Tearoff is set to false by default: set pd_tearoff 0 # Put menu tearoff is set to true by default: set put_tearoff 1 # turn off tearoff menus globally #option add *tearOff 0 # jsarlo set pd_array_listview_pagesize 1000 set pd_array_listview_id(0) 0 set pd_array_listview_entry(0) 0 set pd_array_listview_page(0) 0 # end jsarlo if {$pd_nt == 1} { global pd_guidir set pd_gui2 [string range $argv0 0 [expr [string last \\ $argv0 ] - 1]] regsub -all \\\\ $pd_gui2 / pd_gui3 set pd_guidir [file normalize $pd_gui3/..] load $pd_guidir/bin/pdtcl.dll } if {$pd_nt == 2} { # turn on James Tittle II's fast drawing set tk::mac::useCGDrawing 1 # anti-alias all lines that need it set tk::mac::CGAntialiasLimit 0 global pd_guidir set pd_gui2 [string range $argv0 0 [expr [string last / $argv0 ] - 1]] set pd_guidir [file normalize $pd_gui2/..] load $pd_guidir/bin/libPdTcl.dylib global pd_macready set pd_macready 0 global pd_macdropped set pd_macdropped "" # tk::mac::OpenDocument is called with the filenames put into the # var args whenever docs are either dropped on the Pd.app icon or # opened from the Finder. # It uses menu_doc_open so it can handles numerous file types. proc tk::mac::OpenDocument {args} { global pd_macready pd_macdropped foreach file $args { if {$pd_macready != 0} { pd [concat pd open [pdtk_enquote [file tail $file]] \ [pdtk_enquote [file dirname $file]] \;] menu_doc_open [file dirname $file] [file tail $file] } else { set pd_macdropped $args } } } # intercept kAEQuitApplication from Cmd-Q proc ::tk::mac::Quit {} { puts stderr "::tk::mac::Quit" menu_quit } } # hack so you can easily test-run this script in linux... define pd_guidir # (which is normally defined at startup in pd under linux...) if {$pd_nt == 0} { if {! [info exists pd_guidir]} { global pd_guidir puts stderr {setting pd_guidir to '.'} set pd_guidir . } } #set pd_deffont {courier 10} set pd_deffont console_font set help_top_directory $pd_guidir/doc #==============================================================================# # pd-gui-rewrite-0.43 help browser backport switch -- $pd_nt { 0 { set ::windowingsystem "x11" } 1 { set ::windowingsystem "win32" } 2 { set ::windowingsystem "aqua" } } # Pd's packages are stored in the same directory as the main script (pd-gui.tcl) set auto_path [linsert $auto_path 0 [file dirname [info script]]] # the pd-gui-rewrite-0.43 help browser is backported to Pd-extended 0.42 package require helpbrowser package require msgcat package require tkpng package require tkdnd package require pd_guiprefs package require pd_menus namespace import ::pd_guiprefs::init namespace import ::pd_guiprefs::update_recentfiles namespace import ::pd_guiprefs::write_recentfiles set total_recentfiles 5 ::pd_guiprefs::init # Prefences Dialog # dialog_prefs.tcl must come first because dialog_gui.tcl depends on it # This is an ugly hack-- it should just be loaded as tcl packages like # in 0.43... source [file join [file dirname [info script]] dialog_prefs.tcl] source [file join [file dirname [info script]] dialog_gui.tcl] source [file join [file dirname [info script]] dialog_midi.tcl] source [file join [file dirname [info script]] dialog_audio.tcl] # Add a trace for the color array. This way any gui-plugin can make # color changes simply by changing one of the elements of the pd_colors # array, and all the preference dialog stuff and open patches will # magically update trace add variable pd_colors write ::dialog_prefs::set_color # ... and a trace for the ::gui_preset variable. There's probably # a way to do this inside the dropdown code, which would be better... trace add variable gui_preset write "::dialog_gui::set_gui_preset" # Now that we've got a trace for the colors, we can set a # color scheme if there isn't one in the preferences # (defined in dialog_gui.tcl) if {$::gui_preset eq ""} { set ::gui_preset L2Ork } else { ::dialog_gui::set_gui_preset } # todo: find a home for these: set ::pd_colors(signal_cord_width) 3 set ::pd_colors(control_cord_width) 1 # color scheme # set canvas_fill "white" # set text_color "#000" # set select_color "#e87216" # set dash_outline "#f00" # set dash_fill "#f7f7f7" # set box_outline "#ccc" # set graph_outline "#777" # set atom_box_fill "#eee" # set msg_box_fill "#f8f8f6" # set obj_box_fill "#f6f8f8" # Doesn't look like signal_cord_highlight is used # set signal_cord_highlight "#58a" # set signal_cord "#808095" # set signal_nlet $signal_cord # Todo: make sure these work in k12 mode # set signal_cord_width 3 # set msg_cord_highlight "#474" # set msg_cord "#565" # set msg_nlet "white" # set mixed_nlet "#88aaff" # set msg_cord_width 1 #nlet highlighting stuff set select_nlet_color $pd_colors(selection) set highlight_width 5 # official GNU gettext msgcat shortcut proc _ {s} {return [::msgcat::mc $s]} namespace eval ::pdwindow:: { proc verbose {level postme} {puts stderr "$level: $postme"} proc error {postme} {puts stderr $postme; pdtk_post $postme} proc warn {postme} {::pdwindow::error $postme} } set ::dialog_menubar .mbar set ::modifier $ctrl_key set ::sys_libdir $pd_guidir switch $pd_nt { 0 {set ::pd_path [list ~/pd-l2ork-externals /usr/local/lib/pd-l2ork-externals]} 1 {set ::pd_path [list [file normalize $::env(AppData)/Pd] \ [file normalize $::env(CommonProgramFiles)/Pd]]} 2 {set ::pd_path [list ~/Library/Pd /Library/Pd]} } #==============================================================================# ################## set up main window ######################### # the menus are instantiated here for the main window # for the patch windows, they are created by pdtk_canvas_new #ttk error button customizations ttk::style configure IOErrorOn.TButton -background "#dd2222" ttk::style map IOErrorOn.TButton -background [list active "#ff2222"] \ -foreground [list disabled black] ttk::style configure IOErrorOff.TButton -background lightgrey ttk::style map IOErrorOff.TButton -background [list active $colors(-frame)] match_linux_wm [list menu .mbar -relief flat] match_linux_wm [list menu .mbar.file -tearoff $pd_tearoff -postcommand [concat pdtk_fixfilemenu .mbar.file]] .mbar add cascade -label File -menu .mbar.file match_linux_wm [list menu .mbar.edit -tearoff $pd_tearoff] .mbar add cascade -label Edit -menu .mbar.edit match_linux_wm [list menu .mbar.put -tearoff $pd_tearoff] .mbar add cascade -label Put -menu .mbar.put #match_linux_wm [list menu .mbar.find -tearoff $put_tearoff] #.mbar add cascade -label Find -menu .mbar.find match_linux_wm [list menu .mbar.windows -postcommand [concat pdtk_fixwindowmenu] \ -tearoff $pd_tearoff] match_linux_wm [list menu .mbar.audio -tearoff $pd_tearoff] if {$pd_nt != 2} { .mbar add cascade -label "Windows" -menu .mbar.windows .mbar add cascade -label "Media" -menu .mbar.audio match_linux_wm [list menu .mbar.help -tearoff $pd_tearoff] .mbar add cascade -label "Help" -menu .mbar.help } else { menu .mbar.apple -tearoff 0 .mbar add cascade -label "Apple" -menu .mbar.apple # arrange menus according to Apple HIG .mbar add cascade -label "Media" -menu .mbar.audio .mbar add cascade -label "Window" -menu .mbar.windows match_linux_wm [list menu .mbar.help -tearoff $pd_tearoff] .mbar add cascade -label "Help" -menu .mbar.help } # fix menu font size on Windows with tk scaling = 1 if {$pd_nt == 1} { .mbar.file configure -font menuFont .mbar.edit configure -font menuFont .mbar.find configure -font menuFont .mbar.windows configure -font menuFont .mbar.audio configure -font menuFont .mbar.help configure -font menuFont } proc showhide_printouttext {state} { if {$state} { #pack .printout -side bottom -fill both -expand 1 #pack .controls.clr_console -pady 30 wm deiconify .printout #wm resizable . 1 1 #wm minsize . 460 194 } else { #pack forget .printout wm withdraw .printout #pack forget .controls.clr_console #wm minsize . 0 0 #wm geometry . 355x75 #wm resizable . 0 0 } } set ctrls_audio_on 0 set ctrls_meter_on 0 set ctrls_inlevel 0 set ctrls_outlevel 0 set show_text_window 0 match_linux_wm [list frame .controls] #if { [info tclversion] >= 8.5 && $pd_nt == 0 } { # ttk::separator .eyecandy # pack .eyecandy .controls -fill x -expand 0 #} else { pack .controls -fill x -expand 1 #} match_linux_wm [list frame .controls.switches] match_linux_wm [list checkbutton .controls.switches.audiobutton -text {compute audio } \ -variable ctrls_audio_on \ -command {pd [concat pd dsp $ctrls_audio_on \;]}] match_linux_wm [list checkbutton .controls.switches.meterbutton -text {peak meters } \ -variable ctrls_meter_on \ -command {pd [concat pd meters $ctrls_meter_on \;]}] match_linux_wm [list checkbutton .controls.switches.console -text "console" \ -variable show_console \ -command {showhide_printouttext $show_console}] pack .controls.switches.audiobutton .controls.switches.meterbutton \ .controls.switches.console -side top -anchor w match_linux_wm [list frame .controls.inout] match_linux_wm [list frame .controls.inout.in] match_linux_wm [list label .controls.inout.in.label -text IN] entry .controls.inout.in.level -textvariable ctrls_inlevel -width 3 \ -highlightthickness 0 -takefocus 0 -state readonly -readonlybackground white if { [info tclversion] >= 8.5 && $pd_nt == 0 } { match_linux_wm [list button .controls.inout.in.clip \ -text {CLIP} -state disabled -style IOErrorOff.TButton -width 4] } else { button .controls.inout.in.clip -text {CLIP} -state disabled } match_linux_wm [list frame .controls.inout.in.spacer] pack .controls.inout.in.label .controls.inout.in.level \ .controls.inout.in.clip .controls.inout.in.spacer -side top -pady 1 match_linux_wm [list frame .controls.inout.out] match_linux_wm [list label .controls.inout.out.label -text OUT] entry .controls.inout.out.level -textvariable ctrls_outlevel -width 3 \ -highlightthickness 0 -takefocus 0 -state readonly -readonlybackground white if { [info tclversion] >= 8.5 && $pd_nt == 0 } { match_linux_wm [list button .controls.inout.out.clip \ -text {CLIP} -state disabled -style IOErrorOff.TButton -width 4] } else { button .controls.inout.out.clip -text {CLIP} -state disabled } match_linux_wm [list frame .controls.inout.out.spacer] pack .controls.inout.out.label .controls.inout.out.level \ .controls.inout.out.clip .controls.inout.out.spacer -side top -pady 1 if { [info tclversion] >= 8.5 && $pd_nt == 0 } { match_linux_wm [list ttk::button .controls.dio -text "\nIO Errors\n" \ -command { if {![info exists show_console] || $show_console == 0} \ { menu_toggle_console; }; \ pd [concat pd audiostatus \;]} \ -width 8 -style IOErrorOff.TButton] } else { button .controls.dio -text "DIO\nerrors" \ -command { if {![info exists show_console] || $show_console == 0} \ { .controls.switches.console invoke; }; \ pd [concat pd audiostatus \;]} } #match_linux_wm [list button .controls.clr_console -text "Clear Console" \ # -command [concat menu_clear_console]] pack .controls.inout.in .controls.inout.out -side left -padx 6 pack .controls.inout -side left -padx 14 pack .controls.switches -side right pack .controls.dio -side right -padx 20 #if {[info exists show_console] && $show_console == 1} { # pack .controls.clr_console -pady 30 #} toplevel .printout -class [winfo class .] wm title .printout "Console" # initial location of the console window (+x+y) wm geometry .printout +10+170 # wm minsize .printout 460 194 wm protocol .printout WM_DELETE_WINDOW { .controls.switches.console invoke } match_linux_wm [list frame .printout.frame] text .printout.frame.text -relief sunken -bd 1 -font console_font \ -yscrollcommand ".printout.frame.scroll set" -width 70 -height 24 \ -highlightthickness 0 -takefocus 0 -fg $pd_colors(text_in_console) \ -state disabled -bg $pd_colors(canvas_color) #.printout.frame.text tag configure sel -background $linux_wm_hlcolor # .printout.frame.text insert end "\n\n\n\n\n\n\n\n\n\n" match_linux_wm [list scrollbar .printout.frame.scroll -command ".printout.frame.text yview"] match_linux_wm [list frame .printout.bar] match_linux_wm [list button .printout.bar.clear -text "CLEAR" \ -width 7 -command [concat menu_clear_console]] match_linux_wm [list entry .printout.bar.entry \ -textvariable send_textvariable] bind .printout.bar.entry { pdtk_post "\nmessage-to-pd: $send_textvariable" pd [concat $send_textvariable \;] } #match_linux_wm [list button .printout.bar.x -text "x" \ # -width 2 -command [concat .printout.bar.entry delete 0 end]] match_linux_wm [list label .printout.bar.label -text "Send Message to Pd:"] pack .printout.frame.scroll -side right -fill y pack .printout.frame.text -side left -fill both -expand 1 pack .printout.bar -side bottom -fill x -expand 0 pack .printout.frame -fill both -expand 1 pack .printout.bar.clear -side left -padx 3 -pady 3 #pack .printout.bar.x -side right -padx 3 -pady 3 pack .printout.bar.entry -side right -fill both -expand 1 -padx 3 -pady 3 pack .printout.bar.label -side right -padx 3 -pady 3 # the console is open by default #.controls.switches.console select # in the case console should be turned off by default wm withdraw .printout #wm geometry .printout 1x1+0+0 #wm overrideredirect .printout 1 #wm transient .printout bind .printout.frame.text