UIPainter.st
author Claus Gittinger <cg@exept.de>
Sat, 07 Feb 1998 21:23:24 +0100
changeset 624 26e7978936fc
parent 609 60f89fba074a
child 625 8448535a3334
permissions -rw-r--r--
ignore redraws - components redraw themself. Fixes bad grid-redraw bug.

"
 COPYRIGHT (c) 1995 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.
"


ToolApplicationModel subclass:#UIPainter
	instanceVariableNames:'treeView selectionPanel tabSelection specClass specSelector
		specSuperclass aspects layoutCanvas helpCanvas specCanvas
		transcript'
	classVariableNames:''
	poolDictionaries:''
	category:'Interface-UIPainter'
!

SelectionInTreeView subclass:#TreeView
	instanceVariableNames:'lastDrawnMaster cvsEventsDisabled windowSpec'
	classVariableNames:''
	poolDictionaries:''
	privateIn:UIPainter
!

!UIPainter class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1995 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
"
    GUI-Builder:
    this class allows the user to build its own applications providing a graphical
    user interface to buildin components and to define the behavior of the components
    during runtime. The resulting specifications can be installed as methods on 
    classes, typically subclasses of an ApplicationModel. These specifications
    are used by the UIBuilder to generate the application window and its component
    structues when open the application.

    [start with:]
        UIPainter open

    [author:]
        Claus Gittinger, eXept Software AG
        Claus Atzkern, eXept Software AG

    [see also:]
        UIBuilder
        ApplicationModel
        UISpecification
"

! !

!UIPainter class methodsFor:'instance creation'!

openOnClass:aClass andSelector:aSelector
    "open up an interface builder, fetching a spec from aClass
     via some selector
    "
    ^ self new openOnClass:aClass andSelector:aSelector
!

painter:aBuilderView
    "set the painter
    "
    |application|

    application := self new.
    application painter:aBuilderView.
  ^ application open
! !

!UIPainter class methodsFor:'ST-80 queries'!

preferenceFor:aSymbol
    "ST-80 compatible; always returns false
    "
    ^ false


! !

!UIPainter class methodsFor:'accessing'!

label

    ^'GUI Builder'
! !

!UIPainter class methodsFor:'help specs'!

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

    "
    UIHelpTool openOnClass:UIPainter    
    "

  ^ super helpSpec addPairsFrom:#(

#accept
'Writes back changes.'

#alignSelectionBottom
'Aligns selected widgets to the bottom edge of the dominant widget.'

#alignSelectionCenterHor
'Aligns selected widgets vertical to the center of the dominant widget.'

#alignSelectionCenterVer
'Aligns selected widgets horizontal to the center of the dominant widget.'

#alignSelectionLeft
'Aligns selected widgets to the left edge of the dominant widget.'

#alignSelectionLeftAndRight
'Aligns selected widgets to the right and left edge of the dominant widget.'

#alignSelectionRight
'Aligns selected widgets to the right edge of the dominant widget.'

#alignSelectionTop
'Aligns selected widgets to the top edge of the dominant widget.'

#alignSelectionTopAndBottom
'Aligns selected widgets to the top and bottom edge of the dominant widget.'

#cancel
'Rereads specification and layout.'

#centerSelectionHor
'Centers widgets horizontal to their top widget.'

#centerSelectionVer
'Centers vertical horizontal in contained view.'

#copyExtent
'Copies extent of the selected widget.'

#copyLayout
'Copies layout of the selected widget.'

#fileLoad
'Opens dialog to load an interface from a class.'

#fileLoadSubspec
'Opens dialog to load an subspec interface from a class.'

#fileNew
'Creates new interface.'

#filePickAnInterface
'Changes the cursor for moving it over another view to load its interface.'

#fileSave
'Saves current interface.'

#galleryShown
'Shows or hide gallery view.'

#menuAlignment
'Provides a set of alignment operation on the current selected widgets.'

#moveSelectionDown
'Moves selected widgets down.'

#moveSelectionLeft
'Moves selected widgets out of parent widget.'

#moveSelectionRight
'Moves selected widgets into next widget as child.'

#moveSelectionUp
'Moves selected widgets up.'

#painterShown
'Shows or hide painter view.'

#pasteBuffer
'Pastes widgets at current mouse position.'

#pasteExtent
'Changes extent of all selected widgets to the last copied extent.'

#pasteHeight
'Changes height of all selected widgets to the last copied extent height.'

#pasteLayout
'Changes layout of all selected widgets to the last copied layout.'

#pasteWidth
'Changes width of all selected widgets to the last copied extent width.'

#pasteWithLayout
'Pastes widgets without changing their layouts.'

#setToDefaultExtent
'Sets selected widgets to their default extent.'

#setToDefaultHeight
'Sets selected widgets to their default height.'

#setToDefaultWidth
'Sets selected widgets to their default width.'

#spreadSelectionHor
'Sets horizontal spaces between selected widgets as the same.'

#spreadSelectionVer
'Sets vertical spaces between selected widgets as the same.'

#testStartApplication
'Starts current application on loaded interface.'

)
! !

!UIPainter class methodsFor:'helpers'!

convertString:aString maxLineSize:maxCharactersPerLine skipLineFeed:skipLineFeed
    "converts a string to a string collection with maximum characters
     per line
    "
    |stream
        max     "{ Class:SmallInteger }"
        size    "{ Class:SmallInteger }"
        start   "{ Class:SmallInteger }"
        stop    "{ Class:SmallInteger }"
        cpySz   "{ Class:SmallInteger }"
        lnSz    "{ Class:SmallInteger }"
        atBeginOfLine|

    maxCharactersPerLine < 20 ifFalse:[max := maxCharactersPerLine - 1]
                               ifTrue:[max := 20].

    (size := aString size) <= max ifTrue:[
        ^ aString
    ].
    start  := 1.
    lnSz   := 0.
    stream := (String new:size) writeStream.

    atBeginOfLine := true.

    [start <= size] whileTrue:[
        (start := aString indexOfNonSeparatorStartingAt:start) == 0 ifTrue:[
            ^ stream contents
        ].
        (aString at:start) == $\ ifTrue:[
            skipLineFeed ifFalse:[
                stream nextPut:$\
            ].
            start := start + 1.
            stream cr.
            start := start + 1.
            lnSz := 0.
        ] ifFalse:[
            (stop := aString indexOfSeparatorStartingAt:start) == 0 ifTrue:[
                stop := size + 1
            ].
            (aString at:(stop - 1)) == $\ ifTrue:[
                stop := stop - 1
            ].
            cpySz := stop - start.

            lnSz == 0 ifFalse:[
                (lnSz := lnSz + cpySz) >= max ifTrue:[stream cr.    lnSz := cpySz. atBeginOfLine := true. ]
                                             ifFalse:[stream space. lnSz := lnSz + 1]
            ] ifTrue:[
                lnSz := cpySz
            ].
            stream nextPutAll:aString startingAt:start to:(stop - 1).
            start := stop.
        ]
    ].
    ^ stream contents

    "Modified: / 1.2.1998 / 14:42:56 / cg"
! !

!UIPainter class methodsFor:'interface specs'!

gridParametersSpec
    "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:UIPainter andSelector:#gridParametersSpec
     UIPainter new openInterface:#gridParametersSpec
    "

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'GUI Builder'
              #'layout:' #(#LayoutFrame 44 0 416 0 325 0 613 0)
              #'label:' 'GUI Builder'
              #'min:' #(#Point 10 10)
              #'max:' #(#Point 1280 1024)
              #'bounds:' #(#Rectangle 44 416 326 614)
              #'usePreferredExtent:' false
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#FramedBoxSpec
                    #'name:' 'framedBox'
                    #'layout:' #(#LayoutFrame 0 0.0 3 0.0 0 1.0 -35 1.0)
                    #'component:' 
                     #(#SpecCollection
                        #'collection:' 
                         #(
                           #(#CheckBoxSpec
                              #'name:' 'show'
                              #'layout:' #(#Point 23 24)
                              #'model:' #showGrid
                              #'label:' 'Show grid'
                          )
                           #(#CheckBoxSpec
                              #'name:' 'align'
                              #'layout:' #(#Point 23 52)
                              #'model:' #alignToGrid
                              #'label:' 'Align to Grid'
                          )
                           #(#LabelSpec
                              #'name:' 'hrzLabel'
                              #'layout:' #(#AlignmentOrigin 148 0 99 0 1 0.5)
                              #'label:' 'Horizontal Pixels:'
                              #'adjust:' #right
                              #'resizeForLabel:' true
                          )
                           #(#InputFieldSpec
                              #'name:' 'hrzField'
                              #'layout:' #(#LayoutFrame 154 0 87 0 207 0 109 0)
                              #'model:' #hspace
                              #'type:' #numberOrNil
                          )
                           #(#LabelSpec
                              #'name:' 'vrtLabel'
                              #'layout:' #(#AlignmentOrigin 149 0 124 0 1 0.5)
                              #'label:' 'Vertical Pixels:'
                              #'adjust:' #right
                              #'resizeForLabel:' true
                          )
                           #(#InputFieldSpec
                              #'name:' 'vrtField'
                              #'layout:' #(#LayoutFrame 154 0 112 0 207 0 134 0)
                              #'model:' #vspace
                              #'type:' #numberOrNil
                          )
                        )
                    )
                    #'label:' 'Grid Parameter'
                    #'labelPosition:' #topLeft
                )
                 #(#UISubSpecification
                    #'name:' 'uISubSpecifica1'
                    #'layout:' #(#LayoutFrame 0 0.0 -29 1 0 1.0 -5 1)
                    #'majorKey:' #ToolApplicationModel
                    #'minorKey:' #windowSpecForCommitWithoutChannels
                )
              )
          )
      )
!

nameAndSelectorSpec
    "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:UIPainter andSelector:#nameAndSelectorSpec
     UIPainter new openInterface:#nameAndSelectorSpec
    "

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'GUI Builder'
              #'layout:' #(#LayoutFrame 238 0 270 0 584 0 429 0)
              #'label:' 'GUI Builder'
              #'min:' #(#Point 10 10)
              #'max:' #(#Point 1152 900)
              #'bounds:' #(#Rectangle 238 270 585 430)
              #'usePreferredExtent:' false
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#FramedBoxSpec
                    #'name:' 'framedBox1'
                    #'layout:' #(#LayoutFrame 0 0.0 3 0.0 0 1.0 -35 1.0)
                    #'component:' 
                     #(#SpecCollection
                        #'collection:' 
                         #(
                           #(#LabelSpec
                              #'name:' 'selectorLabel'
                              #'layout:' #(#AlignmentOrigin 77 0.11 39 0 1 0.5)
                              #'label:' 'Selector:'
                              #'adjust:' #right
                              #'resizeForLabel:' true
                          )
                           #(#InputFieldSpec
                              #'name:' 'methodNameField'
                              #'layout:' #(#LayoutFrame 80 0.11 28 0 14 1.0 50 0)
                              #'tabable:' true
                              #'model:' #methodNameChannel
                          )
                           #(#LabelSpec
                              #'name:' 'classLabel'
                              #'layout:' #(#AlignmentOrigin 77 0.11 64 0 1 0.5)
                              #'label:' 'Class:'
                              #'adjust:' #right
                              #'resizeForLabel:' true
                          )
                           #(#InputFieldSpec
                              #'name:' 'classNameField'
                              #'layout:' #(#LayoutFrame 80 0.11 53 0 14 1.0 75 0)
                              #'tabable:' true
                              #'model:' #classNameChannel
                          )
                           #(#LabelSpec
                              #'name:' 'superClassLabel'
                              #'layout:' #(#AlignmentOrigin 77 0.11 89 0 1 0.5)
                              #'label:' 'Superclass:'
                              #'adjust:' #right
                              #'resizeForLabel:' true
                          )
                           #(#ComboBoxSpec
                              #'name:' 'superclassNameComboBox'
                              #'layout:' #(#LayoutFrame 80 0.11 78 0 14 1.0 100 0)
                              #'tabable:' true
                              #'model:' #superclassNameChannel
                              #'comboList:' #superclassNameDefaults
                          )
                        )
                    )
                    #'label:' 'Class and selector for interface'
                    #'labelPosition:' #topLeft
                )
                 #(#UISubSpecification
                    #'name:' 'uISubSpecifica1'
                    #'layout:' #(#LayoutFrame 0 0.0 -29 1 0 1.0 -5 1)
                    #'majorKey:' #ToolApplicationModel
                    #'minorKey:' #windowSpecForCommitWithoutChannels
                )
              )
          )
      )
