ToolApplicationModel.st
author tz
Sat, 04 Apr 1998 19:08:16 +0200
changeset 893 8a142b17a0c8
parent 892 bc4aff74f607
child 907 f4087882555a
permissions -rw-r--r--
some cleans

"
 COPYRIGHT (c) 1997 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice. This software may not
 be provided or otherwise made available to, or used by, any
 other person. No title to or ownership of the software is
 hereby transferred.
"



ApplicationModel subclass:#ToolApplicationModel
	instanceVariableNames:'timeBlock'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-Framework'
!

ToolApplicationModel class instanceVariableNames:'history clipboard settings showHelp'

"
 The following class instance variables are inherited by this class:

	ApplicationModel - ClassResources
	Model - 
	Object - 
"
!

!ToolApplicationModel class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1997 by eXept Software AG
              All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice. This software may not
 be provided or otherwise made available to, or used by, any
 other person. No title to or ownership of the software is
 hereby transferred.
"


!

documentation
"
    Framework class for tool applications.
    Provides hooks for history management,
    showing help texts, about menu, help menu etc.

    [author:]
        Thomas Zwick, eXept Software AG
"
! !

!ToolApplicationModel class methodsFor:'accessing'!

authorLinesForAboutBox
    "extract the author(s) from the documentation method."

    |firstClassWithDocumentation src s line lines|

    firstClassWithDocumentation := self class withAllSuperclasses detect:[:metacls| metacls implements:#documentation].
    firstClassWithDocumentation notNil ifTrue:[
        (firstClassWithDocumentation inheritsFrom:ToolApplicationModel class) ifTrue:[
            src := (firstClassWithDocumentation compiledMethodAt:#documentation) source.
            src notNil ifTrue:[
                s := src readStream.
                s upToAll:'[author:]'.
                s nextLine.   "/ skip to end
                line := s nextLine.   "/ line after [author:]
                lines := OrderedCollection new.
                [line notNil and:[line notEmpty]] whileTrue:[
                    line := line trimBlanks.
                    line size > 1 ifTrue:[
                        lines add:line trimBlanks.
                        line := s nextLine.
                    ] ifFalse:[
                        line := nil
                    ]
                ].
                ^ lines.
            ]
        ]
    ].
    ^ #('unnown')

    "Created: / 1.2.1998 / 15:41:43 / cg"
    "Modified: / 1.2.1998 / 15:59:10 / cg"
!

label

    |label|
    label := ''.
    self name do:
    [:c|
        c isUppercase ifTrue: [label := label, $ ].
        label := label, c
    ].
    ^label trimBlanks
!

settings

    settings isNil ifTrue: [settings := IdentityDictionary new].
    ^settings
!

showHelp

    showHelp isNil ifTrue: [showHelp := true].
    ^showHelp
!

showHelp: aBoolean

    ^showHelp := aBoolean
! !

!ToolApplicationModel class methodsFor:'clipboard'!

clipboard

    ^clipboard
!

clipboard: anEditObject

    clipboard := anEditObject
! !

!ToolApplicationModel class methodsFor:'help specs'!

helpSpec
    "This resource specification was automatically generated
     by the UIHelpTool of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIHelpTool may not be able to read the specification."

    "
     UIHelpTool openOnClass:ToolApplicationModel    
    "

    <resource: #help>

    ^super helpSpec addPairsFrom:#(

#about
'About functions.'

#aboutSTX
'Opens an InfoBox about running ST/X.'

#aboutThisAppliaction
'Opens an InfoBox about release and author of current application.'

#add
'Add functions.'

#commitCancel
'Cancels last edit action.'

#commitOK
'Accepts last edit action.'

#edit
'Edit functions.'

#editCopy
'Copies the selected item(s) to the clipboard.'

#editCut
'Cuts the selected item(s) and places it to the clipboard.'

#editDelete
'Deletes the selected item(s).'

#editMoveDown
'Moves the selected item one step down.'

#editMoveIn
'Moves the selected item into next item as child item.'

#editMoveOut
'Moves the selected item out of parent item.'

#editMoveUp
'Moves the selected item one step up.'

#editPaste
'Pastes the contents of the clipboard.'

#editUndo
'Reverses the last action.'

#file
'File functions.'

#fileBrowseClass
'Opens a System Browser on current class and selector.'

#fileDefineClass
'Opens a dialog to define current class.'

#fileDefineClassAndSelector
'Opens a dialog to define current class and selector.'

#fileExit
'Exits current application.'

#help
'Help functions.'

#helpHelpTool
'Opens a HTML-Browser on the documentation file of the Help Tool.'

#helpShowHelp
'Turns on/off displaying help texts.'

#helpTutorial
'Opens a HTML-Browser on the documentation file of the current application.'

#history
'History functions.'

#historyEmptyMenu
'Deletes all items of the history.'

#historyMenuItem
'Evaluates the text of the menu item for loading.'

#settings
'Settings functions.'

#test
'Test functions.'

)
! !

!ToolApplicationModel class methodsFor:'history'!

getHistory

    history isNil ifTrue: [history := OrderedCollection new].
    ^history

!

historyMaxSize

    ^10

! !

!ToolApplicationModel class methodsFor:'image specs'!

copyIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#copyIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel copyIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@AUUUW@@@A???>@@@A???>O@@A???>@@@A???>@@@@@@?>@EUUU\?>@G???8?>@G???8?>@G???8?>@G???8?>@G???8?>IG???8?>@G???8**MG???8@@@G???8@@KG???8@@@G???8@@@G???8@@HN***(@@@@@@@@@@@') ; colorMapFromArray:#[0 0 0 255 255 255 127 127 127 170 170 170]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@_?<@_?<@_?<@_?<@_?<@_?<???<???<???<???<???<???<???<???<???<???<??8@??8@??8@??8@??8@??8@') ; yourself); yourself]!

cutIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#cutIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel cutIcon'
        ifAbsentPut:[(Depth4Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@DQDQDP0AL@@L@@@SL3L3CBL @B0@@AL3L3LL0B@@3@@@D3L3L0KB@@KB@@@SL3L3LL0@CL@@@AL3L3L0KB@,H@@@D3L3L3LL0L0@@@@SL3L3L0K@0 @@@AL3L3L3LL3@@@@@D3L3L3L03L@@@@@SL3L3L0CL0@@@@AL3L3L3@,CB@@@@D3L3L3@L0L0@@@@2H"H H"0 KBH @@@@@@KL3@@L3LH@@@@@CBCB@@K@K@@@@@@L@LH@@,@L@@@@@@0@0 @B0@0@@@@@CBC@@@C@K@@@@@@@3@@@@@3@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255 127 127 127 170 170 170 255 0 0 0 255 0 0 0 255 0 255 255 255 255 0 255 0 255 127 0 0 0 127 0 0 0 127 0 127 127 127 127 0 127 0 127]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?<@_=\P_=<0_=,0_=50_>5 _>; _?[@_?[@_?.@_?.@_?N@_?[@_>[@_;;8_75<@F1,@D1$@D1$@F ,@C@X@@@@') ; yourself); yourself]!

deleteIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#deleteIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel deleteIcon'
        ifAbsentPut:[(Depth4Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@DQDQDQDQL@@@@@@SL3L3L3L @@@@@AL3L3L3L2@@@@@@D3L3L3L3H@@@H@@SL3L3L3L @@H@@AL3L3L3L2@@@@@@D3L3L3L3@@@@@@@SL3L3L0@ @@@ @AL3L3L3@@@@@@@@D3L3L3L@D@@@H@@SL3L3L0@QL3H @AL3L3L3@A@3LB@@D3L3L3L@DC@0H@@2H"H"H @PLC@ @@@@@@@@@A@0LB@@@@@@@@@@DC@0H@@@@@@@@@@PLC@ @@@@@@@@@A@0LB@@@@@@@@@@DS@2H@@@@@@@@@HAL3HB@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255 127 127 127 170 170 170 255 0 0 0 255 0 0 0 255 0 255 255 255 255 0 255 0 255 127 0 0 0 127 0 0 0 127 0 127 127 127 127 0 127 0 127]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?<@_?<@_?<P_?<P_?<X_?<X_?<H_?0H_?O<_?XL_?_<_?_<_?_<_?_<_?_<_?_<@@_<@@_<@@_<@@_<@@_<@@G0') ; yourself); yourself]!

desktopIcon

    ^Icon
        constantNamed:#'ToolApplicationModel desktopIcon'
        ifAbsentPut:
        [
            |desktopIcon|
            desktopIcon := self stxIcon.
            desktopIcon magnifiedBy: Display preferredIconSize/desktopIcon extent
        ]




!

downIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#downIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel downIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUT@AUUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUT@*$AUPUT***%UPUU***UUPUUZ*)UUPUUV*%UUPUUU*UUUPUUUYUUUP') ; colorMapFromArray:#[255 255 255 0 0 0 0 127 0 255 0 0]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@A?>@A?>@@?<@@_8@@O0@@G @@C@@') ; yourself); yourself]!

downRightIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#downRightIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel downRightIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUUPP@EUUUUPR*UUUUUPR*UUUUUPR*UUUUUPR*UUUUUPR*UUUUUPR*UUUUUPR*UUUUUPR*UUUUUPR*UUTEUPR*UUT!!UPR*UUT(UPR*P@@*EPR*****!!PR*****(PR*****)PR*****%PQUUUU*UPUUUUT)UPUUUUT%UPUUUUTUUP') ; colorMapFromArray:#[255 255 255 0 0 0 0 127 0 255 0 0]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@_ @@_ @@_ @@_ @@_ @@_ @@_ @@_ @@_ @@_ L@_ N@_ O@_?? _??0_??8_??8_??0_?? @@O@@@N@@@L@') ; yourself); yourself]!

helpIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#helpIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel helpIcon'
        ifAbsentPut:[(Depth1Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@O0A@_8@@?<@@8\C@8\A@@\@@@8@@A8@@C0@@G @@G@@@G@@@G@C@@@@@@@@@G@@@G@@@G@@@@@@@@@@') ; colorMapFromArray:#[0 0 0 127 0 127]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@O0@@_8@@?<@@8\@@8\@@@\@@@8@@A8@@C0@@G @@G@@@G@@@G@@@@@@@@@@@G@@@G@@@G@@@@@@@@@@') ; yourself); yourself]!

leftDownIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#leftDownIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel leftDownIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUUPU@@@@@@PUJ****)PUJ****)PUJ****)PUJ****)PUJ)UUUUPUJ)UUUUPUJ)UUUUPUJ)UUUUPUJ)UUUUPUJ)UUUUPUJ)UUUUPUJ)UUUUP@J*@UUUPJ**)UUUPR**%UUUPT**UUUUPUJ)UUUUPUR%UUUUPUTUUUUUPUUUUUUUP') ; colorMapFromArray:#[255 255 255 0 0 0 0 127 0 255 0 0]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@G??8G??8G??8G??8G??8G??8G8@@G8@@G8@@G8@@G8@@G8@@G8@@??@@??@@_>@@O<@@G8@@C0@@A @@@@@@') ; yourself); yourself]!

leftIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#leftIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel leftIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUUPUUUUUUUPUUUUUUUPUUUUUUUPUUUUUUUPUTUUUUUPURUUUUUPUJUUUUUPT*P@@@@PR******PJ******PZ******PV******PU*UUUUUPUZUUUUUPUVUUUUUPUUUUUUUPUUUUUUUPUUUUUUUPUUUUUUUPUUUUUUUPUUUUUUUP') ; colorMapFromArray:#[255 255 255 0 0 0 0 127 0 255 0 0]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@A @@C @@G @@O??<_??<???<???<_??<O??<G @@C @@A @@@@@@@@@@@@@@@@@@@@@@') ; yourself); yourself]!

loadIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#loadIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel loadIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUUPUUUUU?UPUUUUW*5PU???>*/PU:****)PUUUUUUZPP@@@@@EPS?????&PS?????%PS?????&PS?????%PT?????9PT?????9PT?????9PT?????9PT?????9PT?????9PUO????>PUO????>PUO????>PU:*****PUUUUUUUP') ; colorMapFromArray:#[255 255 255 0 0 0 127 127 127 170 170 170]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@G@@@O G??8O??<O??<_??<???<???<???<???<???<_??<_??<_??<_??<_??<_??<O??<O??<O??<O??<O??<') ; yourself); yourself]!

menuIcon

    ^Icon
        constantNamed:#'ToolApplicationModel menuIcon'
        ifAbsentPut:
        [
            |menuIcon|
            menuIcon := self stxIcon.
            menuIcon magnifiedBy: MenuPanel defaultFont height/menuIcon height
        ]
!

newIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#newIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel newIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@AUUUUP@@A????2@@A????2 @A????0@@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@A?????8@C*****(@@@@@@@@@') ; colorMapFromArray:#[0 0 0 255 255 255 127 127 127 170 170 170]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?>@_??@_?? _??0_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8_??8') ; yourself); yourself]!

pasteIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#pasteIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel pasteIcon'
        ifAbsentPut:[(Depth4Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@KLH@@@@@@@@@@@CL3@@@@@@@@@@@CBH"0@@@@@@@@QD,3L3BDQ@@@@@ADQDQDQDQD@@@@@DQDQDQDQDP@@@@@@@@@@DQDQ@ADQDQDQDS@QDQD@D3L3L3L3HADQDP@SL3L3L3L DQDQ@AL3L3L3L2@QDQD@D3L3L3L3HADQDP@SL3L3L3L DQDQ@AL3L3L3L2@QDQD@D3L3L3L3HADQDP@SL3L3L3L DQDQ@AL3L3L3L2@QDQD@D3L3L3L3HADQDP@SL3L3L3L DQDQ@AL3L3L3L2@@@@@@L"H"H"H"H@@@@@@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255 127 127 127 170 170 170 255 0 0 0 255 0 0 0 255 0 255 255 255 255 0 255 0 255 127 0 0 0 127 0 0 0 127 0 127 127 127 127 0 127 0 127]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@<@@@<@@??<@??<@??<@??<???<???<???<???<???<???<???<???<???<???<???<???<???<???<??8@??8@') ; yourself); yourself]!

rightIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#rightIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel rightIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUUPUUUUUUUPUUUUUUUPUUUUUUUPUUUUUUUPUUUUUEUPUUUUUIUPUUUUUJUP@@@@@J%PJ*****)PJ******PJ******PJ*****)PEUUUUZ%PUUUUUJUPUUUUUIUPUUUUUEUPUUUUUUUPUUUUUUUPUUUUUUUPUUUUUUUPUUUUUUUP') ; colorMapFromArray:#[255 255 255 0 0 0 0 127 0 255 0 0]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@F@@@G@@@G ???0???8???<???<???8???0@@G @@G@@@F@@@@@@@@@@@@@@@@@@@@@') ; yourself); yourself]!

saveIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#saveIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel saveIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'AL3L3L@PM3L3L0?PML3L3L=PM3L3L0=PML3L3L?PM3L3L0?PML3L3L?PM3L3L0?PML3L3L?PM3L3L0?PML3L3L?PM@@@@@?PO??????PO??????PO??????PO=UUUU?PO=???[?PO=5O?Z?PO=6O?Z?PO=6O?Z?PO=0O?Z?P5U***U5P') ; colorMapFromArray:#[255 255 255 0 0 0 127 127 127 170 170 170]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???8') ; yourself); yourself]!

startIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#startIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel startIcon'
        ifAbsentPut:[(Depth4Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(4 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@N8@@@@@@@@@@@@N<^@@@@@@@@@@@@;.;.;.;.@@@@@@C/G @@@@8^@@@@@N<^@@@@@A@@@@@@;18@@@@@D@@@@@C.;.;.; @P@@@@@N<^@@@@@@@@@@@@;18@@@C!!G.@@@@C/G @@@@G>@@@@@N;.;.; @_8@@@@@;18@@@@A? @@@@C/G @@@@G>@@@@@N<^@@@@@_8@@@@@;.;.;.@A? @@@@C/G @@@@G>@@@@@N<^@@@@@_8@@@@@;18@@@@@@@@@@@C.; @@@@DQ@@@@C ; 8@@@A&X@@@C 8@8N@@@"H"@@@b') ; colorMapFromArray:#[0 0 0 255 255 255 255 0 0 0 255 0 0 0 255 0 255 255 255 255 0 255 0 255 127 0 0 0 127 0 0 0 127 0 127 127 127 127 0 127 0 127 127 127 127 170 170 170]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@AC@DAG DAG?<@G N@G N@G N@G?.@G N@G _@G _@G?_@G _@G _@G _@G?_@G ? G!!?0G!!?0G!!.PKQNPT(_@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@a') ; yourself); yourself]!

stxIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#stxIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel stxIcon'
        ifAbsentPut:[(Depth2Image new) width: 48; height: 48; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@U@@@@@@@AP@@@@@AUP@@@@@@E@@@@@@AUP@@@@@@T@@@@@@AUP@@@@@EP@@@@@@AUP@@@@@DP@@@@@@AUD@@@@AU@@@@@@@@UT@@@@@T@@@@@@@@UT@@@@QP@@@@@@@@EU@@@@U@@@@@@@@@AU@@@AD@@@@@@@@@ATP@@UP@@@@@@@@@AUP@@Q@@@@@@@@@@@UT@AD@@@@@@@@@@@AQ@DP@@@@@@@@@@@EU@Q@@@@@@@@@@@@ATQT@@@@@@@@@@@@AUTP@@@@@@@@@@@@@EPP@@@@@@@@@@@@@QU@@@@@@@@@@@@@@EU@@@@@@@@@@@@@@UT@@@@@@@@@@@@@AUE@@@@@@@@@@@@@EUU@@@@@@@@@@@@@UPEP@@@@@@@@@@@AUPAT@@@@@@@@@@@EE@AU@@@@@@@@@@AET@@E@@@@@@@@@@AUP@@EP@@@@@@@@@UU@@@AP@@@@@@@@AUP@@@AT@@@@@@@@EUP@@@@T@@@@@@@AUU@@@@@E@@@@@@@EUT@@@@@DP@@@@@@UUP@@@@@AP@@@@@@UUP@@@@@@T@@@@@@UU@@@@@@@E@@@@@@ET@@@@@@@A@@@@@@@@@@@@@@@@P@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@') ; colorMapFromArray:#[25 25 25 0 204 51 0 0 0 255 255 255]; yourself]!

upIcon
    "This resource specification was automatically generated
     by the ImageEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the ImageEditor may not be able to read the specification."

    "
     ImageEditor openOnClass:self andSelector:#upIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel upIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUQUUUPUUUJUUUPUUT*%UUPUUR*)UUPUUJ**UUPUT***%UPUTV*%UUPUUT*%UUPUUT*%UUP_UT*%UUP_UT*%UUP_5T*%UUPWUT*%UUPWWT*%UUPWUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUTUUUUP') ; colorMapFromArray:#[255 255 255 0 0 0 0 127 0 255 0 0]; mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@C@@@G @@O0@@_8@@?<@A?>@A?>@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@@O0@') ; yourself); yourself]! !

!ToolApplicationModel class methodsFor:'interface specs'!

windowSpecForCommit
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:ToolApplicationModel andSelector:#windowSpecForCommit
     ToolApplicationModel new openInterface:#windowSpecForCommit
    "

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #window: 
           #(#WindowSpec
              #name: 'Commit Buttons'
              #layout: #(#LayoutFrame 344 0 371 0 643 0 430 0)
              #label: 'Commit Buttons'
              #min: #(#Point 100 22)
              #max: #(#Point 1152 900)
              #bounds: #(#Rectangle 344 371 644 431)
              #usePreferredExtent: false
          )
          #component: 
           #(#SpecCollection
              #collection: 
               #(
                 #(#ActionButtonSpec
                    #name: 'cancelButton'
                    #layout: #(#LayoutFrame 5 0 0 0 -2 0.5 0 1)
                    #activeHelpKey: #commitCancel
                    #label: 'Cancel'
                    #tabable: true
                    #model: #cancel
                    #enableChannel: #valueOfEnablingCommitButtons
                )
                 #(#ActionButtonSpec
                    #name: 'okButton'
                    #layout: #(#LayoutFrame 2 0.5 0 0.0 -5 1 0 1.0)
                    #activeHelpKey: #commitOK
                    #label: 'OK'
                    #tabable: true
                    #model: #accept
                    #enableChannel: #valueOfEnablingCommitButtons
                )
              )
          )
      )
!

windowSpecForCommitWithoutChannels
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:ToolApplicationModel andSelector:#windowSpecForCommitWithoutChannels
     ToolApplicationModel new openInterface:#windowSpecForCommitWithoutChannels
    "

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #window: 
           #(#WindowSpec
              #name: 'Commit Buttons Without Channels'
              #layout: #(#LayoutFrame 500 0 326 0 799 0 385 0)
              #label: 'Commit Buttons Without Channels'
              #min: #(#Point 100 22)
              #max: #(#Point 1152 900)
              #bounds: #(#Rectangle 500 326 800 386)
              #usePreferredExtent: false
          )
          #component: 
           #(#SpecCollection
              #collection: 
               #(
                 #(#ActionButtonSpec
                    #name: 'cancelButton'
                    #layout: #(#LayoutFrame 5 0 0 0 -2 0.5 0 1)
                    #activeHelpKey: #commitCancel
                    #label: 'Cancel'
                    #tabable: true
                    #model: #cancel
                )
                 #(#ActionButtonSpec
                    #name: 'okButton'
                    #layout: #(#LayoutFrame 2 0.5 0 0.0 -5 1 0 1.0)
                    #activeHelpKey: #commitOK
                    #label: 'OK'
                    #tabable: true
                    #model: #accept
                )
              )
          )
      )
