From: marko Date: Sun, 13 Nov 2005 12:00:23 +0000 (+0000) Subject: Implement canvas switching by clicking on a canvas "tab" at the bottom X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=04c6978bb7919e04a4fd7f57240f18c6cad35c34;p=imunes.git Implement canvas switching by clicking on a canvas "tab" at the bottom of the main window. Double-click on a canvas "tab" opens up a canvas-rename dialog box. Remove canvas switching / selection entries from the top-level canvas menu. Add several new key bindings: Home/End switches to first/last canvas, cursor keys scroll/pan the current viewport on the current canvas. Bug found by: Submitted by: Requested by: Reviewed by: Approved by: Obtained from: --- diff --git a/editor.tcl b/editor.tcl index 741dfd7..a81a02c 100755 --- a/editor.tcl +++ b/editor.tcl @@ -123,7 +123,6 @@ proc undo {} { incr undolevel -1 loadCfg $undolog($undolevel) switchCanvas none - redrawAll } return } @@ -136,7 +135,6 @@ proc redo {} { incr undolevel loadCfg $undolog($undolevel) switchCanvas none - redrawAll } return } @@ -156,7 +154,6 @@ proc redrawAll {} { drawNode $node } } - foreach link $link_list { set nodes [linkPeers $link] if { [getNodeCanvas [lindex $nodes 0]] != $curcanvas || @@ -167,8 +164,6 @@ proc redrawAll {} { redrawLink $link updateLinkLabel $link } - - refreshCanvasMenu return } @@ -2024,6 +2019,12 @@ proc switchCanvas { direction } { set curcanvas [lindex $canvas_list $i] } } + first { + set curcanvas [lindex $canvas_list 0] + } + last { + set curcanvas [lindex $canvas_list end] + } } .hframe.t delete all @@ -2051,6 +2052,32 @@ proc switchCanvas { direction } { } +proc renameCanvasPopup {} { + global curcanvas + + set w .entry1 + catch {destroy $w} + toplevel $w -takefocus 1 + update + grab $w + wm title $w "Canvas rename" + wm iconname $w "Canvas rename" + + label $w.msg -wraplength 5i -justify left -text "Canvas name:" + pack $w.msg -side top + + frame $w.buttons + pack $w.buttons -side bottom -fill x -pady 2m + button $w.buttons.print -text "Apply" -command "renameCanvasApply $w" + button $w.buttons.cancel -text "Cancel" -command "destroy $w" + pack $w.buttons.print $w.buttons.cancel -side left -expand 1 + + entry $w.e1 -bg white + $w.e1 insert 0 [getCanvasName $curcanvas] + pack $w.e1 -side top -pady 5 -padx 10 -fill x +} + + proc renameCanvasApply { w } { global curcanvas changed @@ -2060,75 +2087,11 @@ proc renameCanvasApply { w } { set changed 1 } setCanvasName $curcanvas $newname - refreshCanvasMenu switchCanvas none updateUndoLog } -proc refreshCanvasMenu {} { - global canvas_list curcanvas - - .menubar.canvas delete 0 end - .menubar.canvas add command -label "New" -command { - newCanvas "" - set curcanvas [lindex $canvas_list 0] - switchCanvas prev - set changed 1 - updateUndoLog - refreshCanvasMenu - } - .menubar.canvas add command -label "Rename" -command { - set w .entry1 - catch {destroy $w} - toplevel $w -takefocus 1 - grab $w - wm title $w "Canvas rename" - wm iconname $w "Canvas rename" - - label $w.msg -wraplength 5i -justify left -text "Canvas name:" - pack $w.msg -side top - - frame $w.buttons - pack $w.buttons -side bottom -fill x -pady 2m - button $w.buttons.print -text "Apply" -command "renameCanvasApply $w" - button $w.buttons.cancel -text "Cancel" -command "destroy $w" - pack $w.buttons.print $w.buttons.cancel -side left -expand 1 - - entry $w.e1 -bg white - $w.e1 insert 0 [getCanvasName $curcanvas] - pack $w.e1 -side top -pady 5 -padx 10 -fill x - } - .menubar.canvas add command -label "Delete" -command { - if { [llength $canvas_list] == 1 } { - return - } - foreach obj [.c find withtag node] { - selectNode .c $obj - } - deleteSelection - set i [lsearch $canvas_list $curcanvas] - set canvas_list [lreplace $canvas_list $i $i] - switchCanvas none - set changed 1 - updateUndoLog - refreshCanvasMenu - } - .menubar.canvas add separator - .menubar.canvas add command -label "Previous" -accelerator "PgUp" \ - -command { switchCanvas prev } - .menubar.canvas add command -label "Next" -accelerator "PgDown" \ - -command { switchCanvas next } - .menubar.canvas add separator - foreach canvas $canvas_list { - .menubar.canvas add radiobutton -label [getCanvasName $canvas] \ - -command "switchCanvas none" -indicatoron true \ - -value $canvas -variable curcanvas - } - return -} - - proc animate {} { global animatephase oper_mode diff --git a/filemgmt.tcl b/filemgmt.tcl index b277ef5..ccd8c26 100755 --- a/filemgmt.tcl +++ b/filemgmt.tcl @@ -86,6 +86,7 @@ proc newFile {} { } loadCfg "" set curcanvas [lindex $canvas_list 0] + switchCanvas none redrawAll set currentFile "" wm title . "IMUNES" @@ -107,6 +108,7 @@ proc openFile {} { close $fileId loadCfg $cfg set curcanvas [lindex $canvas_list 0] + switchCanvas none redrawAll set undolevel 0 set redolevel 0 diff --git a/initgui.tcl b/initgui.tcl index 87c66af..b52c8c4 100755 --- a/initgui.tcl +++ b/initgui.tcl @@ -170,8 +170,40 @@ bind . { # Canvas # menu .menubar.canvas -tearoff 0 +.menubar.canvas add command -label "New" -command { + newCanvas "" + switchCanvas last + set changed 1 + updateUndoLog +} +.menubar.canvas add command -label "Rename" -command renameCanvasPopup +.menubar.canvas add command -label "Delete" -command { + if { [llength $canvas_list] == 1 } { + return + } + foreach obj [.c find withtag node] { + selectNode .c $obj + } + deleteSelection + set i [lsearch $canvas_list $curcanvas] + set canvas_list [lreplace $canvas_list $i $i] + switchCanvas prev + set changed 1 + updateUndoLog +} +.menubar.canvas add separator +.menubar.canvas add command -label "Previous" -accelerator "PgUp" \ + -command { switchCanvas prev } bind . { switchCanvas prev } +.menubar.canvas add command -label "Next" -accelerator "PgDown" \ + -command { switchCanvas next } bind . { switchCanvas next } +.menubar.canvas add command -label "First" -accelerator "Home" \ + -command { switchCanvas first } +bind . { switchCanvas first } +.menubar.canvas add command -label "Last" -accelerator "End" \ + -command { switchCanvas last } +bind . { switchCanvas last } # @@ -292,6 +324,19 @@ set c [canvas .c -bd 0 -relief sunken -highlightthickness 0\ -yscrollcommand ".vframe.scroll set"] canvas .hframe.t -width 300 -height 18 -bd 0 -highlightthickness 0 \ -background gray +bind .hframe.t <1> { + set canvas [lindex [.hframe.t gettags current] 1] + if { $canvas != "" && $canvas != $curcanvas } { + set curcanvas $canvas + switchCanvas none + } +} +bind .hframe.t { + set canvas [lindex [.hframe.t gettags current] 1] + if { $canvas != "" } { + renameCanvasPopup + } +} scrollbar .hframe.scroll -orient horiz -command "$c xview" \ -bd 1 -width 14 scrollbar .vframe.scroll -command "$c yview" \ @@ -352,7 +397,10 @@ bind $c <2> "$c scan mark %x %y" bind $c "$c scan dragto %x %y 1" bind $c <4> "$c yview scroll 1 units" bind $c <5> "$c yview scroll -1 units" - +bind . ".c xview scroll 1 units" +bind . ".c xview scroll -1 units" +bind . ".c yview scroll 1 units" +bind . ".c yview scroll -1 units" # # Popup-menu hierarchy @@ -376,8 +424,7 @@ bind . { # # Done with initialization, draw an empty canvas # -refreshCanvasMenu -redrawAll +switchCanvas first # # Fire up the animation loop - used basically for selectbox