home *** CD-ROM | disk | FTP | other *** search
- #---------------------------------------------------------------------------
- #
- # (c) Cayenne Software Inc. 1996
- #
- # File: @(#)helptool.tcl /main/hindenburg/6
- # Author: <generated>
- # Description:
- #---------------------------------------------------------------------------
- # SccsId = @(#)helptool.tcl /main/hindenburg/6 28 Nov 1996 Copyright 1996 Cayenne Software Inc.
-
- # Start user added include file section
-
- require helpdialog.tcl
- require tooloption.tcl
- require m4vardescr.tcl
- require showversio.tcl
-
- # End user added include file section
-
- require "wmttool.tcl"
-
- Class HelpTool : {WmtTool MainWindow} {
- method destructor
- constructor
- method updateToolBar
- method gotoURL
- method gotoPrevious
- method showToc
- method showIndex
- method firstPageURL
- method tocFile
- method indexFile
- method print
- method exit
- method dialog
- attribute hyperStack
- attribute root
- attribute _firstPageURL
- attribute _tocFile
- attribute _indexFile
- attribute viewer
- attribute _dialog
- attribute m4VarDes
- attribute options
- }
-
- method HelpTool::destructor {this} {
- set ref [$this _dialog]
- if {$ref != ""} {
- $ref __tool ""
- }
- # Start destructor user section
-
- $this saveToolBarPresence helptool
- $this saveMessageAreaPresence helptool
- $this saveWindowGeometry helptool
- [$this options] delete
-
- # End destructor user section
- $this WmtTool::destructor
- }
-
- constructor HelpTool {class this name} {
- set this [MainWindow::constructor $class $this $name]
- WmtTool::constructor $class $this $name
-
- $this config -title help -icon help_64 -iconTitle help
-
- $this hyperStack [List new]
- $this closed {%this exit}
-
- # Global Setup
- #
- interface MenuBar $this.bar {
- MenuBarButton file {
- label File
- mnemonic F
- }
- MenuBarButton navigate {
- label Navigate
- mnemonic N
- }
- MenuBarButton view {
- label View
- mnemonic V
- }
- MenuBarButton options {
- label Options
- mnemonic O
- }
- MenuBarButton help {
- label Help
- mnemonic H
- }
- }
-
- [$this menuBar] helpEntry [$this menuBar].help
-
- # Menus
- #
-
- # File Menu
- #
- interface Menu [$this menuBar].file.menu {
- MenuPushButton open {
- label "Open File..."
- mnemonic O
- accelerator Ctrl+F
- activated {
- if {![isCommand .main.open]} {
- FileChooser new .main.open -okPressed {
- .main gotoURL \
- [.main.open selectedSet]
- }
- .main.open delHelpButton
- }
- .main.open popUp
- }
- }
- MenuPushButton print {
- label "Print"
- mnemonic P
- activated {
- .main print
- }
- }
- MenuSeparator sep {
- }
- MenuPushButton exit {
- label "Exit"
- mnemonic E
- activated {
- .main exit
- }
- }
- }
-
- # Navigation Menu
- #
- interface Menu [$this menuBar].navigate.menu {
- pinnable 1
- MenuPushButton contents {
- label "Contents..."
- mnemonic C
- accelerator Ctrl+C
- toolBarPixmap toc
- activated {
- .main showToc
- }
- }
- MenuPushButton index {
- label "Index..."
- mnemonic I
- accelerator Ctrl+I
- toolBarPixmap index
- activated {
- .main showIndex
- }
- }
- MenuPushButton back {
- label "Previous Entry"
- sensitive 0
- mnemonic P
- accelerator Ctrl+P
- toolBarPixmap back
- activated {
- .main gotoPrevious
- }
- }
- }
-
- # View Menu
- #
- interface Menu [$this menuBar].view.menu {
- MenuCheckButton toolbar {
- hintText "Shows or hides the toolbar."
- label "ToolBar"
- mnemonic T
- state 1
- stateChanged {
- .main toolBarPresent [[.main menuBar].view.menu.toolbar state]
- }
- }
- MenuCheckButton messagearea {
- hintText "Shows or hides the message area."
- label "Message Area"
- mnemonic M
- state 1
- stateChanged {
- .main messageAreaPresent [[.main menuBar].view.menu.messagearea state]
- }
- }
- }
-
- # Options Menu
- #
- $this options [ToolOptions new $this.options]
- $this m4VarDes [M4VarDescription new $this.m4VarDes]
- interface Menu [$this menuBar].options.menu {
- MenuPushButton printerSetup {
- label "Printer Setup..."
- mnemonic P
- activated {
- [.main options] psPrinterSetup
- }
- }
- }
-
- # Help Menu
- #
- interface Menu [$this menuBar].help.menu {
- MenuPushButton abouthelptool {
- label "About Help Tool"
- mnemonic A
- activated {
- showVersionDialog [%this label]
- }
- }
- }
-
- $this setToolBarPresence helptool
- if {[$this toolBar] != ""} {
- $this updateToolBar
- }
-
- # Other stuff
- #
-
- $this viewer [HTMLViewer new $this.viewer -panX 0 -panY 0]
- [$this viewer] setSize 550 500
- [$this viewer] hotSpotClicked \
- "$this gotoURL \[[$this viewer] currentHotSpot\]"
-
- $this setMessageAreaPresence helptool
- HelpDialog new $this.help -tool $this
- $this setWindowGeometry helptool
-
- return $this
- }
-
- method HelpTool::updateToolBar {this} {
- [$this toolBar] entrySet "
- [$this menuBar].navigate.menu.contents
- [$this menuBar].navigate.menu.index
- [$this menuBar].navigate.menu.back
- "
- }
-
- method HelpTool::gotoURL {this url} {
- # Special url to show toc dialog.
- if {$url == "helptool://showtoc"} {
- $this showToc
- return
- }
- if [catch {
- if [regexp {^#} $url] {
- # Make relative url absolute.
- set url "[[$this viewer] currentFile]$url"
- } elseif {![regexp {^/} $url]} {
- set url \
- "[file dirname [[$this viewer] currentFile]]/$url"
- }
- [$this viewer] gotoURL $url
- [$this hyperStack] insert $url
- if {[llength [[$this hyperStack] contents]] > 1} {
- .main.bar.navigate.menu.back sensitive 1
- }
- } msg] {
- wmtkerror $msg
- }
- }
-
- method HelpTool::gotoPrevious {this} {
- if {[llength [[$this hyperStack] contents]] == 1} {
- wmtkerror "There is no previous help topic"
- return
- }
- if [catch {
- [$this hyperStack] remove 0
- [$this viewer] gotoURL [[$this hyperStack] index 0]
- } msg] {
- wmtkerror $msg
- }
- if {[llength [[$this hyperStack] contents]] == 1} {
- .main.bar.navigate.menu.back sensitive 0
- }
- }
-
- method HelpTool::showToc {this} {
- [$this dialog] showToc
- }
-
- method HelpTool::showIndex {this} {
- [$this dialog] showIndex
- }
-
- method HelpTool::firstPageURL {this {url -}} {
- if {$url == "-"} {
- return [$this _firstPageURL]
- }
- if {[$this _firstPageURL] == ""} {
- $this gotoURL $url
- }
- $this _firstPageURL $url
- }
-
- method HelpTool::tocFile {this {file -}} {
- if {$file == ""} {
- return [$this _tocFile]
- }
- .main.help loadToc $file
- $this _tocFile $file
- }
-
- method HelpTool::indexFile {this {file -}} {
- if {$file == ""} {
- return [$this _indexFile]
- }
- .main.help loadIndex $file
- $this _indexFile $file
- }
-
- method HelpTool::print {this} {
- wmtkmessage "Printing..."
- set printer [Printer new]
- $printer openPrinter html-print
- set printOut [HTMLPrintOut new -url [[$this viewer] currentFile]]
- $printer print $printOut
- $printOut delete
- $printer close
- wmtkmessage "Done"
- }
-
- method HelpTool::exit {this} {
- $this delete
- GCControl collect
- exit
- }
-
- # Do not delete this line -- regeneration end marker
-
- method HelpTool::dialog {this args} {
- if {$args == ""} {
- return [$this _dialog]
- }
- set ref [$this _dialog]
- if {$ref != ""} {
- $ref __tool ""
- }
- set obj [lindex $args 0]
- if {$obj != ""} {
- $obj __tool $this
- }
- $this _dialog $obj
- }
-
-