reference/ocr-new/ocr-ui.tcl
author viric@llimona
Thu, 18 May 2006 23:12:51 +0200
changeset 0 6b8091ca909a
permissions -rw-r--r--
Init from working directory of svn repository.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
     1
#!/usr/sww/bin/wish -f
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
     2
#
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
     3
# user interface code (tcl visuals) for OCR
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
     4
# started 9/95, Archie Russell 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
     5
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
     6
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
     7
set main_window_width 800
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
     8
set main_window_height 800
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
     9
set dummy 0
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    10
# I'd like to be able to use the above parameters in here,
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    11
# but I think tcl might get a little angry if I try
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    12
# the size of the window, and the position of its upper left
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    13
set main_window_geometry 800x800+200+100
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    14
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    15
set menu_bar_width $main_window_width
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    16
set menu_bar_height 50
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    17
set button_bar_width $main_window_width
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    18
set button_bar_height 100
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    19
set display_height 700
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    20
# save a little room for scrollbars, etc.
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    21
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    22
set canvas_width [expr $main_window_width - 30]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    23
proc init_user_interface {} {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    24
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    25
# tcl requires declaration of global variables used in a fxn
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    26
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    27
    global main_window_geometry main_window_width main_window_height menu_bar_width menu_bar_height button_bar_width button_bar_height display_height
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    28
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    29
# toplevel windows are at the same level as 'xterms'    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    30
    toplevel .main_window
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    31
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    32
# $ sign means 'get the value' (otherwise uses the string)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    33
    wm geometry .main_window $main_window_geometry
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    34
    wm title .main_window "OCR user interface"
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    35
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    36
# frames are subwindows that are there mostly to 'hold' other windows
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    37
    frame .main_window.menu_bar -width $menu_bar_width -height $menu_bar_height -relief raised -bd 2
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    38
    init_menu_bar
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    39
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    40
    frame .main_window.button_bar -width $button_bar_width -height $button_bar_height -relief ridge -bd 5
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    41
    init_button_bar
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    42
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    43
    frame .main_window.display -width $main_window_width -height $display_height -relief ridge -bd 5
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    44
    init_display
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    45
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    46
# pack puts things together: this will put the menu_bar window just above the button_bar_window above the display
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    47
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    48
    pack .main_window.menu_bar .main_window.button_bar .main_window.display -side top -anchor w
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    49
    focus .main_window
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    50
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    51
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    52
proc init_menu_bar { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    53
# this command initializes the main menu bar (stuff like file, etc)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    54
# shortcuts not working! why?
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    55
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    56
    menubutton .main_window.menu_bar.file -text "File " -underline 0 -menu .main_window.menu_bar.file.menu -borderwidth 2
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    57
    init_file_menu
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    58
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    59
    menubutton  .main_window.menu_bar.edit -text "Edit " -underline 0 -menu .main_window.menu_bar.edit.menu  -borderwidth 2
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    60
    init_edit_menu
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    61
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    62
    menubutton  .main_window.menu_bar.options -text "Options " -underline 0 -menu .main_window.menu_bar.options.menu  -borderwidth 2
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    63
    init_options_menu
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    64
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    65
    pack .main_window.menu_bar.file .main_window.menu_bar.edit .main_window.menu_bar.options -side left -padx 1m -pady 1m -fill x
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    66
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    67
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    68
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    69
proc init_file_menu { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    70
# this creates the menu associated with the file menubutton
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    71
    menu .main_window.menu_bar.file.menu
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    72
# and these initialize the entries in the menu (open is linked to the command popup_open_menu)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    73
    .main_window.menu_bar.file.menu add command -label "Open..." -command popup_open_menu
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    74
    .main_window.menu_bar.file.menu add command -label "Close" -command popup_close_menu
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    75
# a separator is just a horizontal line for show
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    76
    .main_window.menu_bar.file.menu add separator
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    77
    .main_window.menu_bar.file.menu add command -label "Save" -command default_save
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    78
    .main_window.menu_bar.file.menu add command -label "Save As..." -command default_save
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    79
    .main_window.menu_bar.file.menu add separator
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    80
    .main_window.menu_bar.file.menu add command -label "Quit" -command popup_quit_dialog_box
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    81
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    82
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    83
proc init_edit_menu { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    84
    global dummy
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    85
    menu .main_window.menu_bar.edit.menu
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    86
    .main_window.menu_bar.edit.menu add radiobutton -label "Nothing" -variable dummy -value 0
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    87
    .main_window.menu_bar.edit.menu add radiobutton -label "Yet" -variable dummy -value 1
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    88
    .main_window.menu_bar.edit.menu add radiobutton -label "Here" -variable dummy -value 2
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    89
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    90
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    91
set word_certainty_value normal
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    92
set screen_view_style facing_page
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    93
proc init_options_menu { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    94
    global dummy word_certainty_value screen_view_style
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    95
    menu .main_window.menu_bar.options.menu
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    96
    .main_window.menu_bar.options.menu add cascade -label "Word Certainty" -menu .main_window.menu_bar.options.menu.word_certainty
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    97
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    98
    menu .main_window.menu_bar.options.menu.word_certainty
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
    99
    .main_window.menu_bar.options.menu.word_certainty add radiobutton -label "Stringent" -variable word_certainty_value -value stringent
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   100
    .main_window.menu_bar.options.menu.word_certainty add radiobutton -label "Normal" -variable word_certainty_value -value normal
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   101
    .main_window.menu_bar.options.menu.word_certainty add radiobutton -label "Lenient" -variable word_certainty_value -value lenient
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   102
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   103
    .main_window.menu_bar.options.menu add cascade -label "Screen View" -menu .main_window.menu_bar.options.menu.screen_view
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   104
    menu .main_window.menu_bar.options.menu.screen_view
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   105
    .main_window.menu_bar.options.menu.screen_view add radiobutton -label "facing page" -variable screen_view_style -value facing_page
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   106
    .main_window.menu_bar.options.menu.screen_view add radiobutton -label "interleave lines" -variable screen_view_style -value interleave_lines
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   107
    .main_window.menu_bar.options.menu.screen_view add radiobutton -label "translation only" -variable screen_view_style -value translation_only
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   108
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   109
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   110
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   111
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   112
proc init_button_bar { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   113
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   114
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   115
proc init_display { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   116
    global display_height canvas_width
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   117
    canvas .main_window.display.work_space -bg white -height $display_height -width $canvas_width -xscrollcommand ".main_window.display.xscroller set" -yscrollcommand ".main_window.display.yscroller set" -scrollincrement 30 -cursor {crosshair black gray}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   118
# two scrollbars
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   119
    scrollbar .main_window.display.xscroller -command ".main_window.display.work_space xview" -orient horizontal 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   120
    scrollbar .main_window.display.yscroller -command ".main_window.display.work_space yview" 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   121
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   122
    pack .main_window.display.xscroller -side bottom -fill x
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   123
    pack .main_window.display.work_space .main_window.display.yscroller -side left -fill y
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   124
    .main_window.display.work_space configure -scrollregion { -5000 -5000 5000 5000 }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   125
    initialize_bindings
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   126
    test_canvas
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   127
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   128
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   129
set x_init 0
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   130
set y_init 0
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   131
set x_final 0
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   132
set y_final 0
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   133
set mouse_mode NONE
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   134
set started_region 0
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   135
set region_count 0
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   136
proc initialize_bindings { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   137
    # facilitates the grabbing of a rectangle of the window
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   138
    # using mouse button 1
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   139
    # and apparently a lot of other junk!
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   140
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   141
    global region_data regions next_button_data next_buttons kill_button_data kill_buttons arrow_data arrows mouse_mode current_object
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   142
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   143
#     bind .main_window.display.work_space <ButtonPress-1> {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   144
# 	if [expr ! [string compare $mouse_mode NONE]] {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   145
# 	    set current_object [find withtag current]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   146
# 	    if [expr ($current_object == "") || ((expr ! [lsearch $next_buttons $current_object]) && (expr ! [lsearch $kill_buttons $current_object]))] {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   147
# 		set mouse_mode making_region
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   148
# 		# start creating the region		
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   149
# 		grab set .main_window.display 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   150
# 		set x_init [.main_window.display.work_space canvasx %x]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   151
# 		set y_init [.main_window.display.work_space canvasy %y]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   152
# 		set region_id [.main_window.display.work_space create rectangle $x_init $y_init $x_init $y_init -outline black -width 3]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   153
# 		set region_data($region_id,x_init) $x_init
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   154
# 		set region_data($region_id,y_init) $y_init
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   155
# 		.main_window.display.work_space itemconfigure $region_id -tags region$region_id
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   156
# 		lappend regions $region_id
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   157
		
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   158
# 	    } elseif {[lsearch $next_buttons $current_object] != -1} {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   159
# 		set mouse_mode making_arrow
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   160
# 		grab set .main_window.display
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   161
# 		set arrow_id [.main_window.display.work_space create line 0 0 1 1]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   162
# 		set arrow_data($arrow_id,x_init) $next_button_data($current_object,x_center)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   163
# 		set arrow_data($arrow_id,y_init) $next_button_data($current_object,y_center)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   164
# 		set arrow_data($arrow_id,start_region) $next_button_data($current_object,region_id)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   165
# 		.main_window.display.work_space coords $arrow_id $arrow_data($arrow_id,x_init) $arrow_data($arrow_id,y_init) $arrow_data($arrow_id,x_init) $arrow_data($arrow_id,y_init)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   166
# 		.main_window.display.work_space itemconfigure $arrow_id -arrow last -arrowshape {6.0m 8.0m 1.5m} -fill blue -tags arrow$arrow_id
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   167
		
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   168
# 		lappend arrows $arrow_id
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   169
# 	    } elseif {[lsearch $kill_buttons $current_object] != -1} {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   170
# 		set mouse_mode killing_region 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   171
# 	    } elseif {[search $prev_buttons $current_object] != -1} {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   172
# 		set moude_mode moving_arrow
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   173
# 	    } else {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   174
# 		puts stdout unknown-mode
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   175
# 	    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   176
# 	} else {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   177
# 	    puts stdout "strange: looks like you are in some unknown state. Sorry"
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   178
#      }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   179
#    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   180
    bind .main_window.display.work_space <ButtonRelease-1> { 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   181
	if [expr ! [string compare $mouse_mode making_region]] {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   182
	    set region_id $current_object
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   183
	    set x_final [.main_window.display.work_space canvasx %x]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   184
	    set y_final [.main_window.display.work_space canvasy %y]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   185
	    set x_init $region_data($region_id,x_init)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   186
	    set y_init $region_data($region_id,y_init)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   187
	    .main_window.display.work_space coords region$region_id $x_init $y_init $x_final $y_final
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   188
	    # if finishing a rectangle, initialize its stuff in the array
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   189
	    if {$x_init <= $x_final} {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   190
		set region_data($region_id,x_init) $x_init
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   191
		set region_data($region_id,x_final) $x_final
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   192
	    } else {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   193
		set region_data($region_id,x_final) $x_init
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   194
		set region_data($region_id,x_init) $x_final
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   195
	    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   196
	    if {$y_init <= $y_final} {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   197
		set region_data($region_id,y_init) $y_init
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   198
		set region_data($region_id,y_final) $y_final
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   199
	    } else {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   200
		set region_data($region_id,y_init) $y_final
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   201
		set region_data($region_id,y_final) $y_init
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   202
	    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   203
	    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   204
	    set region_data($region_id,next_region_id) NONE
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   205
	    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   206
	    make_region_buttons $region_id	    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   207
	    grab release .main_window.display
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   208
	    set mouse_mode NONE
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   209
	    set current_object NONE
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   210
	}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   211
    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   212
							       
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   213
							       
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   214
		
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   215
	
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   216
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   217
    bind .main_window.display.work_space <B1-Motion> {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   218
	if [expr ! [string compare $mouse_mode making_region]]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   219
	{
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   220
	    set region_id $current_object
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   221
	    set x_init $region_data($region_id,x_init)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   222
	    set y_init $region_data($region_id,y_init)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   223
	    set curx [.main_window.display.work_space canvasx %x] 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   224
	    set cury [.main_window.display.work_space canvasy %y]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   225
	    .main_window.display.work_space coords region$region_id $x_init $y_init $curx $cury
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   226
	}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   227
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   228
    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   229
    bind .main_window.display <Leave> {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   230
	# on leaving the display, release control of the mouse etc.
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   231
	# maybe make it scroll instead?
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   232
	if $started_region {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   233
	    grab release .main_window.display
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   234
	    set started_region 0
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   235
	    .main_window.display.work_space coords region$region_id 0 0 0 0  
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   236
	}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   237
    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   238
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   239
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   240
set arrow_in_progress 0
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   241
proc make_region_buttons { reg_id } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   242
    global region_data kill_button_data next_button_data arrow_in_progress current_arrow
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   243
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   244
    set x_init $region_data($reg_id,x_init)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   245
    set y_init $region_data($reg_id,y_init)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   246
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   247
    set next_num [.main_window.display.work_space create rectangle $x_init $y_init [expr $x_init + 20] [expr $y_init + 20] -fill blue -tags "region$reg_id next_button$reg_id"]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   248
    set next_button_data($next_num,reg_id) $reg_id
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   249
    .main_window.display.work_space bind next_button$reg_id <Double-2> {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   250
	set reg_id $next_button_data([.main_window.display.work_space find withtag current],reg_id)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   251
	if { $arrow_in_progress } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   252
	    finish_arrow $reg_id
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   253
	} else {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   254
	    set canvas_x [.main_window.display.work_space canvasx %x] 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   255
	    set canvas_y [.main_window.display.work_space canvasy %y]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   256
	    start_arrow $reg_id $canvas_x $canvas_y
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   257
	    puts stdout "Starting an arrow at $canvas_x $canvas_y"
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   258
	}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   259
    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   260
    set kill_num [.main_window.display.work_space create rectangle [expr $x_init + 20] $y_init [expr $x_init + 40] [expr $y_init + 20] -fill red -tags "region$reg_id kill_button$reg_id"]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   261
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   262
    set kill_button_data($kill_num,reg_id) $reg_id
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   263
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   264
    .main_window.display.work_space bind kill_button$reg_id <Double-2> {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   265
	set reg_id $kill_button_data([.main_window.display.work_space find withtag current],reg_id)
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   266
	destroy_region $reg_id .main_window.display.work_space
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   267
    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   268
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   269
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   270
proc start_arrow { reg_id x_start y_start } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   271
    global arrow_in_progress next_button_data region_data current_arrow
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   272
    set path_name .main_window.display.work_space
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   273
# start an arrow in the middle of the little red button
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   274
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   275
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   276
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   277
    set arrow [.main_window.display.work_space create line $x_start $y_start $x_start $y_start -width 3 -arrow last -arrowshape {6.0m 8.0m 1.5m} -fill blue -tags arrow$reg_id]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   278
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   279
    set region_data($reg_id,arrow) $arrow
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   280
    set arrow_in_progress 1
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   281
    set current_arrow $arrow
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   282
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   283
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   284
proc destroy_region { reg_id path_name } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   285
    $path_name delete region$reg_id
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   286
    puts stdout "Destroying $reg_id"
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   287
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   288
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   289
proc test_canvas { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   290
# just display some junk on the canvas 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   291
   .main_window.display.work_space create text 400 200 -text "Document and text will  be displayed here" -font *-times-*-*-*--24-*-*-*-*-*-*-* -fill black
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   292
    .main_window.display.work_space create text 400 250 -text "Can be displayed in multiple colors etc." -font *-times-*-r-normal--24-*-*-*-*-*-*-* -fill red
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   293
    .main_window.display.work_space create text 400 300 -text "Can grab rectangles of stuff here." -font *-times-*-r-normal--24-*-*-*-*-*-*-* -fill green
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   294
    .main_window.display.work_space create text 400 350 -text "other things semi-working: quit and open (under file)" -font *-times-*-*-*--24-*-*-*-*-*-*-* -fill blue
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   295
   .main_window.display.work_space create text 200 200 -font *-times-*-*-*--10-*-*-*-*-*-*-* -fill black -text "If I hit return
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   296
Will it make any difference
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   297
return
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   298
return"
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   299
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   300
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   301
set open_menu_geometry 600x300+300+400
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   302
set current_directory [pwd]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   303
set open_menu_pattern *
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   304
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   305
proc popup_open_menu { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   306
# this procedure pops up an interactive box which can be used to open files
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   307
# bug: cannot exit menu without selecting a file
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   308
    global open_menu_geometry open_menu_pattern current_directory
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   309
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   310
    toplevel .open_menu
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   311
    wm geometry .open_menu $open_menu_geometry
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   312
    wm title .open_menu Open
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   313
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   314
    # force the user to interact with this box
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   315
    grab set .open_menu 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   316
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   317
    # directory listing and scrollbar
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   318
    frame .open_menu.dirstuff
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   319
    scrollbar .open_menu.dirstuff.yscroll -command ".open_menu.dirstuff.directory yview"
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   320
    listbox .open_menu.dirstuff.directory -yscrollcommand ".open_menu.dirstuff.yscroll set" -geometry 25x12 -relief raised
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   321
    fill_in_directory_box $current_directory $open_menu_pattern
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   322
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   323
    bind .open_menu.dirstuff.directory <Double-Button-1> {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   324
	set file_to_open [selection get]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   325
	if [file isdirectory $file_to_open] {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   326
	    cd $file_to_open
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   327
	    set current_directory [pwd]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   328
	    clear_directory_box
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   329
	    puts stdout "Changing to  $current_directory"
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   330
	    fill_in_directory_box $current_directory $open_menu_pattern
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   331
	} else {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   332
	    puts stdout "Opening file $file_to_open"
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   333
	    destroy .open_menu
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   334
	}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   335
    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   336
    # pattern for listings to match
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   337
    frame .open_menu.pattern_match
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   338
    label .open_menu.pattern_match.label -text "Match files of type:"
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   339
    entry .open_menu.pattern_match.entry -width 5 -relief sunken -bd 2 -textvariable open_menu_pattern
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   340
    # refresh the directory listing after user presses return
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   341
    bind .open_menu.pattern_match.entry <Return> {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   342
	set current_directory [pwd]
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   343
	clear_directory_box
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   344
	fill_in_directory_box $current_directory $open_menu_pattern
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   345
    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   346
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   347
    pack .open_menu.pattern_match.label .open_menu.pattern_match.entry -side left
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   348
    pack .open_menu.dirstuff.directory .open_menu.dirstuff.yscroll -side left -fill y 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   349
    pack .open_menu.pattern_match .open_menu.dirstuff -side top
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   350
    focus .open_menu.pattern_match.entry
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   351
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   352
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   353
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   354
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   355
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   356
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   357
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   358
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   359
proc clear_directory_box { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   360
    	.open_menu.dirstuff.directory delete 0 end
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   361
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   362
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   363
proc fill_in_directory_box { dirname {pattern *} } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   364
    foreach i [exec ls -aF $dirname] {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   365
	if [file isdirectory $i] {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   366
	    .open_menu.dirstuff.directory insert end $i
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   367
	} elseif [string match $pattern $i] {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   368
	    .open_menu.dirstuff.directory insert end $i
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   369
	}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   370
    }
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   371
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   372
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   373
set quit_dialog_geometry 300x150+500+500
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   374
proc popup_quit_dialog_box { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   375
    global quit_dialog_geometry 
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   376
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   377
    toplevel .quit_dialog
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   378
    wm geometry .quit_dialog $quit_dialog_geometry
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   379
    wm title .quit_dialog Quit
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   380
    grab set .quit_dialog
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   381
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   382
   message .quit_dialog.msg -text "You are about to quit OCR-orama.  All changes you have made will be lost."
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   383
    frame .quit_dialog.buttons
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   384
    button .quit_dialog.buttons.ok -text OK -command quit_ok
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   385
    button .quit_dialog.buttons.cancel -text Cancel -command quit_cancel
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   386
	pack .quit_dialog.buttons.ok .quit_dialog.buttons.cancel -side left -expand 1 -fill x 	
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   387
    pack .quit_dialog.msg .quit_dialog.buttons -side top -fill x
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   388
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   389
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   390
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   391
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   392
proc quit_ok { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   393
    destroy .main_window
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   394
    destroy .quit_dialog
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   395
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   396
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   397
proc quit_cancel { } {
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   398
    global command_not_in_progress
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   399
    set command_not_in_progress 1
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   400
    destroy .quit_dialog
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   401
}
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   402
    
6b8091ca909a Init from working directory of svn repository.
viric@llimona
parents:
diff changeset
   403
init_user_interface