!

windowSpecForInfoBar
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:ToolApplicationModel andSelector:#windowSpecForInfoBar
     ToolApplicationModel new openInterface:#windowSpecForInfoBar
    "

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #window: 
           #(#WindowSpec
              #name: 'Info Bar'
              #layout: #(#LayoutFrame 233 0 218 0 732 0 563 0)
              #label: 'Info Bar'
              #min: #(#Point 400 320)
              #max: #(#Point 1152 900)
              #bounds: #(#Rectangle 233 218 733 564)
              #menu: #menu
              #usePreferredExtent: false
          )
          #component: 
           #(#SpecCollection
              #collection: 
               #(
                 #(#ViewSpec
                    #name: 'view'
                    #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
                    #component: 
                     #(#SpecCollection
                        #collection: 
                         #(
                           #(#LabelSpec
                              #name: 'infoLabel'
                              #layout: #(#LayoutFrame 2 0.0 1 0.0 -1 1.0 -1 1.0)
                              #labelChannel: #valueOfInfoLabel
                              #level: -1
                              #adjust: #left
                              #resizeForLabel: false
                          )
                        )
                    )
                )
              )
          )
      )
!

windowSpecForInfoBarWithClock
    "This resource specification was automatically generated
     by the UIPainter of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the UIPainter may not be able to read the specification."

    "
     UIPainter new openOnClass:ToolApplicationModel andSelector:#windowSpecForInfoBarWithClock
     ToolApplicationModel new openInterface:#windowSpecForInfoBarWithClock
    "

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #window: 
           #(#WindowSpec
              #name: 'Info Bar'
              #layout: #(#LayoutFrame 160 0 423 0 659 0 453 0)
              #label: 'Info Bar'
              #min: #(#Point 400 320)
              #max: #(#Point 1152 900)
              #bounds: #(#Rectangle 160 423 660 454)
              #menu: #menu
              #usePreferredExtent: false
          )
          #component: 
           #(#SpecCollection
              #collection: 
               #(
                 #(#ViewSpec
                    #name: 'view'
                    #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
                    #component: 
                     #(#SpecCollection
                        #collection: 
                         #(
                           #(#LabelSpec
                              #name: 'infoLabel'
                              #layout: #(#LayoutFrame 2 0 1 0.0 -81 1 -1 1.0)
                              #labelChannel: #valueOfInfoLabel
                              #level: -1
                              #adjust: #left
                              #resizeForLabel: false
                          )
                           #(#LabelSpec
                              #name: 'timeLabel'
                              #layout: #(#LayoutFrame -79 1 1 0.0 -1 1.0 -1 1.0)
                              #labelChannel: #valueOfTimeLabel
                              #level: -1
                              #adjust: #right
                              #resizeForLabel: false
                          )
                        )
                    )
                )
              )
          )
      )
