--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/reference/ocr-new/comp_menu.tcl Thu May 18 23:12:51 2006 +0200
@@ -0,0 +1,133 @@
+set Comp_menu_up 0
+#current component ascii value
+set curCompId " "
+
+
+set comp_menux 0
+set comp_menuy 0
+
+proc init_component_menu { w x y } {
+ global BACKGROUND FOREGROUND FONT Comp_menu_up global comp_menux \
+ comp_menuy validComponent
+
+
+ if { $Comp_menu_up == 1 } {
+ focus .comp_menu.menu
+ return 1
+ }
+
+ set Comp_menu_up 1
+ toplevel .comp_menu
+ set comp_menux [expr int([expr $x+50])+ 200]
+ set comp_menuy [expr int([expr $y])+ 100]
+
+ wm geometry .comp_menu +$comp_menux+$comp_menuy
+ wm title .comp_menu "Component..."
+ frame .comp_menu.menu -background $BACKGROUND
+
+ button .comp_menu.menu.join -text "Join" -command component_join \
+ -bg $BACKGROUND -fg $FOREGROUND -font $FONT
+ button .comp_menu.menu.horiz -text "Horizontal Split" \
+ -command component_horizontal_split \
+ -bg $BACKGROUND -fg $FOREGROUND -font $FONT
+
+ button .comp_menu.menu.vert -text "Vertical Split" -command \
+ component_vertical_split \
+ -bg $BACKGROUND -fg $FOREGROUND -font $FONT
+ button .comp_menu.menu.learn -text "Learn" -command component_learn \
+ -bg $BACKGROUND -fg $FOREGROUND -font $FONT
+ button .comp_menu.menu.close -text "Cancel" -command {
+ grab release .comp_menu
+ destroy .comp_menu; set Comp_menu_up 0 ; } \
+ -bg $BACKGROUND -fg $FOREGROUND -font $FONT
+
+ pack .comp_menu.menu .comp_menu.menu.join .comp_menu.menu.horiz \
+ .comp_menu.menu.vert .comp_menu.menu.learn \
+ .comp_menu.menu.close -fill x
+ focus .comp_menu.menu
+ #grab .comp_menu
+
+}
+
+
+proc component_join { } {
+global Comp_menu_up
+puts stdout "component_join"
+grab release .comp_menu.menu
+#temporarily bind <Double-1> to join components
+bind .main_window.display.work_space <Double-1> {
+ component_select %W %x %y
+ # joins this selection with next selected component
+ JOIN_COMP
+
+ #put <Double -1> back to the old setting
+ bind .main_window.display.work_space <Double-1> {
+ component_select %W [%W canvasx %x] [%W canvasy %y]
+ init_component_menu %W [%W canvasx %x] [%W canvasy %y]
+ }
+}
+destroy .comp_menu
+set Comp_menu_up 0
+}
+
+proc component_horizontal_split { } {
+global Comp_menu_up
+puts stdout "component_horizontal_split"
+grab release .comp_menu.menu
+SPLIT_COMP_HORIZ
+
+destroy .comp_menu
+set Comp_menu_up 0
+
+}
+
+
+proc component_learn { } {
+ global Comp_menu_up curCompId comp_menux comp_menuy
+puts stdout "component_learn"
+#pops up a little window to put in id for component
+ global save_ascii_geometry BACKGROUND FOREGROUND FONT SMALLFONT write_image
+
+
+ toplevel .learn_comp -background $BACKGROUND
+ wm geometry .learn_comp +[expr $comp_menux +20]+[expr $comp_menuy +20]
+ wm title .learn_comp "Learn Component Id"
+ grab set .learn_comp
+
+
+
+ label .learn_comp.image -bitmap @$write_image -foreground $FOREGROUND -background $BACKGROUND
+ frame .learn_comp.s -background $BACKGROUND
+ label .learn_comp.s.txt -text "Learn Component as:" -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT
+entry .learn_comp.s.ent -relief sunken -bd 2 -textvariable curCompId -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT
+ pack .learn_comp.s.txt .learn_comp.s.ent -side top
+ frame .learn_comp.buttons
+button .learn_comp.buttons.ok -text OK -command { LEARN_COMP $curCompId ; \
+ grab release .learn_comp; destroy .learn_comp} -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+button .learn_comp.buttons.cancel -text Cancel -command {destroy .learn_comp } -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
+ pack .learn_comp.buttons.ok .learn_comp.buttons.cancel -side left -expand 1 -fill x
+ pack .learn_comp.image .learn_comp.s .learn_comp.buttons -side top
+ .learn_comp.s.ent icursor 0
+ .learn_comp.s.ent select range 0 10
+ focus .learn_comp.s.ent
+
+ bind .learn_comp.s.ent <Return> {
+ LEARN_COMP $curCompId
+ grab release .learn_comp
+ destroy .learn_comp
+ }
+
+destroy .comp_menu
+set Comp_menu_up 0
+}
+
+
+
+
+
+
+
+
+
+
+