!

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:UIPainter andSelector:#windowSpec
     UIPainter new openInterface:#windowSpec
    "
    "UIPainter open"

    <resource: #canvas>

    ^
     
       #(#FullSpec
          #'window:' 
           #(#WindowSpec
              #'name:' 'Tree-View'
              #'layout:' #(#LayoutFrame 340 0 328 0 892 0 853 0)
              #'label:' 'Tree-View'
              #'min:' #(#Point 10 10)
              #'max:' #(#Point 1160 870)
              #'bounds:' #(#Rectangle 340 328 893 854)
              #'menu:' #menu
              #'usePreferredExtent:' false
          )
          #'component:' 
           #(#SpecCollection
              #'collection:' 
               #(
                 #(#MenuPanelSpec
                    #'name:' 'menuToolbarView'
                    #'layout:' #(#LayoutFrame -1 0.0 0 0 -1 1.0 32 0)
                    #'tabable:' true
                    #'menu:' #menuToolbar
                    #'showSeparatingLines:' true
                )
                 #(#VariableVerticalPanelSpec
                    #'name:' 'vpanel'
                    #'layout:' #(#LayoutFrame 0 0.0 34 0.0 0 1.0 -26 1.0)
                    #'component:' 
                     #(#SpecCollection
                        #'collection:' 
                         #(
                           #(#VariableHorizontalPanelSpec
                              #'name:' 'hpanel'
                              #'component:' 
                               #(#SpecCollection
                                  #'collection:' 
                                   #(
                                     #(#ArbitraryComponentSpec
                                        #'name:' 'treeView'
                                        #'tabable:' true
                                        #'menu:' #menuEdit
                                        #'hasHorizontalScrollBar:' true
                                        #'hasVerticalScrollBar:' true
                                        #'miniScrollerHorizontal:' true
                                        #'miniScrollerVertical:' true
                                        #'component:' #treeView
                                        #'hasBorder:' false
                                    )
                                     #(#ViewSpec
                                        #'name:' 'specHolderView'
                                        #'component:' 
                                         #(#SpecCollection
                                            #'collection:' 
                                             #(
                                               #(#ViewSpec
                                                  #'name:' 'View'
                                                  #'layout:' #(#LayoutFrame 0 0.0 0 0 0 1.0 28 0)
                                                  #'component:' 
                                                   #(#SpecCollection
                                                      #'collection:' 
                                                       #(
                                                         #(#HorizontalPanelViewSpec
                                                            #'name:' 'panelViewButtons'
                                                            #'layout:' #(#LayoutFrame 0 0.0 2 0 0 0.5 26 0)
                                                            #'component:' 
                                                             #(#SpecCollection
                                                                #'collection:' 
                                                                 #(
                                                                   #(#CheckBoxSpec
                                                                      #'name:' 'checkBox1'
                                                                      #'model:' #galleryShown
                                                                      #'label:' 'Gallery'
                                                                      #'extent:' #(#Point 82 22)
                                                                  )
                                                                   #(#CheckBoxSpec
                                                                      #'name:' 'checkBox2'
                                                                      #'model:' #painterShown
                                                                      #'label:' 'Canvas'
                                                                      #'extent:' #(#Point 119 22)
                                                                  )
                                                                )
                                                            )
                                                            #'horizontalLayout:' #left
                                                            #'verticalLayout:' #top
                                                            #'horizontalSpace:' 4
                                                            #'verticalSpace:' 4
                                                        )
                                                         #(#HorizontalPanelViewSpec
                                                            #'name:' 'horizontalPanelView1'
                                                            #'layout:' #(#LayoutFrame 0 0.5 2 0 0 1.0 26 0)
                                                            #'component:' 
                                                             #(#SpecCollection
                                                                #'collection:' 
                                                                 #(
                                                                   #(#ArrowButtonSpec
                                                                      #'name:' 'arrowButton1'
                                                                      #'activeHelpKey:' #moveSelectionLeft
                                                                      #'tabable:' true
                                                                      #'model:' #moveSelectionLeft
                                                                      #'enableChannel:' #canMoveOrAlignSelection
                                                                      #'isTriggerOnDown:' true
                                                                      #'direction:' #left
                                                                      #'extent:' #(#Point 22 22)
                                                                  )
                                                                   #(#ArrowButtonSpec
                                                                      #'name:' 'arrowButton2'
                                                                      #'activeHelpKey:' #moveSelectionRight
                                                                      #'model:' #moveSelectionRight
                                                                      #'enableChannel:' #canMoveOrAlignSelection
                                                                      #'isTriggerOnDown:' true
                                                                      #'direction:' #right
                                                                      #'extent:' #(#Point 22 22)
                                                                  )
                                                                   #(#ArrowButtonSpec
                                                                      #'name:' 'arrowButton3'
                                                                      #'activeHelpKey:' #moveSelectionDown
                                                                      #'model:' #moveSelectionDown
                                                                      #'enableChannel:' #canMoveOrAlignSelection
                                                                      #'isTriggerOnDown:' true
                                                                      #'direction:' #down
                                                                      #'extent:' #(#Point 22 22)
                                                                  )
                                                                   #(#ArrowButtonSpec
                                                                      #'name:' 'arrowButton4'
                                                                      #'activeHelpKey:' #moveSelectionUp
                                                                      #'model:' #moveSelectionUp
                                                                      #'enableChannel:' #canMoveOrAlignSelection
                                                                      #'isTriggerOnDown:' true
                                                                      #'direction:' #up
                                                                      #'extent:' #(#Point 22 22)
                                                                  )
                                                                )
                                                            )
                                                            #'horizontalLayout:' #right
                                                            #'verticalLayout:' #top
                                                            #'horizontalSpace:' 4
                                                            #'verticalSpace:' 4
                                                        )
                                                      )
                                                  )
                                                  #'level:' 1
                                              )
                                               #(#NoteBookViewSpec
                                                  #'name:' 'noteBook'
                                                  #'layout:' #(#LayoutFrame 0 0.0 29 0.0 0 1.0 -30 1.0)
                                                  #'enableChannel:' #enableChannel
                                                  #'tabable:' true
                                                  #'model:' #tabModel
                                                  #'menu:' #tabList
                                                  #'style:' #(#FontDescription #helvetica #medium #roman 10)
                                                  #'canvas:' #noteBookView
                                              )
                                               #(#HorizontalPanelViewSpec
                                                  #'name:' 'modifyPanel'
                                                  #'layout:' #(#LayoutFrame 0 0.0 -30 1.0 0 1.0 0 1.0)
                                                  #'component:' 
                                                   #(#SpecCollection
                                                      #'collection:' 
                                                       #(
                                                         #(#ActionButtonSpec
                                                            #'name:' 'cancelButton'
                                                            #'activeHelpKey:' #cancel
                                                            #'label:' 'Cancel'
                                                            #'tabable:' true
                                                            #'model:' #cancel
                                                            #'enableChannel:' #modifiedChannel
                                                            #'extent:' #(#Point 179 24)
                                                        )
                                                         #(#ActionButtonSpec
                                                            #'name:' 'acceptButton'
                                                            #'activeHelpKey:' #accept
                                                            #'label:' 'OK'
                                                            #'tabable:' true
                                                            #'model:' #accept
                                                            #'enableChannel:' #modifiedChannel
                                                            #'extent:' #(#Point 180 24)
                                                        )
                                                      )
                                                  )
                                                  #'horizontalLayout:' #fitSpace
                                                  #'verticalLayout:' #fitSpace
                                                  #'horizontalSpace:' 3
                                                  #'verticalSpace:' 3
                                              )
                                            )
                                        )
                                        #'borderWidth:' 1
                                    )
                                  )
                              )
                              #'level:' 1
                              #'handles:' #(#Any 0.329435 1.0)
                          )
                           #(#TextEditorSpec
                              #'name:' 'Transcript'
                              #'hasHorizontalScrollBar:' true
                              #'hasVerticalScrollBar:' true
                              #'miniScrollerHorizontal:' true
                              #'miniScrollerVertical:' true
                          )
                        )
                    )
                    #'handles:' #(#Any 0.880597 1.0)
                )
                 #(#UISubSpecification
                    #'name:' 'infoBarSubSpec'
                    #'layout:' #(#LayoutFrame 0 0.0 -24 1 0 1.0 0 1.0)
                    #'majorKey:' #ToolApplicationModel
                    #'minorKey:' #windowSpecForInfoBarWithClock
                )
              )
          )
      )
! !

!UIPainter 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:UIPainter andSelector:#menu
     (Menu new fromLiteralArrayEncoding:(UIPainter menu)) startUp
    "

    <resource: #menu>

    ^
     
       #(#Menu
          
           #(
             #(#MenuItem
                #'label:' 'About'
                #'labelImage:' #(#ResourceRetriever nil #menuIcon)
                #'submenuChannel:' #menuAbout
            )
             #(#MenuItem
                #'label:' 'File'
                #'value:' #file
                #'enabled:' #enableChannel
                #'submenu:' 
                 #(#Menu
                    
                     #(
                       #(#MenuItem
                          #'label:' 'New'
                          #'value:' #doNew
                          #'activeHelpKey:' #fileNew
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Load...'
                          #'value:' #doFromClass
                          #'activeHelpKey:' #fileLoad
                      )
                       #(#MenuItem
                          #'label:' 'Load Subspec...'
                          #'value:' #loadSubspec
                          #'activeHelpKey:' #fileLoadSubspec
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Save'
                          #'value:' #doInstallSpec
                          #'activeHelpKey:' #fileSave
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Define Class And Selector...'
                          #'value:' #defineClassAndSelector
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Create Aspect Methods'
                          #'value:' #doInstallAspects
                          #'enabled:' #hasSpecClass
                      )
                       #(#MenuItem
                          #'label:' 'Create Hook Methods'
                          #'value:' #doInstallHooks
                          #'enabled:' #hasSpecClass
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Pick An Interface'
                          #'value:' #doPickAView
                          #'activeHelpKey:' #filePickAnInterface
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Show Interface Spec'
                          #'value:' #doWindowSpec
                      )
                       #(#MenuItem
                          #'label:' 'Browse Interface Class'
                          #'value:' #doBrowseAppClass
                          #'enabled:' #hasSpecClass
                      )
                       #(#MenuItem
                          #'label:' 'Browse Aspect Methods'
                          #'value:' #doBrowseAspectMethods
                          #'enabled:' #hasSpecClass
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Exit'
                          #'value:' #closeRequest
                          #'activeHelpKey:' #fileExit
                      )
                    ) nil
                    nil
                )
            )
             #(#MenuItem
                #'label:' 'Edit'
                #'submenuChannel:' #menuEdit
            )
             #(#MenuItem
                #'label:' 'Add'
                #'submenuChannel:' #menuAdd
            )
             #(#MenuItem
                #'label:' 'Align'
                #'submenuChannel:' #menuAlign
            )
             #(#MenuItem
                #'label:' 'Test'
                #'submenu:' 
                 #(#Menu
                    
                     #(
                       #(#MenuItem
                          #'label:' 'Start Application'
                          #'value:' #doStartApplication
                          #'activeHelpKey:' #testStartApplication
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Geometry Test Mode'
                          #'indication:' #'testMode:'
                      )
                    ) nil
                    nil
                )
            )
             #(#MenuItem
                #'label:' 'Settings'
                #'submenu:' 
                 #(#Menu
                    
                     #(
                       #(#MenuItem
                          #'label:' 'Undo Manager'
                          #'value:' #openUndoMenu
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Grid Manager'
                          #'value:' #gridMenu
                      )
                    ) nil
                    nil
                )
            )
             #(#MenuItem
                #'label:' 'History'
                #'submenuChannel:' #menuHistory
            )
             #(#MenuItem
                #'label:' 'Help'
                #'startGroup:' #right
                #'submenuChannel:' #menuHelp
            )
          ) nil
          nil
      )