! !

!ToolApplicationModel class methodsFor:'menu specs'!

menuAbout
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:ToolApplicationModel andSelector:#menuAbout
     (Menu new fromLiteralArrayEncoding:(ToolApplicationModel menuAbout)) startUp
    "

    <resource: #menu>

    ^
     
       #(#Menu
          
           #(
             #(#MenuItem
                #label: 'About Smalltalk/X...'
                #translateLabel: true
                #value: #openAbout
                #activeHelpKey: #aboutSTX
            )
             #(#MenuItem
                #label: '-'
            )
             #(#MenuItem
                #label: 'About This Application...'
                #translateLabel: true
                #value: #openAboutThisApplication
                #activeHelpKey: #aboutThisAppliaction
            )
          ) nil
          nil
      )
!

menuFont
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:ToolApplicationModel andSelector:#menuFont
     (Menu new fromLiteralArrayEncoding:(ToolApplicationModel menuFont)) startUp
    "

    <resource: #menu>

    ^
     
       #(#Menu
          
           #(
             #(#MenuItem
                #label: 'Label...'
                #value: #chooseFont:
                #argument: 'Label Font'
            )
             #(#MenuItem
                #label: 'Button...'
                #value: #chooseFont:
                #argument: 'Button Font'
            )
             #(#MenuItem
                #label: 'Edit...'
                #value: #chooseFont:
                #argument: 'Edit Font'
            )
             #(#MenuItem
                #label: 'List...'
                #value: #chooseFont:
                #argument: 'List Font'
            )
             #(#MenuItem
                #label: 'Tree List...'
                #value: #chooseFont:
                #argument: 'Tree List Font'
            )
             #(#MenuItem
                #label: 'Note Book...'
                #value: #chooseFont:
                #argument: 'Note Book Font'
            )
             #(#MenuItem
                #label: 'Framed Box...'
                #value: #chooseFont:
                #argument: 'Framed Box Font'
            )
             #(#MenuItem
                #label: '-'
            )
             #(#MenuItem
                #label: 'Reset'
                #value: #resetFonts
            )
          ) nil
          nil
      )
