1#
2# This file is part of:
3#
4#  gpsman --- GPS Manager: a manager for GPS receiver data
5#
6# Copyright (c) 1998-2013 Miguel Filgueiras migfilg@t-online.de
7#
8#    This program is free software; you can redistribute it and/or modify
9#      it under the terms of the GNU General Public License as published by
10#      the Free Software Foundation; either version 3 of the License, or
11#      (at your option) any later version.
12#
13#      This program is distributed in the hope that it will be useful,
14#      but WITHOUT ANY WARRANTY; without even the implied warranty of
15#      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16#      GNU General Public License for more details.
17#
18#      You should have received a copy of the GNU General Public License
19#      along with this program.
20#
21#  File: setup.tcl
22#  Last change:  6 October 2013
23#
24# Includes contributions by
25#  - Brian Baulch (baulchb _AT_ onthenet.com.au) marked "BSB contribution"
26#  - Matt Martin (matt.martin _AT_ ieee.org) marked "MGM contribution"
27#  - Valere Robin (valere.robin _AT_ wanadoo.fr) marked "VR contribution"
28#  - David Gardner (djgardner _AT_ users.sourceforge.net) marked
29#    "DJG contribution"
30#
31
32# default set up code; may be overridden by a patch file
33
34##### Img library
35
36 # xbm gives black images
37set ImgOutFormats {bmp gif jpeg png tiff xpm}
38
39##### initialize interface
40
41set NAMEWIDTH [expr $NAMELENGTH+2]
42set COMMENTWIDTH [expr $COMMENTLENGTH+2]
43
44set OBSWIDTH 40
45set OBSHEIGHT 3
46
47set DATEWIDTH $DATEW($DateFormat)
48
49set DATUMWIDTH 32
50
51set SUBDTUNIT $DLUNIT($DISTUNIT,subdist)
52
53  # crosshair cursor centre in pixels from lower right corner
54set CRHAIRx 5
55set CRHAIRy 5
56
57proc GlobalOptionsBindings {} {
58    # change some of the default options and bindings of Tcl widgets
59    global COLOUR
60
61    option add *Frame.borderWidth 0
62    option add *Frame.relief flat
63    option add *Menubutton.relief raised
64    option add *Menubutton.direction below
65    option add *Menu.tearOff 0
66    option add *Entry.exportSelection 1
67    option add *Entry.disabledBackground $COLOUR(bg)
68    option add *Checkbutton.selectColor $COLOUR(check)
69    option add *Radiobutton.selectColor $COLOUR(check)
70    option add *Text.wrap word
71    option add *Text.exportSelection 1
72
73    bind Listbox <B1-Leave> { break }
74    bind Listbox <Button-2> { break }
75    bind Listbox <B2-Motion> { break }
76    return
77}
78
79proc GMInit {} {
80    # set up main window(s)
81    global MapHeight MapWidth LISTWIDTH LISTHEIGHT COLOUR MAPCOLOUR \
82	VERSION SRCDIR LPOSX LPOSY MPOSX MPOSY RPOSX RPOSY MAPSCALE MAPDISTS \
83	MAPDISTVALS MAPSCLENGTH MWINDOWSCONF TYPES RECTYPES MYGPS Temp1 List \
84	ListInds EdWindow GPSLabel PositionFormat Datum GPSState Map \
85	MapBounds TXT MESS DISTUNIT DTUNIT DSCALE SUBDTUNIT SUBDSCALE DLUNIT \
86	MAPDISTUNITS MapScale MpW LsW RcW LsWTit MpWTit RcWTit WConf OVx OVy \
87	XCoord YCoord MapZone MapProjTitle MapTransfTitle MapPFormat MapRange \
88	MapWPMoving MapMakingRT MapLoading MapScInitVal MapImageItems \
89	GetDispl MAPKNOWNPROJS RECPROTOCOLS SYMBOLIMAGE RcMenu GPSProtocol \
90	GPSProtocolExt RealTimeLogAnim PVTState USvState \
91	GSHPVersion NoImgLib ImgOutFormats SmallLogo UNIX GMEd FILEFORMAT \
92	MapScaleButton MapPFDatum AutoNumRts SUPPORTLAPS FixedFont DATUMWIDTH \
93	GPSProtocolButton RECINFO SERIALPORT RECBAUDS
94
95    set MapBounds "0 0 $MapWidth $MapHeight"
96    set MapRange(x) $MapWidth ; set MapRange(y) $MapHeight
97    set MapRange(x0) 0 ; set MapRange(y0) 0
98    set OVx 0 ; set OVy 0 ; set XCoord "" ; set YCoord "" ; set MapZone ""
99    set MapWPMoving -1 ; set MapMakingRT 0 ; set MapLoading 0
100    set MapImageItems ""
101
102    option add *Foreground $COLOUR(fg)
103    option add *Background $COLOUR(bg)
104
105    wm protocol . WM_DELETE_WINDOW { QuitNow }
106    wm title . "$TXT(GMtit) $VERSION"
107    bind . <Control-c> QuitNow
108
109    set mt [Measure "GPS Manager"]
110
111    set WConf(datastate) ""
112
113    switch $MWINDOWSCONF {
114	lists {
115	    set gtit .title
116	    wm geometry . +$LPOSX+$LPOSY
117	    set MpW .mpw.fr ; set LsW .lsw.frls ; set RcW .rcw.fr
118	    frame .lsw
119	    frame $LsW
120
121	    foreach w ".mpw .rcw" t "MpW RcW" p "M R" z "nameMap GPSrec" {
122		set ${t}Tit "GPS Manager"
123		GMToplevel $w $z +[set ${p}POSX]+[set ${p}POSY] {} \
124		    [list WM_DELETE_WINDOW "lower $w"] {}
125		lower $w .
126		frame [set $t] -borderwidth 10
127	    }
128
129	    button .rcw.tit -textvariable RcWTit -width $mt \
130		    -command "Raise . ; .rcw.tit configure -state normal"
131	    bind .rcw.tit <Enter> "set RcWTit {$TXT(mainwd)}"
132	    bind .rcw.tit <Leave> "set RcWTit {GPS Manager}"
133
134	    frame .mpw.top
135	    frame .mpw.top.frNT
136	    set ft .mpw.top.frNT
137	    # to be filled in by proc ToTravel
138	    frame .mpw.top.frT
139	    set WConf(travel,fr) .mpw.top.frT
140	    set WConf(travel,alt) $ft
141	    button $ft.tit -textvariable MpWTit -width $mt \
142		    -command "Raise . ; $ft.tit configure -state normal"
143	    bind $ft.tit <Enter> "set MpWTit {$TXT(mainwd)}"
144	    bind $ft.tit <Leave> "set MpWTit {GPS Manager}"
145
146	    frame .lsw.frmb -borderwidth 2
147	    menubutton .lsw.frmb.dtitle -text Datum -menu .lsw.frmb.dtitle.m
148	    menu .lsw.frmb.dtitle.m \
149		 -postcommand "FillDatumMenu .lsw.frmb.dtitle.m ChangeMapDatum"
150	    label .lsw.frmb.datum -textvariable Datum \
151		    -width $DATUMWIDTH
152
153	    set t [Measure $TXT(GPSrec)]
154	    frame .lsw.frmb.frb
155	    frame .lsw.frmb.frb.sep -height 6 -bg $COLOUR(dialbg) -width $t
156	    button .lsw.frmb.frb.load -text $TXT(load) \
157		    -command { LoadFile Data ; \
158		    .lsw.frmb.frb.load configure -state normal }
159	    set m .lsw.frmb.frb.import.m
160	    menubutton .lsw.frmb.frb.import -text $TXT(import) -menu $m
161	    menu $m
162	    foreach fmt $FILEFORMAT(_type,in,data) {
163		$m add command -label $fmt -command "ImportFile Data $fmt"
164	    }
165	    button .lsw.frmb.frb.save -text $TXT(save) -state disabled \
166		    -command { SaveFile all Data ; \
167		    .lsw.frmb.frb.save configure -state normal }
168	    # based on VR contribution
169	    set m .lsw.frmb.frb.export.m
170	    menubutton .lsw.frmb.frb.export -text $TXT(export) -menu $m \
171		-state disabled
172	    menu $m
173	    foreach fmt $FILEFORMAT(_type,out,data) {
174		$m add command -label $fmt -command "ExportFile all $fmt Data"
175	    }
176	    #--
177	    button .lsw.frmb.frb.search -text $TXT(search) -state disabled \
178		    -command { Search ; \
179		    .lsw.frmb.frb.search configure -state normal }
180	    frame .lsw.frmb.frb.sep2 -height 6 -bg $COLOUR(dialbg) -width $t
181	    set WConf(datastate) [list [list \
182		    button [list .lsw.frmb.frb.save .lsw.frmb.frb.export \
183				.lsw.frmb.frb.search]]]
184	    button .lsw.frmb.mpw -text $TXT(nameMap) -width $t \
185		    -command "ToggleWindow .mpw $MPOSX $MPOSY ; \
186		    .lsw.frmb.mpw configure -state normal"
187	    set RcMenu .lsw.frmb.rcw.m
188	    menubutton .lsw.frmb.rcw -text $TXT(GPSrec) -width $t -menu $RcMenu
189	    frame .lsw.frmb.sep -height 6 -bg $COLOUR(dialbg) -width $t
190	    button .lsw.frmb.opt -text $TXT(options) -width $t \
191		    -command { SetOptions ; \
192	                       .lsw.frmb.opt configure -state normal }
193	}
194	map {
195	    wm geometry . +$MPOSX+$MPOSY
196	    set MpW .fr ; set LsW .lsw.frbl.frls ; set RcW .rcw.fr
197	    frame $MpW -borderwidth 5
198
199	    foreach w ".lsw .rcw" t "LsW RcW" p "L R" z "nameLists GPSrec" {
200		set ${t}Tit "GPS Manager"
201		GMToplevel $w $z +[set ${p}POSX]+[set ${p}POSY] {} \
202		    [list WM_DELETE_WINDOW "lower $w"] {}
203		lower $w .
204		button $w.tit -textvariable ${t}Tit -width $mt \
205			-command "Raise . ; $w.tit configure -state normal"
206		bind $w.tit <Enter> "set ${t}Tit {$TXT(mainwd)}"
207		bind $w.tit <Leave> "set ${t}Tit {GPS Manager}"
208	    }
209
210	    frame .rcw.fr -borderwidth 10
211
212	    frame .lsw.frbl
213	    frame .lsw.frbl.frls -borderwidth 10
214	    frame .lsw.frbl.frb
215	    button .lsw.frbl.frb.load -text $TXT(load) \
216		    -command { LoadFile Data ; \
217		    .lsw.frbl.frb.load configure -state normal }
218	    set m .lsw.frbl.frb.import.m
219	    menubutton .lsw.frbl.frb.import -text $TXT(import) -menu $m
220	    menu $m
221	    foreach fmt $FILEFORMAT(_type,in,data) {
222		$m add command -label $fmt -command "ImportFile Data $fmt"
223	    }
224	    button .lsw.frbl.frb.save -text $TXT(save) -state disabled \
225		    -command { SaveFile all Data ; \
226		    .lsw.frbl.frb.save configure -state normal }
227	    # based on VR contribution
228	    set m .lsw.frbl.frb.export.m
229	    menubutton .lsw.frbl.frb.export -text $TXT(export) -menu $m \
230		-state disabled
231	    menu $m
232	    foreach fmt $FILEFORMAT(_type,out,data) {
233		$m add command -label $fmt -command "ExportFile all $fmt Data"
234	    }
235	    #--
236	    button .lsw.frbl.frb.search -text $TXT(search) -state disabled \
237		    -command { Search ; \
238		    .lsw.frbl.frb.search configure -state normal }
239	}
240    }
241
242    frame $MpW.frm
243    frame $MpW.frm.frmap1
244    set Map $MpW.frm.frmap1.map
245    canvas $Map -borderwidth 5 -relief groove -confine true \
246	    -scrollregion $MapBounds \
247	    -width $MapWidth -height $MapHeight \
248	    -xscrollincrement 1 -yscrollincrement 1 \
249	    -xscrollcommand "$MpW.frm.frmap1.mhscr set" \
250	    -yscrollcommand "$MpW.frm.frmap1.mvscr set"
251    bind $Map <Configure> { MapResize }
252    scrollbar $MpW.frm.frmap1.mvscr -command "ScrollMap y"
253    scrollbar $MpW.frm.frmap1.mhscr -command "ScrollMap x" -orient horizontal
254
255    frame $MpW.frm.frmap3
256    # need another frame for the map-main-window layout
257    frame $MpW.frm.frmap3.fr3
258    set fr3 $MpW.frm.frmap3.fr3
259    canvas $fr3.cv -width $MAPSCLENGTH -height 15 -relief flat
260    label $fr3.cv.val -width 10 -font $FixedFont
261    $fr3.cv create line 0 7.5 $MAPSCLENGTH 7.5 -arrow both \
262	    -fill $MAPCOLOUR(mapsel)
263    $fr3.cv create line 1 0 1 15 -fill $MAPCOLOUR(mapsel)
264    set l [expr $MAPSCLENGTH-1]
265    $fr3.cv create line $l 0 $l 15 -fill $MAPCOLOUR(mapsel)
266    $fr3.cv create window [expr $MAPSCLENGTH/2] 7.5 \
267	    -window $fr3.cv.val
268    menubutton $fr3.mn -text $TXT(change) -menu $fr3.mn.m
269    menu $fr3.mn.m
270    set nf 1 ; set nmd "" ; set MAPDISTVALS ""
271    set u $SUBDTUNIT ; set f $SUBDSCALE ; set ims [lindex $MAPSCALE 0]
272    set imsu [lreplace $MAPSCALE 0 0]
273    # map scale in meters/pixel
274    if { $imsu == [lindex $MAPDISTUNITS($DISTUNIT) 0] } {
275	set ds $DSCALE
276    } else { set ds $SUBDSCALE }
277    set MapScale [expr $ims*$ds*1000.0/$MAPSCLENGTH]
278    foreach d $MAPDISTS {
279	set v [lindex $d 0]
280	if { $v == 1 } {
281	    set u $DTUNIT ; set f 1
282	}
283	set ad [expr $v*$f] ; set t "$v $u"
284	lappend nmd $t ; lappend MAPDISTVALS $ad
285	$fr3.mn.m add radiobutton -label $t -value $t \
286	    -variable MapScaleButton -selectcolor $COLOUR(check) \
287	    -command "MapScaleSet $ad"
288	if { $v == $ims } {
289	    # cannot call MapScaleSet yet!
290	    set nf 0 ; set MapScInitVal $ad
291	    set MapScaleButton $t
292	    $fr3.cv.val configure -text $t
293	}
294    }
295    if { $nf } {
296	if { $imsu != $DTUNIT && $imsu != $SUBDTUNIT && \
297		[lsearch -exact $MAPDISTUNITS($DISTUNIT) $imsu] == -1 } {
298	    GMMessage "$MESS(baddistunit): $imsu"
299	} else {
300	    GMMessage "$MESS(badscale): $MAPSCALE"
301	}
302	set MapScInitVal 1 ; set t "1 $DTUNIT"
303	set MapScaleButton $t
304	$fr3.cv.val configure -text "1 $DTUNIT"
305    }
306    # labels in map scale menu aligned with km values in $MAPDISTVALS
307    set MAPDISTS $nmd
308
309    frame $fr3.sep -height 6 -bg $COLOUR(dialbg) -width 5
310    set mb $fr3.sh
311    menubutton $mb -text $TXT(items) -menu $mb.m
312    menu $mb.m
313    foreach op "loc disp clr" lb "locate displ clear" exc "GR _ GR" \
314	    fp "SelectApplyMapped SelectApplyUnmapped SelectApplyMapped" \
315	    cm "Locate PutMap UnMap" mode "single many many" {
316	set mn $mb.m$op
317	$mb.m add cascade -label $TXT($lb) -menu $mn -state disabled
318	menu $mn
319	foreach wh $TYPES {
320	    if { $wh != $exc } {
321		$mn add command -label $TXT(name$wh) \
322			-command "$fp $wh $mode $cm"
323	    }
324	}
325    }
326    $mb.mloc insert 0 command -label $TXT(prevctr) -command LocatePrevious
327    # DJG contribution
328    $mb.m add cascade -label "$TXT(mkgrp)..." -menu $mb.m.mkg
329    menu $mb.m.mkg
330    $mb.m.mkg add command -label $TXT(dispitems) -command "NewGroupFromMap 1"
331    $mb.m.mkg add command -label $TXT(hiditems) -command "NewGroupFromMap 0"
332    #--
333    set WConf(mapstate) [list [list menu [list [list $mb.m [list 0 2]]]]]
334    lappend WConf(datastate) [list menu [list [list $mb.m 1]]]
335
336    frame $MpW.frmi
337
338    set ltypes $TYPES
339    if { $SUPPORTLAPS } { lappend ltypes LAP }
340    switch $MWINDOWSCONF {
341	lists {
342	    set WConf(mapdatum) "$MpW.frmi.frcoords.dtitle \
343		    $MpW.frmi.frcoords.ptitle"
344	    lappend WConf(mapstate) \
345		[list button \
346		     [list $MpW.frmi.frmbs.msave $MpW.frmi.frmbs.mprint \
347			  $MpW.frmi.frmbs.mclear $MpW.frmi.frmbs.mft]]
348	    set WConf(mapstateback) \
349		[list [list menu [list \
350				      [list $MpW.frmi.frmbs.mback.m \
351					   [list 1 2 3 4]]]]]
352	    set WConf(additemstate) ""
353
354	    set bl [Measure $TXT(backgrnd)]
355	    frame $MpW.frmi.frmbs -borderwidth 2
356	    label $MpW.frmi.frmbs.mtitle -text $TXT(map)
357	    menubutton $MpW.frmi.frmbs.grid -textvariable MapPFormat \
358		    -width 8 -menu $MpW.frmi.frmbs.grid.m
359	    menu $MpW.frmi.frmbs.grid.m -postcommand \
360		"FillPFormtMenu $MpW.frmi.frmbs.grid.m ChangeMapPFormat"
361	    set mb $MpW.frmi.frmbs.grdatum
362	    menubutton $mb -textvariable MapPFDatum \
363		    -width $DATUMWIDTH -menu $mb.m
364	    menu $mb.m -postcommand "FillDatumMenu $mb.m ChangeMPFDatum"
365
366	    label $MpW.frmi.frmbs.zone -textvariable MapZone -width 4 \
367		    -relief sunken
368	    label $MpW.frmi.frmbs.xcoord -textvariable XCoord -width 11 \
369		    -relief sunken
370	    label $MpW.frmi.frmbs.ycoord -textvariable YCoord -width 11 \
371		    -relief sunken
372	    if { $NoImgLib } {
373		button $MpW.frmi.frmbs.msave -text "$TXT(saveto) PS" \
374			-command "SaveMap PS ; \
375		              $MpW.frmi.frmbs.msave configure -state normal" \
376			-state disabled -width $bl
377	    } else {
378		set m $MpW.frmi.frmbs.msave.m
379		menubutton $MpW.frmi.frmbs.msave -text "$TXT(saveto)..." \
380			-menu $m -state disabled -width $bl
381		menu $m
382		$m add command -label PS -command { SaveMap PS }
383		foreach f $ImgOutFormats {
384		    $m add command -label $f -command "SaveMap $f"
385		}
386	    }
387	    button $MpW.frmi.frmbs.mprint -text $TXT(print) \
388		    -command "PrintMap ; \
389		              $MpW.frmi.frmbs.mprint configure -state normal" \
390		    -state disabled -width $bl
391	    menubutton $MpW.frmi.frmbs.mback -text $TXT(backgrnd) -width $bl \
392		    -menu $MpW.frmi.frmbs.mback.m
393	    set mbmn $MpW.frmi.frmbs.mback.m
394	    menu $mbmn
395	    # order of entries used in file map.tcl
396	    $mbmn add cascade -label $TXT(loadmback) -menu $mbmn.m
397	    menu $mbmn.m
398	    $mbmn.m add command -label $TXT(fromfile) -command LoadMapBack
399	    menu $mbmn.m.defs \
400		-postcommand [list FillDefsMenu backgrnd $mbmn.m.defs \
401				  LoadMapBack]
402	    $mbmn.m add cascade -label $TXT(fromdef) -menu $mbmn.m.defs
403	    foreach f [list $TXT(savemback) $TXT(exportTFW) $TXT(chgmback) \
404		            $TXT(clearmback)] \
405		    c {SaveMapBack ExportMapTFW ChangeMapBack ClearMapBack} \
406		    s {normal disabled disabled disabled disabled} {
407		$mbmn add command -label $f -command $c -state $s
408	    }
409	    button $MpW.frmi.frmbs.mclear -text $TXT(clear) -state disabled \
410		    -width $bl \
411		    -command "ClearMap ; \
412		    $MpW.frmi.frmbs.mclear configure -state normal"
413	    button $MpW.frmi.frmbs.mft -text $TXT(optMAPFONT) \
414		-state disabled -width $bl \
415		-command "CanvasChangeFont $Map MapFont MapFont;
416		    $MpW.frmi.frmbs.mft configure -state normal"
417
418	    frame $MpW.frmi.frcoords -borderwidth 2
419	    menubutton $MpW.frmi.frcoords.dtitle -text Datum \
420		    -menu $MpW.frmi.frcoords.dtitle.m
421	    set dm $MpW.frmi.frcoords.dtitle.m
422	    menu $dm -postcommand "FillDatumMenu $dm ChangeMapDatum"
423	    label $MpW.frmi.frcoords.datum -textvariable Datum \
424		    -width $DATUMWIDTH
425	    menubutton $MpW.frmi.frcoords.ptitle -text $TXT(projection) \
426		    -menu $MpW.frmi.frcoords.ptitle.m
427	    menu $MpW.frmi.frcoords.ptitle.m \
428		    -postcommand "FillProjsMenu $MpW.frmi.frcoords.ptitle.m \
429		                   MAPKNOWNPROJS MapProjectionIs"
430	    label $MpW.frmi.frcoords.proj -textvariable MapProjTitle \
431		    -width 20
432	    label $MpW.frmi.frcoords.ttitle -relief raised -text $TXT(transf)
433	    label $MpW.frmi.frcoords.transf -textvariable MapTransfTitle \
434		     -width 20
435
436	    set defsmnbt $MpW.frmi.frcoords.udefs
437	}
438	map {
439	    frame $MpW.frm.top -borderwidth 2
440	    frame $MpW.frm.top.frmap0
441	    # to be filled in by proc ToTravel
442	    frame $MpW.frm.top.frmapT
443	    set WConf(travel,fr) $MpW.frm.top.frmapT
444	    set WConf(travel,alt) [set fr0 $MpW.frm.top.frmap0]
445	    set gtit $fr0.title
446
447	    menubutton $fr0.db -text $TXT(nameData) -width $mt -menu $fr0.db.m
448	    menu $fr0.db.m
449	    $fr0.db.m add command -label "$TXT(load) ..." \
450		    -command "LoadFile Data"
451	    set m $fr0.db.m.import
452	    menu $m
453	    $fr0.db.m add cascade -label "$TXT(import) ..." -menu $m
454	    foreach fmt $FILEFORMAT(_type,in,data) {
455		$m add command -label $fmt -command "ImportFile Data $fmt"
456	    }
457	    $fr0.db.m add command -label "$TXT(save) ..." \
458		    -command "SaveFile all Data" -state disabled
459	    # VR contribution
460	    set m $fr0.db.m.export
461	    menu $m
462	    $fr0.db.m add cascade -label "$TXT(export) ..." -menu $m \
463		-state disabled
464	    foreach fmt $FILEFORMAT(_type,out,data) {
465		$m add command -label $fmt -command "ExportFile all $fmt Data"
466	    }
467	    #--
468	    $fr0.db.m add command -label $TXT(nameLists) \
469		    -command "ToggleWindow .lsw $LPOSX $LPOSY"
470	    $fr0.db.m add command -label "$TXT(search) ..." -command Search \
471		    -state disabled
472	    foreach i $ltypes {
473		set openits [format $TXT(openits) $i]
474		set m $fr0.db.m.e$i
475		$fr0.db.m add cascade -label $TXT(name$i) -menu $m
476		menu $m
477		if { $i == "GR" } {
478		    set tits [list $TXT(newGR) $openits $TXT(clearall) \
479			       "$TXT(loadgrels) ..." $TXT(count)]
480		    set coms [list NewItem OpenSelItems ClearList \
481				  LoadGREls Count]
482		    set sts "normal disabled disabled disabled normal"
483		    set im 4
484		    set imp importgrels ; set impst disabled
485		    set imppr ImportGREls
486		    set acts "save saveels"
487		    set prs "SaveFile SaveGREls"
488		    set exp exportels ; set exppr ExportGREls
489		} elseif { $i != "LAP" } {
490		    set tits [list $TXT(new$i) $openits $TXT(clearall) \
491				  $TXT(count)]
492		    set coms [list NewItem OpenSelItems ClearList Count]
493		    set sts "normal disabled disabled normal"
494		    set im 3
495		    set imp import ; set impst normal
496		    set imppr ImportFile
497		    set acts save ; set prs SaveFile
498		    set exp export ; set exppr ExportFile
499		} else {
500		    # LAP
501		    set tits [list $openits $TXT(clearall) $TXT(count)]
502		    set coms "OpenSelItems ClearList Count"
503		    set sts "disabled disabled normal"
504		    set im 2
505		    set imp "" ; set impst "" ; set imppr ""
506		    set acts save ; set prs SaveFile
507		    set exp "" ; set exppr ""
508		}
509		foreach l $tits c $coms s $sts {
510		    $m add command -label $l -command "$c $i" -state $s
511		}
512		foreach ip $imp s $impst p $imppr {
513		    $m insert $im cascade -label "$TXT($ip) ..." \
514			    -menu $m.$ip -state $s
515		    menu $m.$ip
516		    foreach fmt $FILEFORMAT(_type,in,$i) {
517			regsub -all { } $fmt {_} gfmt
518			$m.$ip add command -label $fmt -command "$p $i $gfmt"
519		    }
520		    incr im
521		}
522		foreach a $acts p $prs {
523		    $m insert $im cascade -label "$TXT($a) ..." \
524			    -menu $m.$a -state disabled
525		    menu $m.$a
526		    $m.$a add command -label $TXT(all) -command "$p all $i"
527		    $m.$a add command -label "$TXT(select) ..." \
528			    -command "$p select $i"
529		    incr im
530		}
531		foreach ep $exp p $exppr {
532		    $m insert $im cascade -label "$TXT($ep) ..." \
533			    -menu $m.$ep -state disabled
534		    menu $m.$ep
535		    foreach fmt $FILEFORMAT(_type,out,$i) {
536			regsub -all { } $fmt {_} gfmt
537			$m.$ep add cascade -label $fmt -menu $m.$ep.f$gfmt
538			menu $m.$ep.f$gfmt
539			$m.$ep.f$gfmt add command -label $TXT(all) \
540				-command "$p all $gfmt $i"
541			$m.$ep.f$gfmt add command -label "$TXT(select) ..." \
542				-command "$p select $gfmt $i"
543		    }
544		    incr im
545		}
546		if { $i == "WP" } {
547		    $m insert [expr [$m index end]-1] cascade \
548			-label $TXT(chgname) -menu $m.ren -state disabled
549		    menu $m.ren
550		    menu $m.ren.m -postcommand \
551			[list FillDefsMenu renamethod $m.ren.m WPChangeNames]
552		    $m.ren add cascade -label $TXT(use) -menu $m.ren.m
553		    $m.ren add command -label $TXT(define) \
554			-command "WPChangeNames \[Define renamethod\]"
555		}
556	    }
557
558	    set RcMenu $fr0.rcw.m
559	    menubutton $fr0.rcw -text $TXT(GPSrec) -width $mt -menu $RcMenu
560	    menubutton $fr0.map -text $TXT(nameMap) -width $mt -menu $fr0.map.m
561	    menu $fr0.map.m
562	    # order of entries used in file map.tcl (proc SetMapBounds)
563	    if { $NoImgLib } {
564		$fr0.map.m add command -label "$TXT(saveto) PS" \
565			-command { SaveMap PS } -state disabled
566	    } else {
567		set m $fr0.map.mapsave
568		$fr0.map.m add cascade -label "$TXT(saveto)..." -menu $m \
569			 -state disabled
570		menu $m
571		$m add command -label PS -command { SaveMap PS }
572		foreach f $ImgOutFormats {
573		    $m add command -label $f -command "SaveMap $f"
574		}
575	    }
576	    $fr0.map.m add command -label $TXT(print) -command PrintMap \
577		    -state disabled
578	    $fr0.map.m add cascade -label $TXT(backgrnd) -menu $fr0.map.mback
579	    menu $fr0.map.mback
580	    $fr0.map.mback add cascade -label $TXT(loadmback) \
581		-menu $fr0.map.mback.m
582	    menu $fr0.map.mback.m
583	    $fr0.map.mback.m add command -label $TXT(fromfile) \
584		-command LoadMapBack
585	    menu $fr0.map.mback.m.defs \
586		-postcommand [list FillDefsMenu backgrnd \
587				  $fr0.map.mback.m.defs LoadMapBack]
588	    $fr0.map.mback.m add cascade -label $TXT(fromdef) \
589		-menu $fr0.map.mback.m.defs
590	    foreach f [list $TXT(savemback) $TXT(exportTFW) $TXT(chgmback) \
591		            $TXT(clearmback)] \
592		    c {SaveMapBack ExportMapTFW ChangeMapBack ClearMapBack} \
593		    s {disabled disabled disabled disabled} {
594		$fr0.map.mback add command -label $f -command $c -state $s
595	    }
596	    $fr0.map.m add command -label $TXT(clear) -command ClearMap \
597		    -state disabled
598	    $fr0.map.m add command -label $TXT(optMAPFONT) \
599		    -command "CanvasChangeFont $Map MapFont MapFont"
600
601	    set defsmnbt $fr0.udefs
602
603	    button $fr0.options -text $TXT(options) -width $mt \
604		    -command "SetOptions ; \
605		    $fr0.options configure -state normal"
606
607	    frame $MpW.frm.frmap3.fr4 -borderwidth 1 -bg $COLOUR(messbg)
608	    set fr4 $MpW.frm.frmap3.fr4
609
610	    menubutton $fr4.datum -textvariable Datum -menu $fr4.datum.m \
611		    -width $DATUMWIDTH
612	    menu $fr4.datum.m \
613		    -postcommand "FillDatumMenu $fr4.datum.m ChangeMapDatum"
614	    menubutton $fr4.proj -textvariable MapProjTitle -width 20 \
615		    -menu $fr4.proj.m
616	    menu $fr4.proj.m \
617		    -postcommand "FillProjsMenu $fr4.proj.m \
618		                     MAPKNOWNPROJS MapProjectionIs"
619	    label $fr4.transf -textvariable MapTransfTitle -relief raised \
620		    -width 20
621
622	    frame $MpW.frm.frmap3.fr5 -borderwidth 1 -bg $COLOUR(messbg)
623	    set fr5 $MpW.frm.frmap3.fr5
624
625	    menubutton $fr5.grid -textvariable MapPFormat -width 8 \
626		    -menu $fr5.grid.m
627	    menu $fr5.grid.m \
628		    -postcommand "FillPFormtMenu $fr5.grid.m ChangeMapPFormat"
629	    label $fr5.zone -textvariable MapZone -width 4 -relief sunken
630	    label $fr5.xcoord -textvariable XCoord -width 11 -relief sunken
631	    label $fr5.ycoord -textvariable YCoord -width 11 -relief sunken
632	    menubutton $fr5.grdat -textvariable MapPFDatum \
633		    -width $DATUMWIDTH -menu $fr5.grdat.m
634	    menu $fr5.grdat.m \
635		    -postcommand "FillDatumMenu $fr5.grdat.m ChangeMPFDatum"
636
637	    set WConf(mapdatum) "$fr4.datum $fr4.proj"
638	    lappend WConf(mapstate) \
639		[list menu [list [list $fr0.map.m [list 0 1 3 4]]]]
640	    set WConf(mapstateback) \
641		[list [list menu [list \
642				      [list $fr0.map.mback [list 1 2 3 4]]]]]
643	    set WConf(additemstate) $fr0.db.m.e
644	    lappend WConf(datastate) \
645		    [list menu [list [list $fr0.db.m [list 2 3 5]]]] \
646		    [list button [list .lsw.frbl.frb.save \
647				      .lsw.frbl.frb.export \
648				      .lsw.frbl.frb.search]]
649	}
650    }
651
652    set mn $defsmnbt.mn
653    menubutton $defsmnbt -text $TXT(defs) -menu $mn
654    menu $mn
655    $mn add cascade -label $TXT(projection) -menu $mn.proj
656    menu $mn.proj
657    $mn.proj add command -label $TXT(define) -command DefineProjection
658    menu $mn.proj.mn \
659	    -postcommand "FillProjsMenu $mn.proj.mn UProjs OpenUserProjection"
660    $mn.proj add cascade -label "$TXT(open)..." -menu $mn.proj.mn
661    foreach t {datum ellpsd backgrnd renamethod plugin} {
662	$mn add separator
663	$mn add cascade -label $TXT($t) -menu $mn.$t
664	menu $mn.$t
665	$mn.$t add command -label $TXT(define) -command "Define $t"
666	menu $mn.$t.mn -postcommand [list FillDefsMenu $t $mn.$t.mn \
667					 [list Inspect $t]]
668	$mn.$t add cascade -label "$TXT(open)..." -menu $mn.$t.mn
669    }
670    # menu used for plug-ins (see array PLGSWelcomed, plugins.tcl)
671    menu $mn.plugin.exec
672    $mn.plugin add cascade -label "$TXT(use)..." -menu $mn.plugin.exec
673    $mn add separator
674    $mn add command -label $TXT(syusrmenu) -command SymbolCustomMenu
675
676    if { $SmallLogo == "" } {
677	menubutton $gtit -text "GPS Manager" -menu $gtit.m
678    } else {
679	menubutton $gtit -image $SmallLogo -menu $gtit.m
680    }
681    menu $gtit.m
682    $gtit.m add command -label $TXT(about) -command About
683    $gtit.m add command -label $TXT(exit) -command QuitNow
684
685    set tw [Measure $TXT(nameWP)]
686    set bw [Measure $TXT(clear)]
687    foreach i $ltypes {
688	set openits [format $TXT(openits) $i]
689	set EdWindow($i) .gm$i ; set ListInds($i) ""
690	set GMEd($i,Show) 0
691
692	set n $TXT(name$i)
693	set List($i) $LsW.frl$i.frl.box
694	frame $LsW.frl$i -borderwidth 2
695	frame $LsW.frl$i.frb
696	menubutton $LsW.frl$i.frb.file -text $n -width $tw \
697		-menu $LsW.frl$i.frb.file.m
698	menu $LsW.frl$i.frb.file.m
699	frame $LsW.frl$i.frl
700	listbox $LsW.frl$i.frl.box -height $LISTHEIGHT -width $LISTWIDTH \
701 	    -yscrollcommand "$LsW.frl$i.frl.bscr set" \
702 	    -selectmode single -exportselection 1
703	# SH contribution: no such bindings in non-unix systems
704	if { $UNIX } {
705	    bind $LsW.frl$i.frl.box <Enter> { focus %W }
706	    bind $LsW.frl$i.frl.box <Leave> "focus $LsW"
707	}
708	bind $LsW.frl$i.frl.box <Double-1> "OpenListItem $i"
709	bind $LsW.frl$i.frl.box <Key> { ScrollListIndex %W %A }
710	scrollbar $LsW.frl$i.frl.bscr -command "$LsW.frl$i.frl.box yview"
711	# BSB contribution: wheelmouse scrolling
712	Mscroll $LsW.frl$i.frl.box
713
714	# order of menu entries is used elsewhere!
715	if { $i == "GR" } {
716	    set tits [list $TXT(newGR) $openits $TXT(clearall) \
717			  "$TXT(load) ..." "$TXT(loadgrels) ..." $TXT(count)]
718	    set coms "NewItem OpenSelItems ClearList LoadFile LoadGREls Count"
719	    set sts "normal disabled disabled normal disabled normal"
720	    set im 5
721	    set imp importgrels ; set impst disabled
722	    set imppr ImportGREls
723	    set acts "save saveels"
724	    set prs "SaveFile SaveGREls"
725	    set exp exportels ; set exppr ExportGREls
726	} elseif { $i != "LAP" } {
727	    set tits [list $TXT(new$i) $openits $TXT(clearall) \
728			  "$TXT(load) ..." $TXT(count)]
729	    set coms "NewItem OpenSelItems ClearList LoadFile Count"
730	    set sts "normal disabled disabled normal normal"
731	    set im 4
732	    set imp import ; set impst normal
733	    set imppr ImportFile
734	    set acts save ; set prs SaveFile
735	    set exp export ; set exppr ExportFile
736	} else {
737	    # LAP
738	    set tits [list $openits $TXT(clearall) "$TXT(load) ..." \
739			  $TXT(count)]
740	    set coms "OpenSelItems ClearList LoadFile Count"
741	    set sts "disabled disabled normal normal"
742	    set im 3
743	    set imp "" ; set impst "" ; set imppr ""
744	    set acts save ; set prs SaveFile
745	    set exp "" ; set exppr ""
746	}
747	set m $LsW.frl$i.frb.file.m
748	foreach l $tits c $coms s $sts {
749	    $m add command -label $l -command "$c $i" -state $s
750	}
751	foreach ip $imp s $impst p $imppr {
752	    $m insert $im cascade -label "$TXT($ip) ..." -menu $m.$ip -state $s
753	    menu $m.$ip
754	    foreach fmt $FILEFORMAT(_type,in,$i) {
755		$m.$ip add command -label $fmt -command "$p $i $fmt"
756	    }
757	    incr im
758	}
759	foreach a $acts p $prs {
760	    $m insert $im cascade -label "$TXT($a) ..." \
761		    -menu $m.$a -state disabled
762	    menu $m.$a
763	    $m.$a add command -label $TXT(all) -command "$p all $i"
764	    $m.$a add command -label "$TXT(select) ..." -command "$p select $i"
765	    incr im
766	}
767	foreach ep $exp p $exppr {
768	    $m insert $im cascade -label "$TXT($ep) ..." \
769		    -menu $m.$ep -state disabled
770	    menu $m.$ep
771	    foreach fmt $FILEFORMAT(_type,out,$i) {
772		$m.$ep add cascade -label $fmt -menu $m.$ep.f$fmt
773		menu $m.$ep.f$fmt
774		$m.$ep.f$fmt add command -label $TXT(all) \
775			-command "$p all $fmt $i"
776		$m.$ep.f$fmt add command -label "$TXT(select) ..." \
777			-command "$p select $fmt $i"
778	    }
779	    incr im
780	}
781	if { $i == "WP" } {
782	    $m insert [expr [$m index end]-1] cascade -label $TXT(chgname) \
783		-menu $m.ren -state disabled
784	    menu $m.ren
785	    menu $m.ren.m -postcommand [list FillDefsMenu \
786					 renamethod $m.ren.m WPChangeNames]
787	    $m.ren add cascade -label $TXT(use) -menu $m.ren.m
788	    $m.ren add command -label $TXT(define) \
789		-command "WPChangeNames \[Define renamethod\]"
790	}
791    }
792    foreach t $TYPES {
793	bind $LsW.frl$t.frl.box <Button-3> \
794	    "ToggleDisplayItem $t \[%W nearest %y\]"
795    }
796
797    frame $RcW.frgps -borderwidth 2
798    if { $MYGPS == "Garmin" } {
799	global MyProdDescr
800
801	set MyProdDescr $TXT(GPSrec)
802	label $RcW.frgps.title -width 40 -textvariable MyProdDescr
803    } else {
804	label $RcW.frgps.title -text $TXT(GPSrec)
805    }
806
807    # receiver window; create and fill also receiver menu
808    # changes here should be reflected in procs DisableGPS and EnableGPs
809    #  in file gpsinfo.tcl
810    menu $RcMenu
811    $RcMenu add command -label $TXT(recwindow) \
812	    -command "ToggleWindow .rcw $RPOSX $RPOSY"
813    $RcMenu add separator
814    menu $RcMenu.dev
815    menu $RcMenu.pm
816    $RcMenu add cascade -label $TXT(optDEFSPORT) -menu $RcMenu.dev
817    $RcMenu add cascade -label $TXT(protcl) -menu $RcMenu.pm
818
819    frame $RcW.frgps.dev -borderwidth 2 -bg $COLOUR(messbg)
820    set fdev $RcW.frgps.dev
821    # changing device when not connected
822    label $fdev.tdev -text $TXT(optDEFSPORT)
823    entry $fdev.dev -width 14 -textvariable SERIALPORT
824    $RcMenu.dev add command -label $TXT(chgdev) -command GPSChangeDevice
825    # changing baud rate when connected
826    if { $MYGPS == "Garmin" } {
827	menubutton $fdev.baud -text $TXT(optSERIALBAUD) \
828	    -menu $fdev.baud.mn -state disabled
829	menu $fdev.baud.mn
830	$RcMenu.dev add cascade -label $TXT(optSERIALBAUD) \
831	    -menu $RcMenu.dev.baud -state disabled
832	menu $RcMenu.dev.tbaud
833	foreach b $RECBAUDS {
834	    $fdev.baud.mn add command -label $b -command "GPSChangeBaud $b"
835	    $RcMenu.dev.tbaud add command -label $b -command "GPSChangeBaud $b"
836	}
837    }
838
839    frame $RcW.frgps.prt -borderwidth 2 -bg $COLOUR(messbg)
840    set fprt $RcW.frgps.prt
841    menubutton $fprt.title -text $TXT(protcl) -menu $fprt.title.m
842    menu $fprt.title.m
843    set GPSProtocolExt $TXT($GPSProtocol)
844    foreach p $RECPROTOCOLS($MYGPS) {
845	$fprt.title.m add command -label $TXT($p) \
846		-command "GPSChangeProtocol $p"
847	$RcMenu.pm add radiobutton -label $TXT($p) -value $p \
848	    -variable GPSProtocolButton -selectcolor $COLOUR(check) \
849	    -command "GPSChangeProtocol $p"
850    }
851    set GPSProtocolButton $GPSProtocol
852    label $fprt.prot -textvariable GPSProtocolExt -width 16
853
854    if { $MYGPS != "Magellan" } {
855	frame $RcW.frgps.rlt -borderwidth 2 -bg $COLOUR(messbg)
856	set frlt $RcW.frgps.rlt
857	label $frlt.title -text $TXT(realtimelog)
858	menu $RcMenu.rtm
859	$RcMenu add cascade -label $TXT(realtimelog) -menu $RcMenu.rtm
860	$RcMenu.rtm add command -label $TXT(getlog) \
861		-command GPSRealTimeLogOnOff
862	$RcMenu.rtm add command -label $TXT(dolog) -command { set PVTState on }
863	$RcMenu.rtm add checkbutton -label $TXT(animation) \
864	        -offvalue 0 -onvalue 1 -variable RealTimeLogAnim \
865	        -selectcolor $COLOUR(check)
866	# Travel entry added below if Garmin
867
868	button $frlt.onoff -text $TXT(getlog) -width 10 \
869		-command "GPSRealTimeLogOnOff ; \
870		$frlt.onoff configure -state normal"
871	button $frlt.show -text $TXT(dolog) \
872		-command "set PVTState on ; $frlt.show configure -state normal"
873	button $frlt.anim -text $TXT(animation) \
874		-command "set RealTimeLogAnim 1 ; \
875		$frlt.anim configure -state normal"
876	set WConf(realtime) [list $frlt.onoff [list $RcMenu.rtm 0]]
877	set WConf(realtimetype) "button menuentry"
878	grid configure $frlt.title -row 0 -column 0 -columnspan 2 -sticky news
879	grid configure $frlt.onoff -row 1 -column 0 -rowspan 2 -sticky ew
880	grid configure $frlt.show -row 1 -column 1 -sticky news
881	grid configure $frlt.anim -row 2 -column 1 -sticky news
882	if { $MYGPS == "Garmin" } {
883	    $RcMenu.rtm add separator
884	    $RcMenu.rtm add command -label $TXT(travel) -command ToTravel
885	    button $frlt.trv -text $TXT(travel) \
886		    -command "$frlt.trv configure -state normal ; ToTravel"
887	    grid configure $frlt.trv -row 3 -column 0 -columnspan 2
888	}
889    } else {
890	set WConf(realtime) ""
891	set WConf(realtimetype) ""
892    }
893
894    frame $RcW.frgps.bs -borderwidth 2
895    set GPSState offline ; set GPSLabel $TXT(offline)
896    set r [Measure "Turn Off"]
897    button $RcW.frgps.bs.state -textvariable GPSLabel -fg $COLOUR(offline) \
898	    -width $r \
899	    -command { CheckGPS ; $RcW.frgps.bs.state configure -state normal }
900    bind $RcW.frgps.bs.state <Enter> { set GPSLabel $TXT(check) }
901    bind $RcW.frgps.bs.state <Leave> { set GPSLabel $TXT($GPSState) }
902    $RcMenu add command -accelerator $TXT(check) \
903	    -image $SYMBOLIMAGE(diamond_red) -command CheckGPS
904    button $RcW.frgps.bs.off -text $TXT(turnoff) -state disabled -width $r \
905	    -command TurnOff
906    $RcMenu add command -label $TXT(turnoff) -state disabled \
907	    -command TurnOff
908    set r [Measure $TXT(nameLAP)]
909    frame $RcW.frget -borderwidth 2
910    frame $RcW.frget.frget1
911    # the following frame only children are the buttons for types in $RECTYPES
912    frame $RcW.frget.frget2
913    label $RcW.frget.frget1.title -text $TXT(get)
914    # the following menu only entries are for types in $RECTYPES
915    menu $RcMenu.gm
916    set gmlst ""
917    $RcMenu add cascade -label $TXT(get) -state disabled -menu $RcMenu.gm
918    checkbutton $RcW.frget.frget1.displ -text $TXT(mapitems) \
919	    -variable GetDispl -onvalue 1 -offvalue 0 \
920	    -selectcolor $COLOUR(check)
921
922    # the following frame only children are the buttons for types in $RECTYPES
923    frame $RcW.frput -borderwidth 2
924    label $RcW.frput.title -text $TXT(put)
925    # the following menu only entries are for types in $RECTYPES
926    menu $RcMenu.ptm
927    set ptmlst ""
928    $RcMenu add cascade -label $TXT(put) -state disabled -menu $RcMenu.ptm
929    set gmix 0 ; set ptmix 0
930    foreach i $RECTYPES {
931	set n $TXT(name$i)
932	button $RcW.frget.frget2.get$i -text $n -width $r -state disabled \
933	    -command "GetFromGPS $i ; \
934	                 $RcW.frget.frget2.get$i configure -state normal"
935	$RcMenu.gm add command -label $n -command "GetFromGPS $i" \
936	    -state disabled
937	lappend gmlst rec,getmn,$i $gmix
938	incr gmix
939	# BSB contribution: no IC put button
940	if { $i != "IC" && $i != "LAP" } {
941	    menubutton $RcW.frput.put$i -text $n -width $r -state disabled \
942		    -menu $RcW.frput.put$i.m
943	    menu $RcW.frput.put$i.m
944	    $RcW.frput.put$i.m add command -label $TXT(all) \
945		    -command "PutOnGPS all $i"
946	    $RcW.frput.put$i.m add command -label "$TXT(select) ..." \
947		    -command "PutOnGPS select $i"
948	    menu $RcMenu.ptm.m$i
949	    $RcMenu.ptm add cascade -label $n -menu $RcMenu.ptm.m$i \
950		    -state disabled
951	    lappend ptmlst rec,putmn,$i $ptmix
952	    incr ptmix
953	    $RcMenu.ptm.m$i add command -label $TXT(all) \
954		    -command "PutOnGPS all $i"
955	    $RcMenu.ptm.m$i add command -label "$TXT(select) ..." \
956		    -command "PutOnGPS select $i"
957	    if { $AutoNumRts && $i == "RT" } {
958		$RcW.frput.put$i.m add command -label $TXT(numberfrom0) \
959		    -command ResetAutoNumberRT
960		$RcMenu.ptm.m$i add command -label $TXT(numberfrom0) \
961		    -command ResetAutoNumberRT
962	    }
963	}
964    }
965    # other information types that can be got from the receiver
966    foreach i $RECINFO {
967	set n $TXT(name$i)
968	button $RcW.frget.frget2.get$i -text $n -width $r -state disabled \
969	    -command "GetFromGPS $i ; \
970	                 $RcW.frget.frget2.get$i configure -state normal"
971	$RcMenu.gm add command -label $n -command "GetFromGPS $i" \
972	    -state disabled
973	lappend gmlst rec,getmn,$i $gmix
974	incr gmix
975    }
976    array set WConf $gmlst
977    array set WConf $ptmlst
978    set WConf(rec,getbs) [winfo children $RcW.frget.frget2]
979    set WConf(rec,putbs) [Delete [winfo children $RcW.frput] $RcW.frput.title]
980    # BSB contribution
981    if { $MYGPS == "Lowrance" } {
982	frame $RcW.frinfo -borderwidth 2
983	frame $RcW.frinfo1 -borderwidth 2
984	label $RcW.frinfo.tprod -relief raised -width 10 -text $TXT(prod)
985	label $RcW.frinfo.prod -width 16 -textvariable Prod
986	label $RcW.frinfo.twp -relief raised -width 19 -text $TXT(WPCapac)
987	label $RcW.frinfo.wp -width 6 -textvariable MAX(WP)
988	label $RcW.frinfo.trt -relief raised -width 16 -text $TXT(RTCapac)
989	label $RcW.frinfo.rt -width 6 -textvariable MAX(RT)
990	label $RcW.frinfo.tic -relief raised -width 16 -text $TXT(ICCapac)
991	label $RcW.frinfo.ic -width 6 -textvariable MAX(IC)
992	label $RcW.frinfo1.tprt -relief raised -width 10 -text $TXT(protcl)
993	label $RcW.frinfo1.prt -width 16 -textvariable Protv
994	label $RcW.frinfo1.ticg -relief raised -width 16 -text $TXT(ICGraph)
995	label $RcW.frinfo1.icg -width 6 -textvariable MAXICG
996	label $RcW.frinfo1.ttr -relief raised -width 16 -text $TXT(TRCapac)
997	label $RcW.frinfo1.tr -width 6 -textvariable MAX(TR)
998	label $RcW.frinfo1.twr -relief raised -width 19 -text $TXT(WPperRT)
999	label $RcW.frinfo1.wr -width 6 -textvariable MAXWPINROUTE
1000    }
1001    # end of BSB contribution
1002
1003    # packing
1004    if { $MWINDOWSCONF == "map" } {
1005	set c -1
1006	foreach b \
1007	    "$gtit $fr0.db $fr0.rcw $fr0.map $defsmnbt $fr0.options" {
1008	    grid $b -row 0 -column [incr c] -ipadx 3
1009	}
1010	grid $fr0
1011	pack $MpW.frm.top
1012    }
1013    grid $Map -row 0 -column 0 -sticky nesw
1014    grid $MpW.frm.frmap1.mvscr -row 0 -column 1 -sticky ns
1015    grid $MpW.frm.frmap1.mhscr -row 1 -column 0 -sticky ew
1016    grid rowconfigure $MpW.frm.frmap1 0 -weight 1
1017    grid columnconfigure $MpW.frm.frmap1 0 -weight 1
1018
1019    grid $fr3.cv -row 0 -column 0 -sticky nesw
1020    grid $fr3.mn -row 0 -column 1 -sticky nesw -padx 2
1021    grid $fr3.sep -row 0 -column 2 -sticky nesw -padx 10
1022    grid $fr3.sh -row 0 -column 3 -sticky nesw -padx 5
1023
1024    foreach i $ltypes {
1025	pack $LsW.frl$i.frl.box $LsW.frl$i.frl.bscr -side left \
1026		-fill y -expand 1
1027	pack $LsW.frl$i.frb.file -side top -pady 5
1028	pack $LsW.frl$i.frb $LsW.frl$i.frl -side top \
1029		-fill y -expand 1
1030	pack $LsW.frl$i -side left -fill y
1031    }
1032
1033    switch $MWINDOWSCONF {
1034	lists {
1035	    grid $fr3
1036	    pack $MpW.frm.frmap3 -pady 2 -side bottom
1037	    # must be the last one to be packed under $MpW.frm
1038	    pack $MpW.frm.frmap1 -expand 1 -fill both
1039
1040	    pack $defsmnbt $MpW.frmi.frcoords.transf \
1041		    $MpW.frmi.frcoords.ttitle $MpW.frmi.frcoords.proj \
1042		    $MpW.frmi.frcoords.ptitle $MpW.frmi.frcoords.datum \
1043		    $MpW.frmi.frcoords.dtitle -pady 2 -side bottom
1044	    pack $MpW.frmi.frmbs.mtitle $MpW.frmi.frmbs.grid \
1045		    $MpW.frmi.frmbs.grdatum \
1046		    $MpW.frmi.frmbs.zone $MpW.frmi.frmbs.xcoord \
1047		    $MpW.frmi.frmbs.ycoord $MpW.frmi.frmbs.msave \
1048		    $MpW.frmi.frmbs.mprint $MpW.frmi.frmbs.mback \
1049		    $MpW.frmi.frmbs.mclear $MpW.frmi.frmbs.mft -pady 5
1050
1051	    pack $MpW.frmi.frcoords -side top
1052	    pack $MpW.frmi.frmbs -side bottom
1053
1054	    pack $MpW.frm -side left -fill y -fill both -expand 1
1055	    pack $MpW.frmi -side left -fill y
1056	}
1057	map {
1058	    grid $fr4.datum -row 0 -column 0 -sticky nesw
1059	    grid $fr4.proj -row 0 -column 1 -sticky nesw -padx 3
1060	    grid $fr4.transf -row 0 -column 2 -sticky nesw -padx 3
1061
1062	    grid $fr5.grid -row 0 -column 0 -sticky nesw
1063	    grid $fr5.zone -row 0 -column 1 -sticky nesw -padx 3
1064	    grid $fr5.xcoord -row 0 -column 2 -sticky nesw -padx 3
1065	    grid $fr5.ycoord -row 0 -column 3 -sticky nesw -padx 3
1066	    grid $fr5.grdat -row 1 -column 0 -columnspan 4 -sticky nesw
1067
1068	    grid $fr3 -row 0 -column 0
1069	    grid $fr4 -row 1 -column 0
1070	    grid $fr5 -row 0 -column 1 -rowspan 2 -padx 10
1071
1072	    pack $MpW.frm.frmap3 -pady 2 -side bottom
1073	    # must be the last one to be packed under $MpW.frm
1074	    pack $MpW.frm.frmap1 -expand 1 -fill both
1075
1076	    pack $MpW.frm -expand 1 -fill both
1077	    pack $MpW -expand 1 -fill both
1078
1079	    pack .lsw.frbl.frb.load .lsw.frbl.frb.import .lsw.frbl.frb.save \
1080		.lsw.frbl.frb.export .lsw.frbl.frb.search -side left -padx 3
1081	    pack .lsw.frbl.frb $LsW -side top -pady 3
1082	    pack .lsw.tit .lsw.frbl -side top -pady 5
1083	}
1084    }
1085
1086    grid $RcW.frgps.dev.tdev $RcW.frgps.dev.dev
1087    if { $MYGPS == "Garmin" } {
1088	grid $RcW.frgps.dev.baud -columnspan 2
1089    }
1090    pack $RcW.frgps.prt.title $RcW.frgps.prt.prot -side left
1091    pack $RcW.frgps.bs.state $RcW.frgps.bs.off -side left -pady 2
1092    if { $MYGPS != "Magellan" } {
1093	pack $RcW.frgps.title $RcW.frgps.dev $RcW.frgps.prt $RcW.frgps.rlt \
1094	    $RcW.frgps.bs -side top -pady 5
1095    } else {
1096	pack $RcW.frgps.title $RcW.frgps.dev $RcW.frgps.prt $RcW.frgps.bs \
1097		-side top -pady 5
1098    }
1099    pack $RcW.frget.frget1.title $RcW.frget.frget1.displ -side left -padx 5
1100    foreach i [concat $RECTYPES $RECINFO] {
1101	pack $RcW.frget.frget2.get$i -side left -pady 2
1102    }
1103    pack $RcW.frget.frget1 $RcW.frget.frget2 -side top
1104    pack $RcW.frput.title -side top
1105    # BSB contribution: no IC put button
1106    foreach i $RECTYPES {
1107	if { $i != "IC" && $i != "LAP" } {
1108	    pack $RcW.frput.put$i -side left -pady 2
1109	}
1110    }
1111
1112    switch $MWINDOWSCONF {
1113	lists {
1114	    pack .lsw.frmb.dtitle .lsw.frmb.datum -pady 2 -side top
1115	    pack .lsw.frmb.frb.sep .lsw.frmb.frb.load .lsw.frmb.frb.import \
1116		.lsw.frmb.frb.save .lsw.frmb.frb.export .lsw.frmb.frb.search \
1117		.lsw.frmb.frb.sep2 -side top -pady 3 -fill x
1118	    pack .lsw.frmb.frb -pady 20 -side top
1119	    pack .lsw.frmb.opt -pady 5 -side bottom
1120	    pack .lsw.frmb.sep -pady 5 -side bottom -fill x
1121	    pack .lsw.frmb.rcw .lsw.frmb.mpw -pady 5 -side bottom
1122	    pack $LsW .lsw.frmb -side left -fill y
1123	    pack $gtit .lsw -side top -pady 3
1124
1125	    grid .mpw.top.frNT.tit -row 0 -column 0
1126	    grid .mpw.top.frNT
1127	    pack .mpw.top $MpW -side top -pady 3
1128	}
1129	map {
1130	    pack $RcW.frgps $RcW.frget $RcW.frput -side top -pady 5
1131	    pack .rcw.tit $RcW -side top -pady 3
1132
1133	    # BSB contribution
1134	    if { $MYGPS == "Lowrance" } {
1135		pack $RcW.frinfo1 -side bottom -pady 5
1136		pack $RcW.frinfo1.tprt $RcW.frinfo1.prt $RcW.frinfo1.twr \
1137			$RcW.frinfo1.wr $RcW.frinfo1.ticg $RcW.frinfo1.icg \
1138			$RcW.frinfo1.ttr $RcW.frinfo1.tr -side left -pady 2
1139		pack $RcW.frinfo -side bottom -pady 5
1140		pack $RcW.frinfo.tprod $RcW.frinfo.prod $RcW.frinfo.twp \
1141			$RcW.frinfo.wp $RcW.frinfo.trt $RcW.frinfo.rt \
1142			$RcW.frinfo.tic $RcW.frinfo.ic -side left -pady 2
1143	    }
1144	    # end of BSB contribution
1145	}
1146    }
1147
1148    SetMapBindings
1149
1150    AttachPlugIns .
1151
1152    # saved state
1153    if { [file readable $USvState] } {
1154	RestoreState
1155    }
1156    return
1157}
1158
1159proc About {} {
1160    # create modal dialog for displaying information about GPSMan
1161    #  single button: OK; binding: return
1162    global EPOSX EPOSY TXT
1163
1164    set gs [grab current]
1165    GMToplevel .about message +$EPOSX+$EPOSY {} \
1166        [list WM_DELETE_WINDOW  [list DestroyRGrabs .about $gs]] \
1167        [list <Key-Return> [list DestroyRGrabs .about $gs]]
1168
1169    AboutInfo .about
1170
1171    frame .about.fr.bt
1172    button .about.fr.ok -text $TXT(ok) -command [list DestroyRGrabs .about $gs]
1173    pack .about.fr.ok
1174    pack .about.fr -side top -pady 5
1175    RaiseWindow .about
1176    update idletasks
1177    grab .about
1178    return
1179}
1180
1181##### initializing variables and quitting
1182
1183proc GMStart {} {
1184    # initialize (most) global variables
1185    global Index Number Storage File Proc FDDatum \
1186	TYPES PROCTYPES CursorsChanged MapWidth MapHeight MAPW2 MAPH2 \
1187	AzimuthDegrees MapEmpty DataDefault DataIndex PositionFormat \
1188	DEFAULTSYMBOL DEFAULTDISPOPT Datum EMPTYSTR Anim \
1189	BalloonX BalloonY USERDIR RealTimeLogOn \
1190	RealTimeLogAnim PVTState USvState USvData USvMap \
1191	BITMAPS SERIALPORT DEFSPORT tcl_platform DEFTRTWIDTH DEFTTRWIDTH \
1192	DEFTLNWIDTH GPSProtocol RECPROTOCOLS GetDispl UNIX MAPCOLOUR \
1193	MapFont MAPFONT Travelling Travel TRAVELFONT NAMEWIDTH \
1194	MapMeasure DEFMAPPROJ DEFMAPPFRMT ALTUNIT AltUnit GMEd PlotWNo \
1195	FILEFORMAT DEFTRECPROTOCOL MapPFDatum DEFMAPPFDATUM \
1196	RealTimeGettingFix MAPWIDTH MAPHEIGHT GFShowInfo FromTimeOffset \
1197	RecCanChgBaud PlotFont PLOTFONT ReplNames
1198
1199    # BSB contribution: globals needed for Lowrance receivers
1200    global UnusedICInx UnusedWPInx MAX MYGPS
1201
1202    GlobalOptionsBindings
1203
1204    # I/O port
1205    if { $UNIX && $SERIALPORT == "" } {
1206	set SERIALPORT $DEFSPORT
1207    }
1208
1209       # receiver supports changing baud rate when connected
1210    set RecCanChgBaud 0
1211    if { $MYGPS == "Garmin" } {
1212	set GPSProtocol $DEFTRECPROTOCOL
1213	if { [regsub {^usb=} $SERIALPORT "" p] } {
1214	    # I/O port given as command argument
1215	    set SERIALPORT $p
1216	    set GPSProtocol garmin_usb
1217	}
1218    } else { set GPSProtocol [lindex $RECPROTOCOLS($MYGPS) 0] }
1219    set GetDispl 0
1220
1221    # data-base
1222    set Number(Data) 0
1223           # the first element in Storage(_) must be identifier storage
1224           #  and the last one the display state
1225           # WPNum needed only for Lowrance receivers
1226           # WPRoute is set separately because cannot be edited
1227           # WPAlt and TPalt are lists with altitude in metres,
1228           #  altitude in user unit and user unit (as $ALTUNIT);
1229           #  empty list stands for undefined, last 2 elements may
1230           #  be missing if user unit is metre
1231           # ??MBack is name of map background definition to load when item
1232           #  is displayed and the map is empty; empty string means undefined;
1233           #  not valid for GR and LAP
1234    set Storage(WP) {WPName WPNum WPCommt WPObs WPPFrmt WPPosn WPDatum
1235	             WPDate WPSymbol WPDispOpt WPAlt WPMBack WPHidden WPDispl}
1236    set DataDefault(WP) [list "" -1 "" "" $PositionFormat "" $Datum \
1237	    "" $DEFAULTSYMBOL $DEFAULTDISPOPT "" "" "" 0]
1238    set Storage(RT) {RTIdNumber RTCommt RTObs RTWPoints RTStages RTWidth
1239	             RTColour RTMBack RTDispl}
1240    set DataDefault(RT) [list "" "" "" "" "" $DEFTRTWIDTH $MAPCOLOUR(RT) "" 0]
1241    set stRS {RScommt RSlabel RShidden}
1242    set DataDefault(RS) [list "" "" ""]
1243    set Storage(TR) {TRName TRObs TRDatum TRTPoints TRSegStarts TRHidden
1244                     TRWidth TRColour TRMBack TRDispl}
1245    set DataDefault(TR) [list "" "" $Datum "" "" "" $DEFTTRWIDTH \
1246			     $MAPCOLOUR(TR) "" 0]
1247    set stTP {TPlatd TPlongd TPlatDMS TPlongDMS TPdate TPsecs TPalt TPdepth}
1248    set DataDefault(TP) [list "" "" "" "" "01-Jan-1988 00:00:00" 0 "" ""]
1249    set Storage(LN) {LNName LNObs LNDatum LNPFrmt LNLPoints LNSegStarts \
1250	             LNWidth LNColour LNMBack LNDispl}
1251    set DataDefault(LN) [list "" "" $Datum $PositionFormat "" "" $DEFTLNWIDTH \
1252 	                      $MAPCOLOUR(LN) "" 0]
1253    set stLP {LPposn LPalt}
1254    set DataDefault(LP) [list "" ""]
1255    set Storage(GR) {GRName GRObs GRConts GRDispl}
1256    set DataDefault(GR) [list "" "" "" 0]
1257    # LAPs should be considered here, just in case support for them is asked
1258    #  during the current session
1259    set types $TYPES ; set ptypes $PROCTYPES
1260    lappend types LAP ; lappend ptypes GMLap
1261    # LAPName is formatted date and is not to be edited
1262    # LAPStart is the time stamp (list with formatted date and secs)
1263    # LAPDispl is here only for uniformity; it should be always 0
1264    set Storage(LAP) {LAPName LAPObs LAPStart LAPDur LAPDist LAPBegPosn
1265	LAPEndPosn LAPCals LAPTRIx LAPPFrmt LAPDatum LAPDispl}
1266    set DataDefault(LAP) [list "" "" "" 0 0 "" "" 0 "" $PositionFormat \
1267			      $Datum 0]
1268    foreach wh $types proc $ptypes {
1269	set Index($wh) 0 ; set Number($wh) 0 ; set Proc($wh) $proc
1270	set k 0
1271	foreach da $Storage($wh) {
1272	    set DataIndex($da) $k ; incr k
1273	}
1274    }
1275    foreach d "RS TP LP" {
1276	set k 0
1277	foreach da [set st$d] {
1278	    set DataIndex($da) $k ; incr k
1279	}
1280    }
1281    set GMEd(TR,ptname) TP
1282    set GMEd(LN,ptname) LP
1283
1284    # files
1285    set filetypes {WP RT TR LN LAP GR Data WPDistBear WPNearest RTComp TRComp
1286                   Map Plot MapBkInfo Image PVTData Info tfwfile}
1287    foreach t $filetypes { set File($t) "" }
1288    set FDDatum ""
1289    set USvState [file join $USERDIR sstate]
1290    set USvData [file join $USERDIR sdata]
1291    set USvMap [file join $USERDIR smap]
1292    set FromTimeOffset ""
1293
1294    # foreign formats
1295    set FILEFORMAT(_type,in,data) [set FILEFORMAT(_type,out,data) ""]
1296    foreach t $TYPES {
1297	set FILEFORMAT(_type,in,$t) [set FILEFORMAT(_type,out,$t) ""]
1298    }
1299    foreach fmt $FILEFORMAT(names) {
1300	if { $fmt == "GPSMan" || \
1301		 ( ! [catch {set dep $FILEFORMAT($fmt,depends)}] && \
1302		   ! [eval $dep] ) } {
1303	    continue
1304	}
1305	if { [catch {set ts $FILEFORMAT($fmt,types)}] } {
1306	    foreach "in_ts out_ts" $FILEFORMAT($fmt,io_types) { break }
1307	} { set in_ts [set out_ts $ts] }
1308	if { ! [catch {set FILEFORMAT($fmt,GREls)}] } {
1309	    lappend in_ts GR ; lappend out_ts GR
1310	}
1311	if { $FILEFORMAT($fmt,filetype) == "data" } {
1312	    foreach m $FILEFORMAT($fmt,mode) {
1313		lappend FILEFORMAT(_type,$m,data) $fmt
1314	    }
1315	}
1316	foreach m $FILEFORMAT($fmt,mode) {
1317	    foreach t [set ${m}_ts] {
1318		lappend FILEFORMAT(_type,$m,$t) $fmt
1319	    }
1320	}
1321    }
1322    foreach i [array names FILEFORMAT _type,*] {
1323	set FILEFORMAT($i) [lsort -dictionary $FILEFORMAT($i)]
1324    }
1325
1326    # real-time and travel/navigation
1327    set RealTimeLogOn 0 ; set RealTimeLogAnim 0 ; set RealTimeGettingFix 0
1328    set PVTState abort
1329    set Travelling 0
1330    if { [set Travel(font) $TRAVELFONT] == "default" } {
1331	set Travel(font) $TkDefaultFont
1332    }
1333    array set Travel {
1334	tosave {conf,1 conf,2 travel,cdsp font warn warn,* mindist offroad
1335	    chggparam chggwparam chggix}
1336	conf,1  {lab+fix lab+speed c_trkcts c_trn c_vel_z lab+hour
1337	lab+alt lab+nxtWP lab+prvWP lab+dist lab+vmg lab+ete lab+eta
1338	lab+xtk lab+cts}
1339	conf,2  {lab+fix lab+speed c_trkcts lab+hour lab+pos lab+alt lab+trk
1340	         c_vel_z}
1341	travel,cdsp 1
1342	warn  1
1343	warn,prox 0
1344	warn,prox,wpn ""
1345	warn,prox,dst 1
1346	warn,prox,level medium
1347	warn,anchor 0
1348	warn,anchor,wpn ""
1349	warn,anchor,dst 1
1350	warn,anchor,level medium
1351	warn,speed 0
1352	warn,speed,max 50
1353	warn,speed,level high
1354	warn,vspeed 0
1355	warn,vspeed,min -6
1356	warn,vspeed,max 6
1357	warn,vspeed,level medium
1358	warn,trn 0
1359	warn,trn,max 60
1360	warn,trn,level low
1361	warn,xtk 0
1362	warn,xtk,max 5
1363	warn,xtk,level low
1364	mindist 0.1
1365	offroad 0
1366	chggparam 0.8
1367	chggwparam 0.9
1368	chggix 2
1369    }
1370    trace variable Travel(chggix) w TravelChgGParam
1371    set Travel(elsizes) "4 4 8 23 5 4 $NAMEWIDTH $NAMEWIDTH 9 9 4 4 4 4 4"
1372    array set Travel {
1373	els
1374	  {fix speed hour pos alt trk nxtWP prvWP ete eta vmg xtk cts trn dist}
1375	cvss {c_trkcts c_trn c_vel_z}
1376	trav,els {fix speed hour pos alt trk}
1377	trav,cvels {{c_vel_z vel_z}}
1378	displays {1 2}
1379	warnings {prox anchor speed trn vspeed xtk}
1380	nav 0
1381	nav,els {nxtWP prvWP ete eta vmg xtk cts trn dist}
1382	nav,cvels {{c_trkcts cts}}
1383	nav,over land
1384	nav,datum {WGS 84}
1385	nav,maxdtime 5
1386	posns {}
1387	prevtime -1
1388	prevposn {}
1389	warncancel {}
1390	nav,pmode 1
1391	nav,pnear 0
1392	nav,prvrs 0
1393	chggvals {0.95 0.9 0.8 0.7 0.6}
1394	chggwvals {0.98 0.95 0.9 0.8 0.7}
1395	chggmaxix 4
1396    }
1397    # conditions for issuing warnings and their contents
1398    #  variables assumed to be defined in the context of execution,
1399    #  apart from $TXT():
1400    #    $posn, $datum, $speed (user units), $vel_z (m/s), $trn (-180..180),
1401    #    $xtk (signed, user units)
1402    #  any of these, except $posn, $datum, may be "" for undefined
1403    array set Travel {
1404	warn:prox,cond {
1405	    [ComputeDist $posn $Travel(warn,prox,pos) $datum] < $Travel(warn,prox,dst)
1406	}
1407	warn:prox,cont {[format $TXT(trvwarrv) $Travel(warn,prox,wpn)]}
1408	warn:anchor,cond {
1409	    [ComputeDist $posn $Travel(warn,anchor,pos) $datum] > $Travel(warn,anchor,dst)
1410	}
1411	warn:anchor,cont {[format $TXT(trvwleave) $Travel(warn,anchor,wpn)]}
1412	warn:speed,cond { $speed != {} && $speed > $Travel(warn,speed,max) }
1413	warn:speed,cont {[format $TXT(trvwspeed) $Travel(warn,speed,max)]}
1414	warn:trn,cond { $trn != {} && abs($trn) > $Travel(warn,trn,max) }
1415	warn:trn,cont {[format $TXT(trvwtrn) $Travel(warn,trn,max)]}
1416	warn:vspeed,cond {
1417	    $vel_z != {} && ($vel_z < $Travel(warn,vspeed,min) || $vel_z > $Travel(warn,vspeed,max))
1418	}
1419	warn:vspeed,cont {[format $TXT(trvwvspeed) $Travel(warn,vspeed,min) $Travel(warn,vspeed,max)]}
1420	warn:xtk,cond { $xtk != {} && abs($xtk) > $Travel(warn,xtk,max) }
1421	warn:xtk,cont {[format $TXT(trvwxtk) $Travel(warn,xtk,max)]}
1422    }
1423
1424    # map
1425    set MapEmpty 1 ; set MapMeasure ""
1426    set MapWidth $MAPWIDTH ; set MapHeight $MAPHEIGHT
1427    set MAPW2 [expr $MapWidth/2.0] ; set MAPH2 [expr $MapHeight/2.0]
1428    set Anim(number) 0
1429    foreach x "high medium low" y "important normal info" {
1430	set MAPCOLOUR(trvwrn$x) $MAPCOLOUR(trvwrn$y)
1431    }
1432    if { [set MapFont $MAPFONT] == "default" } {
1433	set MapFont $TkDefaultFont
1434    }
1435    MapProjectionIs $DEFMAPPROJ
1436    # order is important here
1437    set MapPFDatum $DEFMAPPFDATUM
1438    ChangeMapPFormat $DEFMAPPFRMT
1439
1440    if { [set PlotFont $PLOTFONT] == "default" } {
1441	set PlotFont $TkDefaultFont
1442    }
1443
1444    # varia
1445    set ReplNames(busy) 0
1446    set GFShowInfo 1
1447    set AltUnit $ALTUNIT
1448    set PlotWNo 0
1449    set CursorsChanged 0
1450    set BalloonX 0 ; set BalloonY 0
1451    set EMPTYSTR ""
1452    set a 0
1453    foreach b "N NE E SE S SW W NW" {
1454	set AzimuthDegrees($b) $a ; incr a 45
1455    }
1456    set BITMAPS {brokenline}
1457    InitBitmaps
1458
1459    # initializations depending on receiver brand
1460    # BSB contribution
1461    if { $MYGPS != "Lowrance" } {
1462	StartGPS
1463    } else {
1464	set UnusedWPInx 0
1465	for {set i 1} {$i < $MAX(WP)} {incr i} {
1466	   lappend UnusedWPInx $i
1467	}
1468	set UnusedICInx 0
1469	for {set i 1} {$i < $MAX(WP)} {incr i} {
1470	   lappend UnusedICInx $i
1471	}
1472    }
1473
1474    return
1475}
1476
1477proc QuitNow {} {
1478    global MESS TXT SAVESTATE
1479
1480    switch $SAVESTATE {
1481	never {
1482	    if { ! [GMConfirm $MESS(oktoexit)] } { return }
1483	}
1484	ask {
1485	    switch [GMSelect $MESS(savestate) \
1486		    [list $TXT(ok) $TXT(no) $TXT(cancel)] "ok no cancel"] {
1487		ok { SaveState }
1488		cancel { return }
1489	    }
1490	}
1491	always {
1492	    SaveState
1493	}
1494    }
1495    GPSBye
1496    exit 0
1497}
1498
1499