--- a/UIPainter.st Fri Jun 20 19:29:36 1997 +0200
+++ b/UIPainter.st Fri Jun 20 19:33:06 1997 +0200
@@ -12,9 +12,8 @@
ApplicationModel subclass:#UIPainter
- instanceVariableNames:'activeHelpTool layoutTool objectList selectionPanel tabSelection
- lastSlice specView fileName specClass specSelector specSuperclass
- aspects'
+ instanceVariableNames:'activeHelpTool layoutTool specTool objectList selectionPanel
+ tabSelection specClass specSelector specSuperclass aspects'
classVariableNames:''
poolDictionaries:''
category:'Interface-UIPainter'
@@ -87,6 +86,26 @@
! !
+!UIPainter class methodsFor:'help specs'!
+
+helpSpec
+ "return a dictionary filled with helpKey -> helptext associations.
+ These are used by the activeHelp tool."
+
+ |dict|
+
+ dict := super helpSpec.
+ dict at:#maxChars put:'set the maximum number of
+characters that are allowed
+in the editfield.'.
+ dict at:#id put:'enter the name of the field
+here. This ID can be used
+by the applicationModel
+to access components,
+using #componentAt:<key>'.
+ ^ dict
+! !
+
!UIPainter class methodsFor:'icons'!
iconAlignB
@@ -598,7 +617,9 @@
accept
|layout|
- tabSelection = layoutTool label ifTrue:[
+ objectList removeDependent:self.
+
+ self isLayoutToolSelected ifTrue:[
(layout := layoutTool layout) notNil ifTrue:[
layoutTool layoutType == #Extent ifTrue:[
self painter setExtent:layout
@@ -607,22 +628,24 @@
]
]
] ifFalse:[
- tabSelection = 'Help' ifTrue:[
+ self isHelpToolSelected ifTrue:[
activeHelpTool accept
].
- self painter updateFromSpec:(specView specEdited)
+ self painter updateFromSpec:(specTool specEdited).
].
- self cancel
+ self modifiedChannel value:false.
+ objectList addDependent:self.
- "Modified: 17.6.1997 / 12:50:59 / cg"
!
cancel
"cancel all changes and read back attributes from current view
"
- specView specEdited:(self painter specForSelection).
- layoutTool update.
- self modifiedChannel value:false.
+ self modifiedChannel value ifTrue:[
+ specTool specEdited:(self painter specForSelection).
+ layoutTool layoutView:(layoutTool layoutView).
+ self modifiedChannel value:false.
+ ]
!
doubleClick
@@ -643,10 +666,10 @@
] ifTrue:[
cls := specClass
].
-
- (cls respondsTo:#helpSpec) ifTrue:[
- activeHelpTool dictionary:(cls helpSpec).
- ]
+ (cls isSubclassOf:UISpecification) ifTrue:[
+ cls := self class
+ ].
+ activeHelpTool dictionary:(cls helpSpec).
].
].
^ activeHelpTool
@@ -722,17 +745,27 @@
noteBookView
"automatically generated by UIPainter ..."
- |noteBook channel|
+ |noteBook channel n1 n2|
(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.
+ noteBook := View new.
+ layoutTool := UILayoutTool new.
+ specTool := UISpecificationTool new.
channel := self modifiedChannel.
+
layoutTool masterApplication:self.
- specView masterApplication:self.
+ specTool masterApplication:self.
+
+ n1 := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
+ n2 := SubCanvas origin:0.0@0.0 corner:1.0@1.0 in:noteBook.
+
+ n1 client:layoutTool.
+ specTool builder:(n2 client:specTool).
+
+ layoutTool masterApplication:self.
+ specTool masterApplication:self.
layoutTool modifiedHolder:channel.
- specView modifiedHolder:channel.
+ specTool modifiedHolder:channel.
builder aspectAt:#noteBookView put:noteBook.
].
^ noteBook
@@ -770,7 +803,6 @@
|holder|
(holder := builder bindingAt:#tabModel) isNil ifTrue:[
- lastSlice := 'Basics'.
holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
builder aspectAt:#tabModel put:holder.
].
@@ -796,10 +828,12 @@
something ~~ #layout ifTrue:[
self objectListChanged
] ifFalse:[
- (self modifiedChannel value) ifFalse:[
- layoutTool update
- ]
- ]
+ self modifiedChannel value ifTrue:[
+ ^ self
+ ].
+ layoutTool update
+ ].
+ self modifiedChannel value:false
]
! !
@@ -820,61 +854,46 @@
objectListChanged
"something changed in the painter view
"
- |setSel view slices list spec props size same|
+ |oldSelection view slices list spec props size|
props := objectList selectedProperty.
+ oldSelection := tabSelection.
tabSelection := nil.
props isNil ifFalse:[
view := props view.
spec := props spec copy.
- layoutTool forView == view ifFalse:[
+ layoutTool layoutView == view ifFalse:[
slices := spec class slices.
size := slices size + 1.
list := Array new:size.
slices keysAndValuesDo:[:i :s|list at:i put:(s first asString)].
- list at:size put:(layoutTool label).
+ list at:size put:(layoutTool class label).
(self tabList) value:list.
] ifTrue:[
list := self tabList value
].
- (list findFirst:[:aName| aName = lastSlice]) ~~ 0 ifTrue:[
- setSel := lastSlice
+ (list findFirst:[:n| n = oldSelection ]) ~~ 0 ifTrue:[
+ tabSelection := oldSelection
+ ] ifFalse:[
+ tabSelection := list first
]
].
- layoutTool forView:view.
- specView specEdited:spec.
- self tabModel value:setSel.
-! !
-
-!UIPainter methodsFor:'file access'!
-
-openFile:aFileName
- |aStream |
-
- aStream := FileStream readonlyFileNamed:aFileName.
+ layoutTool layoutView:view.
+ specTool specEdited:spec.
- aStream notNil ifTrue:[
- self painter fileInContentsFrom:aStream.
- aStream close.
- fileName := aFileName
- ]
-
-
-!
-
-saveAs:aFileName
- |aStream|
-
- aStream := FileStream newFileNamed:aFileName.
-
- aStream notNil ifTrue:[
- self painter storeContentsOn:aStream.
- aStream close.
- fileName := aFileName
+ tabSelection notNil ifTrue:[
+ self isLayoutToolSelected ifTrue:[
+ (self noteBookView subViews at:1) raise
+ ] ifFalse:[
+ specTool selection:tabSelection.
+ (self noteBookView subViews at:2) raise
+ ]
].
+ (builder componentAt:#noteBook) selection:tabSelection.
+ self modifiedChannel value:false.
! !
!UIPainter methodsFor:'private'!
@@ -883,6 +902,16 @@
^ objectList painter
! !
+!UIPainter methodsFor:'queries'!
+
+isHelpToolSelected
+ ^ tabSelection = 'Help'
+!
+
+isLayoutToolSelected
+ ^ tabSelection = layoutTool class label
+! !
+
!UIPainter methodsFor:'selection'!
tabSelection
@@ -890,29 +919,18 @@
!
tabSelection:something
- |specEdited slices spec idx|
-
- something isNil ifTrue:[^ self].
+ |raiseViewIdx|
- tabSelection := something.
-
- (specEdited := specView specEdited) notNil ifTrue:[
- slices := specEdited class slices.
- lastSlice := tabSelection.
+ something notNil ifTrue:[
+ raiseViewIdx := 1.
+ tabSelection := something.
- idx:= slices findFirst:[:aSlice| aSlice first = tabSelection ].
- idx == 0 ifTrue:[
- layoutTool update.
- ^ layoutTool raise.
+ self isLayoutToolSelected ifFalse:[
+ specTool selection:tabSelection.
+ raiseViewIdx := 2
].
- spec := specEdited class perform:((slices at:idx) last).
- ].
- specView raise.
-
- specEdited isNil ifTrue:[
- specView buildFromSpec:nil
- ] ifFalse:[
- specView buildFromSpec:spec
+ (self noteBookView subViews at:raiseViewIdx) raise.
+ self cancel.
]
! !
@@ -1279,6 +1297,9 @@
^ self information:'no help text defined'
].
dict := activeHelpTool dictionary.
+ (cls isSubclassOf:UISpecification) ifTrue:[
+ cls := self class
+ ].
src := '' writeStream.
src nextPutAll:'helpSpec
@@ -1334,18 +1355,6 @@
"Modified: 17.6.1997 / 12:33:31 / cg"
!
-doOpen
- |box|
-
- box := FileSelectionBox new.
- box title:(resources string:'Which file ?').
- box selectingDirectory:false.
- box pattern:'*.*'.
- box action:[:aFile| self openFile:aFile ].
- box open
-
-!
-
doPickAView
|painter view className methodName cls sel accepted spec s|
@@ -1378,27 +1387,6 @@
!
-doSave
- fileName notNil ifTrue:[
- self saveAs:fileName
- ] ifFalse:[
- self doSaveAs
- ]
-
-!
-
-doSaveAs
- |box|
-
- box := FileSelectionBox new.
- box title:(resources string:'Which file ?').
- box selectingDirectory:false.
- box pattern:'*.*'.
- box action:[:aFile| self saveAs:aFile ].
- box open
-
-!
-
doStartApplication
|cls|