ToolApplicationModel.st
author tz
Sat, 14 Feb 1998 20:43:52 +0100
changeset 838 d2588cca5a15
parent 834 ac1655bd31bb
child 844 5d9915ac0be6
permissions -rw-r--r--
some obselete texts removed

"
 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 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
"
    Standard framework for tools; provides hooks for history management,
    showing help texts, about menu, help menu etc.
    See concrete subclasses for examples.

    [author:]
        Thomas Zwick
"
! !

!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
!

showHelp

    ^showHelp ? (showHelp := true)
!

showHelp: aBoolean

    ^showHelp := aBoolean
! !

!ToolApplicationModel class methodsFor:'clipboard'!

clipboard

    ^clipboard
!

clipboard: anEditObject

    clipboard := anEditObject
! !

!ToolApplicationModel class methodsFor:'help specs'!

helpSpec
    "return a dictionary filled with helpKey -> helptext associations.
     These are used by the activeHelp tool."

    "
    UIHelpTool openOnClass:ToolApplicationModel    
    "

  ^ 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
'Cancel last edit action.'

#commitOK
'Accept last edit action.'

#edit
'Edit functions.'

#editCopy
'Copies the selected item to the clipboard.'

#editCut
'Cuts the selected item and place it to the clipboard.'

#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.'

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

#helpTutorial
'Opens a HTML-browser with a tutorial for beginners.'

#history
'History functions.'

#historyEmptyMenu
'Deletes all items of the history.'

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

#test
'Test functions.'

)

! !

!ToolApplicationModel class methodsFor:'history'!

getHistory

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

!

historyMaxSize

    ^10

! !

!ToolApplicationModel class methodsFor:'interface specs'!

windowSpecForCommit

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'layout:' #(#LayoutFrame 343 0 328 0 642 0 387 0)
              #'min:' #(#Point 100 22)
              #'max:' #(#Point 1152 900)
              #'bounds:' #(#Rectangle 343 328 643 388)
              #'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

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'layout:' #(#LayoutFrame 343 0 328 0 642 0 387 0)
              #'min:' #(#Point 100 22)
              #'max:' #(#Point 1152 900)
              #'bounds:' #(#Rectangle 343 328 643 388)
              #'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

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'layout:' #(#LayoutFrame 366 0 355 0 865 0 700 0)
              #'min:' #(#Point 400 320)
              #'max:' #(#Point 1152 900)
              #'bounds:' #(#Rectangle 366 355 866 701)
              #'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
                          )
                        )
                    )
                )
              )
          )
      )
!

windowSpecForInfoBarWithClock

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'layout:' #(#LayoutFrame 349 0 227 0 848 0 572 0)
              #'min:' #(#Point 400 320)
              #'max:' #(#Point 1152 900)
              #'bounds:' #(#Rectangle 349 227 849 573)
              #'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
                          )
                           #(#LabelSpec
                              #'name:' 'timeLabel'
                              #'layout:' #(#LayoutFrame -79 1 1 0.0 -1 1.0 -1 1.0)
                              #'labelChannel:' #valueOfTimeLabel
                              #'level:' -1
                              #'adjust:' #right
                          )
                        )
                    )
                )
              )
          )
      )
! !

!ToolApplicationModel class methodsFor:'menu specs'!

menuAbout
    "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: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
      )

    "Modified: / 30.1.1998 / 00:03:11 / cg"
!

menuHelp
    "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:ToolApplicationModel andSelector:#menuHelp
     (Menu new fromLiteralArrayEncoding:(ToolApplicationModel menuHelp)) startUp
    "

    <resource: #menu>

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

menuSettings
    "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:ToolApplicationModel andSelector:#menuSettings
     (Menu new fromLiteralArrayEncoding:(ToolApplicationModel menuSettings)) startUp
    "

    <resource: #menu>

    ^
     
       #(#Menu
          
           #(
             #(#MenuItem
                #'label:' 'Language...'
                #'translateLabel:' true
                #'value:' #languageSetting
            )
          ) nil
          nil
      )

    "Modified: / 30.1.1998 / 00:04:14 / cg"
! !

!ToolApplicationModel class methodsFor:'resources'!

desktopIcon

    |desktopIcon|
    desktopIcon := self stxIcon.
    ^desktopIcon magnifiedBy: Display preferredIconSize/desktopIcon extent



!

downIcon
    "Generated by the Image Editor"
    "
    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'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); 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]!

downLeftIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#downLeftIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel downLeftIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUUPUUUUU@@PUUUUUJ)PUUUUUJ)PUUUUUJ)PUUUUUJ)PUUUUUJ)PUUUUUJ)PUUUUUJ)PUUUUUJ)PUUAUUJ)PUT%UUJ)PUR%UUJ)PUJ$@@J)PT*****)PR*****)PV*****)PU*****)PUZ%UUUUPUV%UUUUPUU%UUUUPUUUUUUUP'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@G8@@G8@@G8@@G8@@G8@@G8@@G8@@G8@@G8@0G8A0G8C0G8G??8O??8_??8_??8O??8G??8C0@@A0@@@0@@'); yourself); yourself]!

downRightIcon
    "Generated by the Image Editor"
    "
    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'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); 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]!

fileOutIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#fileOutIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel fileOutIcon'
        ifAbsentPut:[(Depth2Image new) width: 24; height: 24; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@B@@@@@@@B @@@@@@*(@@@@@BB @@@@@BB@@@@@@B@@@@@@@B@@@@@@@B@@@@@@@B@@@@@@@B@@@@@@@@@@@@@@@@@@@@@@@@@@@@D@@AQDEADQAAADDADQA@AD@ADQAAQDEADQAAADDADQAAA@@@PAAAAEE@@DA'); colorMap:((OrderedCollection new add:(Color black); add:(Color white); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); mask:((Depth1Image new) width: 24; height: 24; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@A@A.A%BDG2ADI%@$I@SDH@@@H@@@H@@@H@@@H@@@@@@@@@@@Z&KW_7_;[6_;[6_;_7_;[6_;[6L+I[@Q'); yourself); yourself]!

leftDownIcon
    "Generated by the Image Editor"
    "
    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'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); 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
    "Generated by the Image Editor"
    "
    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'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); 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]!

leftUpIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#leftUpIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel leftUpIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUUPUTUUUUUPUR%UUUUPUJ)UUUUPT**UUUUPR**%UUUPJ**)UUUP%Z)UUUUPUJ)UUUUPUJ)UUUUPUJ)UUUUPUJ)UUUUPUJ)UUUUPUJ)UUUUPUJ)UUUUPUJ)@@@@PUJ****)PUJ****)PUJ****)PUJ****)PUEUUUUUPUUUUUUUP'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@A @@C0@@G8@@O<@@_>@@??@@??@@G8@@G8@@G8@@G8@@G8@@G8@@G8@@G??8G??8G??8G??8G??8G??8@@@@'); yourself); yourself]!

loadIcon
    "Generated by the Image Editor"
    "
    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'); colorMap:(((Array new:4) at:1 put:((Color white)); at:2 put:((Color black)); at:3 put:((Color grey:49.9962)); at:4 put:((Color grey:66.9978)); yourself)); 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

    |menuIcon|
    menuIcon := self stxIcon.
    ^menuIcon magnifiedBy: MenuPanel defaultFont height/menuIcon height
!

newIcon
    "Generated by the Image Editor"
    "
    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*****(@@@@@@@@@'); colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color grey:49.9962)); at:4 put:((Color grey:66.9978)); yourself)); 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]!

removeIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#removeIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel removeIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@BUUUUP@@B/???2@@B+???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*???:(@B+???>(@B/????(@B*****(@@@@@@@@@'); colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color grey:49.9962)); at:4 put:((Color grey:66.9978)); yourself)); 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]!

rightIcon
    "Generated by the Image Editor"
    "
    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'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); 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
    "Generated by the Image Editor"
    "
    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'); colorMap:(((Array new:4) at:1 put:((Color white)); at:2 put:((Color black)); at:3 put:((Color grey:49.9962)); at:4 put:((Color grey:66.9978)); yourself)); mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???<???8'); yourself); yourself]
!

searchIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#searchIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel searchIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@CV*@MZ(@@@@@@@@@CV*@MZ(@CV*@MZ(@CV*@MZ(@CV*@MZ(@CV*@MZ(@CV*@MZ(@CV*JMZ(@CV(@AZ(@CV(6!!Z(@CV(@AZ(@CV*@MZ(@@@@@@@@@@MZ 5Z@@@@@@@@@@@A(@A(@@@@@@@@@@@M*@M*@@@@@@@@@@'); colorMap:((OrderedCollection new add:(Color black); add:(Color grey:74.5083); add:(Color grey:49.9962); add:(Color white); yourself)); mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@_<?8_<?8_<?8_<?8_<?8_<?8_<?8_<?8_??8_??8_??8_??8_??8_??8_??8G?? G?? C8_@C8_@G<? G<? '); yourself); yourself]!