!

menuHelp
    "This resource specification was automatically generated
     by the MenuEditor of ST/X."

    "Do not manually edit this!! If it is corrupted,
     the MenuEditor may not be able to read the specification."

    "
     MenuEditor new openOnClass:ToolApplicationModel andSelector:#menuHelp
     (Menu new fromLiteralArrayEncoding:(ToolApplicationModel menuHelp)) startUp
    "

    <resource: #menu>

    ^
     
       #(#Menu
          
           #(
             #(#MenuItem
                #label: 'Documentation'
                #translateLabel: true
                #value: #openDocumentation
                #activeHelpKey: #helpTutorial
                #enabled: #valueOfHavingTutorial
            )
             #(#MenuItem
                #label: '-'
            )
             #(#MenuItem
                #label: 'Show Help Texts'
                #translateLabel: true
                #activeHelpKey: #helpShowHelp
                #indication: #showHelp:
            )
          ) nil
          nil
      )
! !

!ToolApplicationModel class methodsFor:'startup / release'!

preSnapshot

    clipboard := nil
!

uninitialize

    settings := showHelp := history := clipboard := nil
! !

!ToolApplicationModel methodsFor:'aspects'!

valueOfCanCopy

    |holder|
    (holder := builder bindingAt:#valueOfCanCopy) isNil ifTrue:[
        builder aspectAt:#valueOfCanCopy put:(holder :=  false asValue).
    ].
    ^ holder

