simplified to make microsoft cc happy
(died with too-many-parenthesises error) - sigh
ToolApplicationModel subclass:#HTMLBrowser
instanceVariableNames:''
classVariableNames:''
poolDictionaries:''
category:'Interface-Browsers'
!
HTMLBrowser class instanceVariableNames:'lastFileName'
"
The following class instance variables are inherited by this class:
ToolApplicationModel - history clipboard showHelp
ApplicationModel - ClassResources
Model -
Object -
"
!
!HTMLBrowser class methodsFor:'documentation'!
documentation
"
The future HTML Browser.
[author:]
Thomas Zwick, eXept Software AG
"
! !
!HTMLBrowser class methodsFor:'accessing'!
lastFileName
^lastFileName
!
lastFileName: aFileName
^lastFileName := aFileName
! !
!HTMLBrowser class methodsFor:'history'!
historyMaxSize
^25
! !
!HTMLBrowser class methodsFor:'interface specs'!
windowSpec
"this window spec was automatically generated by the ST/X UIPainter"
"do not manually edit this - the painter/builder may not be able to
handle the specification if its corrupted."
"
UIPainter new openOnClass:HTMLBrowser andSelector:#windowSpec
HTMLBrowser new openInterface:#windowSpec
"
"HTMLBrowser open"
<resource: #canvas>
^
#(#FullSpec
#'window:'
#(#WindowSpec
#'name:' 'HTML Browser'
#'layout:' #(#LayoutFrame 385 0 376 0 684 0 675 0)
#'label:' 'HTML Browser'
#'min:' #(#Point 10 10)
#'max:' #(#Point 1152 864)
#'bounds:' #(#Rectangle 385 376 685 676)
#'menu:' #menu
#'usePreferredExtent:' false
)
#'component:'
#(#SpecCollection
#'collection:'
#(
#(#MenuPanelSpec
#'name:' 'menuToolbarView'
#'layout:' #(#LayoutFrame 0 0.0 0 0 0 1.0 32 0)
#'menu:' #menuToolbar
#'showSeparatingLines:' true
)
#(#HTMLViewSpec
#'name:' 'htmlView'
#'layout:' #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0)
#'model:' #valueOfHTMLDocument
#'hasHorizontalScrollBar:' true
#'hasVerticalScrollBar:' true
)
#(#UISubSpecification
#'name:' 'uISubSpecification1'
#'layout:' #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
#'majorKey:' #ToolApplicationModel
#'minorKey:' #windowSpecForInfoBarWithClock
)
)
)
)
! !
!HTMLBrowser class methodsFor:'menu specs'!
menu
"this window spec was automatically generated by the ST/X MenuEditor"
"do not manually edit this - the builder may not be able to
handle the specification if its corrupted."
"
MenuEditor new openOnClass:HTMLBrowser andSelector:#menu
(Menu new fromLiteralArrayEncoding:(HTMLBrowser menu)) startUp
"
<resource: #menu>
^
#(#Menu
#(
#(#MenuItem
#'label:' 'About'
#'activeHelpKey:' #about
#'accessCharacterPosition:' 1
#'labelImage:' #(#ResourceRetriever nil #menuIcon)
#'submenuChannel:' #menuAbout
)
#(#MenuItem
#'label:' 'File'
#'translateLabel:' true
#'activeHelpKey:' #file
#'submenu:'
#(#Menu
#(
#(#MenuItem
#'label:' 'Load...'
#'translateLabel:' true
#'value:' #doLoad
#'activeHelpKey:' #fileLoad
#'enabled:' #isStandAlone
)
#(#MenuItem
#'label:' '-'
)
#(#MenuItem
#'label:' 'Print'
#'value:' #'doPerform:'
#'argument:' #'menu_print'
)
#(#MenuItem
#'label:' '-'
)
#(#MenuItem
#'label:' 'Exit'
#'translateLabel:' true
#'value:' #closeRequest
#'activeHelpKey:' #fileExit
)
) nil
nil
)
)
#(#MenuItem
#'label:' 'Navigate'
#'submenuChannel:' #menuNavigate
)
#(#MenuItem
#'label:' 'Misc'
#'submenu:'
#(#Menu
#(
#(#MenuItem
#'label:' 'Source...'
#'value:' #'doPerform:'
#'argument:' #'menu_source'
)
#(#MenuItem
#'label:' '-'
)
#(#MenuItem
#'label:' 'Settings...'
#'value:' #'doPerform:'
#'argument:' #'menu_settings'
)
) nil
nil
)
)
#(#MenuItem
#'label:' 'History'
#'activeHelpKey:' #history
#'submenuChannel:' #menuHistory
)
#(#MenuItem
#'label:' 'Help'
#'startGroup:' #right
#'activeHelpKey:' #help
#'submenuChannel:' #menuHelp
)
) nil
nil
)
!
menuNavigate
"this window spec was automatically generated by the ST/X MenuEditor"
"do not manually edit this - the builder may not be able to
handle the specification if its corrupted."
"
MenuEditor new openOnClass:HTMLBrowser andSelector:#menuNavigate
(Menu new fromLiteralArrayEncoding:(HTMLBrowser menuNavigate)) startUp
"
<resource: #menu>
^
#(#Menu
#(
#(#MenuItem
#'label:' 'Next'
#'value:' #'doPerform:'
#'enabled:' #valueOfCanNavigateToNext
#'argument:' '1'
#'labelImage:' #(#ResourceRetriever nil #rightIcon 'Next')
)
#(#MenuItem
#'label:' 'Previous'
#'value:' #'doPerform:'
#'enabled:' #valueOfCanNavigateToPrevious
#'argument:' '-1'
#'labelImage:' #(#ResourceRetriever nil #leftIcon 'Previous')
)
#(#MenuItem
#'label:' '-'
)
#(#MenuItem
#'label:' 'Home'
#'value:' #'doPerform:'
#'argument:' #'menu_home'
)
#(#MenuItem
#'label:' 'Back'
#'value:' #'doPerform:'
#'argument:' #'menu_back'
)
#(#MenuItem
#'label:' 'Reload'
#'value:' #'doPerform:'
#'argument:' #'menu_reload'
)
) nil
nil
)
!
menuToolbar
"this window spec was automatically generated by the ST/X MenuEditor"
"do not manually edit this - the builder may not be able to
handle the specification if its corrupted."
"
MenuEditor new openOnClass:HTMLBrowser andSelector:#menuToolbar
(Menu new fromLiteralArrayEncoding:(HTMLBrowser menuToolbar)) startUp
"
<resource: #menu>
^
#(#Menu
#(
#(#MenuItem
#'label:' 'Load'
#'isButton:' true
#'value:' #doLoad
#'labelImage:' #(#ResourceRetriever nil #loadIcon)
)
#(#MenuItem
#'label:' ''
)
#(#MenuItem
#'label:' 'Next'
#'isButton:' true
#'value:' #'doPerform:'
#'enabled:' #valueOfCanNavigateToNext
#'argument:' '1'
#'labelImage:' #(#ResourceRetriever nil #rightIcon)
)
#(#MenuItem
#'label:' 'Previous'
#'isButton:' true
#'value:' #'doPerform:'
#'enabled:' #valueOfCanNavigateToPrevious
#'argument:' '-1'
#'labelImage:' #(#ResourceRetriever nil #leftIcon)
)
) nil
nil
)
! !
!HTMLBrowser methodsFor:'accessing - views'!
htmlViewDoc
^(builder componentAt: #htmlView) scrolledView
! !
!HTMLBrowser methodsFor:'aspects'!
valueOfCanNavigateToNext
|holder|
(holder := builder bindingAt:#valueOfCanNavigateToNext) isNil ifTrue:[
builder aspectAt:#valueOfCanNavigateToNext put:(holder := false asValue).
].
^ holder
!
valueOfCanNavigateToPrevious
|holder|
(holder := builder bindingAt:#valueOfCanNavigateToPrevious) isNil ifTrue:[
builder aspectAt:#valueOfCanNavigateToPrevious put:(holder := false asValue).
].
^ holder
!
valueOfHTMLDocument
|holder|
(holder := builder bindingAt:#valueOfHTMLDocument) isNil ifTrue:[
builder aspectAt:#valueOfHTMLDocument put:(holder := ValueHolder new).
].
^ holder
! !
!HTMLBrowser methodsFor:'help'!
openTutorial
self doPerform: #menu_help
! !
!HTMLBrowser methodsFor:'startup / release'!
postOpenWith:aBuilder
self loadFromFile: self class lastFileName.
self htmlViewDoc history addAll: self historyEntries.
self updateChannels.
super postOpenWith:aBuilder.
! !
!HTMLBrowser methodsFor:'user actions'!
doLoad
self loadFromFile:
(FileSelectionBrowser request: 'Load a HTML File' fileFilters: #('.htm' '*.html'))
!
doPerform: what
(self htmlViewDoc respondsTo: what)
ifTrue:
[
self htmlViewDoc perform: what.
self valueOfHTMLDocument value: self htmlViewDoc currentURL.
self class lastFileName: self htmlViewDoc currentURL
]
ifFalse:
[
self valueOfHTMLDocument value:
(self class lastFileName: (self htmlViewDoc history at:
(self htmlViewDoc history indexOf: self valueOfHTMLDocument value) + what asInteger ifAbsent: [self class lastFileName])).
].
self updateChannels
!
loadFromFile: aFileName
self valueOfHTMLDocument value: aFileName.
aFileName notNil
ifTrue:
[
self class lastFileName: aFileName
].
self updateChannels
!
updateChannels
|htmlViewDoc|
htmlViewDoc := self htmlViewDoc.
(htmlViewDoc history at:
(htmlViewDoc history indexOf: self valueOfHTMLDocument value) + 1
ifAbsent: nil) isNil
ifTrue: [self valueOfCanNavigateToNext value: false]
ifFalse: [self valueOfCanNavigateToNext value: true].
(htmlViewDoc history at:
(htmlViewDoc history indexOf: self valueOfHTMLDocument value) - 1
ifAbsent: nil) isNil
ifTrue: [self valueOfCanNavigateToPrevious value: false]
ifFalse: [self valueOfCanNavigateToPrevious value: true].
"self emptyHistory."
htmlViewDoc history do: [:url| self addToHistory: url -> #loadFromFile:].
! !
!HTMLBrowser class methodsFor:'documentation'!
version
^ '$Header$'
! !