~ubuntu-branches/ubuntu/dapper/malaga/dapper

« back to all changes in this revision

Viewing changes to tcl/allomorph.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Bushnell, BSG
  • Date: 2005-01-10 11:52:04 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050110115204-hpgncw5pb0m1t8i6
Tags: 6.13-5
debian/control (malaga-doc Recommends): Suggest gv as a
postscript-viewer instead of ghostview.  (Closes: #289701).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# This file is part of Malaga, a system for Natural Language Analysis.
2
 
# Copyright (C) 1995-1998 Bjoern Beutel
3
 
#
4
 
# Bjoern Beutel
5
 
# Universitaet Erlangen-Nuernberg
6
 
# Abteilung fuer Computerlinguistik
7
 
# Bismarckstrasse 12
8
 
# D-91054 Erlangen
9
 
# e-mail: malaga@linguistik.uni-erlangen.de
10
 
#
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.
15
 
#
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.
20
 
#
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
24
 
 
25
 
# description =================================================================
26
 
 
27
 
# Main module to display allomorphs produced by mallex.
28
 
#
29
 
# Global variables:
30
 
# $allomorph_numbers -- the list of allomorph numbers
31
 
# $allomorph_cat($number) -- the categorie of allomorph $number
32
 
 
33
 
# functions ===================================================================
34
 
 
35
 
proc allomorph_display {} {
36
 
# Display allomorphs.
37
 
 
38
 
  global font font_size char_set allomorph_numbers allomorph_cat allomorph_surf
39
 
  
40
 
  .allomorph.frame.canvas delete matrix_tag
41
 
  
42
 
  set canvas_border 10
43
 
  set char_height $font_size(allomorph)
44
 
  set current_y $canvas_border
45
 
  set start_x $canvas_border
46
 
  set max_x $start_x
47
 
  
48
 
  # Run through the allomorph list:
49
 
  set first_allomorph 1
50
 
  foreach number $allomorph_numbers {
51
 
    
52
 
    # Space between allomorphs
53
 
    if {! $first_allomorph} {
54
 
      incr current_y $char_height
55
 
    }
56
 
 
57
 
    # Display allomorph number
58
 
    set number_id [.allomorph.frame.canvas create matrix \
59
 
                   $start_x $current_y \
60
 
                   "! \"$number: \"" \
61
 
                   -font $font(allomorph) \
62
 
                   -char_set $char_set \
63
 
                   -tags matrix_tag]
64
 
    
65
 
    # Display allomorph surface
66
 
    set matrix_id [.allomorph.frame.canvas create matrix \
67
 
                   [widget_right .allomorph.frame.canvas $number_id ] \
68
 
                   $current_y \
69
 
                   "\"$allomorph_surf($number)\"" \
70
 
                   -font $font(allomorph) \
71
 
                   -char_set $char_set \
72
 
                   -tags matrix_tag]
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]
76
 
    
77
 
    # Display allomorph category
78
 
    set matrix_id [.allomorph.frame.canvas create matrix \
79
 
                   [widget_right .allomorph.frame.canvas $number_id ] \
80
 
                   $current_y \
81
 
                   $allomorph_cat($number) \
82
 
                   -font $font(allomorph) \
83
 
                   -char_set $char_set \
84
 
                   -tags matrix_tag]
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]
88
 
    
89
 
    # Center allomorph number vertically
90
 
    .allomorph.frame.canvas move $number_id \
91
 
    0 [expr ($current_y \
92
 
             - [widget_bottom .allomorph.frame.canvas $number_id])/2]
93
 
    
94
 
    set first_allomorph 0
95
 
  }
96
 
  
97
 
  # Reconfigure scroll bars:
98
 
  .allomorph.frame.canvas configure \
99
 
  -scrollregion \
100
 
  "0 0 [expr $max_x + $canvas_border] [expr $current_y + $canvas_border]"
101
 
}
102
 
 
103
 
#------------------------------------------------------------------------------
104
 
 
105
 
proc allomorph_read {} {
106
 
# Read the malaga allomorphs.
107
 
 
108
 
  global allomorph_numbers allomorph_cat allomorph_surf
109
 
  
110
 
  set allomorph_numbers {}
111
 
  
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]
118
 
  }
119
 
}
120
 
 
121
 
#------------------------------------------------------------------------------
122
 
 
123
 
proc allomorph_open_window {} {
124
 
# Create window where to display the allomorphs
125
 
 
126
 
  global allomorph_geometry
127
 
 
128
 
  if [winfo exists .allomorph] {return}
129
 
 
130
 
  if {! [info exists allomorph_geometry]} {set allomorph_geometry 600x400}
131
 
  
132
 
  # Define start window.
133
 
  toplevel .allomorph
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
139
 
 
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
146
 
  
147
 
  create_scroll_frame allomorph
148
 
  focus .allomorph.frame.canvas
149
 
}
150
 
 
151
 
#------------------------------------------------------------------------------
152
 
 
153
 
proc allomorph_close_window {} {
154
 
# Close the allomorph window
155
 
 
156
 
  global allomorph_geometry
157
 
  
158
 
  if [winfo exists .allomorph] {
159
 
    set allomorph_geometry [wm geometry .allomorph]
160
 
    destroy .allomorph
161
 
  }
162
 
}
163
 
 
164
 
#------------------------------------------------------------------------------
165
 
 
166
 
proc allomorph_redraw {mode} {
167
 
 
168
 
  allomorph_open_window
169
 
 
170
 
  if {$mode == "reload"} {allomorph_read}
171
 
  allomorph_display
172
 
  if {[wm state .allomorph] == "normal"} {raise .allomorph}
173
 
}
174
 
 
175
 
#------------------------------------------------------------------------------
176
 
 
177
 
proc allomorph_init {} {
178
 
# Initialize the variables of "allomorph".
179
 
 
180
 
  global font font_size
181
 
 
182
 
  set font(allomorph) $font($font_size(allomorph))
183
 
}
184
 
 
185
 
# end of file =================================================================