!

valueOfCanCut

    |holder|
    (holder := builder bindingAt:#valueOfCanCut) isNil ifTrue:[
        builder aspectAt:#valueOfCanCut put:(holder :=  false asValue).
    ].
    ^ holder

!

valueOfCanPaste

    |holder|
    (holder := builder bindingAt:#valueOfCanPaste) isNil ifTrue:[
        builder aspectAt:#valueOfCanPaste put:(holder :=  false asValue).
    ].
    ^ holder

!

valueOfCanUndo

    |holder|
    (holder := builder bindingAt:#valueOfCanUndo) isNil ifTrue:[
        builder aspectAt:#valueOfCanUndo put:(holder :=  false asValue).
    ].
    ^ holder

!

valueOfEnablingCommitButtons

    |holder|
    (holder := builder bindingAt:#valueOfEnablingCommitButtons) isNil ifTrue:[
        builder aspectAt:#valueOfEnablingCommitButtons put:(holder :=  false asValue).
    ].
    ^ holder

!

valueOfHavingDocumentation

    |holder|
    (holder := builder bindingAt:#valueOfHavingDocumentation) isNil ifTrue:[
        builder aspectAt:#valueOfHavingDocumentation put:(holder :=  (self class implements: #openDocumentation) asValue).
    ].
    ^ holder