!

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

    <resource: #menu>

    ^
     
       #(#Menu
          
           #(
             #(#MenuItem
                #'label:' 'Buttons'
                #'submenu:' 
                 #(#Menu
                    
                     #(
                       #(#MenuItem
                          #'label:' 'Action Button'
                          #'value:' #'addWidget:'
                          #'argument:' #ActionButtonSpec
                          #'labelImage:' #(#ResourceRetriever #ActionButtonSpec #icon 'Action Button')
                      )
                       #(#MenuItem
                          #'label:' 'Arrow Button'
                          #'value:' #'addWidget:'
                          #'argument:' #ArrowButtonSpec
                          #'labelImage:' #(#ResourceRetriever #ArrowButtonSpec #icon 'Arrow Button')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Toggle'
                          #'value:' #'addWidget:'
                          #'argument:' #ToggleSpec
                          #'labelImage:' #(#ResourceRetriever #ToggleSpec #icon 'Toggle')
                      )
                       #(#MenuItem
                          #'label:' 'Radio Button'
                          #'value:' #'addWidget:'
                          #'argument:' #RadioButtonSpec
                          #'labelImage:' #(#ResourceRetriever #RadioButtonSpec #icon 'Radio Button')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Check Box'
                          #'value:' #'addWidget:'
                          #'argument:' #CheckBoxSpec
                          #'labelImage:' #(#ResourceRetriever #CheckBoxSpec #icon 'Check Box')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Up Down Button'
                          #'value:' #'addWidget:'
                          #'argument:' #UpDownButtonSpec
                          #'labelImage:' #(#ResourceRetriever #UpDownButtonSpec #icon 'Up Down Button')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Slider'
                          #'value:' #'addWidget:'
                          #'argument:' #SliderSpec
                          #'labelImage:' #(#ResourceRetriever #SliderSpec #icon 'Slider')
                      )
                       #(#MenuItem
                          #'label:' 'Thumb Wheel'
                          #'value:' #'addWidget:'
                          #'argument:' #ThumbWheelSpec
                          #'labelImage:' #(#ResourceRetriever #ThumbWheelSpec #icon 'Thumb Wheel')
                      )
                    ) nil
                    nil
                )
            )
             #(#MenuItem
                #'label:' 'Menus'
                #'submenu:' 
                 #(#Menu
                    
                     #(
                       #(#MenuItem
                          #'label:' 'Combo Box'
                          #'value:' #'addWidget:'
                          #'argument:' #ComboBoxSpec
                          #'labelImage:' #(#ResourceRetriever #ComboBoxSpec #icon 'Combo Box')
                      )
                       #(#MenuItem
                          #'label:' 'Combo List'
                          #'value:' #'addWidget:'
                          #'argument:' #ComboListSpec
                          #'labelImage:' #(#ResourceRetriever #ComboListSpec #icon 'Combo List')
                      )
                       #(#MenuItem
                          #'label:' 'PopUp List'
                          #'value:' #'addWidget:'
                          #'argument:' #PopUpListSpec
                          #'labelImage:' #(#ResourceRetriever #ComboListSpec #icon 'PopUp List')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Tab'
                          #'value:' #'addWidget:'
                          #'argument:' #TabViewSpec
                          #'labelImage:' #(#ResourceRetriever #TabViewSpec #icon 'Tab')
                      )
                       #(#MenuItem
                          #'label:' 'Note Book'
                          #'value:' #'addWidget:'
                          #'argument:' #NoteBookViewSpec
                          #'labelImage:' #(#ResourceRetriever #NoteBookViewSpec #icon 'Note Book')
                      )
                       #(#MenuItem
                          #'label:' 'Gallery'
                          #'value:' #'addWidget:'
                          #'argument:' #UIGalleryViewSpec
                          #'labelImage:' #(#ResourceRetriever #UIGalleryViewSpec #icon 'Gallery')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Menu Panel'
                          #'value:' #'addWidget:'
                          #'argument:' #MenuPanelSpec
                          #'labelImage:' #(#ResourceRetriever #MenuPanelSpec #icon 'Menu Panel')
                      )
                    ) nil
                    nil
                )
            )
             #(#MenuItem
                #'label:' 'Text Views'
                #'submenu:' 
                 #(#Menu
                    
                     #(
                       #(#MenuItem
                          #'label:' 'Text Editor'
                          #'value:' #'addWidget:'
                          #'argument:' #TextEditorSpec
                          #'labelImage:' #(#ResourceRetriever #TextEditorSpec #icon 'Text Editor')
                      )
                       #(#MenuItem
                          #'label:' 'Input Field'
                          #'value:' #'addWidget:'
                          #'argument:' #InputFieldSpec
                          #'labelImage:' #(#ResourceRetriever #InputFieldSpec #icon 'Input Field')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Label'
                          #'value:' #'addWidget:'
                          #'argument:' #LabelSpec
                          #'labelImage:' #(#ResourceRetriever #LabelSpec #icon 'Label')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'HTML View'
                          #'value:' #'addWidget:'
                          #'argument:' #HTMLViewSpec
                          #'labelImage:' #(#ResourceRetriever #HTMLViewSpec #icon 'HTML View')
                      )
                    ) nil
                    nil
                )
            )
             #(#MenuItem
                #'label:' 'Lists'
                #'submenu:' 
                 #(#Menu
                    
                     #(
                       #(#MenuItem
                          #'label:' 'List'
                          #'value:' #'addWidget:'
                          #'argument:' #SequenceViewSpec
                          #'labelImage:' #(#ResourceRetriever #SequenceViewSpec #icon 'List')
                      )
                       #(#MenuItem
                          #'label:' 'Data Set List'
                          #'value:' #'addWidget:'
                          #'argument:' #DataSetSpec
                          #'labelImage:' #(#ResourceRetriever #DataSetSpec #icon 'Data Set List')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Tree List'
                          #'value:' #'addWidget:'
                          #'argument:' #SelectionInTreeViewSpec
                          #'labelImage:' #(#ResourceRetriever #SelectionInTreeViewSpec #icon 'Tree List')
                      )
                       #(#MenuItem
                          #'label:' 'File Tree List'
                          #'value:' #'addWidget:'
                          #'argument:' #FileSelectionTreeSpec
                          #'labelImage:' #(#ResourceRetriever #FileSelectionTreeSpec #icon 'File Tree List')
                      )
                    ) nil
                    nil
                )
            )
             #(#MenuItem
                #'label:' 'Boxes'
                #'submenu:' 
                 #(#Menu
                    
                     #(
                       #(#MenuItem
                          #'label:' 'Box'
                          #'value:' #'addWidget:'
                          #'argument:' #ViewSpec
                          #'labelImage:' #(#ResourceRetriever #ViewSpec #icon 'Box')
                      )
                       #(#MenuItem
                          #'label:' 'Framed Box'
                          #'value:' #'addWidget:'
                          #'argument:' #FramedBoxSpec
                          #'labelImage:' #(#ResourceRetriever #FramedBoxSpec #icon 'Framed Box')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Horizontal Panel'
                          #'value:' #'addWidget:'
                          #'argument:' #HorizontalPanelViewSpec
                          #'labelImage:' #(#ResourceRetriever #HorizontalPanelViewSpec #icon 'Horizontal Panel')
                      )
                       #(#MenuItem
                          #'label:' 'Vertical Panel'
                          #'value:' #'addWidget:'
                          #'argument:' #VerticalPanelViewSpec
                          #'labelImage:' #(#ResourceRetriever #VerticalPanelViewSpec #icon 'Vertical Panel')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Area Panel'
                          #'value:' #'addWidget:'
                          #'argument:' #PanelViewSpec
                          #'labelImage:' #(#ResourceRetriever #PanelViewSpec #icon 'Area Panel')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Variable Horizontal Panel'
                          #'value:' #'addWidget:'
                          #'argument:' #VariableHorizontalPanelSpec
                          #'labelImage:' #(#ResourceRetriever #VariableHorizontalPanelSpec #icon 'Variable Horizontal Panel')
                      )
                       #(#MenuItem
                          #'label:' 'Variable Vertical Panel'
                          #'value:' #'addWidget:'
                          #'argument:' #VariableVerticalPanelSpec
                          #'labelImage:' #(#ResourceRetriever #VariableVerticalPanelSpec #icon 'Variable Vertical Panel')
                      )
                    ) nil
                    nil
                )
            )
             #(#MenuItem
                #'label:' 'Misc'
                #'submenu:' 
                 #(#Menu
                    
                     #(
                       #(#MenuItem
                          #'label:' 'Arbitrary Component'
                          #'value:' #'addWidget:'
                          #'argument:' #ArbitraryComponentSpec
                          #'labelImage:' #(#ResourceRetriever #ArbitraryComponentSpec #icon 'Arbitrary Component')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Sub Specification'
                          #'value:' #'addWidget:'
                          #'argument:' #UISubSpecification
                          #'labelImage:' #(#ResourceRetriever #ArbitraryComponentSpec #icon 'Sub Specification')
                      )
                       #(#MenuItem
                          #'label:' 'Sub Canvas'
                          #'value:' #'addWidget:'
                          #'argument:' #SubCanvasSpec
                          #'labelImage:' #(#ResourceRetriever #SubCanvasSpec #icon 'Sub Canvas')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Progress Indicator'
                          #'value:' #'addWidget:'
                          #'argument:' #ProgressIndicatorSpec
                          #'labelImage:' #(#ResourceRetriever #ProgressIndicatorSpec #icon 'Progress Indicator')
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Divider'
                          #'value:' #'addWidget:'
                          #'argument:' #DividerSpec
                          #'labelImage:' #(#ResourceRetriever #DividerSpec #icon 'Divider')
                      )
                       #(#MenuItem
                          #'label:' 'Region'
                          #'value:' #'addWidget:'
                          #'argument:' #RegionSpec
                          #'labelImage:' #(#ResourceRetriever #RegionSpec #icon 'Region')
                      )
                    ) nil
                    nil
                )
            )
          ) nil
          nil
      )
!

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

    <resource: #menu>

    ^
     
       #(#Menu
          
           #(
             #(#MenuItem
                #'label:' 'Align Left'
                #'value:' #alignSelectionLeft
                #'activeHelpKey:' #alignSelectionLeft
                #'enabled:' #hasSelection
                #'labelImage:' #(#ResourceRetriever #UIPainter #iconAlignL 'Align Left')
            )
             #(#MenuItem
                #'label:' 'Align Right'
                #'value:' #alignSelectionRight
                #'activeHelpKey:' #alignSelectionRight
                #'enabled:' #hasSelection
                #'labelImage:' #(#ResourceRetriever #UIPainter #iconAlignR 'Align Right')
            )
             #(#MenuItem
                #'label:' 'Align Left & Right'
                #'value:' #alignSelectionLeftAndRight
                #'activeHelpKey:' #alignSelectionLeftAndRight
                #'enabled:' #hasSelection
                #'labelImage:' #(#ResourceRetriever #UIPainter #iconAlignLR 'Align Left & Right')
            )
             #(#MenuItem
                #'label:' 'Align top'
                #'value:' #alignSelectionTop
                #'activeHelpKey:' #alignSelectionTop
                #'enabled:' #hasSelection
                #'labelImage:' #(#ResourceRetriever #UIPainter #iconAlignT 'Align top')
            )
             #(#MenuItem
                #'label:' 'Align Bottom'
                #'value:' #alignSelectionBottom
                #'activeHelpKey:' #alignSelectionBottom
                #'enabled:' #hasSelection
                #'labelImage:' #(#ResourceRetriever #UIPainter #iconAlignB 'Align Bottom')
            )
             #(#MenuItem
                #'label:' 'Align Top & Bottom'
                #'value:' #alignSelectionTopAndBottom
                #'activeHelpKey:' #alignSelectionTopAndBottom
                #'enabled:' #hasSelection
                #'labelImage:' #(#ResourceRetriever #UIPainter #iconAlignTB 'Align Top & Bottom')
            )
             #(#MenuItem
                #'label:' 'Align Centered Horizontal'
                #'value:' #alignSelectionCenterHor
                #'activeHelpKey:' #alignSelectionCenterHor
                #'enabled:' #hasSelection
                #'labelImage:' #(#ResourceRetriever #UIPainter #iconAlignCenterH 'Align Centered Horizontal')
            )
             #(#MenuItem
                #'label:' 'Align Centered Vertical'
                #'value:' #alignSelectionCenterVer
                #'activeHelpKey:' #alignSelectionCenterVer
                #'enabled:' #hasSelection
                #'labelImage:' #(#ResourceRetriever #UIPainter #iconAlignCenterV 'Align Centered Vertical')
            )
             #(#MenuItem
                #'label:' '-'
            )
             #(#MenuItem
                #'label:' 'Spread Horizontal'
                #'value:' #spreadSelectionHor
                #'activeHelpKey:' #spreadSelectionHor
                #'enabled:' #hasSelection
            )
             #(#MenuItem
                #'label:' 'Spread Vertical'
                #'value:' #spreadSelectionVer
                #'activeHelpKey:' #spreadSelectionVer
                #'enabled:' #hasSelection
            )
             #(#MenuItem
                #'label:' '-'
            )
             #(#MenuItem
                #'label:' 'Center Horizontal In Frame'
                #'value:' #centerSelectionHor
                #'activeHelpKey:' #centerSelectionHor
                #'enabled:' #hasSelection
            )
             #(#MenuItem
                #'label:' 'Center Vertical In Frame'
                #'value:' #centerSelectionVer
                #'activeHelpKey:' #centerSelectionVer
                #'enabled:' #hasSelection
            )
          ) nil
          nil
      )

    "Modified: / 27.1.1998 / 21:27:33 / cg"
