# HG changeset patch # User ca # Date 948805267 -3600 # Node ID 52898ecde37d70d20675775836c7da6927a0d7c4 # Parent 66252dfdd14c0f037fba91428e4ac13f7559b199 tabing: use map/unmap insteat of raise diff -r 66252dfdd14c -r 52898ecde37d UISpecificationTool.st --- a/UISpecificationTool.st Mon Jan 24 17:37:26 2000 +0100 +++ b/UISpecificationTool.st Tue Jan 25 14:01:07 2000 +0100 @@ -15,12 +15,19 @@ ApplicationModel subclass:#UISpecificationTool instanceVariableNames:'modifiedHolder aspects specification selection specChannel - scrolledView windowFrame acceptChannel' + buildInView listOfSpecViews' classVariableNames:'' poolDictionaries:'' category:'Interface-UIPainter' ! +ViewScroller subclass:#BuildInView + instanceVariableNames:'outerFrame' + classVariableNames:'' + poolDictionaries:'' + privateIn:UISpecificationTool +! + !UISpecificationTool class methodsFor:'documentation'! copyright @@ -650,39 +657,41 @@ !UISpecificationTool class methodsFor:'interface specs'! windowSpec - "this window spec was automatically generated by the ST/X UIPainter" + "This resource specification was automatically generated + by the UIPainter of ST/X." - "do not manually edit this - the painter/builder may not be able to - handle the specification if its corrupted." + "Do not manually edit this!! If it is corrupted, + the UIPainter may not be able to read the specification." " UIPainter new openOnClass:UISpecificationTool andSelector:#windowSpec UISpecificationTool new openInterface:#windowSpec + UISpecificationTool open " - "UISpecificationTool open" - ^ - - #(#FullSpec - #'window:' - #(#WindowSpec - #'name:' 'uIPainterView' - #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) - #'label:' 'unnamed canvas' - #'bounds:' #(#Rectangle 0 0 300 300) - ) - #'component:' - #(#SpecCollection - #'collection:' - #( - #(#ViewSpec - #'name:' 'Frame' - #'layout:' #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) - ) - ) - ) + ^ + #(#FullSpec + #name: #windowSpec + #window: + #(#WindowSpec + #label: 'unnamed canvas' + #name: 'unnamed canvas' + #bounds: #(#Rectangle 30 217 330 517) + ) + #component: + #(#SpecCollection + #collection: #( + #(#ArbitraryComponentSpec + #name: 'ArbitraryComponent1' + #layout: #(#LayoutFrame 0 0.0 0 0.0 0 1.0 0 1.0) + #hasBorder: false + #component: #buildInViewTop + ) + ) + + ) ) ! ! @@ -705,52 +714,33 @@ specification:aSpec "sets current edit specification " - self releaseResources. - aSpec isNil ifTrue:[ - specChannel notNil ifTrue:[ specChannel release ]. - aspects notNil ifTrue:[ aspects release ]. - - specChannel := nil. - specification := nil. - aspects := nil. - ] ifFalse:[ - "/ same type of spec - simply change the spec; - "/ no need to setup everything - - specification class == aSpec class ifTrue:[ - specification := aSpec. - ^ specChannel value:specification. - ]. - - specChannel notNil ifTrue:[ specChannel release ]. - aspects notNil ifTrue:[ aspects release ]. + ^ self specificationChanged + ]. + "/ same type of spec - simply change the spec; no need to setup everything - specification := aSpec. - - "/ some tricky specs need the builder - "/ during the addBindings phase. - "/ This is passed down in a special UIBindingsDictionary - "/ (remain backward compatible) - - aspects := UISpecification newBindingsDictionary. - aspects builder:builder. - aspects at:#modifiedChannel put:modifiedHolder. - aspects at:#acceptChannel put:self acceptChannel. + specification class == aSpec class ifTrue:[ + specification := aSpec. + ^ specChannel value:specification. + ]. + self specificationChanged. + specification := aSpec. + + "/ some tricky specs need the builder during the addBindings phase. + "/ This is passed down in a special UIBindingsDictionary + "/ (remain backward compatible) - specChannel := specification asValue. - specification class addBindingsTo:aspects for:specification channel:specChannel. - - "/ arrange for being notified, if any aspect changes - aspects do:[:el| el addDependent:self ]. - ]. + aspects := UISpecification newBindingsDictionary. + aspects builder:builder. + aspects at:#modifiedChannel put:modifiedHolder. + aspects at:#acceptChannel put:self acceptChannel. - selection notNil ifTrue:[ - self clearScrolledView. - selection := nil. - ]. + specChannel := specification asValue. + specification class addBindingsTo:aspects for:specification channel:specChannel. - "Modified: / 16.7.1998 / 19:39:42 / cg" + "/ arrange for being notified, if any aspect changes + aspects do:[:el| el addDependent:self ]. + ! ! !UISpecificationTool methodsFor:'accessing channels'! @@ -759,9 +749,7 @@ "set the value holder set to true in case of modifying attributes " - modifiedHolder notNil ifTrue:[ - modifiedHolder removeDependent:self. - ]. + modifiedHolder removeDependent:self. (modifiedHolder := aValueHolder) notNil ifTrue:[ modifiedHolder addDependent:self. @@ -810,19 +798,35 @@ ! -releaseResources - "release resources - " - |frame appl| +buildInViewTop + ^ buildInView superView + + +! + +specificationChanged - builder notNil ifTrue:[ - frame := self windowFrame. - appl := builder application. - builder application:appl. - builder componentAt:#Frame put:frame. + specChannel notNil ifTrue:[ + specChannel release. + specChannel := nil. + ]. + aspects notNil ifTrue:[ + aspects release. + aspects := nil. ]. + selection := nil. + specification := nil. - "Modified: / 20.6.1998 / 15:45:20 / cg" + listOfSpecViews notNil ifTrue:[ + buildInView scrolledView:nil. + + listOfSpecViews do:[:aView| + aView notNil ifTrue:[ + aView destroy + ] + ]. + listOfSpecViews := nil. + ]. ! specificationFor:aKey @@ -830,16 +834,10 @@ subspecifications or subcanvases. Get the subspecification from the current specification" - |cls| - - cls := specification class. - (cls respondsTo:aKey) ifTrue:[ - ^ cls perform:aKey + specification notNil ifTrue:[ + ^ specification class perform:aKey ifNotUnderstood:nil ]. ^ nil - - "Created: / 4.2.1998 / 23:52:39 / stefan" - "Modified: / 4.2.1998 / 23:58:23 / stefan" ! ! !UISpecificationTool methodsFor:'change & update'! @@ -867,79 +865,90 @@ "Modified: / 16.7.1998 / 19:25:59 / cg" ! ! +!UISpecificationTool methodsFor:'initialization'! + +initialize + |view| + + super initialize. + view := ScrollableView for:BuildInView. + view verticalScrollable:true. + view verticalMini:true. + view autoHideScrollBars:true. + view level:0. + buildInView := view scrolledView. +! ! + !UISpecificationTool methodsFor:'selection'! selection:something "selection changed " - |slices idx spec window| + |slices index spec window| specification notNil ifTrue:[ slices := specification class slices. - idx:= slices findFirst:[:aSlice| aSlice first = something ]. + index := slices findFirst:[:aSlice| aSlice first = something ]. - idx ~~ 0 ifTrue:[ - spec := specification class perform:((slices at:idx) last). + index ~~ 0 ifTrue:[ + spec := specification class perform:((slices at:index) last) ] ]. spec ~= selection ifTrue:[ - self releaseResources. - self clearScrolledView. - - window := self scrolledView scrolledView. - - spec notNil ifTrue:[ - builder buildFromSpec:spec in:window. - - window allViewBackground:(self windowFrame viewBackground). - window extent:1.0@(window preferredExtent y). - window realizeAllSubViews. - self scrolledView sizeChanged:nil. - ] + (selection := spec) notNil ifTrue:[ + listOfSpecViews isNil ifTrue:[ + listOfSpecViews := Array new:(slices size). + ] ifFalse:[ + window := listOfSpecViews at:index + ]. + window isNil ifTrue:[ + builder buildFromSpec:spec in:(window := SimpleView new). + listOfSpecViews at:index put:window. + ]. + ]. + buildInView scrolledView:window. ]. - selection := spec. ! ! -!UISpecificationTool methodsFor:'spec. window'! +!UISpecificationTool::BuildInView methodsFor:'accessing'! -clearScrolledView +scrolledView:aView + "set the view to be scrolled" + |scr| + + scrolledView == aView ifTrue:[^ self]. - scrolledView isNil ifFalse:[ - scrolledView scrolledView destroySubViews. - ] -! + outerFrame isNil ifTrue:[ + self level:0. + outerFrame := SimpleView origin:0.0@0.0 corner:1.0@1.0 in:self. + realized ifTrue:[outerFrame realize]. + ]. -scrolledView - |frame vscroller| + scrolledView notNil ifTrue:[scrolledView unmap]. - scrolledView isNil ifTrue:[ - frame := self windowFrame. - vscroller := ScrollableView for:ViewScroller origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:frame. - vscroller verticalScrollable:true. - vscroller verticalMini:true. - vscroller autoHideScrollBars:true. - scrolledView := vscroller scrolledView. - scrolledView scrolledView:View new. - frame realizeAllSubViews. - frame sizeChanged:nil. + (scrolledView := aView) isNil ifTrue:[ + ^ self + ]. + + scrolledView superView == outerFrame ifFalse:[ + scrolledView borderWidth:0; level:0. - "/ we dont want any 3D effect for the scrolled view. - "/ must change the slaveViews level late, after realization. - "/ (scrolledView has its own idea, changing the level of - "/ the scrolled view. - scrolledView level:0. + outerFrame addSubView:scrolledView. + scrolledView origin:0@0 corner:1.0 @ (scrolledView preferredExtent y). + scrolledView := scrolledView. + scrolledView allViewBackground:(self viewBackground). ]. - ^ scrolledView - "Modified: / 21.5.1998 / 00:59:05 / cg" -! + realized ifTrue:[ + scrolledView realize. + self sizeChanged:nil. + ]. -windowFrame - windowFrame isNil ifTrue:[ - windowFrame := builder componentAt:#Frame - ]. - ^ windowFrame. + + + + ! ! !UISpecificationTool class methodsFor:'documentation'!