!

valueOfHavingExamples

    |holder|
    (holder := builder bindingAt:#valueOfHavingExamples) isNil ifTrue:[
        builder aspectAt:#valueOfHavingExamples put:(holder :=  (self class implements: #openExamples) asValue).
    ].
    ^ holder

!

valueOfHavingTutorial

    ^self valueOfHavingDocumentation

!

valueOfInfoLabel

    |holder|
    (holder := builder bindingAt:#valueOfInfoLabel) isNil ifTrue:[
        builder aspectAt:#valueOfInfoLabel put:(holder :=  ValueHolder new).
    ].
    ^ holder

!

valueOfTimeLabel

    |holder|
    (holder := builder bindingAt:#valueOfTimeLabel) isNil ifTrue:[
        builder aspectAt:#valueOfTimeLabel put:(holder :=  ValueHolder new).
    ].
    ^ holder

! !

!ToolApplicationModel methodsFor:'clipboard'!

clipboard

    ^self class clipboard
!

clipboard: anEditObject

    self class clipboard: anEditObject.

    self valueOfCanPaste value: anEditObject notNil
! !

!ToolApplicationModel methodsFor:'help'!

defaultInfoLabel

    ^''
!

openAbout
    "show an about box"

    |box|

    box := AboutBox new.
    box autoHideAfter:10 with:[].
    box showAtCenter

!

