--- a/UIPainter.st Wed Apr 30 16:49:35 1997 +0200
+++ b/UIPainter.st Wed May 21 12:39:28 1997 +0200
@@ -1,46 +1,14 @@
-"
- COPYRIGHT (c) 1995 by Claus Gittinger
- All Rights Reserved
-
- This software is furnished under a license and may be used
- only in accordance with the terms of that license and with the
- inclusion of the above copyright notice. This software may not
- be provided or otherwise made available to, or used by, any
- other person. No title to or ownership of the software is
- hereby transferred.
-"
-
ApplicationModel subclass:#UIPainter
- instanceVariableNames:'topView workView propertyView treeView elementMenu fileName
- specClass specSelector specSuperclass aspects'
+ instanceVariableNames:'objectList currentView selectionPanel tabSelection lastSlice
+ specView layoutTool emptyView fileName specClass specSelector
+ specSuperclass aspects'
classVariableNames:''
poolDictionaries:''
category:'Interface-UIPainter'
!
-HorizontalPanelView subclass:#ButtonPanel
- instanceVariableNames:'receiver argumentToSelector'
- classVariableNames:''
- poolDictionaries:''
- privateIn:UIPainter
-!
-
!UIPainter class methodsFor:'documentation'!
-copyright
-"
- COPYRIGHT (c) 1995 by Claus Gittinger
- 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
"
not yet finished, not yet published, not yet released.
@@ -48,16 +16,240 @@
[start with:]
UIPainter open
"
+
+! !
+
+!UIPainter class methodsFor:'instance creation'!
+
+listHolder:aListHolder
+ |application|
+
+ application := self new.
+ application objectList:aListHolder.
+ ^ application open
+!
+
+painter:aBuilderView
+ |application|
+
+ application := self new.
+ application painter:aBuilderView.
+ ^ application open
! !
!UIPainter class methodsFor:'ST-80 queries'!
preferenceFor:aSymbol
^ false
+
+
+! !
+
+!UIPainter class methodsFor:'constants'!
+
+titleOfLayoutMenu
+ ^ 'Dimension'
! !
!UIPainter class methodsFor:'interface specs'!
+menuSpec
+ ^ #(#Menu #(
+ #(#MenuItem
+ #'label:' 'file'
+ #'nameKey:' #file
+ #'submenu:'
+ #(#Menu #(
+ #(#MenuItem
+ #'label:' 'new'
+ #'nameKey:' #removeAll
+ )
+ #(#MenuItem
+ #'label:' 'from class ...'
+ #'nameKey:' #doFromClass
+ )
+ #(#MenuItem
+ #'label:' 'pick a view '
+ #'nameKey:' #doPickAView
+ )
+ #(#MenuItem
+ #'label:' 'load'
+ #'nameKey:' #doOpen
+ )
+ #(#MenuItem
+ #'label:' 'save'
+ #'nameKey:' #doSave
+ )
+ #(#MenuItem
+ #'label:' 'save as ...'
+ #'nameKey:' #doSaveAs
+ )
+ #(#MenuItem
+ #'label:' 'raise'
+ #'nameKey:' #doRaise
+ )
+ #(#MenuItem
+ #'label:' 'quit'
+ #'nameKey:' #closeRequest
+ )
+ )
+ #(3 3 1)
+ nil
+ )
+ )
+ #(#MenuItem
+ #'label:' 'font'
+ #'nameKey:' #font
+ #'submenu:'
+ #(#Menu #(
+ #(#MenuItem
+ #'label:' 'larger'
+ #'nameKey:' #largerFont
+ )
+ #(#MenuItem
+ #'label:' 'smaller'
+ #'nameKey:' #smallerFont
+ )
+ #(#MenuItem
+ #'label:' 'normal'
+ #'nameKey:' #normalFont
+ )
+ #(#MenuItem
+ #'label:' 'bold'
+ #'nameKey:' #boldFont
+ )
+ #(#MenuItem
+ #'label:' 'italic'
+ #'nameKey:' #italicFont
+ )
+ #(#MenuItem
+ #'label:' 'bold italic'
+ #'nameKey:' #boldItalicFont
+ )
+ #(#MenuItem
+ #'label:' 'font panel'
+ #'nameKey:' #showFontPanel
+ )
+ )
+ #(2 4)
+ nil
+ )
+ )
+ #(#MenuItem
+ #'label:' 'special'
+ #'nameKey:' #special
+ #'submenu:'
+ #(#Menu #(
+ #(#MenuItem
+ #'label:' 'group radioButtons'
+ #'nameKey:' #groupRadioButtons
+ )
+ #(#MenuItem
+ #'label:' 'group enterFields'
+ #'nameKey:' #groupEnterFields
+ )
+ )
+ nil
+ nil
+ )
+ )
+ #(#MenuItem
+ #'label:' 'misc'
+ #'nameKey:' #misc
+ #'submenu:'
+ #(#Menu #(
+ #(#MenuItem
+ #'label:' 'grid'
+ #'nameKey:' #grid
+ #'submenu:'
+ #(#Menu #(
+ #(#MenuItem
+ #'label:' '\c show'
+ #'nameKey:' #gridShown
+ )
+ #(#MenuItem
+ #'label:' '\c align'
+ #'nameKey:' #gridAlign
+ )
+ )
+ nil
+ nil
+ )
+ )
+ #(#MenuItem
+ #'label:' 'undo'
+ #'nameKey:' #undo
+ #'submenu:'
+ #(#Menu #(
+ #(#MenuItem
+ #'label:' 'last'
+ #'nameKey:' #undoLast
+ )
+ #(#MenuItem
+ #'label:' 'menu'
+ #'nameKey:' #openUndoMenu
+ )
+ #(#MenuItem
+ #'label:' 'delete'
+ #'nameKey:' #removeUndoHistory
+ )
+ )
+ #(2)
+ nil
+ )
+ )
+ )
+ nil
+ nil
+ )
+ )
+ #(#MenuItem
+ #'label:' 'code'
+ #'nameKey:' #code
+ #'submenu:'
+ #(#Menu #(
+ #(#MenuItem
+ #'label:' 'class & method'
+ #'nameKey:' #defineClassAndSelector
+ )
+ #(#MenuItem
+ #'label:' 'install spec'
+ #'nameKey:' #doInstallSpec
+ )
+ #(#MenuItem
+ #'label:' 'install aspects'
+ #'nameKey:' #doInstallAspects
+ )
+ #(#MenuItem
+ #'label:' 'windowSpec'
+ #'nameKey:' #doWindowSpec
+ )
+ )
+ #( 1 2 )
+ nil
+ )
+ )
+ #(#MenuItem
+ #'label:' 'test'
+ #'nameKey:' #test
+ #'submenu:'
+ #(#Menu #(
+ #(#MenuItem
+ #'label:' '\c test mode'
+ #'nameKey:' #testMode
+ )
+ )
+ nil
+ nil
+ )
+ )
+ )
+ nil
+ nil
+ )
+
+!
+
nameAndSelectorSpec
"this window spec was automatically generated by the ST/X UIPainter"
@@ -72,7 +264,7 @@
<resource: #canvas>
^
-
+
#(#FullSpec
#'window:'
#(#WindowSpec
@@ -196,26 +388,538 @@
)
)
- "Modified: 3.4.1997 / 20:14:32 / cg"
+!
+
+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:' 'uIPainterView'
+ #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0)
+ #'label:' 'Tree-View'
+ #'bounds:' #(#Rectangle 0 0 460 390)
+ )
+ #'component:'
+ #(#SpecCollection
+ #'collection:'
+ #(
+ #(#ViewSpec
+ #'name:' 'view1'
+ #'layout:' #(#LayoutFrame 0 0.0 29 0.0 0 1.0 0 1.0)
+ #'component:'
+ #(#SpecCollection
+ #'collection:'
+ #(
+ #(#SequenceViewSpec
+ #'name:' 'selectionInList'
+ #'layout:' #(#LayoutFrame 0 0.0 40 0.0 0 0.35 0 1.0)
+ #'enableChannel:' #canModify
+ #'menu:' #objectListMenu
+ #'model:' #objectList
+ #'callbacksSpec:'
+ #(#UIEventCallbackSubSpec
+ #'doubleClickSelector:' #doubleClick
+ )
+ #'hasHorizontalScrollBar:' true
+ #'hasVerticalScrollBar:' true
+ #'miniScrollerHorizontal:' false
+ #'miniScrollerVertical:' false
+ #'isMultiSelect:' true
+ )
+ #(#PanelViewSpec
+ #'name:' 'panelViewButtons'
+ #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 40 0.0)
+ #'component:'
+ #(#SpecCollection
+ #'collection:'
+ #(
+ #(#HorizontalPanelViewSpec
+ #'name:' 'hrzPanelViewAlignH'
+ #'component:'
+ #(#SpecCollection
+ #'collection:'
+ #(
+ #(#ActionButtonSpec
+ #'name:' 'alignLeft'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_alignL.xbm'
+ #'defaultable:' true
+ #'model:' #alignSelectionLeft
+ #'hasCharacterOrientedLabel:' false
+ #'isTriggerOnDown:' false
+ #'enableChannel:' #canModify
+ #'autoRepeat:' false
+ #'extent:' #(#Point 24 24)
+ )
+ #(#ActionButtonSpec
+ #'name:' 'alignRight'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_alignR.xbm'
+ #'defaultable:' true
+ #'model:' #alignSelectionRight
+ #'hasCharacterOrientedLabel:' false
+ #'isTriggerOnDown:' false
+ #'enableChannel:' #canModify
+ #'autoRepeat:' false
+ #'extent:' #(#Point 24 24)
+ )
+ #(#ActionButtonSpec
+ #'name:' 'alignHorizontal'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_alignLR.xbm'
+ #'defaultable:' true
+ #'model:' #alignSelectionLeftAndRight
+ #'hasCharacterOrientedLabel:' false
+ #'isTriggerOnDown:' false
+ #'enableChannel:' #canModify
+ #'autoRepeat:' false
+ #'extent:' #(#Point 24 24)
+ )
+ )
+ )
+ #'level:' 0
+ #'horizontalLayout:' #center
+ #'verticalLayout:' #center
+ #'horizontalSpace:' 3
+ #'verticalSpace:' 3
+ #'extent:' #(#Point 84 30)
+ )
+ #(#HorizontalPanelViewSpec
+ #'name:' 'hrzPanelViewAlignV'
+ #'component:'
+ #(#SpecCollection
+ #'collection:'
+ #(
+ #(#ActionButtonSpec
+ #'name:' 'alignBottom'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_alignB.xbm'
+ #'defaultable:' true
+ #'model:' #alignSelectionBottom
+ #'isTriggerOnDown:' false
+ #'enableChannel:' #canModify
+ #'autoRepeat:' false
+ #'extent:' #(#Point 24 24)
+ )
+ #(#ActionButtonSpec
+ #'name:' 'alignTop'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_alignT.xbm'
+ #'defaultable:' true
+ #'model:' #alignSelectionTop
+ #'isTriggerOnDown:' false
+ #'enableChannel:' #canModify
+ #'autoRepeat:' false
+ #'extent:' #(#Point 24 24)
+ )
+ #(#ActionButtonSpec
+ #'name:' 'alignVertical'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_alignTB.xbm'
+ #'defaultable:' true
+ #'model:' #alignSelectionTopAndBottom
+ #'isTriggerOnDown:' false
+ #'enableChannel:' #canModify
+ #'autoRepeat:' false
+ #'extent:' #(#Point 24 24)
+ )
+ )
+ )
+ #'level:' 0
+ #'horizontalLayout:' #center
+ #'verticalLayout:' #center
+ #'horizontalSpace:' 3
+ #'verticalSpace:' 3
+ #'extent:' #(#Point 84 30)
+ )
+ #(#HorizontalPanelViewSpec
+ #'name:' 'hrzPanelViewCenter'
+ #'component:'
+ #(#SpecCollection
+ #'collection:'
+ #(
+ #(#ActionButtonSpec
+ #'name:' 'centerHorizontal'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_alignCH.xbm'
+ #'defaultable:' true
+ #'model:' #alignSelectionCenterHor
+ #'isTriggerOnDown:' false
+ #'enableChannel:' #canModify
+ #'autoRepeat:' false
+ #'extent:' #(#Point 25 24)
+ )
+ #(#ActionButtonSpec
+ #'name:' 'centerVertical'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_alignCV.xbm'
+ #'defaultable:' true
+ #'model:' #alignSelectionCenterVer
+ #'isTriggerOnDown:' false
+ #'enableChannel:' #canModify
+ #'autoRepeat:' false
+ #'extent:' #(#Point 25 24)
+ )
+ )
+ )
+ #'level:' 0
+ #'horizontalLayout:' #center
+ #'verticalLayout:' #center
+ #'horizontalSpace:' 3
+ #'verticalSpace:' 3
+ #'extent:' #(#Point 59 30)
+ )
+ #(#HorizontalPanelViewSpec
+ #'name:' 'hrzPanelViewMove'
+ #'component:'
+ #(#SpecCollection
+ #'collection:'
+ #(
+ #(#ActionButtonSpec
+ #'name:' 'moveLeft'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_moveLeft.xbm'
+ #'defaultable:' true
+ #'model:' #moveSelectionLeft
+ #'isTriggerOnDown:' true
+ #'enableChannel:' #canModify
+ #'autoRepeat:' true
+ #'extent:' #(#Point 26 24)
+ )
+ #(#ActionButtonSpec
+ #'name:' 'moveRight'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_moveRight.xbm'
+ #'defaultable:' true
+ #'model:' #moveSelectionRight
+ #'isTriggerOnDown:' true
+ #'enableChannel:' #canModify
+ #'autoRepeat:' true
+ #'extent:' #(#Point 26 24)
+ )
+ #(#ActionButtonSpec
+ #'name:' 'moveUp'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_moveUp.xbm'
+ #'defaultable:' true
+ #'model:' #moveSelectionUp
+ #'isTriggerOnDown:' true
+ #'enableChannel:' #canModify
+ #'autoRepeat:' true
+ #'extent:' #(#Point 26 24)
+ )
+ #(#ActionButtonSpec
+ #'name:' 'moveDown'
+ #'label:' ''
+ #'translateLabel:' true
+ #'labelChannel:' #'LABELb_moveDown.xbm'
+ #'defaultable:' true
+ #'model:' #moveSelectionDown
+ #'isTriggerOnDown:' true
+ #'enableChannel:' #canModify
+ #'autoRepeat:' true
+ #'extent:' #(#Point 26 24)
+ )
+ )
+ )
+ #'level:' 0
+ #'horizontalLayout:' #center
+ #'verticalLayout:' #center
+ #'horizontalSpace:' 3
+ #'verticalSpace:' 3
+ #'extent:' #(#Point 119 30)
+ )
+ )
+ )
+ #'level:' 1
+ #'horizontalLayout:' #fitSpace
+ #'verticalLayout:' #fitSpace
+ #'horizontalSpace:' 4
+ #'verticalSpace:' 4
+ )
+ #(#NoteBookViewSpec
+ #'name:' 'propertyView'
+ #'layout:' #(#LayoutFrame 0 0.35 40 0.0 0 1.0 -30 1.0)
+ #'model:' #tabModel
+ #'menu:' #tabList
+ #'tabWidget:' #Window
+ #'direction:' #top
+ #'useIndex:' false
+ #'fitLastRow:' true
+ #'moveSelectedRow:' true
+ #'enableChannel:' #canModify
+ #'level:' 0
+ #'canvas:' #noteBookView
+ )
+ #(#HorizontalPanelViewSpec
+ #'name:' 'hrzPanelViewOk'
+ #'layout:' #(#LayoutFrame 0 0.35 -30 1.0 0 1.0 0 1.0)
+ #'component:'
+ #(#SpecCollection
+ #'collection:'
+ #(
+ #(#ActionButtonSpec
+ #'name:' 'cancelButton'
+ #'label:' 'cancel'
+ #'model:' #cancel
+ #'isTriggerOnDown:' false
+ #'enableChannel:' #modifiedChannel
+ #'autoRepeat:' false
+ #'extent:' #(#Point 145 24)
+ )
+ #(#ActionButtonSpec
+ #'name:' 'acceptButton'
+ #'label:' 'ok'
+ #'model:' #accept
+ #'isTriggerOnDown:' false
+ #'enableChannel:' #modifiedChannel
+ #'autoRepeat:' false
+ #'extent:' #(#Point 145 24)
+ )
+ )
+ )
+ #'level:' 0
+ #'horizontalLayout:' #fitSpace
+ #'verticalLayout:' #fitSpace
+ #'horizontalSpace:' 3
+ #'verticalSpace:' 3
+ )
+ )
+ )
+ )
+ #(#MenuPanelSpec
+ #'name:' 'menuBar1'
+ #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 29 0)
+ #'menu:' #pullDownMenu
+ )
+ )
+ )
+ )
! !
-!UIPainter methodsFor:'BuilderView interface'!
+!UIPainter methodsFor:'actions'!
-update:what
+accept
+ "automatically generated by UIPainter ..."
+ |layout|
- elementMenu deselect.
- treeView builderViewChanged:what.
- propertyView builderViewChanged:what.
+ currentView notNil ifTrue:[
+ tabSelection = 'Dimension' ifTrue:[
+ (layout := layoutTool layout) notNil ifTrue:[
+ layoutTool layoutType == #Extent ifTrue:[
+ self painter setExtent:layout
+ ] ifFalse:[
+ self painter setDimension:layout
+ ]
+ ]
+ ] ifFalse:[
+ self painter updateFromSpec:(specView specEdited).
+ ].
+ self cancel
+ ]
+
+!
+
+cancel
+ "cancel all changes and read back attributes from current view
+ "
+ specView specEdited:(self painter specFor:currentView).
+ layoutTool forView:currentView.
+ self modifiedChannel value:false.
! !
!UIPainter methodsFor:'aspects'!
-aspectFor:aKey
- ^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ]
+canModify
+ "automatically generated by UIPainter ..."
+
+ |holder|
+
+ (holder := builder bindingAt:#canModify) isNil ifTrue:[
+ holder := AspectAdaptor new subject:(self painter); forAspect:#canModify.
+ builder aspectAt:#canModify put:holder.
+ ].
+ ^ holder
+
+
+
+!
+
+doubleClick
+ objectList selectGroup
+!
+
+modifiedChannel
+
+ |holder|
+
+ (holder := builder bindingAt:#modifiedChannel) isNil ifTrue:[
+ builder aspectAt:#modifiedChannel put:(holder := false asValue).
+ ].
+ ^ holder
+!
+
+noteBookView
+ "automatically generated by UIPainter ..."
+
+ |noteBook channel|
+
+ (noteBook := builder bindingAt:#noteBookView) isNil ifTrue:[
+ noteBook := View origin:0.0 @0.0 corner:1.0@1.0.
+ layoutTool := UIPropertyView for:#Dimension in:noteBook.
+ specView := UIPropertyView for:#Specification in:noteBook.
+ emptyView := View origin:0.0 @0.0 corner:1.0@1.0 in:noteBook.
+ channel := self modifiedChannel.
+ layoutTool modifiedHolder:channel.
+ specView modifiedHolder:channel.
+ specView viewBackground:(layoutTool viewBackground).
+ emptyView viewBackground:(layoutTool viewBackground).
+ builder aspectAt:#noteBookView put:noteBook.
+ ].
+ ^ noteBook
+!
+
+objectList
+ ^ objectList
+!
+
+objectListMenu
+ "returns a block which returns the menu
+ "
+ ^ [self painter menu]
+
+
+
+!
+
+pullDownMenu
+ |menu painter|
+
+ menu := Menu new.
+ menu fromLiteralArrayEncoding:(self class menuSpec).
+ menu receiver:self.
+ ^ menu
+!
+
+tabList
+ "automatically generated by UIPainter ..."
+
+ |holder|
+
+ (holder := builder bindingAt:#tabList) isNil ifTrue:[
+ builder aspectAt:#tabList put:(holder := ValueHolder new).
+ ].
+ ^ holder
+!
+
+tabModel
+ "automatically generated by UIPainter ..."
+
+ |holder|
+
+ (holder := builder bindingAt:#tabModel) isNil ifTrue:[
+ lastSlice := 'Basics'.
+ holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
+ builder aspectAt:#tabModel put:holder.
+ ].
+ ^ holder
! !
-!UIPainter methodsFor:'filein & fileout'!
+!UIPainter methodsFor:'binding access'!
+
+aspectFor:aKey
+ "check wether aspect is assigned to a label icon
+ "
+ (aKey startsWith:'LABEL') ifFalse:[
+ ^ aspects at:aKey ifAbsent:[ super aspectFor:aKey ]
+ ].
+ ^ Image fromFile:(aKey copyFrom:(('LABEL' size) + 1))
+! !
+
+!UIPainter methodsFor:'change & update'!
+
+update:something with:aParameter from:someObject
+
+ (someObject == objectList and:[something ~~ #list]) ifTrue:[
+ something ~~ #layout ifTrue:[
+ self objectListChanged
+ ] ifFalse:[
+ (self modifiedChannel value) ifFalse:[
+ layoutTool forView:currentView
+ ]
+ ]
+ ]
+! !
+
+!UIPainter methodsFor:'event handling'!
+
+doesNotUnderstand:aMessage
+ |painter|
+
+ painter := self painter.
+
+ (painter respondsTo:(aMessage selector)) ifTrue:[
+ ^ aMessage sendTo:painter
+ ].
+ self error
+
+!
+
+objectListChanged
+ "something changed in the painter view
+ "
+ |setSel slices list spec props|
+
+ props := objectList selectedProperty.
+ tabSelection := nil.
+
+ props isNil ifFalse:[
+ currentView := props view.
+ layoutTool forView:currentView.
+
+ spec := props spec copy.
+ slices := spec class slices.
+ list := slices collect:[:slice| slice first asString ].
+ list add:'Dimension'.
+ (self tabList) value:list.
+
+ (list findFirst:[:aName| aName = lastSlice]) ~~ 0 ifTrue:[
+ setSel := lastSlice
+ ]
+ ].
+
+ specView specEdited:spec.
+ self tabModel value:setSel.
+! !
+
+!UIPainter methodsFor:'file access'!
openFile:aFileName
|aStream |
@@ -223,11 +927,12 @@
aStream := FileStream readonlyFileNamed:aFileName.
aStream notNil ifTrue:[
- workView fileInContentsFrom:aStream.
+ self painter fileInContentsFrom:aStream.
aStream close.
fileName := aFileName
]
+
!
saveAs:aFileName
@@ -236,51 +941,94 @@
aStream := FileStream newFileNamed:aFileName.
aStream notNil ifTrue:[
- workView storeContentsOn:aStream.
+ self painter storeContentsOn:aStream.
aStream close.
fileName := aFileName
].
! !
-!UIPainter methodsFor:'help'!
+!UIPainter methodsFor:'private'!
+
+painter
+ ^ objectList painter
+!
-helpTextFor:aComponent
- |sel|
+workView
+ ^ self painter
+! !
+
+!UIPainter methodsFor:'selection'!
+
+tabSelection
+ ^ tabSelection
+!
+
+tabSelection:something
+ |specEdited slices spec idx|
- (aComponent isKindOf:Button) ifTrue:[
- (sel := aComponent changeMessage) notNil ifTrue:[
- "/ take the buttons change symbol as resource-key
- ^ resources string:(sel asString)
- ]
+ (tabSelection := something) notNil ifTrue:[
+ (specEdited := specView specEdited) notNil ifTrue:[
+ slices := specEdited class slices.
+ lastSlice := tabSelection.
+
+ idx:= slices findFirst:[:aSlice| aSlice first = tabSelection ].
+ idx == 0 ifTrue:[
+ layoutTool forView:currentView.
+ ^ layoutTool raise.
+ ].
+ spec := specEdited class perform:((slices at:idx) last).
+ ]
].
- ^ nil
-
- "Modified: 31.8.1995 / 20:49:58 / claus"
+ specEdited isNil ifTrue:[
+ emptyView raise
+ ] ifFalse:[
+ specView raise.
+ specView buildFromSpec:spec
+ ]
! !
-!UIPainter methodsFor:'initialization'!
+!UIPainter methodsFor:'startup / release'!
+
+closeRequest
+ "close all windows open by builder
+ "
+ objectList removeDependent:self.
+ objectList painter release.
+ objectList := nil.
-createCanvas
+ selectionPanel notNil ifTrue:[
+ selectionPanel closeRequest
+ ].
+ super closeRequest.
+
+!
+
+closeRequestFor:aTopView
+ "handle a close request for a specific view
+ "
|topView|
- super initialize.
-
- topView := StandardSystemView new.
- topView label:'unnamed'.
- topView extent:300@300.
- topView application:self.
+ topView := self window.
- workView := UIPainterView in:topView.
- workView layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
-
- ^ workView.
-
- "Builder new createCanvas open"
+ topView == aTopView ifTrue:[
+ super closeRequestFor:aTopView
+ ] ifFalse:[
+ aTopView == selectionPanel window ifTrue:[
+ aTopView application:nil.
+ aTopView terminate.
+ selectionPanel := nil.
+ ] ifFalse:[
+ topView raise.
+ topView device beep
+ ]
+ ].
!
-initChannels
- |cls|
+openInterface
+ "open interfaces
+ "
+ |painterView painter cls topView|
aspects := IdentityDictionary new.
@@ -303,393 +1051,68 @@
(specSelector notNil ifTrue:[specSelector]
ifFalse:[#windowSpec]) asValue
).
-!
-initPullDownMenu:aMenu
- aMenu labels:(resources array:#(
- 'file'
- 'font'
- 'type'
- 'align'
- 'dimension'
- 'special'
- 'misc'
- 'code'
- 'test'
- )).
-
- aMenu selectors:#(#file
- #font
- #type
- #align
- #dimension
- #special
- #misc
- #code
- #test
- ).
+ painterView := StandardSystemView new.
+ painterView label:'unnamed'.
+ painterView extent:300@300.
- aMenu at:#file
- putLabels:(resources array:
- #('new'
- 'from class ...'
- 'pick a view '
- '-'
- 'load'
- 'save'
- 'save as ...'
- '-'
- 'install spec'
- 'install aspects'
- '-'
-"/ 'source'
- 'windowSpec'
- 'inspect me'
- 'raise'
- '-'
- 'print'
- '-'
- 'quit'
- ))
- selectors:#(doNew
- doFromClass
- doPickAView
- nil
- doOpen
- doSave
- doSaveAs
- nil
- doInstallSpec
- doInstallAspects
- nil
-"/ doSource
- doWindowSpec
- inspect
- doRaise
- nil
- doPrint
- nil
- doFinish
- )
- receiver:self.
-
- aMenu at:#font putMenu:(workView subMenuFont menuView).
+ painter := UIPainterView in:painterView.
+ painter layout:(0.0 @ 0.0 corner:1.0 @ 1.0) asLayout.
- aMenu at:#type
- putLabels:(resources array:#(
- 'basic widgets'
- 'layout'
- 'text'
- 'interactors'
- 'modal'
- 'other'
- '-'
- 'all'
- ) )
- selectors:#(showBasicWidgets
- showLayoutWidgets
- showTextWidgets
- showInteractorWidgets
- showModalWidgets
- showOtherWidgets
- nil
- showAllWidgets
- )
- receiver:self.
-
- aMenu at:#align putMenu:(workView subMenuAlign menuView).
- aMenu at:#dimension putMenu:(workView subMenuDimension menuView).
+ objectList := painter listHolder.
+ objectList addDependent:self.
- aMenu at:#special
- putLabels:(resources array:#(
- 'group radioButtons'
- 'group enterFields'
- ) )
- selectors:#(
- groupRadioButtons
- groupEnterFields
- )
- receiver:workView.
-
- aMenu at:#code
- putLabels:(resources array:#(
- 'class & method'
- ) )
- selectors:#(
- defineClassAndSelector
- )
- receiver:self.
+ super openInterface.
- aMenu at:#misc putMenu:(self menuMisc).
-
- aMenu at:#test
- putLabels:(resources array:#(
- '\c test mode'
- ) )
- selectors:#(doToggleTest
- )
- receiver:self.
-
- (aMenu menuAt:#test) checkToggleAt:#doToggleTest put:(workView testMode).
-!
-
-openInterface
- |inset panel menu|
-
- self initChannels.
- workView := self createCanvas.
-
- topView := StandardSystemView new.
+ topView := self window.
topView label:'Interface Builder'.
topView icon:(Image fromFile:'bitmaps/Builder.xbm' resolution:100).
- topView extent:(600 @ 400).
- menu := PullDownMenu in:topView.
- panel := ButtonPanel in:topView.
- inset := menu preferredExtent y + panel preferredExtent y.
-
- panel origin:0.0@(menu preferredExtent y) corner:1.0@inset .
- panel receiver:workView.
-
- elementMenu := HVScrollableView for:SelectionInListView miniScrollerH:true in:topView.
- elementMenu origin:0.0@0.0 corner:0.3 @ 1.0.
- elementMenu topInset:inset .
- elementMenu := elementMenu scrolledView.
+ painterView openInGroup:(topView windowGroup).
- elementMenu action:[:selection |
- workView testMode ifTrue:[
- elementMenu deselect
- ] ifFalse:[
- selection notNil ifTrue:[
- workView createWidgetWithClass:
- (Smalltalk at:(elementMenu selectionValue asSymbol))
- ]
- ]
- ].
-
- treeView := HVScrollableView for:UIPainterTreeView miniScrollerH:true in:topView.
- treeView origin:0.3 @ 0.0 corner:0.6@1.0.
- treeView topInset:inset .
- treeView := treeView scrolledView.
- treeView builderView:workView.
-
- propertyView := View origin:(0.6 @ 0.0) corner:1.0@1.0 in:topView.
- propertyView topInset:inset .
- propertyView := UIPropertyView in:propertyView builder:workView.
-
- workView addDependent:self.
- self initPullDownMenu:menu.
- topView application:self.
- builder window:topView.
- topView beMaster.
- workView topView beSlave.
- topView open.
- workView topView openInGroup:(topView windowGroup).
-
+ topView beMaster.
+ painterView beSlave.
+ painterView application:self.
+ painterView open.
+ selectionPanel := UISelectionPanel open.
+ selectionPanel window beSlave.
+ selectionPanel window application: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"
+ via some selector
+ "
+ |painter|
- |specArray|
+ self openInterface.
+ painter := self painter.
specClass := aClass name.
specSuperclass := aClass superclass name.
specSelector := aSelector.
- self openInterface.
- workView className:aClass name.
- workView methodName:aSelector.
- workView setupFromSpec:(aClass perform:aSelector).
-!
-
-openOnSpec:aSpecOrSpecArray
- "open up an interface builder, given some specArray"
-
- |newBuilder|
-
- newBuilder := self new.
-! !
-
-!UIPainter methodsFor:'menus'!
-
-menuMisc
-
- |menuView menuGrid menuUndo|
-
- menuView := MenuView labels:
- (resources array:#(
- 'grid'
- 'undo'
- )
- )
- selectors:#(
- #grid
- #undo
- )
- receiver:self.
-
+ painter className:aClass name.
+ painter methodName:aSelector.
+ painter setupFromSpec:(aClass perform:aSelector).
- menuGrid := PopUpMenu labels:(
- resources array:#(
- '\c show'
- '\c align'
- )
- )
- selectors:#(
- #gridShown:
- #gridAlign:
- )
- receiver:workView.
-
- menuGrid checkToggleAt:#gridShown: put:(workView gridShown).
- menuGrid checkToggleAt:#gridAlign: put:(workView gridAlign).
- menuView subMenuAt:#grid put:menuGrid.
-
- menuUndo := PopUpMenu labels:(
- resources array:#(
- 'last'
- 'menu'
- '-'
- 'delete'
- )
- )
- selectors:#(
- #undoLast
- #openUndoMenu
- nil
- #removeUndoHistory
- )
- receiver:workView.
-
- menuView subMenuAt:#undo put:menuUndo.
- ^ menuView
! !
-!UIPainter methodsFor:'setup choices'!
-
-showAllWidgets
- "create list of basic widgets"
-
- self showWidgetsWhere:[:class | true]
-!
-
-showBasicWidgets
- "create list of basic widgets"
-
- self showWidgetsInCategory:'Views-Basic'
- butNot:[:class | class isKindOf:ModalBox class]
-!
-
-showInteractorWidgets
- "create list of interactor widgets"
-
- self showWidgetsInCategory:'Views-Interactors'
- butNot:[:class | class isKindOf:ModalBox class]
-!
-
-showLayoutWidgets
- "create list of basic widgets"
-
- self showWidgetsInCategory:'Views-Layout'
- butNot:[:class | class isKindOf:ModalBox class]
-!
-
-showModalWidgets
- "create list of modal widgets"
-
- self showWidgetsWhere:[:class | class isKindOf:ModalBox class]
-!
-
-showOtherWidgets
- "create list of other widgets"
-
- |check cat|
-
- check := [:class |
- (#('Views-Basic'
- 'Views-Interactors'
- 'Views-Layout'
- 'Views-Text') includes:class category) not].
- self showWidgetsWhere:check
- butNot:[:class | class isKindOf:ModalBox class]
-!
-
-showTextWidgets
- "create list of basic widgets"
-
- self showWidgetsInCategory:'Views-Text'
- butNot:[:class | class isKindOf:ModalBox class]
-!
-
-showWidgetsInCategory:aCategory
- "create list of basic widgets"
-
- self showWidgetsWhere:[:class | class category = aCategory]
-!
-
-showWidgetsInCategory:aCategory butNot:excludeBlock
- "create list of basic widgets"
-
- self showWidgetsWhere:[:class | class category = aCategory]
- butNot:excludeBlock
-!
-
-showWidgetsWhere:aBlock
- "create list of widgets where aBlock avaluates to true"
-
- self showWidgetsWhere:aBlock butNot:[:class | false]
-!
-
-showWidgetsWhere:aBlock butNot:excludeBlock
- "create list of widgets where aBlock evaluates to true and excludeBlock
- evaluates to false"
-
- |list|
-
- list := OrderedCollection new:0.
- SimpleView allSubclassesDo:[:aSubclass |
- (aBlock value:aSubclass) ifTrue:[
- (excludeBlock value:aSubclass) ifFalse:[
- list add:(aSubclass name)
- ]
- ]
- ].
- (aBlock value:View) ifTrue:[
- (excludeBlock value:View) ifFalse:[
- list add:'View'
- ]
- ].
- (list size == 0) ifFalse:[
- list sort
- ].
- elementMenu list:list
-! !
-
-!UIPainter methodsFor:'user interaction'!
-
-closeRequest
- workView notNil ifTrue:[workView release. workView := nil].
- super closeRequest
-!
-
-closeRequestFor:aTopView
- aTopView == topView ifTrue:[
- super closeRequestFor:aTopView
- ] ifFalse:[
- topView raise.
- topView device beep
- ]
-! !
-
-!UIPainter methodsFor:'user interaction - dialogs'!
+!UIPainter methodsFor:'user interaction - dialog'!
checkClassAndSelector
"check for class & superclass"
@@ -740,6 +1163,8 @@
]
].
^ true
+
+
!
defineClassAndSelector
@@ -749,36 +1174,38 @@
[
again := false.
+
(self openDialogInterface:#nameAndSelectorSpec) ifTrue:[
specClass := (self aspectFor:#classNameChannel) value.
specSelector := (self aspectFor:#methodNameChannel) value.
specSuperclass := (self aspectFor:#superclassNameChannel) value.
- again := self checkClassAndSelector not.
- again ifFalse:[
- workView className:specClass superclassName:specSuperclass selector:specSelector.
- ].
+ (again := self checkClassAndSelector not) ifFalse:[
+ self painter className:specClass
+ superclassName:specSuperclass
+ selector:specSelector.
+ ]
]
+
] doWhile:[again]
+
! !
-!UIPainter methodsFor:'user interaction - menu'!
-
-doFinish
- self closeRequest
-!
+!UIPainter methodsFor:'user interaction - pullDown'!
doFromClass
- |className methodName cls sel accepted failed spec s|
+ |className methodName cls sel accepted failed spec s painter|
- className := '' asValue.
+ className := '' asValue.
methodName := '' asValue.
- (s := workView className) notNil ifTrue:[
+ painter := self painter.
+
+ (s := painter className) notNil ifTrue:[
className value:s
].
- (s := workView methodName) notNil ifTrue:[
+ (s := painter methodName) notNil ifTrue:[
methodName value:s
].
@@ -813,16 +1240,15 @@
self warn:'not a windowSpec method'
].
"/ ok, got it
- workView className:className value.
- workView methodName:methodName value.
- workView setupFromSpec:spec.
- ^ self
+ painter className:className value.
+ painter methodName:methodName value.
+ painter setupFromSpec:spec.
+ ^ self
]
]
]
] doWhile:[accepted and:[failed]].
- "Modified: 5.9.1995 / 18:47:57 / claus"
!
doInstallAspects
@@ -836,12 +1262,13 @@
^ self
].
- workView className:specClass superclassName:specSuperclass selector:specSelector.
+ self painter className:specClass
+ superclassName:specSuperclass
+ selector:specSelector.
- code := workView generateAspectMethods.
+ code := self painter generateAspectMethods.
(ReadStream on:code) fileIn.
- "Modified: 4.9.1995 / 17:06:10 / claus"
!
doInstallSpec
@@ -855,16 +1282,13 @@
^ self
].
- workView className:specClass superclassName:specSuperclass selector:specSelector.
+ self painter className:specClass
+ superclassName:specSuperclass
+ selector:specSelector.
- code := workView generateCode.
+ code := self painter generateCode.
(ReadStream on:code) fileIn.
- "Modified: 4.9.1995 / 17:06:10 / claus"
-!
-
-doNew
- workView removeAll.
!
doOpen
@@ -876,30 +1300,31 @@
box pattern:'*.*'.
box action:[:aFile| self openFile:aFile ].
box open
+
!
doPickAView
- |view className methodName cls sel accepted spec s|
+ |painter view className methodName cls sel accepted spec s|
- view := Display viewFromUser.
- view isNil ifTrue:[^ self].
- spec := UISpecification fromView:view topView.
+ (view := Display viewFromUser) notNil ifTrue:[
+ painter := self painter.
- "/ ok, got it
- workView setupFromSpec:spec.
- workView className:view class name.
- workView methodName:#newSpec.
- ^ self
+ spec := UISpecification fromView:view topView.
- "Modified: 5.9.1995 / 23:25:53 / claus"
-!
-
-doPrint
- ^ self
+ "/ ok, got it
+ painter setupFromSpec:spec.
+ painter className:view class name.
+ painter methodName:#newSpec.
+ ]
!
doRaise
- workView topView raise
+ self painter topView raise.
+
+ selectionPanel notNil ifTrue:[
+ selectionPanel window raise
+ ]
+
!
doSave
@@ -908,6 +1333,7 @@
] ifFalse:[
self doSaveAs
]
+
!
doSaveAs
@@ -919,162 +1345,18 @@
box pattern:'*.*'.
box action:[:aFile| self saveAs:aFile ].
box open
-!
-doSource
- |code v|
-
- code := workView generateCode.
- v := CodeView open.
- v contents:code.
- v label:(workView applicationName).
- ^ self
-
- "Modified: 5.9.1995 / 21:02:05 / claus"
-!
-
-doToggleTest
- workView testMode:(workView testMode not)
!
doWindowSpec
|code code2 v|
- code := workView generateWindowSpecMethodSource.
-"/ code2 := workView generateAspectMethods.
- code2 notNil ifTrue:[
- code := code , code2.
- ].
+ code := self painter generateWindowSpecMethodSource.
v := CodeView open.
v contents:code.
v label:'windowSpec'.
- ^ self
- "Modified: 5.9.1995 / 21:04:14 / claus"
-! !
-
-!UIPainter::ButtonPanel class methodsFor:'documentation'!
-
-version
- ^ '$Header$'
-! !
-
-!UIPainter::ButtonPanel methodsFor:'accessing'!
-
-receiver
- ^ receiver
-!
-
-receiver:aReceiver
- receiver := aReceiver
-! !
-
-!UIPainter::ButtonPanel methodsFor:'initialization'!
-
-initialize
- "initialize and setup buttons
- "
- super initialize.
-
- self level:-1.
- self borderWidth:0.
- self horizontalLayout:#leftSpace.
- argumentToSelector := 1.
-
- self specification do:[:anArray|
- |selector image button seperator|
-
- selector := anArray at:1.
-
- selector notNil ifTrue:[
- image := Image fromFile:( anArray at:2 ).
- button := Button label:image in:self.
-
- selector last == $: ifFalse:[
- button action:[
- receiver notNil ifTrue:[
- receiver perform:selector
- ]
- ]
- ] ifTrue:[
- button pressAction:[
- receiver notNil ifTrue:[
- receiver perform:selector with:argumentToSelector
- ].
- receiver enableUndoHistory:false.
- ].
- button releaseAction:[ receiver enableUndoHistory:true ].
- button autoRepeat:true.
- button menuHolder:self; menuMessage:#editMenu; menuPerformer:self.
- ]
- ] ifFalse:[
- seperator := View in:self.
- seperator extent:20@1.
- seperator borderWidth:0.
- ]
- ].
-
-!
-
-specification
- "return a spec for the buttons in the panel;
- entries consists of selector and bitmap-filename.
- nil selectors are taken as separators (see setupButtonPanel)"
-
- ^ #(
- #( alignSelectionLeft 'b_alignL.xbm' )
- #( alignSelectionRight 'b_alignR.xbm' )
- #( alignSelectionLeftAndRight 'b_alignLR.xbm' )
- #( nil )
- #( alignSelectionTop 'b_alignT.xbm' )
- #( alignSelectionBottom 'b_alignB.xbm' )
- #( alignSelectionTopAndBottom 'b_alignTB.xbm' )
- #( nil )
- #( alignSelectionCenterHor 'b_alignCH.xbm' )
- #( alignSelectionCenterVer 'b_alignCV.xbm' )
- #( nil )
- #( moveSelectionLeft: 'b_moveLeft.xbm' )
- #( moveSelectionRight: 'b_moveRight.xbm' )
- #( moveSelectionUp: 'b_moveUp.xbm' )
- #( moveSelectionDown: 'b_moveDown.xbm' )
- )
-
-
-! !
-
-!UIPainter::ButtonPanel methodsFor:'menu'!
-
-editMenu
- "edit menu used by buttons using an argument for the receiver; the argumentToSelector
- "
- |menu|
-
- menu := PopUpMenu labels:#( '1' '2' '4' '10' '20' '..' )
- args:#( 1 2 4 10 20 nil ).
-
- menu action:[:anArg||no|
- (no := anArg) isNil ifTrue:[
- no := EnterBox request:'number'.
- no := SmallInteger readFrom:no onError:0.
- ].
- no ~~ 0 ifTrue:[
- |index view|
-
- view := (WindowGroup lastEventQuerySignal raise) view.
- view := view menuPerformer.
- argumentToSelector := no.
- view pressAction value.
- argumentToSelector := 1.
- ]
- ].
- ^ menu
-! !
-
-!UIPainter::ButtonPanel methodsFor:'queries'!
-
-specClass
- ^ HorizontalPanelViewSpec
! !
!UIPainter class methodsFor:'documentation'!