-# $Id: initgui.tcl,v 1.37 2007/07/19 02:33:14 marko Exp $
+# $Id: initgui.tcl,v 1.38 2007/07/19 08:27:45 marko Exp $
#
# Copyright 2004, 2005 University of Zagreb, Croatia. All rights reserved.
#
# NAME
# initgui.tcl
# FUNCTION
-# Initialize GUI. Not included in imunes when opearting in batch mode.
+# Initialize GUI. Not included when operating in batch mode.
#****
# link currently created, this value is set to an empty string.
# * selectbox -- the value of the box representing all the selected items
# * selected -- containes the list of node_id's of all selected nodes.
-# * newCanves --
+# * newCanvas --
#
# * animatephase -- starting dashoffset. With this value the effect of
# rotating line around selected itme is achived.
#****
-
set newlink ""
set selectbox ""
set selected ""
set clock_seconds 0
set oper_mode edit
set grid 24
+set showGrid 1
set zoom 1.0
set curcanvas [lindex $canvas_list 0]
set autorearrange_enabled 0
+# resize Oval/Rectangle, "false" or direction: north/west/east/...
+set resizemode false
+
#
# Initialize a few variables to default values
#
set defSerBandwidth 2048000
set defSerDelay 2500
+set newoval ""
+set defOvalColor #CFCFFF
+set defOvalLabelFont "Arial 12"
+set newrect ""
+set defRectColor #C0C0FF
+set defRectLabelFont "Arial 12"
+set defTextFont "Arial 12"
+set defTextFontFamily "Arial"
+set defTextFontSize 12
+set defTextColor #000000
+
set showIfNames 0
set showIfIPaddrs 0
set showIfIPv6addrs 0
set showLinkLabels 0
set showIPsecConfig 1
+set showBkgImage 0
+set showAnnotations 1
+
set supp_router_models "xorp quagga static"
set def_router_model quagga
#
wm minsize . 640 400
-wm geometry . 1016x716
+wm geometry . 1016x716-30+30
wm title . IMUNES
menu .menubar
$w.e1 insert 0 "lpr"
pack $w.e1 -side top -pady 5 -padx 10 -fill x
}
+
.menubar.file add separator
.menubar.file add command -label Quit -underline 0 -command { exit }
set changed 1
updateUndoLog
}
-.menubar.canvas add command -label "Rename" -command renameCanvasPopup
+.menubar.canvas add command -label "Rename" -command { renameCanvasPopup 0 0 }
.menubar.canvas add command -label "Delete" -command {
if { [llength $canvas_list] == 1 } {
return
}
.menubar.canvas add separator
.menubar.canvas add command -label "Resize" -command resizeCanvasPopup
+
+# There are unresolved scale issues for Background images
+# .menubar.canvas add command -label "Background Image" -underline 0 \
+# -command { selectBkgImage }
+
.menubar.canvas add separator
.menubar.canvas add command -label "Previous" -accelerator "PgUp" \
-command { switchCanvas prev }
}
}
}
+# .menubar.view add checkbutton -label "Show Background Image" \
+# -underline 5 -variable showBkgImage \
+# -command { redrawAll }
+.menubar.view add checkbutton -label "Show Annotations" \
+ -underline 5 -variable showAnnotations \
+ -command { redrawAll }
+.menubar.view add checkbutton -label "Show Grid" \
+ -underline 5 -variable showGrid \
+ -command { redrawAll }
+
.menubar.view add command -label "Show All" \
-underline 5 -command {
set showIfNames 1
}
}
pack .left.$b -side top
+ # hover status line
+ switch -exact -- $b {
+ select { set msg "Select tool" }
+ link { set msg "Create link" }
+ hub { set msg "Add new Hub" }
+ lanswitch { set msg "Add new LAN switch" }
+ router { set msg "Add new Router" }
+ host { set msg "Add new Host" }
+ pc { set msg "Add new PC" }
+ rj45 { set msg "Add new external interface" }
+ default { set msg "" }
+ }
+ bind .left.$b <Any-Enter> ".bottom.textbox config -text {$msg}"
+ bind .left.$b <Any-Leave> ".bottom.textbox config -text {}"
}
+
+foreach b {rectangle oval text} {
+ set image [image create photo -file $ROOTDIR/$LIBDIR/icons/tiny/$b.gif]
+ radiobutton .left.$b -indicatoron 0 \
+ -variable activetool -value $b -selectcolor [.left cget -bg] \
+ -width 32 -height 32 -activebackground gray -image $image \
+ -command {
+ global activetool
+ }
+ pack .left.$b -side bottom
+ # hover status line
+ switch -exact -- $b {
+ rectangle { set msg "Rectangle" }
+ oval { set msg "Oval" }
+ text { set msg "Text" }
+ default { set msg "" }
+ }
+ bind .left.$b <Any-Enter> ".bottom.textbox config -text {$msg}"
+ bind .left.$b <Any-Leave> ".bottom.textbox config -text {}"
+}
+
+
foreach b {router host pc hub lanswitch frswitch rj45} {
set $b [image create photo -file $ROOTDIR/$LIBDIR/icons/normal/$b.gif]
}
set pseudo [image create photo]
-set text [image create photo]
-
. configure -background #808080
frame .grid
-background gray \
-xscrollcommand ".hframe.scroll set" \
-yscrollcommand ".vframe.scroll set"]
+
canvas .hframe.t -width 300 -height 18 -bd 0 -highlightthickness 0 \
-background gray \
-xscrollcommand ".hframe.ts set"
set curcanvas $canvas
switchCanvas none
} else {
- renameCanvasPopup
+ renameCanvasPopup %X %Y
}
}
}
pack .bottom -side bottom -fill x
label .bottom.textbox -relief sunken -bd 1 -anchor w -width 999
label .bottom.zoom -relief sunken -bd 1 -anchor w -width 10
+bind .bottom.zoom <Double-1> "setZoom %X %Y"
+bind .bottom.zoom <3> "selectZoom %X %Y"
label .bottom.cpu_load -relief sunken -bd 1 -anchor w -width 9
label .bottom.mbuf -relief sunken -bd 1 -anchor w -width 15
label .bottom.oper_mode -relief sunken -bd 1 -anchor w -width 9
$c bind linklabel <Any-Leave> "anyLeave $c"
$c bind node <Double-1> "popupConfigDialog $c"
$c bind nodelabel <Double-1> "popupConfigDialog $c"
+$c bind grid <Double-1> "double1onGrid $c %x %y"
$c bind link <Double-1> "popupConfigDialog $c"
$c bind linklabel <Double-1> "popupConfigDialog $c"
+$c bind oval <Double-1> "popupConfigDialog $c"
+$c bind rectangle <Double-1> "popupConfigDialog $c"
+$c bind text <Double-1> "popupConfigDialog $c"
+$c bind text <KeyPress> "textInsert $c %A"
+$c bind text <Return> "textInsert $c \\n"
$c bind node <3> "button3node $c %x %y"
$c bind nodelabel <3> "button3node $c %x %y"
$c bind link <3> "button3link $c %x %y"
$c bind linklabel <3> "button3link $c %x %y"
+
+$c bind oval <3> "button3annotation oval $c %x %y"
+$c bind rectangle <3> "button3annotation rectangle $c %x %y"
+$c bind text <3> "button3annotation text $c %x %y"
+
+$c bind selectmark <Any-Enter> "selectmarkEnter $c %x %y"
+$c bind selectmark <Any-Leave> "selectmarkLeave $c %x %y"
+
bind $c <1> "button1 $c %x %y none"
bind $c <Control-Button-1> "button1 $c %x %y ctrl"
bind $c <B1-Motion> "button1-motion $c %x %y"
bind . <Down> ".c yview scroll 1 units"
bind . <Up> ".c yview scroll -1 units"
+# Escape to Select mode
+bind . <Key-Escape> "set activetool select"
+
#
# Popup-menu hierarchy
#