openAboutThisApplication
    "show an about this application box"

    |rev box|
    rev := ''.
    self class revision notNil ifTrue: [rev := '  (rev: ', self class revision printString, ')'].
    box := AboutBox title:
        '\The application\\' withCRs
        , self class name asBoldText, rev
        , '\\has been designed and implemented by: \' withCRs
        , ((self class authorLinesForAboutBox collect:[:l | '- ' , l]) asStringWith:$\) withCRs
        , '\\' withCRs.

     box   label:'About This Application'.
     box   autoHideAfter:10 with:[].
     box   showAtCenter.
!

openHTMLDocument: aHTMLFilename

    HTMLDocumentView openFullOnDocumentationFile: aHTMLFilename
!

openTutorial: aHTMLFilename

    self openHTMLDocument: aHTMLFilename
!

showHelp
    "answer whether showing help is turned on/off"

    |currentActiveHelp|

    currentActiveHelp := ActiveHelp currentHelpListener.

    ^self class showHelp 
        and: [currentActiveHelp notNil and: [masterApplication notNil 
                ifFalse: [currentActiveHelp interestedIn: self window]
                ifTrue:  [currentActiveHelp interestedIn: masterApplication window]]]
!

showHelp: aValue
    "toggle showing help"

    (self class showHelp: aValue)
        ifTrue: [ActiveHelp startFor: self]
        ifFalse: [ActiveHelp stopFor: self. self updateInfoLabel]
!

showHelp:aHelpText for:view
    "display aHelpText in the info label or if present detour to masterApplication."

    self showHelp ifFalse: [^true].
    masterApplication notNil ifTrue: [masterApplication showHelp: aHelpText for:view].
    aHelpText isNil 
        ifTrue:  [self updateInfoLabel] 
        ifFalse: [self valueOfInfoLabel value: (aHelpText asString printString readStream through: $.)].
    ^true
!

updateInfoLabel

    self valueOfInfoLabel value: self defaultInfoLabel
! !

!ToolApplicationModel methodsFor:'history'!

addToHistory: aHistoryEntry

    aHistoryEntry key size = 0 ifTrue: [^nil].
    self history remove: (self history detect: [:histEntry| histEntry key = aHistoryEntry key] ifNone: nil) ifAbsent: nil.
    self history addFirst: aHistoryEntry.
    [self history size > self class historyMaxSize] whileTrue: [self history removeLast]
!

emptyHistory

    ^self history removeAll
!

history

    ^self class getHistory
!

historyEntries

    ^self history collect: [:asso| asso key]
!