!

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

    <resource: #menu>

    ^
     
       #(#Menu
          
           #(
             #(#MenuItem
                #'label:' 'Cut'
                #'value:' #deleteSelection
                #'activeHelpKey:' #editCut
                #'enabled:' #hasSelection
                #'shortcutKeyCharacter:' #Cut
            )
             #(#MenuItem
                #'label:' 'Copy'
                #'value:' #copySelection
                #'activeHelpKey:' #editCopy
                #'enabled:' #hasSelection
                #'shortcutKeyCharacter:' #Copy
            )
             #(#MenuItem
                #'label:' 'Paste'
                #'nameKey:' #paste
                #'value:' #paste
                #'activeHelpKey:' #editPaste
                #'enabled:' #canPaste
                #'submenu:' 
                 #(#Menu
                    
                     #(
                       #(#MenuItem
                          #'label:' 'Paste'
                          #'value:' #pasteBuffer
                          #'activeHelpKey:' #pasteBuffer
                          #'shortcutKeyCharacter:' #Paste
                      )
                       #(#MenuItem
                          #'label:' 'Keep Layout'
                          #'value:' #pasteWithLayout
                          #'activeHelpKey:' #pasteWithLayout
                          #'enabled:' #canKeepLayoutInSelection
                      )
                    ) nil
                    nil
                )
            )
             #(#MenuItem
                #'label:' '-'
            )
             #(#MenuItem
                #'label:' 'Undo'
                #'nameKey:' #undo
                #'value:' #undoLast
                #'activeHelpKey:' #editUndo
                #'enabled:' #hasUndoHistory
                #'shortcutKeyCharacter:' #Cmdu
            )
             #(#MenuItem
                #'label:' '-'
            )
             #(#MenuItem
                #'label:' 'Align'
                #'submenuChannel:' #menuAlign
            )
             #(#MenuItem
                #'label:' 'Move'
                #'submenuChannel:' #menuMove
            )
             #(#MenuItem
                #'label:' 'Dimension'
                #'value:' #dimension
                #'enabled:' #hasSelection
                #'submenu:' 
                 #(#Menu
                    
                     #(
                       #(#MenuItem
                          #'label:' 'Default Extent'
                          #'value:' #setToDefaultExtent
                          #'activeHelpKey:' #setToDefaultExtent
                          #'enabled:' #canMoveOrAlignSelection
                      )
                       #(#MenuItem
                          #'label:' 'Default Width'
                          #'value:' #setToDefaultWidth
                          #'activeHelpKey:' #setToDefaultWidth
                          #'enabled:' #canMoveOrAlignSelection
                      )
                       #(#MenuItem
                          #'label:' 'Default Height'
                          #'value:' #setToDefaultHeight
                          #'activeHelpKey:' #setToDefaultHeight
                          #'enabled:' #canMoveOrAlignSelection
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Copy Extent'
                          #'value:' #copyExtent
                          #'activeHelpKey:' #copyExtent
                          #'enabled:' #hasSingleSelection
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Paste Extent'
                          #'value:' #pasteExtent
                          #'activeHelpKey:' #pasteExtent
                          #'enabled:' #canMoveOrAlignSelection
                      )
                       #(#MenuItem
                          #'label:' 'Paste Width'
                          #'value:' #pasteWidth
                          #'activeHelpKey:' #pasteWidth
                          #'enabled:' #canMoveOrAlignSelection
                      )
                       #(#MenuItem
                          #'label:' 'Paste Height'
                          #'value:' #pasteHeight
                          #'activeHelpKey:' #pasteHeight
                          #'enabled:' #canMoveOrAlignSelection
                      )
                       #(#MenuItem
                          #'label:' '-'
                      )
                       #(#MenuItem
                          #'label:' 'Copy Layout'
                          #'value:' #copyLayout
                          #'activeHelpKey:' #copyLayout
                          #'enabled:' #hasSingleSelection
                      )
                       #(#MenuItem
                          #'label:' 'Paste Layout'
                          #'value:' #pasteLayout
                          #'activeHelpKey:' #pasteLayout
                          #'enabled:' #canMoveOrAlignSelection
                      )
                    ) nil
                    nil
                )
            )
          ) nil
          nil
      )
!

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

    <resource: #menu>

    ^
     
       #(#Menu
          
           #(
             #(#MenuItem
                #'label:' 'Move Up'
                #'value:' #doStepUp
                #'activeHelpKey:' #moveSelectionUp
                #'enabled:' #canMoveOrAlignSelection
                #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #upIcon 'Move Up')
            )
             #(#MenuItem
                #'label:' 'Move Down'
                #'value:' #doStepDown
                #'activeHelpKey:' #moveSelectionDown
                #'enabled:' #canMoveOrAlignSelection
                #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #downIcon 'Move Down')
            )
             #(#MenuItem
                #'label:' 'Move In'
                #'value:' #doStepIn
                #'activeHelpKey:' #moveSelectionRight
                #'enabled:' #canMoveSelectionIntoContainer
                #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #downRightIcon 'Move In')
            )
             #(#MenuItem
                #'label:' 'Move Out'
                #'value:' #doStepOut
                #'activeHelpKey:' #moveSelectionLeft
                #'enabled:' #canMoveSelectionOutOfContainer
                #'labelImage:' #(#ResourceRetriever #ToolApplicationModel #leftDownIcon 'Move Out')
            )
          ) 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:UIPainter andSelector:#menuToolbar
     (Menu new fromLiteralArrayEncoding:(UIPainter menuToolbar)) startUp
    "

    <resource: #menu>

    ^
     
       #(#Menu
          
           #(
             #(#MenuItem
                #'label:' 'Start'
                #'isButton:' true
                #'value:' #doStartApplication
                #'activeHelpKey:' #testStartApplication
                #'labelImage:' #(#ResourceRetriever nil #startIcon)
            )
             #(#MenuItem
                #'label:' ''
            )
             #(#MenuItem
                #'label:' 'New'
                #'isButton:' true
                #'value:' #doNew
                #'activeHelpKey:' #fileNew
                #'labelImage:' #(#ResourceRetriever nil #newIcon)
            )
             #(#MenuItem
                #'label:' 'Load'
                #'isButton:' true
                #'value:' #doFromClass
                #'activeHelpKey:' #fileLoad
                #'labelImage:' #(#ResourceRetriever nil #loadIcon)
            )
             #(#MenuItem
                #'label:' 'Save'
                #'isButton:' true
                #'value:' #doInstallSpec
                #'activeHelpKey:' #fileSave
                #'labelImage:' #(#ResourceRetriever nil #saveIcon)
            )
             #(#MenuItem
                #'label:' ''
            )
             #(#MenuItem
                #'label:' 'Move Up'
                #'isButton:' true
                #'value:' #doStepUp
                #'activeHelpKey:' #moveSelectionUp
                #'enabled:' #canChangeOrderInContainer
                #'labelImage:' #(#ResourceRetriever nil #upIcon)
            )
             #(#MenuItem
                #'label:' 'Move Down'
                #'isButton:' true
                #'value:' #doStepDown
                #'activeHelpKey:' #moveSelectionDown
                #'enabled:' #canChangeOrderInContainer
                #'labelImage:' #(#ResourceRetriever nil #downIcon)
            )
             #(#MenuItem
                #'label:' 'Move In'
                #'isButton:' true
                #'value:' #doStepIn
                #'activeHelpKey:' #moveSelectionRight
                #'enabled:' #canMoveSelectionIntoContainer
                #'labelImage:' #(#ResourceRetriever nil #downRightIcon)
            )
             #(#MenuItem
                #'label:' 'Move Out'
                #'isButton:' true
                #'value:' #doStepOut
                #'activeHelpKey:' #moveSelectionLeft
                #'enabled:' #canMoveSelectionOutOfContainer
                #'labelImage:' #(#ResourceRetriever nil #leftDownIcon)
            )
             #(#MenuItem
                #'label:' ''
            )
             #(#MenuItem
                #'label:' 'Align left'
                #'isButton:' true
                #'value:' #alignSelectionLeft
                #'activeHelpKey:' #alignSelectionLeft
                #'labelImage:' #(#ResourceRetriever nil #iconAlignL)
            )
             #(#MenuItem
                #'label:' 'Align right'
                #'isButton:' true
                #'value:' #alignSelectionRight
                #'activeHelpKey:' #alignSelectionRight
                #'labelImage:' #(#ResourceRetriever nil #iconAlignR)
            )
             #(#MenuItem
                #'label:' 'Align left & right'
                #'isButton:' true
                #'value:' #alignSelectionLeftAndRight
                #'activeHelpKey:' #alignSelectionLeftAndRight
                #'labelImage:' #(#ResourceRetriever nil #iconAlignLR)
            )
             #(#MenuItem
                #'label:' 'Align top'
                #'isButton:' true
                #'value:' #alignSelectionTop
                #'activeHelpKey:' #alignSelectionTop
                #'labelImage:' #(#ResourceRetriever nil #iconAlignT)
            )
             #(#MenuItem
                #'label:' 'Align bottom'
                #'isButton:' true
                #'value:' #alignSelectionBottom
                #'activeHelpKey:' #alignSelectionBottom
                #'labelImage:' #(#ResourceRetriever nil #iconAlignB)
            )
             #(#MenuItem
                #'label:' 'Align top & bottom'
                #'isButton:' true
                #'value:' #alignSelectionTopAndBottom
                #'activeHelpKey:' #alignSelectionTopAndBottom
                #'labelImage:' #(#ResourceRetriever nil #iconAlignTB)
            )
             #(#MenuItem
                #'label:' ''
            )
             #(#MenuItem
                #'label:' 'Align centered horizontal'
                #'isButton:' true
                #'value:' #alignSelectionCenterHor
                #'activeHelpKey:' #alignSelectionCenterHor
                #'labelImage:' #(#ResourceRetriever nil #iconAlignCenterH)
            )
             #(#MenuItem
                #'label:' 'Align centered vertical'
                #'isButton:' true
                #'value:' #alignSelectionCenterVer
                #'activeHelpKey:' #alignSelectionCenterVer
                #'labelImage:' #(#ResourceRetriever nil #iconAlignCenterV)
            )
          ) nil
          nil
      )
! !

