1
# This file is part of Malaga, a system for Natural Language Analysis.
2
# Copyright (C) 1995-1998 Bjoern Beutel
5
# Universitaet Erlangen-Nuernberg
6
# Abteilung fuer Computerlinguistik
9
# e-mail: malaga@linguistik.uni-erlangen.de
11
# This program is free software; you can redistribute it and/or modify
12
# it under the terms of the GNU General Public License as published by
13
# the Free Software Foundation; either version 2 of the License, or
14
# (at your option) any later version.
16
# This program is distributed in the hope that it will be useful,
17
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU General Public License for more details.
21
# You should have received a copy of the GNU General Public License
22
# along with this program; if not, write to the Free Software
23
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
# description =================================================================
27
# Main module to display allomorphs produced by mallex.
30
# $allomorph_numbers -- the list of allomorph numbers
31
# $allomorph_cat($number) -- the categorie of allomorph $number
33
# functions ===================================================================
35
proc allomorph_display {} {
38
global font font_size char_set allomorph_numbers allomorph_cat allomorph_surf
40
.allomorph.frame.canvas delete matrix_tag
43
set char_height $font_size(allomorph)
44
set current_y $canvas_border
45
set start_x $canvas_border
48
# Run through the allomorph list:
50
foreach number $allomorph_numbers {
52
# Space between allomorphs
53
if {! $first_allomorph} {
54
incr current_y $char_height
57
# Display allomorph number
58
set number_id [.allomorph.frame.canvas create matrix \
61
-font $font(allomorph) \
65
# Display allomorph surface
66
set matrix_id [.allomorph.frame.canvas create matrix \
67
[widget_right .allomorph.frame.canvas $number_id ] \
69
"\"$allomorph_surf($number)\"" \
70
-font $font(allomorph) \
73
set max_x [maximum $max_x \
74
[widget_right .allomorph.frame.canvas $matrix_id]]
75
set current_y [widget_bottom .allomorph.frame.canvas $matrix_id]
77
# Display allomorph category
78
set matrix_id [.allomorph.frame.canvas create matrix \
79
[widget_right .allomorph.frame.canvas $number_id ] \
81
$allomorph_cat($number) \
82
-font $font(allomorph) \
85
set max_x [maximum $max_x \
86
[widget_right .allomorph.frame.canvas $matrix_id]]
87
set current_y [widget_bottom .allomorph.frame.canvas $matrix_id]
89
# Center allomorph number vertically
90
.allomorph.frame.canvas move $number_id \
92
- [widget_bottom .allomorph.frame.canvas $number_id])/2]
97
# Reconfigure scroll bars:
98
.allomorph.frame.canvas configure \
100
"0 0 [expr $max_x + $canvas_border] [expr $current_y + $canvas_border]"
103
#------------------------------------------------------------------------------
105
proc allomorph_read {} {
106
# Read the malaga allomorphs.
108
global allomorph_numbers allomorph_cat allomorph_surf
110
set allomorph_numbers {}
112
# Read all allomorphs
113
while {[set line [read_line stdin]] != "end" } {
114
set allomorph_number [lindex $line 0]
115
lappend allomorph_numbers $allomorph_number
116
set allomorph_surf($allomorph_number) [lindex $line 1]
117
set allomorph_cat($allomorph_number) [lindex $line 2]
121
#------------------------------------------------------------------------------
123
proc allomorph_open_window {} {
124
# Create window where to display the allomorphs
126
global allomorph_geometry
128
if [winfo exists .allomorph] {return}
130
if {! [info exists allomorph_geometry]} {set allomorph_geometry 600x400}
132
# Define start window.
134
wm title .allomorph "Malaga Allomorphs"
135
wm iconname .allomorph "Allomorphs"
136
wm minsize .allomorph 100 100
137
wm geometry .allomorph $allomorph_geometry
138
wm focusmodel .allomorph active
140
# Define the different menus.
141
frame .allomorph.menu -relief raised -borderwidth 1
142
pack .allomorph.menu -side top -fill x
143
create_window_menu allomorph
144
create_font_menu allomorph
145
tk_menuBar .allomorph.menu .allomorph.menu.window .allomorph.menu.fonts
147
create_scroll_frame allomorph
148
focus .allomorph.frame.canvas
151
#------------------------------------------------------------------------------
153
proc allomorph_close_window {} {
154
# Close the allomorph window
156
global allomorph_geometry
158
if [winfo exists .allomorph] {
159
set allomorph_geometry [wm geometry .allomorph]
164
#------------------------------------------------------------------------------
166
proc allomorph_redraw {mode} {
168
allomorph_open_window
170
if {$mode == "reload"} {allomorph_read}
172
if {[wm state .allomorph] == "normal"} {raise .allomorph}
175
#------------------------------------------------------------------------------
177
proc allomorph_init {} {
178
# Initialize the variables of "allomorph".
180
global font font_size
182
set font(allomorph) $font($font_size(allomorph))
185
# end of file =================================================================