menuHistory

    |menu|
    menu := Menu new receiver: self.
    (self history collect: [:histEntry| histEntry value]) asSet asOrderedCollection do:
    [:historyEntryType|    
        menu addItemGroup: ((self history select: [:histEntry| histEntry value = historyEntryType]) collect: [:histEntry|  MenuItem new label: histEntry key printString; value: histEntry value; argument: histEntry key; activeHelpKey: #historyMenuItem]).
    ]. 
    menu addItem: (MenuItem new label: 'Empty History'; value: #emptyHistory; activeHelpKey: #historyEmptyMenu).

    ^menu
!

removeFromHistory: aHistoryEntry

    self history remove: (self history detect: [:histEntry| histEntry key = aHistoryEntry key] ifNone: nil) ifAbsent: nil.
    [self history size > self class historyMaxSize] whileTrue: [self history removeLast]
! !

!ToolApplicationModel methodsFor:'queries'!

allToolInstances

    ^self class settings at: #Instances ifAbsent: [^#()]
!

preferredExtent
    "preferred extent of my window; top/main menu and top toolbar (named by 'menuToolbarView')
     will be considered"

    |window menu menuToolbarView preferredExtentOfWindow|

    window          := self builder window. 
    menu            := window subViews first.
    menuToolbarView := builder componentAt: #menuToolbarView.

    preferredExtentOfWindow := window extent.
    menu class = MenuPanel ifTrue: [preferredExtentOfWindow := preferredExtentOfWindow max: menu preferredExtent].
    menuToolbarView notNil ifTrue: [preferredExtentOfWindow := preferredExtentOfWindow max: menuToolbarView preferredExtent].

    ^window minExtent max: (preferredExtentOfWindow min: window maxExtent)
! !

!ToolApplicationModel methodsFor:'settings'!

allFontViewsDo: aBlock
    "evaluates aBlock for all views with fonts"

    |fontViews|

    fontViews := OrderedCollection new.

    self builder windowGroup views do: [:v| v class = MenuPanel ifTrue: [fontViews add: v]]. 

    builder namedComponents do: 
    [:aView|    
        aView allSubViewsDo: 
        [:v|
            v font notNil ifTrue: [fontViews add: v]
        ] 
    ].
    fontViews do: aBlock
!

chooseFont: viewFont
    "chooses a font for viewFont and puts it into the settings dictionary;
     finally update all my views"

    |defaultFont font|

    viewFont = 'Label Font'      ifTrue: [defaultFont := Label defaultFont].
    viewFont = 'Button Font'     ifTrue: [defaultFont := Button defaultFont].
    viewFont = 'Edit Font'       ifTrue: [defaultFont := TextView defaultFont].
    viewFont = 'List Font'       ifTrue: [defaultFont := ListView defaultFont].
    viewFont = 'Tree List Font'  ifTrue: [defaultFont := SelectionInTreeView defaultFont].
    viewFont = 'Note Book Font'  ifTrue: [defaultFont := NoteBookView defaultFont].
    viewFont = 'Framed Box Font' ifTrue: [defaultFont := FramedBox defaultFont].

    (font := FontPanel 
        fontFromUserInitial: (self class settings at: viewFont asSymbol ifAbsent: nil) ? defaultFont
        title: 'Choose ', viewFont) notNil
    ifTrue:
    [      
        self class settings at: viewFont asSymbol put: (font on: device).
        self updateFonts
    ].
    ^font
!

resetFonts
    "sets the fonts in the settings to nil and resets the views to its default font"

    (self class settings)
        at: #'Label Font'      put: Label defaultFont;
        at: #'Button Font'     put: Button defaultFont;
        at: #'Edit Font'       put: TextView defaultFont;
        at: #'List Font'       put: ListView defaultFont;
        at: #'Tree List Font'  put: SelectionInTreeView defaultFont;
        at: #'Note Book Font'  put: NoteBookView defaultFont;
        at: #'Framed Box Font' put: FramedBox defaultFont.

    self updateFonts.

    (self class settings)
        removeKey: #'Label Font'      ifAbsent: nil;
        removeKey: #'Button Font'     ifAbsent: nil;
        removeKey: #'Edit Font'       ifAbsent: nil;
        removeKey: #'List Font'       ifAbsent: nil;
        removeKey: #'Tree List Font'  ifAbsent: nil;
        removeKey: #'Note Book Font'  ifAbsent: nil;
        removeKey: #'Framed Box Font' ifAbsent: nil.

!

updateFonts
    "takes defined fonts from the settings and set them to the corresponding views"

    |settings labelFont buttonFont editFont listFont treeListFont noteBookFont framedBoxFont updateFontsBlock|

    settings     := self class settings.

    labelFont     := settings at: #'Label Font'      ifAbsent: nil.
    buttonFont    := settings at: #'Button Font'     ifAbsent: nil.
    editFont      := settings at: #'Edit Font'       ifAbsent: nil.
    listFont      := settings at: #'List Font'       ifAbsent: nil.
    treeListFont  := settings at: #'Tree List Font'  ifAbsent: nil.
    noteBookFont  := settings at: #'Note Book Font'  ifAbsent: nil.
    framedBoxFont := settings at: #'Framed Box Font' ifAbsent: nil.

    updateFontsBlock :=
    [:v|     
        (labelFont notNil and: [v font ~= labelFont and: [(v class == Label) or: [v isKindOf: Toggle]]])
            ifTrue: [v font: labelFont; fixSize; sizeChanged:nil; invalidate].
        (buttonFont notNil and: [v font ~= buttonFont and: [v class == Button or: [v class == PopUpList]]])
            ifTrue: [v label isString ifTrue: [|e|e := v extent. v font: buttonFont; extent: e; invalidate]].
        (editFont  notNil and: [v font ~= editFont and: [v isKindOf: TextView]])
            ifTrue: [v font: editFont; invalidate].
        (listFont notNil and: [v font ~= listFont and: [v class = SelectionInListView or: [v class = DataSetView]]])
            ifTrue: [v font: listFont. v invalidate].
        (treeListFont notNil and: [v font ~= treeListFont and: [v isKindOf: SelectionInTreeView]])
            ifTrue: [v font: treeListFont; invalidate].
        (noteBookFont notNil and: [v font ~= noteBookFont and: [v class == NoteBookView]])
            ifTrue: [v font: noteBookFont; invalidate].
        (framedBoxFont notNil and: [v font ~= framedBoxFont and: [v class == FramedBox]])
            ifTrue: [v font: framedBoxFont; invalidate]
    ].

    self allFontViewsDo: [:v| updateFontsBlock value: v] 

! !

!ToolApplicationModel methodsFor:'startup / release'!

allButOpenInterface:aSymbol

    super allButOpenInterface:aSymbol.

    builder window extent: self preferredExtent.
    builder window label: self class label.

    ^builder
!

close

    self uninitialize.

    super close
!

closeRequest

    self uninitialize.

    super closeRequest
!

postOpenWith:aBuilder

    super postOpenWith:aBuilder.

    self class showHelp ifTrue: [ActiveHelp startFor: self].
    self updateInfoLabel.
    self updateFonts.

!

reOpen

    self close.

    self class open
!

removeAllTemporalViews

    self builder namedComponents keys copy do: 
    [:comp| 
        (comp includesString: '_Temporal') ifTrue: [self builder namedComponents removeKey: comp]
    ]
!

startClockOnTimedBlock: aBlock

    timeBlock := aBlock.
    aBlock value.

!

uninitialize

    self showHelp ifTrue: [ActiveHelp stopFor: self].
    timeBlock notNil ifTrue: [Processor removeTimedBlock:timeBlock. timeBlock := nil].

! !

!ToolApplicationModel class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview2/ToolApplicationModel.st,v 1.52 1998-04-04 17:08:16 tz Exp $'
! !