home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
tooloption.tcl
< prev
next >
Wrap
Text File
|
1997-11-25
|
9KB
|
300 lines
#---------------------------------------------------------------------------
#
# (c) Cayenne Software Inc. 1996
#
# File: @(#)tooloption.tcl /main/titanic/10
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)tooloption.tcl /main/titanic/10 25 Nov 1997 Copyright 1996 Cayenne Software Inc.
# Start user added include file section
require "classmaker.tcl"
require "asciiprint.tcl"
# End user added include file section
Class ToolOptions : {Object} {
constructor
method destructor
method createBox
method setContexts
method aPrinterSetup
method psPrinterSetup
method syntax
attribute syntaxEntries
}
constructor ToolOptions {class this name} {
set this [Object::constructor $class $this $name]
# Start constructor user section
# End constructor user section
return $this
}
method ToolOptions::destructor {this} {
# Start destructor user section
# End destructor user section
}
method ToolOptions::createBox {this name {isWinVar 1}} {
if $win95 {
set isWinVar 0
}
# retrieve M4 variables
set m4varList ""
set m4winvarList ""
foreach context [$this ${name}Contexts] {
set m4var M4_$name
set m4winvar M4_win_$name
if {"$context" != ""} {
set ${m4var}__${context} [m4_var get $m4var -context $context]
set ${m4winvar}__${context} [m4_var get $m4winvar -context $context]
lappend m4varList ${m4var}__${context}
lappend m4winvarList ${m4winvar}__${context}
} else {
set $m4var [m4_var get $m4var]
set $m4winvar [m4_var get $m4winvar]
lappend m4varList $m4var
lappend m4winvarList $m4winvar
}
}
# create dialog box
ClassMaker::extend TemplateDialog Options${name}TemplateDialog \
[concat name context isWinVar m4varList $m4varList \
m4winvarList $m4winvarList]
Options${name}TemplateDialog new $wmttoolObj.$name \
-modal yes \
-title [cap_underscores $name] \
-name $name \
-context "" \
-isWinVar $isWinVar \
-m4varList $m4varList \
-m4winvarList $m4winvarList \
-helpPressed [list .main helpOnName $name] \
-cancelPressed {%this delete} \
-okPressed {
foreach m4var [%this m4varList] {
if {"[context $m4var]" == "[%this context]"} break
}
%this $m4var [%this.ng.top.r.m4var text]
if [%this isWinVar] {
foreach m4winvar [%this m4winvarList] {
if {"[context $m4winvar]" == "[%this context]"} break
}
%this $m4winvar [%this.ng.top.m4winvar state]
}
foreach m4var [%this m4varList] {
if {"[m4_var get $m4var]" != "[%this $m4var]"} {
catch {m4_var set $m4var [%this $m4var]}
}
}
if [%this isWinVar] {
foreach m4winvar [%this m4winvarList] {
if {"[m4_var get $m4winvar]" != "[%this $m4winvar]"} {
catch {m4_var set $m4winvar [%this $m4winvar]}
}
}
}
%this delete
}
foreach m4var $m4varList {
$wmttoolObj.$name $m4var [set $m4var]
}
if $isWinVar {
foreach m4winvar $m4winvarList {
$wmttoolObj.$name $m4winvar [set $m4winvar]
}
}
NamedGroup new $wmttoolObj.$name.ng
set top [DlgColumn new $wmttoolObj.$name.ng.top]
set m4var [lindex $m4varList 0]
if $isWinVar {
set m4winvar [lindex $m4winvarList 0]
}
$wmttoolObj.$name.ng label "[[$wmttoolObj m4VarDes] getUiName $m4var]"
DlgRow new $top.r -spaceType NONE -justification FILLED -verShrinkFactor 0
SingleLineText new $top.r.m4var -columnCount 40 \
-text "[set $m4var]" -justification CENTER -horStretchFactor 100
PushButton new $top.r.browse -label "Browse..." -activated {
if $win95 {
set filter "Programs|*.com;*.exe;*.bat;*.cmd|All Files (*.*)|*|"
} else {
set filter "*"
}
FileChooser new .main.browsedit \
-title "Browse" \
-filter $filter \
-okPressed {
[%this parent].m4var text \
[lindex [.main.browsedit selectedSet] 0]
}
set dir [path_name directory [[%this parent].m4var text]]
if {$dir != ""} {
.main.browsedit directory $dir
}
.main.browsedit delHelpButton
.main.browsedit popUp
} -horStretchFactor 0 -justification CENTER
if $isWinVar {
CheckButton new $top.m4winvar \
-label "[[$wmttoolObj m4VarDes] getUiName $m4winvar]" \
-state [set $m4winvar]
}
Label new $top.contextLab \
-text "Context:"
set entrySet ""
foreach context [$this ${name}Contexts] {
if {"$context" == ""} {
lappend entrySet none
} else {
lappend entrySet $context
}
}
ClassMaker::extend OptionMenu ${name}OptionMenu [list box isWinVar]
${name}OptionMenu new $top.context \
-isWinVar $isWinVar \
-entrySet $entrySet \
-selected [lindex $entrySet 0] \
-box $wmttoolObj.$name \
-selectionChanged {
set newContext [%this selected]
if {"$newContext" == "none"} {
set newContext ""
}
set context [[%this box] context]
if {"$context" == "$newContext"} return
foreach m4var [[%this box] m4varList] {
if {"[context $m4var]" == "$context"} break
}
[%this box] $m4var [[%this box].ng.top.r.m4var text]
if [%this isWinVar] {
foreach m4winvar [[%this box] m4winvarList] {
if {"[context $m4winvar]" == "$context"} break
}
[%this box] $m4winvar [[%this box].ng.top.m4winvar state]
}
[%this box] context $newContext
foreach m4var [[%this box] m4varList] {
if {"[context $m4var]" == "$newContext"} break
}
[%this box].ng.top.r.m4var text [[%this box] $m4var]
if [%this isWinVar] {
foreach m4winvar [[%this box] m4winvarList] {
if {"[context $m4winvar]" == "$newContext"} break
}
[%this box].ng.top.m4winvar state [[%this box] $m4winvar]
}
}
$wmttoolObj.$name popUp
}
method ToolOptions::setContexts {this name contexts} {
$this ${name}Contexts $contexts
}
method ToolOptions::aPrinterSetup {this} {
# create dialog box
set box $wmttoolObj.printerSetup
AsciiPrinterDlg new $box \
-options [$wmttoolObj options]
$box popUp
}
method ToolOptions::psPrinterSetup {this} {
set box $wmttoolObj.printerSetup
PrinterChooser new $box \
-title "Printer Setup" \
-psPrinterCmd "[m4_var get M4_ps_printer]" \
-pageWidth "[m4_var get M4_ps_page_w]" \
-pageHeight "[m4_var get M4_ps_page_h]" \
-helpPressed {
if [catch {$wmttoolObj helpOnName printerSetup}] {
showHelp GEN/m_prsu.html#dialogbox
}
} \
-cancelPressed {%this delete} \
-okPressed {
set dim ""
set psPageW [%this pageWidth]
set psPageH [%this pageHeight]
if {$psPageW <= 0} {
set dim Width
} elseif {$psPageH <= 0} {
set dim Height
}
if {"$dim" != ""} {
wmtkerror "Page $dim must be a positive value"
return
}
if {"[m4_var get M4_ps_page_w]" != "$psPageW"} {
catch {m4_var set M4_ps_page_w "$psPageW"}
}
if {"[m4_var get M4_ps_page_h]" != "$psPageH"} {
catch {m4_var set M4_ps_page_h "$psPageH"}
}
set psPrinter [%this psPrinterCmd]
if {"[m4_var get M4_ps_printer]" != "$psPrinter"} {
catch {m4_var set M4_ps_printer "$psPrinter"}
}
%this delete
}
$box popUp
}
method ToolOptions::syntax {this} {
set box .main.syntax
TemplateDialog new $box \
-modal yes \
-autoPopDown 0 \
-title "Syntax" \
-helpPressed {.main helpOnName syntax} \
-cancelPressed {%this delete} \
-okPressed {
set errorMsg ""
foreach entry [[.main options] syntaxEntries] {
set m4var M4_${entry}_syntax
set spec [[.main m4VarDes] getUiName $m4var]
set text [%this.top.$entry text]
if {[M4SyntaxChecker::checkSyntaxSpec "$text"] == -1} {
if {"$errorMsg" != ""} {
append errorMsg "\n"
}
append errorMsg "Syntax error in $spec specification"
}
}
if {"$errorMsg" != ""} {
wmtkerror $errorMsg
return
}
foreach entry [[.main options] syntaxEntries] {
set m4var M4_${entry}_syntax
set text [%this.top.$entry text]
if {"[m4_var get $m4var]" != "$text"} {
catch {m4_var set $m4var $text}
}
}
M4SyntaxChecker::m4varsChanged
%this popDown
%this delete
}
DlgColumn new $box.top
foreach entry [$this syntaxEntries] {
set m4var M4_${entry}_syntax
set $m4var [m4_var get $m4var]
Label new $box.top.${entry}Lab \
-text "[[.main m4VarDes] getUiName $m4var]:"
SingleLineText new $box.top.$entry \
-text "[set $m4var]"
}
$box popUp
}
# Do not delete this line -- regeneration end marker