2 package provide mlcm::gui 0.1
4 namespace eval mlcm::gui {
10 return ".top[incr _gid]"
14 set bg1 [$btn cget -background]
15 set bg2 [$btn cget -activebackground]
16 if ![string equal $bg1 $bg2] {
17 $btn configure -background $bg2
18 after 200 $btn configure -background $bg1
24 set res [eval button $args]
26 set under [$res cget -underline]
27 set key [$res cget -text]
29 set key [string index $key $under]
30 bind . <Alt-KeyPress-$key> "mlcm::gui::_activate $res"
31 puts "bound $key to $res"
40 proc _header {that frm db} {
41 set maxrow [$db get maxrow]
43 tixScrolledWindow $scrw
44 pack $scrw -side left -expand yes -fill both
45 set panel [$scrw subwidget window]
46 set lbl [label $panel.maxrow -text "[mlcm::lang::msg maxrow]: $maxrow"]
47 set bf [_button $panel.first -command "mlcm::gui::_dbfirst $db" \
48 -text [mlcm::lang::msg first] -underline 0]
49 set bp [_button $panel.prev -command "mlcm::gui::_dbprev $db" \
50 -text [mlcm::lang::msg prev] -underline 0]
51 set bn [_button $panel.next -command "mlcm::gui::_dbnext $db" \
52 -text [mlcm::lang::msg next] -underline 0]
53 set bl [_button $panel.last -command "mlcm::gui::_dblast $db" \
54 -text [mlcm::lang::msg last] -underline 0]
55 pack $panel.maxrow $panel.first $panel.prev $panel.next \
56 $panel.last -side left
60 puts "first [$db name]"
64 puts "prev [$db name]"
68 puts "next [$db name]"
72 puts "last [$db name]"
75 proc _workarea {that frm db} {
77 tixPanedWindow $pnw -orientation horizontal
78 pack $pnw -side top -expand yes -fill both
79 $pnw add pane1 -size 444
82 # left area: result set list
83 set htmlw $pnw.pane1.text
84 set scb $pnw.pane1.scby
86 scrollbar $scb -command "$htmlw yview"
87 $htmlw configure -yscrollcommand "$scb set"
88 pack $scb -side right -expand no -fill y
89 pack $htmlw -side right -expand yes -fill both
94 label $pnw.pane2.lbl -text "edit me"
95 pack $pnw.pane2.lbl -side left -expand yes -fill both
98 # create new gui hierarchy for db
99 # @param parent parent window where to put the gui into
100 # if empty, a new toplevel window is created
101 # @param profile actual profile to use
102 # @param db actual database to use
104 proc new {parent profile db} {
105 set that [openIsisRec -fdt $mlcm::meta::fdtGui]
108 if ![string length $parent] {
109 set parent [_newwindow]
112 } elseif [string equal . $parent] {
119 $that add top $parent db $db stub [$db stub]
126 pack $main -side top -fill both -expand yes
128 set actmenu [$profile menu]
129 set mbar [frame $main.menubar -bd 5]
130 pack $mbar -side top -fill x
131 mlcm::menu::showmenu $actmenu $mbar
133 set fhead [frame $main.frhead]
134 pack $fhead -side top -expand no -fill x
135 _header $that $fhead $db
137 set fwork [frame $main.workarea]
138 pack $fwork -side top -expand yes -fill both
139 _workarea $that $fwork $db
142 wm title $parent "MLCM - [$db name]"
144 wm geom $parent 500x400+80+80
150 # setup global/openIsis variables for active window
152 set stb [$that get stub]
153 set openIsis::srv $stb
154 set htmlw [$that get html]
155 proc ::openIsis::puts msg "
160 # show all db entries
162 set db [$that get db]
163 set htmlw [$that get html]
166 set tsp [tsp list $db]
168 for {$db all} {[$db hasNext]} {} {
170 if ![openIsis::isis read -rowid $mfn -db $dbn] {
171 puts "no record for mfn $mfn"
174 if [catch {openIsis::Tspr $tsp}] {
176 puts "error in $tsp:\n$errorInfo"
183 proc _chktsp {name dbn path res} {
185 set ret "$path/$dbn.$name"
186 if [file readable $ret] {
189 set ret "$path/$name"
194 # first, look for <path_of_db>/<name_of_db>.<tsp>.tsp
195 # second, look for <path_of_db>/<tsp>.tsp
196 # third, scan $::auto_path for <name_of_db>.<tsp>.tsp
197 # fourth, scan $::auto_path for <tsp>.tsp
198 # fifth, raise an error
199 # @param tsp name of tsp file without extension
200 # @param db actual databse object
201 # @return path to tsp file
206 set path "$auto_path"
208 set cfg [$db get 4002]
209 set dbp [$cfg get {803 {}}]
210 if [string length $dbp] {
211 set path "$dbp $auto_path"
216 if [_chktsp $tsp $dbn $p res] {
220 error "cannot find $tsp in $path"