reference/ocr-new/comp_menu.tcl
changeset 0 6b8091ca909a
equal deleted inserted replaced
-1:000000000000 0:6b8091ca909a
       
     1 set Comp_menu_up 0
       
     2 #current component ascii value
       
     3 set curCompId " "
       
     4 
       
     5 
       
     6 set comp_menux 0
       
     7 set comp_menuy 0
       
     8 
       
     9 proc init_component_menu { w x y } {
       
    10     global BACKGROUND  FOREGROUND FONT Comp_menu_up  global comp_menux \
       
    11 	    comp_menuy validComponent
       
    12  
       
    13    
       
    14     if { $Comp_menu_up == 1 } {
       
    15 	focus .comp_menu.menu
       
    16 	return 1
       
    17     }
       
    18 
       
    19     set  Comp_menu_up 1
       
    20     toplevel .comp_menu
       
    21     set comp_menux  [expr int([expr $x+50])+ 200]
       
    22     set comp_menuy  [expr int([expr $y])+ 100]
       
    23 
       
    24     wm geometry .comp_menu +$comp_menux+$comp_menuy 
       
    25     wm title .comp_menu "Component..."
       
    26     frame  .comp_menu.menu -background $BACKGROUND
       
    27 
       
    28     button .comp_menu.menu.join -text "Join" -command component_join \
       
    29 	    -bg $BACKGROUND -fg $FOREGROUND -font $FONT
       
    30     button .comp_menu.menu.horiz  -text "Horizontal Split" \
       
    31 	    -command component_horizontal_split \
       
    32 	    -bg $BACKGROUND -fg $FOREGROUND -font $FONT 
       
    33 
       
    34     button .comp_menu.menu.vert -text "Vertical Split" -command \
       
    35 	    component_vertical_split \
       
    36 	    -bg $BACKGROUND -fg $FOREGROUND -font $FONT
       
    37     button .comp_menu.menu.learn -text "Learn" -command component_learn \
       
    38 	    -bg $BACKGROUND -fg $FOREGROUND -font $FONT
       
    39     button .comp_menu.menu.close -text "Cancel" -command {  
       
    40 	grab release .comp_menu 
       
    41 	destroy .comp_menu; set Comp_menu_up 0 ;  } \
       
    42  	    -bg $BACKGROUND -fg $FOREGROUND -font $FONT
       
    43  
       
    44    pack .comp_menu.menu  .comp_menu.menu.join .comp_menu.menu.horiz \
       
    45 	    .comp_menu.menu.vert .comp_menu.menu.learn \
       
    46 	    .comp_menu.menu.close -fill x
       
    47    focus .comp_menu.menu	
       
    48    #grab .comp_menu	
       
    49     
       
    50 }
       
    51 
       
    52 
       
    53 proc component_join { } {
       
    54 global Comp_menu_up
       
    55 puts stdout "component_join"
       
    56 grab release .comp_menu.menu
       
    57 #temporarily bind <Double-1> to join components
       
    58 bind .main_window.display.work_space <Double-1> {
       
    59     component_select %W %x %y 
       
    60     # joins this selection with next selected component
       
    61     JOIN_COMP
       
    62 
       
    63     #put <Double -1> back to the old setting
       
    64     bind .main_window.display.work_space <Double-1> {
       
    65 	component_select %W [%W canvasx %x]  [%W canvasy %y] 
       
    66         init_component_menu %W [%W canvasx %x]  [%W canvasy %y] 
       
    67     }
       
    68 }
       
    69 destroy .comp_menu
       
    70 set Comp_menu_up 0
       
    71 }    
       
    72 
       
    73 proc component_horizontal_split { } {
       
    74 global Comp_menu_up
       
    75 puts stdout "component_horizontal_split"
       
    76 grab release .comp_menu.menu
       
    77 SPLIT_COMP_HORIZ
       
    78 
       
    79 destroy .comp_menu
       
    80 set Comp_menu_up 0
       
    81 
       
    82 }
       
    83 
       
    84 
       
    85 proc component_learn { } {
       
    86     global Comp_menu_up curCompId comp_menux comp_menuy
       
    87 puts stdout "component_learn"
       
    88 #pops up a little window to put in id for component
       
    89     global save_ascii_geometry BACKGROUND FOREGROUND FONT SMALLFONT write_image
       
    90 
       
    91     
       
    92     toplevel .learn_comp -background $BACKGROUND
       
    93     wm geometry .learn_comp  +[expr $comp_menux +20]+[expr $comp_menuy +20]
       
    94     wm title .learn_comp  "Learn Component Id"
       
    95            grab set .learn_comp
       
    96    
       
    97     
       
    98 
       
    99     label .learn_comp.image -bitmap @$write_image -foreground $FOREGROUND -background $BACKGROUND
       
   100     frame .learn_comp.s -background $BACKGROUND
       
   101     label .learn_comp.s.txt -text "Learn Component as:" -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
       
   102 entry .learn_comp.s.ent -relief sunken -bd 2 -textvariable curCompId -foreground $FOREGROUND -background $BACKGROUND -font $SMALLFONT    
       
   103     pack .learn_comp.s.txt .learn_comp.s.ent -side top
       
   104     frame .learn_comp.buttons
       
   105 button .learn_comp.buttons.ok -text OK -command { LEARN_COMP $curCompId ; \
       
   106     grab release .learn_comp; destroy .learn_comp}  -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
       
   107 button .learn_comp.buttons.cancel -text Cancel -command {destroy .learn_comp } -fg $FOREGROUND -background $BACKGROUND -font $SMALLFONT -width 5
       
   108     pack .learn_comp.buttons.ok .learn_comp.buttons.cancel -side left -expand 1 -fill x 	
       
   109     pack .learn_comp.image .learn_comp.s .learn_comp.buttons -side top
       
   110     .learn_comp.s.ent icursor 0
       
   111     .learn_comp.s.ent select range 0 10
       
   112     focus .learn_comp.s.ent
       
   113  
       
   114     bind .learn_comp.s.ent <Return> {
       
   115 	LEARN_COMP $curCompId
       
   116 	grab release .learn_comp
       
   117 	destroy .learn_comp
       
   118     }
       
   119 
       
   120 destroy .comp_menu
       
   121 set Comp_menu_up 0
       
   122 }
       
   123 
       
   124 
       
   125 
       
   126 
       
   127 
       
   128 
       
   129 
       
   130 
       
   131 
       
   132 
       
   133