startIcon
    "Generated by the Image Editor"
    "
    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'); colorMap:((OrderedCollection new add:(Color black); add:(Color white); add:(Color red:100.0 green:0.0 blue:0.0); add:(Color red:0.0 green:100.0 blue:0.0); add:(Color red:0.0 green:0.0 blue:100.0); add:(Color red:0.0 green:100.0 blue:100.0); add:(Color red:100.0 green:100.0 blue:0.0); add:(Color red:100.0 green:0.0 blue:100.0); add:(Color red:49.9962 green:0.0 blue:0.0); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:0.0 green:0.0 blue:49.9962); add:(Color red:0.0 green:49.9962 blue:49.9962); add:(Color red:49.9962 green:49.9962 blue:0.0); add:(Color red:49.9962 green:0.0 blue:49.9962); add:(Color grey:49.9962); add:(Color grey:66.9978); yourself)); 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
    "Generated by the Image Editor"
    "
    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@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); colorMap:((OrderedCollection new add:(Color grey:9.99924); add:(Color red:0.0 green:80.0 blue:20.0); add:(Color black); add:(Color white); yourself)); yourself]
!

upIcon
    "Generated by the Image Editor"
    "
    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*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUT*%UUPUUTUUUUP'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); 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]!

upRightIcon
    "Generated by the Image Editor"
    "
    ImageEditor openOnClass:self andSelector:#upRightIcon
    "

    <resource: #image>

    ^Icon
        constantNamed:#'ToolApplicationModel upRightIcon'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUTUUPUUUUT%UPUUUUT)UPP@@@@*UPR*****%PR*****)PR*****)PR*****%PR*UUU*UPR*UUT)UPR*UUT%UPR*UUTUUPR*UUUUUPR*UUUUUPR*UUUUUPR*UUUUUPR*UUUUUPR*UUUUUPR*UUUUUPR*UUUUUPQUUUUUUPUUUUUUUP'); colorMap:((OrderedCollection new add:(Color white); add:(Color black); add:(Color red:0.0 green:49.9962 blue:0.0); add:(Color red:100.0 green:0.0 blue:0.0); yourself)); 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]! !

!ToolApplicationModel class methodsFor:'startup / release'!

preSnapshot

    clipboard := nil
   
!

uninitialize

    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

!

valueOfHavingClipboard

    |holder|
    (holder := builder bindingAt:#valueOfHavingClipboard) isNil ifTrue:[
        builder aspectAt:#valueOfHavingClipboard put:(holder :=  self class clipboard notNil asValue).
    ].
    ^ holder

!

valueOfHavingTutorial

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

!

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 valueOfHavingClipboard 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
        , (Text string: self class name emphasis: #bold), 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.

    "Modified: / 1.2.1998 / 15:59:58 / cg"
!

openTutorial: aHTMLFilename

    HTMLDocumentView openFullOnDocumentationFile: aHTMLFilename
!

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

    |currentActiveHelp|
    currentActiveHelp := ActiveHelp currentHelpListener.

    ^self class showHelp 
        and: [currentActiveHelp notNil and: [currentActiveHelp interestedIn: self builder 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].
    self masterApplication notNil
    ifTrue:
    [
        ^masterApplication showHelp: aHelpText for:view
    ]
    ifFalse:
    [
        aHelpText isNil 
            ifTrue:  [self updateInfoLabel] 
            ifFalse: [self valueOfInfoLabel value: (aHelpText asString printString upTo: Character cr)].

        ^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
!

menuHistory

    |menu a|
    menu := Menu new receiver: self.
    (self history collect: [:histEntry| histEntry value]) asSet asOrderedCollection do:
    [:historyEntryType|    
        menu addItemGroup: ((a := 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'!

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:'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.

    timeBlock := [self showTime].
    self showTime.
    self class showHelp ifTrue: [ActiveHelp startFor: self].
    self updateInfoLabel.
!

reOpen

    self close.

    self class open
!

removeAllTemporalViews

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

uninitialize

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

!ToolApplicationModel methodsFor:'window events'!

showTime

    |now hours minutes suffix|

    now := Time now.

    hours := now hours.
    minutes := now minutes printString.
    suffix := ''.

    (resources at:'TIME_FORMAT' ifAbsent:12) == 12 ifTrue:[
        suffix := ' am '.  
        hours > 12 ifTrue: [hours := hours - 12. suffix := ' pm '].
    ].

    minutes size = 1 ifTrue: [minutes := '0', minutes].

    self valueOfTimeLabel value: hours printString, ':', minutes, suffix.

    Processor removeTimedBlock: timeBlock.
    Processor addTimedBlock: timeBlock afterSeconds: 1

    "Modified: / 5.2.1998 / 09:23:20 / cg"
! !

!ToolApplicationModel class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview2/ToolApplicationModel.st,v 1.39 1998-02-14 19:43:52 tz Exp $'
! !