!UIPainter class methodsFor:'resources'!

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

    <resource: #image>

    ^Icon
        constantNamed:#'UIPainter iconAlignB'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@E@@@@@@@G@@@@@@@G@E@@@@@G@G@@@@@G@G@@@@@G@G@@@E@G@G@@@G@G@G@K@G@G@G@@@G@G@G@A@G@G@G@@@G@G@G@K@@@@@@@@B*****(@B*****(@@@@@@@@@@@@@@@@@@@@@@@@@'); colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color red:0.0 green:0.0 blue: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 C@G @@G'' @G'' @G'' @G'' G'''' G'''' G'''' G''''!!G'''' G'''' G'''' G'''' O??0O??0@@@@@@@C@@@@'); yourself); yourself]!

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

    <resource: #image>

    ^Icon
        constantNamed:#'UIPainter iconAlignCenterH'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUUPUUUUUUUPUUUUUUUPV*****)PV*****)PUUUMUUUPUUT?UUUPUUS?5UU\UUO?=UUWUT???UUPUTUUUUUPUUUUUUUPV*****)PV*****)PUUUMUUUPUUT?UUUPUUS?5UUPUUO?=UUPUT???UUWUTUUUUUPUUUUUUUPUUUUUUUP'); colorMap:(((Array new:4) at:1 put:((Color white)); at:2 put:((Color black)); at:3 put:((Color red:0.0 green:0.0 blue:49.9962)); at:4 put:((Color grey:49.9962)); yourself)); mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@BO??0O??0@G@@@O @@_0@@?8@A?<@A?<@@@@@O??0O??3@G@@@O @@_0@@?8@A?<@A?<@@@@@@@@@'); yourself); yourself]!

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

    <resource: #image>

    ^Icon
        constantNamed:#'UIPainter iconAlignCenterV'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'UUUUUUUPUUUUUUUPUUV%UV%PUUV%UV%PUUV%UV%PTEV$EV%PT=V$=V%PT?V$?V%PT?6$?6%WT?>$?>%PT?>$?>%_T?6$?6%PT?V$?V%PT=V$=V%PT5V$5V%WUUV%UV%PUUV%UV%PUUV%UV%_UUV%UV%WUUV%UV%PUUUUUUUPUUUUUUUQ'); colorMap:(((Array new:4) at:1 put:((Color white)); at:2 put:((Color black)); at:3 put:((Color red:0.0 green:0.0 blue:49.9962)); at:4 put:((Color grey:49.9962)); yourself)); mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@LA!!@LA @LA LM!! NM1 OM9 O-= O=? O=? O=? O-= OM9 NM1 DL!!#@LA @LA @LA @LA @@@C@@@@'); yourself); yourself]!

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

    <resource: #image>

    ^Icon
        constantNamed:#'UIPainter iconAlignL'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@(@@@@@@@(@@@@@@@(UUUP@I@(_??0@@@(@@@@@@@(@@@@@@@(@@@@@@@(@@@@@@@(UUUU@@@(_???@@@(@@@@@E@(@@@@@@@(@@@@@@@(@@@@@@@(UU@@@@@(_?@@@@@(@@@@@@@(@@@@@@@@@@@@@E@@@@@@@@'); colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color red:0.0 green:0.0 blue:49.9977)); at:4 put:((Color grey:66.9978)); yourself)); mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@F@@@G?>@G?>@G?>@G?>@F@@@F@@@G?? G?? G?? G?? F@@@F@@@G? @G? @G? @G? @F@@@@@@@@@@@'); yourself); yourself]!

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

    <resource: #image>

    ^Icon
        constantNamed:#'UIPainter iconAlignLR'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@(@@@B @@(@@@B @@(UUUR I@(_??2 @@(@@@B @@(@@@B @@(@@@B @@(@@@B @@(UUUR @@(_??2 @@(@@@B E@(@@@B @@(@@@B @@(@@@B @@(UUUR @@(_??B @@(@@@B @@(@@@B @@@@@@@@E@@@@@@@@'); colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color red:0.0 green:0.0 blue:49.9977)); at:4 put:((Color grey:66.9978)); yourself)); mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@F@A G?? G?? G?? G?? F@A F@A G?? G?? G?? G?? F@A F@A G?? G?? G?; G?? F@A @@@@@@@@'); yourself); yourself]!

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

    <resource: #image>

    ^Icon
        constantNamed:#'UIPainter iconAlignR'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@B @@@@@@B @@@UUUR I@@_??2 @@@@@@B @@@@@@B @@@@@@B @@@@@@B @@EUUUR @@G???2 @@@@@@B E@@@@@B @@@@@@B @@@@@@B @@@@EUR @@@@G?2 @@@@@@B @@@@@@B @@@@@@@@E@@@@@@@@'); colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color red:0.0 green:0.0 blue:49.9977)); at:4 put:((Color grey:66.9978)); yourself)); mask:((Depth1Image new) width: 22; height: 22; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@A A?? A?? A?? A?? @@A @@A G?? G?? G?? G?? @@A @@A @G? @G? @G? @G? @@A @@@@@@@@'); yourself); yourself]!

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

    <resource: #image>

    ^Icon
        constantNamed:#'UIPainter iconAlignT'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@@@@@@@@@@@@@@@@@@B*****(@B*****(@@@@@@@@@@E@E@E@K@G@G@G@@@G@G@G@A@G@G@G@@@G@G@G@K@G@G@G@@@@@G@G@@@@@G@G@@@@@G@G@@@@@G@G@@@@@G@@@@@@@G@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color red:0.0 green:0.0 blue: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:'@@@@@@@C@@@@O??0O??0G'''' G'''' G'''' G'''' G''''!!G'''' G'''' G'''' @G'' @G'' @G'' @G'' @G @@G C@@@@@@@@@@@@'); yourself); yourself]!

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

    <resource: #image>

    ^Icon
        constantNamed:#'UIPainter iconAlignTB'
        ifAbsentPut:[(Depth2Image new) width: 22; height: 22; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@A@@@@@@@@@@@@@@@@B*****(@B*****(@@@@@@@@@@E@E@E@G@G@G@G@@@G@G@G@@@G@G@G@@@G@G@G@H@G@G@G@@@G@G@G@A@G@G@G@@@G@G@G@@@G@G@D@@@@@@@@@@B*****(@B*****(@@@@@@@@@@@@@@@@H@@@@@@@@'); colorMap:(((Array new:4) at:1 put:((Color black)); at:2 put:((Color white)); at:3 put:((Color red:0.0 green:0.0 blue: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:'@@@@@@@C@@@@O??0O??0G'''' G''''!!G'''' G'''' G'''' G'''' G'''' G'''' G''''!!G''''!!G''& G'''' O??0O??2@@@@@@@@@@@@'); yourself); yourself]! !

!UIPainter methodsFor:'actions'!

accept
    "accept changes done to the specification. The component assigned to the
     specification will change immediately dependant on the attributes derived
     from the specification.
    "
    |layout spec prop key layoutTool|

    self isLayoutToolSelected ifTrue:[
        layoutTool := self layoutTool.

        (layout := layoutTool layout) notNil ifTrue:[
            layoutTool layoutType == #Extent ifTrue:[
                layoutTool layoutView == self painter topView ifTrue:[
                    layoutTool layoutView extent:layout
                ] ifFalse:[
                    self painter setExtent:layout
                ]
            ] ifFalse:[
                self painter setLayout:layout
            ]
        ]
    ] ifFalse:[
        spec := self specTool specification.

        self isHelpToolSelected ifTrue:[
            self helpTool accept.
            key  := self helpTool helpKey.
            prop := treeView propertySelected.

            prop notNil ifTrue:[
                prop spec activeHelpKey:key
            ].
            spec activeHelpKey:key.
        ] ifFalse:[
            self painter updateFromSpec:spec.
        ]
    ].
    self modifiedChannel value:false.
!

addWidget: aSpecClass

    self addWidgetOfSpec: (Array with: (Smalltalk at: aSpecClass) new)

!

addWidgetOfSpec: aSpec

    |newSel|  
    (newSel := self pasteSpecifications:aSpec keepLayout:false at:0@0) notNil
    ifTrue:
    [
        self select: newSel
    ]
    ifFalse:
    [   
        ((treeView selection size = 0) or: [treeView selectedNode isNil])
        ifTrue:
        [                          
            treeView selection: #(1).
        ]
        ifFalse:
        [  
            treeView selectNode: (treeView detectNode: [:n| n = treeView selectedNode parent])
        ].
        self addWidgetOfSpec: aSpec
    ]

!

cancel
    "cancel all changes done to the specification; reread attributes from the
     assigned component
    "
    |spec key view|

    self isModified ifTrue:[
        (spec := self painter specForSelection) notNil ifTrue:[
            key := spec activeHelpKey.
        ].
        self helpTool helpKey:key.
        self specTool specification:spec.
        view := self layoutTool layoutView.

        self setViewInLayoutTool:view.
        spec class == DataSetSpec ifTrue:[
            view columnDescriptors:(spec columns)
        ].        
        self modifiedChannel value:false.
    ]
!

moveSelectionDown
    "move selected components down
    "
    self painter moveSelectionDown
!

moveSelectionLeft
    "move selected components left
    "
    self painter moveSelectionLeft

!

moveSelectionRight
    "move selected components right
    "
    self painter moveSelectionRight

!

moveSelectionUp
    "move selected components up
    "
    self painter moveSelectionUp

! !

!UIPainter methodsFor:'aspects'!

canChangeOrderInContainer
    "returns a boolean value holder which is true if the component order can be changed within their container.
    "
    ^ builder booleanValueAspectFor:#canChangeOrderInContainer
!

canMoveOrAlignSelection
    "returns a boolean value holder which is true in case that any selection exists
     and all widgets in the selection can change its layout through to a move or
     align operation
    "
    ^ builder booleanValueAspectFor:#canMoveOrAlignSelection
!

canMoveSelectionIntoContainer
    "returns a boolean value holder which is true in case that one component is selected
     and can change its container widget to the next element in the list which will have
     the same container.
    "
    ^ builder booleanValueAspectFor:#canMoveSelectionIntoContainer
!

canMoveSelectionOutOfContainer
    "returns a boolean value holder which is true in case that one component is selected
     which is contained within another component
    "
    ^ builder booleanValueAspectFor:#canMoveSelectionOutOfContainer
!

enableChannel
    "true if modifications are allowed otherwise running test
    "
  ^ self painter enableChannel
!

galleryShown
    "returns a boolean value holder which is set to true if the gallery is shown
    "
    |holder|

    (holder := builder bindingAt:#galleryShown) isNil ifTrue:[
        builder aspectAt:#galleryShown put:(holder :=  true asValue).
        holder addDependent:self
    ].
    ^ holder

!

hasOneSelectionOtherThanCanvas
    "returns a value holder which is true in case that one component is selected
     other than the canvas.
    "
    ^ builder booleanValueAspectFor:#hasOneSelectionOtherThanCanvas
!

modifiedChannel
    "returns a boolean value holder which is set to true if something is modified
     and not accepted
    "
    ^ builder booleanValueAspectFor:#modifiedChannel
!

noteBookView
    "returns the notebook view; initialize components within the notebook
    "
    |noteBook channel helpTool layoutTool specTool|

    (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
        noteBook   := View new.
        layoutTool := UILayoutTool new.
        helpTool   := UIHelpTool   new.
        helpTool helpSpecFrom:specClass.
        specTool   := UISpecificationTool new.
        channel    := self modifiedChannel.

        layoutTool masterApplication:self.
        specTool   masterApplication:self.
        helpTool   masterApplication:self.

        layoutCanvas := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
        helpCanvas   := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
        specCanvas   := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.

        layoutCanvas client:layoutTool.
        helpCanvas   client:helpTool.
        specTool builder:(specCanvas client:specTool).

        layoutTool masterApplication:self.
        specTool   masterApplication:self.
        helpTool   masterApplication:self.

        layoutTool modifiedHolder:channel.
        helpTool   modifiedHolder:channel.
        specTool   modifiedHolder:channel.

        builder aspectAt:#noteBookView put:noteBook.
    ].
    ^ noteBook
!

painterShown
    "returns a boolean value holder which is set to true if the painter is shown
    "
    |holder|

    (holder := builder bindingAt:#painterShown) isNil ifTrue:[
        builder aspectAt:#painterShown put:(holder :=  true asValue).
        holder addDependent:self
    ].
    ^ holder

!

tabList
    "returns a value holder which keeps a list of labels assigned to the tabs
    "
    |holder|

    (holder := builder bindingAt:#tabList) isNil ifTrue:[
        builder aspectAt:#tabList put:(holder :=  ValueHolder new).
        holder value:#( 'Properties' ).
    ].
    ^ holder
!

tabModel
    "returns a value holder which keeps the current name of the tab selected
    "
    |holder|

    (holder := builder bindingAt:#tabModel) isNil ifTrue:[
        holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
        builder aspectAt:#tabModel put:holder.
    ].
    ^ holder
!

treeView
    "returns the selection tree view which holds all widget identifiers
    "
    ^ treeView
! !

!UIPainter methodsFor:'binding access'!

aspectFor:aKey
    "aspect for a key
    "
  ^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ]
! !

!UIPainter methodsFor:'building editors'!

openDataSetColumnEditor
    "opens a column editor
    "
    |cls aspect editor columns|

    cls := self resolveName:specClass.

    cls isNil ifTrue:[
        ^ self information:'No application class defined yet!!'
    ].
    aspect := self specTool specification columns.
    editor := DataSetBuilder new.
    editor masterApplication:self.
    editor columns:aspect fromView:(self layoutTool layoutView).
    editor rowClassName:(self specTool specification rowClassName).
    editor openModal.

    editor hasChanged ifTrue:[
        self specTool specification columns:(editor columns).
        self specTool specification rowClassName:(editor rowClassName).
        self modifiedChannel value:true.
    ].
!

openEditMenu
    "opens a menu editor on current widget
    "
    |cls aspect editor|

    cls := self resolveName:specClass.

    cls isNil ifTrue:[
        ^ self information:'No application class defined yet!!'
    ].

    cls notNil ifTrue:[
        (aspect := self specTool specification menuSelector) notNil ifTrue:[
            aspect := aspect asSymbol
        ] ifFalse:[
            "/ cg: q&d hack ...

            aspect := treeView propertySelected.
            aspect notNil ifTrue:[
                Object errorSignal handle:[:ex |
                    aspect := nil.
                ] do:[
                    aspect := aspect view asMenu.
                ]
            ].
        ].
        
        editor := MenuEditor new.
        editor masterApplication:self.
        editor useHelpDictionary:(self helpTool dictionary).
        editor openModalOnClass:cls andSelector:aspect.
        self helpTool updateList.

        editor selectorName ~= aspect ifTrue:[
            editor didInstall ifTrue:[
                self specTool specification menuSelector:editor selectorName asSymbol.
                self modifiedChannel value:true.
                self accept
            ]
        ].
    ]

    "Modified: 31.7.1997 / 14:26:13 / cg"
!

openHierarchicalListEditor
    "opens a hierarchical list editor editor on current widget
    "
    |cls aspect editor|

    cls := self resolveName:specClass.

    cls isNil ifTrue:[
        ^ self information:'No application class defined yet!!'
    ].

    (aspect := self specTool specification hierarchicalList) notNil ifTrue:[
        aspect := aspect asSymbol
    ] ifFalse:[
        "/ cg: q&d hack ...

        aspect := treeView propertySelected.
        aspect notNil ifTrue:[
            Object errorSignal handle:[:ex |
                aspect := nil.
            ] do:[
                aspect := aspect view asMenu.
            ]
        ].
    ].
    
    editor := HierarchicalListEditor new.
    editor masterApplication:self.
    editor openModalOnClass:cls andSelector:aspect.

    editor selectorName ~= aspect ifTrue:[
        editor didInstall ifTrue:[
            self specTool specification hierarchicalList:editor selectorName asSymbol.
            self modifiedChannel value:true.
            self accept
        ]
    ]
!

openSubSpecGuiPainter
    "opens a GUI Painter on the current subspecification"

    |spec cls meta sel|

    spec := self specTool specification.
    cls := spec majorKey.
    cls isNil ifTrue:[
        cls := self specClass.
    ].
    (cls isNil or:[(cls := self resolveName:specClass) isNil]) ifTrue:[
        ^ self warn:'Cannot find class'.
    ].
    sel := spec minorKey.
    meta := cls class whichClassIncludesSelector:sel.
    meta isNil ifTrue:[
        ^ self warn:'Cannot find ''', sel, ''' in class ''', cls name, ''''
    ].

    self class openOnClass:meta soleInstance andSelector:spec minorKey.

    "Created: / 6.2.1998 / 13:03:59 / stefan"
    "Modified: / 6.2.1998 / 13:59:30 / stefan"
!

openTabItemEditor
    "opens a column editor
    "
    |cls aspect editor columns|

    cls := self resolveName:specClass.

    cls isNil ifTrue:[
        ^ self information:'no application class defined yet'
    ].
    aspect := self specTool specification listSelector.
    editor := TabItemEditor new.
    editor masterApplication:self.

    editor openModalOnClass:cls andSelector:aspect.

    editor selector ~= aspect ifTrue:[
        editor didInstall ifTrue:[
            self specTool specification listSelector:(editor selector).
            self modifiedChannel value:true.
            self accept.
        ]
    ]
! !

!UIPainter methodsFor:'change & update'!

layoutChanged
    "called by the painter/canvas whenever the layout of the current selected
     widget changed
    "
    self isModified ifFalse:[
        self layoutTool update.
        self modifiedChannel value:false
    ]
!

propertyChanged
    "called by the painter/canvas whenever the property of the current selected
     widget changed
    "
    |p|

    (p := treeView propertySelected) notNil ifTrue:[
        self specTool specification:(p spec copy).
        self setViewInLayoutTool:(p view).
        self modifiedChannel value:false
    ] ifFalse:[
        self layoutTool layoutView notNil ifTrue:[
            self modifiedChannel value:false.
            self treeSelection
        ]
    ]
!

update:something with:aParameter from:someObject
    "catch change notifications
    "
    someObject == treeView model ifTrue:[
        (something == #selection
        or:[something == #selectionIndex]) ifTrue:[self treeSelection].
      ^ self
    ].

    self galleryShown == someObject ifTrue:[
        (self galleryShown value) ifTrue:[
            self raiseUIView:(selectionPanel window)
        ] ifFalse:[
            self hideUIView:(selectionPanel window)
        ].
      ^ self
    ].

    self painterShown == someObject ifTrue:[
        (self painterShown value) ifTrue:[
            self raiseUIView:(self painter topView)
        ] ifFalse:[
            self hideUIView:(self painter topView)
        ].
      ^ self
    ].

    "Modified: / 29.10.1997 / 17:48:19 / cg"
! !

!UIPainter methodsFor:'event handling'!

doesNotUnderstand:aMessage

    |painter|

    painter := self painter.

    (painter respondsTo:(aMessage selector)) ifTrue:[
        ^ aMessage sendTo:painter
    ].
    super doesNotUnderstand:aMessage

! !

!UIPainter methodsFor:'help'!

defaultInfoLabel

    specClass isNil ifTrue: [^'No class and selector defined'].
    ^specClass printString, ' >> ', specSelector
!

openTutorial

    self openTutorial: 'tools/uipainter/TOP.html'
!

showHelp:aHelpText for:view
    "display active help texts in my own info area."

    |txt|

    aHelpText isNil ifTrue:[
        txt := nil
    ] ifFalse:[
        txt := self class 
                convertString:(aHelpText asString)
                maxLineSize:(transcript width // transcript font width)
               skipLineFeed:true
    ].
    transcript hideCursor.
    transcript contents:txt.
    ^ true

    "Modified: / 29.10.1997 / 22:33:55 / cg"
! !

!UIPainter methodsFor:'printing'!

show:aText
    transcript hideCursor.
    transcript contents:aText.
        
! !

!UIPainter methodsFor:'private'!

checkModified
    "check interface modification
    "
    self painter isModified
    ifTrue:
    [
        ((YesNoBox title:'Interface was modified!!')        
            noText:'Cancel';
            yesText:'Waste it and proceed';
            showAtPointer;
            accepted) ifFalse: [^false].
        self painter resetModification
    ].
    ^true
!

hideUIView:aView
    "hide the view which is an application or top view
    "
    aView beIndependent.
    aView unmap.
!

raiseTabView

    self isLayoutToolSelected ifTrue:[
        layoutCanvas raise
    ] ifFalse:[
        self isHelpToolSelected ifTrue:[
            helpCanvas raise
        ] ifFalse:[
            self specTool selection:tabSelection.
            specCanvas raise
        ]
    ]
!

raiseUIView:aView
    "raise the view which is an application or top view
    "
    aView map.
    aView bePartner.
!

setClass:cls selector:selector
    "set the application class and the selector under which the
     window specification should be stored
    "
    |clsName superClassName|

    clsName := cls name.
    superClassName := cls superclass name.

    (self aspectFor:#classNameChannel) value:clsName.
    (self aspectFor:#methodNameChannel) value:(selector ? '').
    (self aspectFor:#superclassNameChannel) value:superClassName.

    self painter 
            className:clsName 
            superclassName:superClassName
            selector:(selector ? '').

    self specClass:clsName.
    specSelector := (selector ? '').
    specSuperclass := superClassName.

    specClass notNil & selector notNil ifTrue:[
        self addToHistory: (specClass, ' ', specSelector) -> #loadFromMessage:.
        self updateInfoLabel
    ].

    "Modified: / 5.2.1998 / 09:44:58 / stefan"
!

setViewInLayoutTool:aView
    "set view for layout tool
    "
    |type|

    self painter topView == aView ifTrue:[
        type := #Extent
    ].
    self layoutTool layoutView:aView type:type

!

specClass:aClass

    specClass := aClass isBehavior ifTrue:[aClass name]
                                   ifFalse:[aClass].
    self helpTool helpSpecFrom:specClass.

    "Modified: / 5.2.1998 / 09:42:57 / stefan"
! !

!UIPainter methodsFor:'private tools'!

helpTool
    "returns the help tool
    "
    helpCanvas isNil ifTrue:[
        self noteBookView
    ].
    ^ helpCanvas application
!

layoutTool
    "returns the layout tool
    "
    layoutCanvas isNil ifTrue:[
        self noteBookView
    ].
    ^ layoutCanvas application
!

painter
    "returns the painter/canvas view
    "
    ^ treeView canvas
!

specTool
    "returns the spec tool
    "
    specCanvas isNil ifTrue:[
        self noteBookView
    ].
    ^ specCanvas application
! !

!UIPainter methodsFor:'queries'!

hasSpecClass
    "checks whether an application class is defined
    "
    ^ (self resolveName:specClass) notNil
!

hasSpecClassAndSelector
    "checks whether an application class and a selector under which
     the window specification is stored is defined.
    "
    specSelector size > 1 ifTrue:[
        ^ self hasSpecClass
    ].
  ^ false
!

isHelpToolSelected
    "returns true if current selected tab in the noteBook is assigned
     to the 'Help' tool
    "
    ^ tabSelection = UIHelpTool label

!

isLayoutToolSelected
    "returns true if current selected tab in the noteBook is assigned
     to the 'Layout' tool
    "
    ^ tabSelection = UILayoutTool label
!

isModified
    "returns true if current specification or layout is modified
    "
    ^ self modifiedChannel value
!

isPainterEnabled
    "returns true if not running in test mode
    "
    ^ self painter enabled
! !

!UIPainter methodsFor:'selection'!

tabSelection
    "returns name of current selected tab in the notebook.
    "
    ^ tabSelection
!

tabSelection:something
    "the tab selection of the notebook changed
    "

    |whatToDo|

    (something isNil or:[tabSelection = something]) ifTrue:[
        ^ self
    ].

    self isModified ifTrue:[
        whatToDo := DialogBox 
                        confirmWithCancel:'Accept change made in ' , tabSelection printString , ' section?'
                        labels:#('Cancel' 'Ignore' 'Accept')
                        default:3.
        whatToDo isNil ifTrue:[^self].
        whatToDo == true ifTrue:[
            self accept
        ] ifFalse:[
            self cancel
        ]
    ].

    tabSelection := something.
    self raiseTabView.
    self cancel.

    "Modified: / 26.10.1997 / 15:54:15 / cg"
!

treeSelection
    "called whenever the selection of the treeview changed
    "
    |view list spec slices size property tabComponent|

    self isModified ifTrue:[
        (self confirm:'Accept change made in ' , tabSelection printString , ' section ?') ifTrue:[
            self accept
        ]
    ].
    self canMoveOrAlignSelection        value:(treeView canMoveOrAlignSelection).
    self canChangeOrderInContainer      value:(treeView canChangeOrderInContainer).
    self canMoveSelectionIntoContainer  value:(treeView canMoveSelectionIntoContainer).
    self canMoveSelectionOutOfContainer value:(treeView canMoveSelectionOutOfContainer).
    self hasOneSelectionOtherThanCanvas value:(treeView hasOneSelectionOtherThanCanvas).

    treeView isCanvasSelected ifTrue:[
        spec := treeView canvasSpec.
        view := self painter topView.
    ] ifFalse:[
        (property := treeView propertySelected) notNil ifTrue:[
            treeView canResizeSelectedWidget ifTrue:[
                view := property view.
            ].
            spec := property spec copy.
        ]
    ].
    tabComponent := builder componentAt:#noteBook.
    self setViewInLayoutTool:view.
    self specTool specification:spec.

    spec notNil ifTrue:[
        self helpTool helpKey:(spec activeHelpKey).
        slices := spec class slices.
        size   := slices size.

        view notNil ifTrue:[
            list := Array new:(size + 2).
            list at:(size + 2) put:(UILayoutTool label).
        ] ifFalse:[
            list := Array new:(size + 1).
        ].
        1 to:size do:[:i| list at:i put:((slices at:i) first asString)].
        list at:(size + 1) put:(UIHelpTool   label).

        self tabList value:list.
        self show:(spec class name).
        tabComponent enabled:true.

        (tabSelection := tabComponent selection) isNil ifTrue:[
            tabComponent setSelection:(tabSelection := list first)
        ].
        self raiseTabView
    ] ifFalse:[
        self helpTool helpKey:nil.
        tabComponent enabled:false.
        self show:nil.
    ].
    self modifiedChannel value:false.
! !

!UIPainter methodsFor:'startup / release'!

closeRequest
    "close all windows open by builder
    "
    self checkModified ifFalse:[^self].

    treeView model removeDependent:self.
    self painter release.
    ColorMenu releaseResources.

    selectionPanel notNil ifTrue:[
        selectionPanel masterApplication:nil.
        selectionPanel closeRequest
    ].
    selectionPanel := nil.
    treeView       := nil.

    ActiveHelp stopFor:self.

    super closeRequest.

    "Modified: / 27.10.1997 / 00:01:30 / cg"
!

closeRequestFor:aTopView
    "handle a close request for a specific view
    "
    |topView|

    topView := self window.

    topView == aTopView ifTrue:[
        super closeRequestFor:aTopView
    ] ifFalse:[
        aTopView = selectionPanel window ifTrue:[
            self galleryShown value:false
        ] ifFalse:[
            aTopView == (self painter topView) ifTrue:[
                self painterShown value:false
            ] ifFalse:[
                aTopView closeRequest
            ]
        ].
        topView raise.
    ].
!

openInterface:aSymbol
    "open interfaces
    "
    |painterView painter cls topView|

    aspects := IdentityDictionary new.

    aspects at:#classNameChannel put:(
        (specClass notNil ifTrue:[specClass]
                         ifFalse:['NewApplication']) asValue
    ).
    specSuperclass isNil ifTrue:[
        specClass notNil ifTrue:[
            (cls := self resolveName:specClass) notNil ifTrue:[
                specSuperclass := cls superclass name.
            ]
        ]
    ].
    aspects at:#superclassNameChannel put:(
        (specSuperclass notNil ifTrue:[specSuperclass]
                         ifFalse:['ApplicationModel']) asValue
    ).
    aspects at:#superclassNameDefaults put:#('ApplicationModel' 'SimpleDialog') asValue.
    aspects at:#methodNameChannel put:(
        (specSelector notNil ifTrue:[specSelector asValue]
                            ifFalse:[#windowSpec]) asValue
    ).

    treeView    := TreeView new.
    painterView := StandardSystemView new.
    painterView label:'unnamed canvas'.
    painterView extent:300@300.

    painter := UIPainterView in:painterView.
    painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.

    treeView := treeView canvas:painter.
    painter treeView:treeView.
    treeView model addDependent:self.

    super openInterface:aSymbol.

    transcript := (self builder componentAt:#Transcript) scrolledView.
    topView := self window.
    topView bePartner.
    topView label:'GUI Painter'.

    painterView openInGroup:(topView windowGroup).
    painterView bePartner.
    painterView application:self.
    painterView open.

    painterView application:self.
    selectionPanel := UISelectionPanel new.
    selectionPanel allButOpenInterface:#windowSpec.
    selectionPanel window openInGroup:(topView windowGroup).
    selectionPanel window bePartner.
    selectionPanel openWindow.
    selectionPanel masterApplication:self.

    topView iconLabel:'GUI Painter'.
    topView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).

    painterView iconLabel:'GUI Painter'.
    painterView icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).

    selectionPanel window iconLabel:'GUI Painter'.
    selectionPanel window icon:(Image fromFile:'bitmaps/UIPainter.xbm' resolution:100).

    ActiveHelp startFor:self.
!

openNewWindowCanvas
    "open new
    "
    self open.


!

openOnClass:aClass
    "open up an interface builder
    "
    self openOnClass:aClass andSelector:#windowSpec
!

openOnClass:aClass andSelector:aSelector
    "open up an interface builder, fetching a spec from someClass
     via some selector
    "
    |painter|

    aClass isNil ifTrue:[
        (self confirm:'nil class given to UIPainter (class was probably renamed ?)\\Open anyway (to create a new interface) ?' withCRs)
        ifFalse:[^ nil].
    ].

    self openInterface.

    aClass notNil ifTrue:[
        painter := self painter.
        self setClass:aClass selector:aSelector.
        (aClass respondsTo:aSelector) ifTrue:[
            painter setupFromSpec:(aClass perform:aSelector).
        ]
    ]

    "Modified: / 25.10.1997 / 19:11:51 / cg"
    "Modified: / 5.2.1998 / 09:48:15 / stefan"
! !

!UIPainter methodsFor:'user interactions'!

doBrowseAppClass
    "open a browser on the class"

    |cls|

    self painter isModified ifTrue:[
        self warn:'The current interface has not yet been saved.\\The browser will show the code of the old interface.' withCRs.
    ].
    cls := self resolveName:specClass.

    cls notNil ifTrue:[
        SystemBrowser openInClass:cls
    ] ifFalse:[
        self information:'No class defined!!'.
    ].

!

doBrowseAspectMethods
    "open a browser on the aspect methods"

    |cls methods|

    self painter isModified ifTrue:[
        self warn:'The current interface has not yet been saved.\\The browser may show the code of the old aspect methods.' withCRs.
    ].
    cls := self resolveName:specClass.

    cls notNil ifTrue:[
        methods := self painter aspectMethods.
        methods isEmpty ifTrue:[
            self warn:'No aspect methods have been saved yet!!'.
            ^ self.
        ].
        SystemBrowser browseMethods:methods title:'Aspect methods'.
    ] ifFalse:[
        self information:'No class defined!!'.
    ].

    "Created: / 25.10.1997 / 19:07:55 / cg"
!

doFromClass

    self loadFromMessage: 
        (ResourceSelectionBrowser
            request: 'Load Interface From Class'
            onSuperclass: nil
            andClass: specClass
            andSelector: specSelector
            withResourceTypes: #(canvas))
!

doInstallAspects
    "install aspects and actions
    "
    |code|

    self hasSpecClassAndSelector ifFalse:[
        self defineClassAndSelector
    ].

    self checkClassAndSelector ifFalse:[
        ^ self
    ].

    self painter className:specClass
        superclassName:specSuperclass
              selector:specSelector.

    code := self painter generateAspectMethods.
    (ReadStream on:code) fileIn.

!

doInstallHooks
    "install application hooks
    "
    |code|

    self hasSpecClassAndSelector ifFalse:[
        self defineClassAndSelector
    ].

    self checkClassAndSelector ifFalse:[
        ^ self
    ].

    self painter className:specClass
        superclassName:specSuperclass
              selector:specSelector.

    code := self painter generateHookMethods.
    (ReadStream on:code) fileIn.

    "Created: / 31.10.1997 / 17:37:54 / cg"
!

doInstallSpec
    "install window specification
    "
    |code painter|

    self hasSpecClassAndSelector ifFalse:[
        self defineClassAndSelector
    ].

    self checkClassAndSelector ifFalse:[
        ^ self
    ].

    self isModified ifTrue:[
        (self confirm:'Accept change made in ' , tabSelection printString , ' section?') ifTrue:[
            self accept
        ] ifFalse:[
            (self confirm:'Load old interface?') ifFalse:[
                ^ self
            ]
        ]
    ].

    painter := self painter.

    painter className:specClass
       superclassName:specSuperclass
             selector:specSelector.

    code := painter generateWindowSpecMethodSource withCRs.
    painter resetModification.
    (ReadStream on:code) fileIn.

    self helpTool installHelpSpecInto:specClass
!

doNew
    "remove all components and associated resources
    "
    self painter isModified ifTrue:[
        (self confirm:'Edit a new interface without saving current?') ifFalse:[
            ^ self
        ]
    ].
    self painter removeAll.
!

doPickAView
    "pick a view and setup specifications
    "
    |painter view cls spec app|

    self painter isModified ifTrue:[
        (self confirm:'pick another interface without saving your modifications ?') ifFalse:[
            ^ self
        ]
    ].

    (view := Screen current viewFromUser) notNil ifTrue:[
        view == Screen current rootView ifFalse:[
            painter := self painter.
            spec    := UISpecification fromView:view topView.

         "/ ok, got it

            (app := view application) notNil ifTrue:[
                cls := app class
            ] ifFalse:[
                cls := view class
            ].
            self setClass:cls selector:nil.

            painter setupFromSpec:spec.
        ]
    ]

    "Modified: / 1.11.1997 / 13:47:49 / cg"
!

doStartApplication
    "start current edited application
    "
    |cls app infoMessage|

    self isModified ifTrue:[
        (self confirm:'Accept change made in ' , tabSelection printString , ' section?') ifTrue:[
            self accept.
            "/  "XXX must be fixed - canvas changes are not recorded in the history
            "/  so isModified returns false here
            "/
            "/ self painter isModified ifTrue:[
            "/
                (self confirm:'Reinstall the new interface?' withCRs) ifTrue:[
                    self doInstallSpec
                ]
            "/ ].
        ]
    ].
    self painter isModified ifTrue:[
        (self confirm:'The current interface has not yet been reinstalled!!\\Start anyway (based upon the previous interface)?' withCRs) ifFalse:[
            ^ self
        ]
    ].

    (specClass isNil or:[specSelector size < 2]) ifTrue:[
        infoMessage := 'No class and selector defined!!'.
    ] ifFalse:[
        cls := self resolveName:specClass.

        cls isNil ifTrue:[
            infoMessage := 'Class does not exist!!'.
        ] ifFalse:[
            (cls respondsTo:specSelector) ifFalse:[
                infoMessage := ('No method for: #' 
                                , specSelector , ' in ' , cls name
                                , '\\(did you install the interface?)') withCRs.
            ]
        ]
    ].

    infoMessage notNil ifTrue:[
        ^ self information:infoMessage
    ].
    app := cls new.
    (app respondsTo:#openInterface:) ifFalse:[
        ^ self warn:('The application does not respond to the ''openInterface:'' message.\\(maybe its supposed to be used as subApplication/subCanvas)') withCRs.
    ].        
    app openInterface:specSelector

    "Modified: / 29.10.1997 / 19:01:50 / cg"
!

doWindowSpec
   "create the window specification but do not write to application; instead
    open a view
   "
   |code v|

   code := self painter generateWindowSpecMethodSource.

   v := CodeView open.
   v contents:code.
   v label:'windowSpec'.

!

loadFromMessage: aMessage

    ((aMessage size > 0) and: [self checkModified])
    ifTrue:
    [
        |readStream aClass aSelector|
        readStream := aMessage readStream.
        (aClass := Smalltalk at: (readStream upTo: $ ) asSymbol) notNil
        ifTrue:
        [
            aSelector :=  readStream upToEnd asSymbol.
            self setClass: aClass selector: aSelector.
            (aClass respondsTo:aSelector) 
            ifTrue:
            [
                self painter setupFromSpec:(aClass perform:aSelector).
            ]
        ]
    ]

!

loadSubspec

    |subSpecMessage|
    (subSpecMessage := ResourceSelectionBrowser
            request: 'Load Subspec From Class'
            onSuperclass: nil
            andClass: specClass
            andSelector: specSelector
            withResourceTypes: #(canvas)) notNil
    ifTrue:
    [
        |readStream aClass aSelector|
        readStream := subSpecMessage readStream.
        (aClass := Smalltalk at: (readStream upTo: $ ) asSymbol) notNil
        ifTrue:
        [
            aSelector :=  readStream upToEnd asSymbol.
            (aClass name == specClass and: [aSelector == specSelector]) ifTrue: [^self warn: 'Current interface as subspec not allowed!!'].
            (aClass respondsTo:aSelector) 
            ifTrue:
            [
                self addWidgetOfSpec: (Array with: (UISubSpecification new majorKey: aClass name; minorKey: aSelector))
            ]
        ]
    ]
! !

!UIPainter methodsFor:'user interactions - dialog'!

checkClassAndSelector
    "check for class & superclass"

    |superclass cls|

    specClass isNil ifTrue:[^ false].

    cls := self resolveName:specClass.

    cls isNil ifTrue:[
        superclass := self resolveName:specSuperclass.

        superclass isNil ifTrue:[
            self warn:'No class named ' , specSuperclass , ' exists!!'.
            ^ false.
        ].
        (self confirm:'Create ' , specClass , '?') ifTrue:[
            superclass subclass:(specClass asSymbol)
                       instanceVariableNames:''
                       classVariableNames:''
                       poolDictionaries:''
                       category:'Applications'.
            ^ true.
        ].
        ^ false.
    ].
    cls isBehavior ifFalse:[
        self warn:'A global named ' , specClass , ' exists, but is no class.'.
        ^ false.
    ].

    specSuperclass isBehavior ifFalse:[
        specSuperclass isEmpty ifFalse:[
            superclass := self resolveName:specSuperclass
        ] ifTrue:[
            specSuperclass := nil.
        ]
    ] ifTrue:[
        superclass := specSuperclass
    ].

    specSuperclass notNil ifTrue:[
        superclass isNil ifTrue:[
            self warn:'No class named ' , specSuperclass , ' exists!!'.
            ^ false.
        ].

        (cls isSubclassOf:superclass) ifFalse:[
            self information:('A global named ' , specClass , ' exists,\' ,
                              'but is not a subclass of ' , superclass name , '.\\' ,
                              'Check and try again if that is not what you want.') withCRs.
        ]
    ].

    superclass isNil ifTrue:[
        cls notNil ifTrue:[
            specSuperclass := cls superclass name
        ]
    ].

    ^ true

    "Modified: 12.8.1997 / 23:39:10 / cg"
!

defineClassAndSelector
    "launch a dialog to define class, superclass and method"

    |again tmp|

    [
        again := false.

        (tmp := specClass) isNil ifTrue:[tmp := 'NewApplication'].
        aspects at:#classNameChannel put:tmp asValue.

        (tmp := specSelector) isNil ifTrue:[tmp := 'windowSpec'].
        aspects at:#methodNameChannel put:tmp asValue.

        (tmp := specSuperclass) isNil ifTrue:[tmp := 'ApplicationModel'].
        aspects at:#superclassNameChannel put:tmp asValue.

        (self openDialogInterface:#nameAndSelectorSpec) ifTrue:[

            specClass    := (self aspectFor:#classNameChannel) value.
            specSelector := (self aspectFor:#methodNameChannel) value.
            specSelector notNil ifTrue:[specSelector := specSelector asSymbol].
            specSuperclass := (self aspectFor:#superclassNameChannel) value.

            (again := self checkClassAndSelector not) ifFalse:[
                self painter className:specClass
                        superclassName:specSuperclass
                              selector:specSelector.
            ]
        ]

    ] doWhile:[again].

    self specClass:specClass.
!

gridMenu
    "open a dialog for grip parameters configuration
    "
    |hspace vspace bindings painter gridPara|

    painter  := self painter.
    bindings := IdentityDictionary new.
    gridPara := painter gridParameters copy.

    bindings at:#showGrid    put:(painter gridShown asValue).
    bindings at:#alignToGrid put:(painter gridAlign asValue).
    bindings at:#hspace      put:((gridPara at:1) asValue).
    bindings at:#vspace      put:((gridPara at:2) asValue).

    (self openDialogInterface:#gridParametersSpec withBindings:bindings) ifFalse:[
        ^ self
    ].

    hspace := (bindings at:#hspace) value ? 5.
    vspace := (bindings at:#vspace) value ? 5.

    gridPara at:1 put:hspace.
    gridPara at:2 put:vspace.
    gridPara at:5 put:hspace.
    gridPara at:6 put:vspace.

    painter gridShown:false.
    painter gridAlign:false.
    painter gridParameters:gridPara.
    painter gridAlign:(bindings at:#alignToGrid) value.
    painter gridShown:(bindings at:#showGrid) value.


! !

!UIPainter methodsFor:'user interactions - move'!

doStepDown
    "move selected component after the next component in the hierarchy of
     its container widget
    "
    treeView doStepOver:1
!

doStepIn
    "change the container of the selected widget
    "
    treeView doStepIn
!

doStepOut
    "change the container of the selected widget
    "
    treeView doStepOut
!

doStepUp
    "move selected component before the previous component in the hierarchy of
     its container widget
    "
    treeView doStepOver:-1
! !

!UIPainter::TreeView class methodsFor:'constants'!

defaultNameOfCanvas
    "returns the default name (id) of the application
    "
    ^ 'Canvas'
! !

!UIPainter::TreeView class methodsFor:'documentation'!

documentation
"
    selection in tree view; only used by the UIPainter

    [see also:]
        SelectionInTreeView
        SelectionInTree
        TreeItem
        UIPainter

    [author:]
        Claus Atzkern
"


! !

!UIPainter::TreeView methodsFor:'accessing'!

canvas
    "returns the canvas( UIPainter )
    "
  ^ model root contents view


!

canvas:aCanvas
    "install canvas( UIPainter )
    "
    |props|

    props := UIPainterView::ViewProperty new.
    props view:aCanvas.
    model root:(TreeItem name:(self class defaultNameOfCanvas) contents:props).
    model root expand.
    self enableChannel:(aCanvas enableChannel).

!

canvasSpec
    "returns spec assigned to canvas
    "
    |spec|

    spec := WindowSpec new.

    spec fromView:(self canvas topView) callBack:nil.
    spec name:(listOfNodes at:1) name.

    windowSpec notNil ifTrue:[
        spec copyValuesFromSpec:windowSpec
    ].
    ^ spec

    "Modified: / 29.10.1997 / 18:06:44 / cg"
!

canvasSpec:aSpec
    "update canvas from spec
    "
    |spec|

    self setAttributesFromWindowSpec:aSpec.
    spec := aSpec copy.
    spec  menu:nil.
    spec flags:nil.

    spec setAttributesIn:(self canvas topView) with:(UIBuilder new isEditing:true).
!

itemOfView:aView
    "returns item assigned to view or nil
    "
    aView notNil ifTrue:[
        self allItemsDo:[:anItem|
            (anItem contents view == aView) ifTrue:[^ anItem]
        ]
    ].
  ^ nil


! !

!UIPainter::TreeView methodsFor:'accessing property'!

propertiesDo:aOneArgBlock
    "evaluate the argument a block on each property
    "
    self allItemsDo:[:anItem| aOneArgBlock value:(anItem contents)]


!

propertyDetect:aOneArgBlock
    "evaluate the block on each property
    "
    self allItemsDo:[:anItem|
        (aOneArgBlock value:(anItem contents)) ifTrue:[^ anItem contents]
    ].
  ^ nil

!

propertySelected
    "returns current selected property or nil in case of multi selection
     or empty selection
    "
    |idx|

    selection size == 1 ifTrue:[
        (idx := selection first) ~~ 1 ifTrue:[          "canvas: not yet supported"
            ^ (listOfNodes at:idx) contents
        ]
    ].
  ^ nil

! !

!UIPainter::TreeView methodsFor:'adding & removing'!

addProperty:aProperty
    "add a new item
    "
    |parent| 

    parent := self detectItemRespondsToView:(aProperty view superView).

    parent notNil ifTrue:[
        model add:(TreeItem name:(aProperty name) contents:aProperty) below:parent
    ]

!

removeAll
    "remove all items other than canvas
    "
    lastDrawnMaster := nil.
    windowSpec := nil.

    self canvas subViews copy do:[:aView|
        (aView isKindOf:InputView) ifFalse:[aView destroy]
    ].
    model root name:(self class defaultNameOfCanvas).
    model root children:(OrderedCollection new).
    model recomputeList.
    self selection:nil.


!

removeView:aView
    "remove a view
    "
    |item prnt|

    ((item := self itemOfView:aView) notNil and:[(prnt := item parent) notNil]) ifTrue:[
        aView destroy.
        prnt contents view sizeChanged:nil.
        model remove:item
    ]


! !

!UIPainter::TreeView methodsFor:'building'!

generateFullSpecForComponents:aSpecArray
    "generates a full spec for components
    "
    |fullSpec winSpec|

    fullSpec := FullSpec new.

    fullSpec fromBuilder:(self canvas topView)
              components:(SpecCollection new collection:aSpecArray).

    windowSpec notNil ifTrue:[
        winSpec := fullSpec window.
        winSpec copyValuesFromSpec:windowSpec
    ].    
    ^ fullSpec literalArrayEncoding.

    "Modified: / 29.10.1997 / 18:05:58 / cg"
!

setAttributesFromWindowSpec:aWindowSpec
    "set windowSpec from argument a WindowSpec
    "
    windowSpec := WindowSpec new copyValuesFromSpec:aWindowSpec.
    self canvasNameChanged:aWindowSpec name.

    "Modified: / 29.10.1997 / 18:06:56 / cg"
! !

!UIPainter::TreeView methodsFor:'canvas selection'!

cvsSelection:aSelection
    "canvas changed its selection
    "
    |sel list rcLt|

    list := OrderedCollection new.

    aSelection isNil ifFalse:[
        aSelection isCollection ifTrue:[
            aSelection notNil ifTrue:[sel := aSelection]
        ] ifFalse:[
            sel := Array with:aSelection
        ]
    ].

    sel notNil ifTrue:[
        rcLt := false.

        sel do:[:aView||item|
            (item := self itemOfView:aView) notNil ifTrue:[
                list add:item.

                [(item := item parent) notNil] whileTrue:[
                    item hidden ifTrue:[
                        rcLt := true.
                        item expand.
                    ]
                ]
            ]
        ].
        rcLt ifTrue:[model recomputeList].
        sel := list collect:[:anItem| listOfNodes findFirst:[:el| el == anItem]]
    ] ifFalse:[
        sel := list
    ].
    self cvsEventsDisabledDo:[ self selection:sel ].            




!

cvsSelectionAdd:aView
    "canvas adds a view to current selection
    "
    |parent item rcLt oldSel|

    item := self itemOfView:aView.

    item notNil ifTrue:[
        parent := item.

        [ (parent := parent parent) notNil ] whileTrue:[
            parent hidden ifTrue:[
                rcLt := true.
                parent expand.
            ]
        ].
        rcLt == true ifTrue:[model recomputeList].

        oldSel := selection copy.
        self addToSelection:(listOfNodes findFirst:[:el| el == item]).
        self selectionChangedFrom:oldSel
    ].            



!

cvsSelectionRemove:aView
    "canvas removes a view from current selection
    "
    |parent item rcLt oldSel|

    item := self itemOfView:aView.

    item notNil ifTrue:[
        parent := item.

        [ (parent := parent parent) notNil ] whileTrue:[
            parent hidden ifTrue:[
                rcLt := true.
                parent expand.
            ]
        ].
        rcLt == true ifTrue:[model recomputeList].

        oldSel := selection copy.
        self removeFromSelection:(listOfNodes findFirst:[:el| el == item]).
        self selectionChangedFrom:oldSel
    ].            



! !

!UIPainter::TreeView methodsFor:'change & update'!

canvasNameChanged:aName
    "called if identification name assigned to window (canvas) changed
    "
    |name node|

    node := listOfNodes at:1.

    (    aName size ~~ 0
     and:[(name := aName string withoutSeparators) size ~~ 0
     and:[(self propertyDetect:[:p| p name = name]) isNil
     and:[node name ~= name]]]
    ) ifTrue:[
        node name: name.
        self redrawLine:1.
    ].
!

layoutChanged
    "layout of any component changed; in case of single selection, the
     application will be informed to update its layout
    "
    selection size == 1 ifTrue:[
        self application layoutChanged
    ]


!

propertyChanged:aProperty
    "property of view derived from argument a property changed
    "
    |item idx end|

    item := self itemOfView:(aProperty view).

    item notNil ifTrue:[
        item contents:aProperty.

        item name = aProperty name ifFalse:[
            idx := self firstLineShown.

            (end := self lastLineShown) > listOfNodes size ifTrue:[
                end := listOfNodes size
            ].                          
            item name: aProperty name.

            [idx <= end] whileTrue:[
                (listOfNodes at:idx) == item ifTrue:[
                    self redrawLine:idx.                "/ is visible; redraw line
                    end := 0
                ] ifFalse:[
                    idx := idx + 1
                ]
            ]
        ].

        self selectedNode == item ifTrue:[              "/ inform application
            self application propertyChanged
        ]
    ].


! !

!UIPainter::TreeView methodsFor:'drag & drop'!

canDrop:anObjectOrCollection
    "can drop ? delegate to canvas
    "
  ^ self canvas canDrop:anObjectOrCollection
!

drop:anObjectOrCollection at:aPoint
    "drop objects ? delegate to canvas
    "
    self canvas drop:anObjectOrCollection at:aPoint
! !

!UIPainter::TreeView methodsFor:'enumerating'!

allItemsDo:aOneArgBlock
    "evaluate the argument a block on each item other than the canvas
    "
    model root allChildrenDo:aOneArgBlock


! !

!UIPainter::TreeView methodsFor:'event processing'!

cvsEventsDisabledDo:aBlock
    "evaluate the block without raising selection changed notifications
     to canvas
    "
    |restoreCvsEvents|

    restoreCvsEvents  := cvsEventsDisabled.
    cvsEventsDisabled := true.
    aBlock value.
    cvsEventsDisabled := restoreCvsEvents.


!

cvsSetupListDo:aBlock
    "evaluate block without handling notifications from model; after evaluation
     the new list will be recomputed
    "
    model removeDependent:self.

    self cvsEventsDisabledDo:[
        self selection:nil.
        aBlock value
    ].
    model addDependent:self.
    model recomputeList.

!

doubleClicked
    "disable collapse of canvas item
    "
    self selectedNode == model root ifFalse:[
        super doubleClicked
    ]


! !

!UIPainter::TreeView methodsFor:'initialization'!

initialize
    "initialization; set multiple select and model
    "

    super initialize.

    self multipleSelectOk:true.
    cvsEventsDisabled := false.
    self showDirectoryIndicator: true.
    self showDirectoryIndicatorForRoot: false
! !

!UIPainter::TreeView methodsFor:'private'!

figureFor:aNode
    "returns image for an spec item"

    |cls icon|

    cls := aNode contents spec class.
    aNode contents spec isNil ifTrue: [cls := WindowSpec].
    icon := cls icon.
    icon extent y > 16 ifTrue: [icon := icon magnifiedBy: 16/icon extent y].
    icon device ~~ device ifTrue: [icon := icon onDevice: device].
    ^icon
!

selectionChangedFrom:oldSelection
    "selection has changed. update master selection and raise notification
     to canvas in case of enabled cvs events
    "
    |sel size|

    super selectionChangedFrom:oldSelection.
    size := selection size.

    cvsEventsDisabled ifFalse:[
        (size ~~ 0 and:[size ~~ 1 or:[selection first ~~ 1]]) ifTrue:[
            sel := OrderedCollection new.

            selection do:[:i|
                i ~~ 1 ifTrue:[sel add:(listOfNodes at:i) contents view]
            ]
        ].
        self canvas updateSelectionFromModel:sel
    ].

    size ~~ 0 ifTrue:[
        sel := selection first.

        (listOfNodes at:sel) == lastDrawnMaster ifFalse:[
            self redrawLine:sel
        ]
    ]
! !

!UIPainter::TreeView methodsFor:'queries'!

canChangeOrderInContainer
    "returns true if any selection exists and all widgets in the selection
     can change their layout through to a move or align operation.
    "
    |canvas|

    ((selection size ~~ 1) or: [(selection at: 1) == 1]) ifTrue:[
        ^ false
    ].
    ^ true
!

canMoveOrAlignSelection
    "returns true if any selection exists and all widgets in the selection
     can change their layout through to a move or align operation.
    "
    |canvas|

    selection size == 0 ifTrue:[
        ^ false
    ].
    canvas := self canvas.

    selection do:[:i|
        i == 1 ifTrue:[^ false].

        (canvas canChangeLayoutOfView:((listOfNodes at:i) contents view)) ifFalse:[
            ^ false
        ]
    ].
    ^ true
!

canMoveSelectionIntoContainer
    "returns true in case that one component is selected and can change its container
     widget to the next element in the list which will have the same container.
    "
    |item prnt|

    (     (item := self selectedNode) isNil
      or:[(prnt := item parent) isNil
      or:[(prnt := prnt childAt:((prnt indexOfChild:item) + 1)) isNil
      or:[prnt contents spec class supportsSubComponents not]]]
    ) ifTrue:[
        ^ false
    ].
  ^ true
!

canMoveSelectionOutOfContainer
    "returns true in case that one component is selected which is contained within
     another component.
    "
    |item prnt|

    (     (item := self selectedNode) isNil
      or:[(prnt := item parent) isNil
      or:[prnt parent isNil]]
    ) ifTrue:[
        ^ false
    ].
  ^ true
!

canResizeSelectedWidget
    "returns true in case of one widget selected and is contained
     within a widget which allows to resize sub components
    "
    |n|

    (n := self selectedNode) notNil ifTrue:[
        (n := n parent) notNil ifTrue:[
            ^ (n parent isNil or:[n contents spec class canResizeSubComponents])
        ]
    ].
    ^ false
!

hasOneSelectionOtherThanCanvas
    "returns true in case that one selection exists other than the canvas
    "
    ^ (selection size == 1 and:[selection first ~~ 1])
!

isCanvasSelected
    "returns true in case of a single selection and the
     selection is the canvas (index 1)
    "
    ^ (selection size == 1 and:[self isInSelection:1])
! !

!UIPainter::TreeView methodsFor:'seraching'!

detectItemRespondsToView:aView
    "detect the item responding to the view. The item of the view or the first
     subview providing the item is returned. If no property is detected nil is
     returned
    "
    |view item|

    (view := aView) notNil ifTrue:[
        [(item := self itemOfView:view) isNil] whileTrue:[
            (view := view superView) isNil ifTrue:[^ listOfNodes at:1]
        ].
    ].
    ^ item

! !

!UIPainter::TreeView methodsFor:'user interactions'!

doStepIn
    |item prnt canvas|

    (     (item := self selectedNode) isNil
      or:[(prnt := item parent) isNil
      or:[(prnt := prnt childAt:((prnt indexOfChild:item) + 1)) isNil
      or:[prnt contents spec class supportsSubComponents not]]]
    ) ifFalse:[
        canvas := self canvas.
        canvas deleteSelection.
        canvas setSelection:(prnt contents view) withRedraw:false.
        canvas pasteWithLayout.
    ]
!

doStepOut
    |item next prnt canvas|

    (     (item := self selectedNode) isNil
      or:[(prnt := item parent) isNil
      or:[(next := prnt parent) isNil]]
    ) ifTrue:[
        ^ self
    ].
    model removeDependent:self.

    canvas := self canvas.
    canvas deleteSelection.
    canvas setSelection:(next contents view) withRedraw:false.
    canvas pasteWithLayout.

!

doStepOver:anIndex
    "move child 'anOffset' forward or backward in list of children
    "
    |item idx size prnt spVw view canvas|

    (    (item := self selectedNode) isNil
     or:[(prnt := item parent) isNil
     or:[(size := prnt children size) < 2
     or:[(idx  := prnt indexOfChild:item) == 0]]]
    ) ifTrue:[
        ^ self
    ].
    model removeDependent:self.
    model removeSelection.
    selection := nil.
    model addDependent:self.
    idx := idx + anIndex.

    idx < 1 ifTrue:[idx := size]
           ifFalse:[idx > size ifTrue:[idx := 1]].

    model add:item beforeIndex:idx below:prnt.
    idx    := prnt indexOfChild:item.
    view   := item contents view.
    spVw   := prnt contents view.
    canvas := self canvas.

    canvas hideSelection.

 "/ input view might by contained in sequence
    ((size := canvas findInputViewIn:spVw) ~~ 0 and:[idx >= size]) ifTrue:[
        idx := idx + 1
    ].
    spVw changeSequenceOrderFor:view to:idx.

    spVw specClass isLayoutContainer ifFalse:[
        spVw subViews do:[:v| v raise ].
        canvas inputView raise
    ].
    canvas showSelection.
    self selectNode:item.
! !

!UIPainter class methodsFor:'documentation'!

version
    ^ '$Header$'
! !