#!/bin/sh
# TkMapEdit Ver.2.1 \
	exec wish4.1 -f $0 ${1+"$@"}
# Copyright (c) 1994,95,96 Takeshi Taguchi (translator@grape.ifnet.or.jp).
# All rights reserved.
# Permission is hereby granted, without written agreement and without
# license or royalty fees, to use, copy, modify, and distribute this
# software and documentations for *any* purpose.
# ##

# --------------------------------------------------------------------
# set up tcl lib dir
# --------------------------------------------------------------------
set maped(localLibDir) /home/usrs1/taguchi/lib/tkmapedit2/lib
if {[file isdirectory $maped(localLibDir)]} {
    lappend auto_path $maped(localLibDir)
} else {
    lappend auto_path [pwd]/lib .
}

# --------------------------------------------------------------------
# Read Resources
# --------------------------------------------------------------------
loadAppDefaults [set className [winfo class .]] startupFile

# Global Resource Definition (minimal):
# Resource Name     means       
# defaultIconPath   path name which icon stored.
# viewerExec        strings which 'eval'ed on viewer-mode (see Util Menu)
# editorExec        strings which 'eval'ed on editor-mode (see Util Menu)
# publicHtmlDir     your public_html dir name.
# serverTopDir      top dir at your own server.
# ##
# IMPOTANT: following substitutions are available.
# %U : subst to the URL which asotiated to the selected item.
# %F : subst to the File Name which asotiated to the selected item.
# ##
option add {*version} 2.1 widgetDefault
option add {*patchLevel} 0 widgetDefault
set maped(defaultIconPath) /home/usrs1/taguchi/lib/tkmapedit2/icon
if {[file isdirectory $maped(defaultIconPath)]} {
    option add {*defaultIconPath} $maped(defaultIconPath) widgetDefault
} else {
    option add {*defaultIconPath} [pwd]/icon widgetDefault
}
option add {*viewerExec} [list exec netscape -remote openURL(%U)] \
	widgetDefault; # Fuumm. Actuary, I DON'T like it. But this is default.
# option add {*viewerExec} [list send surfit {create_window %U}] \
	widgetDefault; # ofcause! we can use SurfIt!!
# option add {*viewerExec} [list send tkwww {tkW3NavigateGoto %U}] \
	widgetDefault; # and we can also use a traditional viewer.
option add {*editorExec} [list exec emacsclient %F] \
	widgetDefault; # I believe EMACS is king of Editors on this planets.
# option add {*editorExec} [list send tkHTML {OpenFile %F}] \
	widgetDefault; # BUT, tkHTML is a great HTML editor, isn't it?
option add {*serverTopDir} {} widgetDefault
option add {*publicHtmlDir} {public_html} widgetDefault
option add {*welcomeHtml} {index.html} widgetDefault
option add {*mapFormat} [list \
	[list {CERN Httpd} {}] [list {NCSA Httpd} {}] \
	[list {NetSite} 3] [list {Client Side Map} 12]]
option add {*animateIcon} True widgetDefault
option add {*animateDelay} 1000 widgetDefault
option add {*printDistination} printer widgetDefault
option add {*printFileName} {} widgetDefault
option add {*printOrientation} portrait widgetDefault
option add {*printColorMode} {mono} widgetDefault
option add {*printSize} {a4} widgetDefault
option add *Canvas.itemColor black widgetDefault
option add *Canvas.itemWidth 1 widgetDefault
option add *Canvas.drawingColor green widgetDefault
option add *Canvas.drawingWidth 1 widgetDefault
option add *Canvas.fillColor black widgetDefault
option add *Canvas.selectColor red widgetDefault
option add *Canvas.selectWidth 3 widgetDefault
option add *Canvas.handleColor red widgetDefault
option add *Canvas.stipple gray25 widgetDefault
option add *Canvas.selectStipple gray50 widgetDefault
option add *Canvas.background white widgetDefault

# Initialization for Global Variables.
set maped(fillFlag) 0;      # None fill
set maped(utilFlag) 0;      # Do NOT call any external utils.
set maped(baseURL) {};      # BASE URL for Clicable Map.
set maped(curObj) {select}; # default
set maped(mode) {init};     # initial state
set maped(curHandle) {};    # current Handle
set maped(curPos) {};       # current Vertex No.
set maped(DEBUG) 1;         # DEBUG FLAG
set maped(defaultURL) {};   # default URL
set maped(curFileName) {};  # current map file name
set maped(curFormat) \
	[lindex [lindex [option get . mapFormat {}] 0] 0]; # current map format
set maped(tmpFormat) {};    # tmp for FileSelectionBox
set maped(curName) {};      # current map name (Client side)
set maped(PS.Distination) [option get . printDistination {}]; # where print to ...
set maped(PS.PostScript) [option get . printFileName {}]; # PostScript file name
set maped(PS.Orientation) [option get . printOrientation {}]; # direction of paper
set maped(PS.Color) [option get . printColorMode {}]; # mono/grey/color
set maped(PS.Size) [option get . printSize {}]; # paper size
set maped(PS.cmdStr) "lpr"
if {[info exists env(PRINTER)]} {
    set maped(PS.cmdStr) "$maped(PS.cmdStr) -P$env(PRINTER)"
}
set maped(ICON.error) [image create bitmap -file [option get . defaultIconPath {}]/error.xbm]
set maped(ICON.info) [image create bitmap -file [option get . defaultIconPath {}]/info.xbm]
set maped(ICON.questhead) [image create bitmap -file [option get . defaultIconPath {}]/queshead.xbm]
set maped(ICON.question) [image create bitmap -file [option get . defaultIconPath {}]/question.xbm]
set maped(ICON.warning) [image create bitmap -file [option get . defaultIconPath {}]/warning.xbm]
set maped(allowNetscapeBUG) 0
# --------------------------------------------------------------------
# Set up for help related stuff
# --------------------------------------------------------------------
option add *docURL "file:[pwd]/doc/index.html" widgetDefault

# --------------------------------------------------------------------
# Create main window panel
# --------------------------------------------------------------------
mainwin:create maped

# --------------------------------------------------------------------
# Set up for wm related stuff
# --------------------------------------------------------------------
icon:create maped $argv0

# --------------------------------------------------------------------
# load from args
# --------------------------------------------------------------------
if {$argv != {}} {
    file:loadFromArgs maped $argv
}
