checkin from browser
authorca
Mon, 03 Mar 1997 11:04:20 +0100
changeset 74 dfa8644e0287
parent 73 2087134eea96
child 75 c9779da5ce4e
checkin from browser
UIPropertyView.st
--- a/UIPropertyView.st	Sun Mar 02 13:47:11 1997 +0100
+++ b/UIPropertyView.st	Mon Mar 03 11:04:20 1997 +0100
@@ -1,7 +1,7 @@
 ApplicationModel subclass:#UIPropertyView
-	instanceVariableNames:'builderView modified propertyFrame propertyList propertySpecs
-		currentView currentSpec propertyAspects layoutAspects layoutType
-		specBeingEdited userSelectedProperty currentSpecChannel'
+	instanceVariableNames:'builderView modified currentView shownSpec propertyAspects
+		layoutAspects layoutType specBeingEdited specChannel
+		propertySelection'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Interface-UIPainter'
@@ -1210,47 +1210,35 @@
     propertyAspects := nil.
 
     currentView isNil ifTrue:[
-        propertyList selectionIndex:nil.
-        currentSpecChannel := nil.
-        propertyList list:#().
-        propertySpecs := nil.
-
-        "/ must setup for a WindowSpec (to allow entry of min- maxSize etc).
-"/      propertyList list:#('Basics' 'Detail').
-      ^ self modified:false.
+        specChannel := nil.
+      ^ self propertyList:nil
     ].
 
     prevSpecClass   := specBeingEdited class.
     specBeingEdited := (builderView generateSpecFor:currentView) first.
 
     (    (specBeingEdited class == prevSpecClass)
-     and:[currentSpecChannel notNil]
+     and:[specChannel notNil]
     ) ifTrue:[
         "can keep current specifications plus current property selection
         "
-        self reload.
-      ^ self.
+      ^ self reload.
     ].
 
-    propertyList selectionIndex:nil.
     propertyAspects := IdentityDictionary new.
-    propertySpecs   := OrderedCollection new.
     slices          := currentView specClass slices.
 
     list := slices collect:[:slice|
-        propertySpecs add:(slice last).
         slice first asString
     ].
     list := list, (Array with:(self class titleOfLayoutMenu)).
 
-    currentSpecChannel := specBeingEdited asValue.
+    specChannel := specBeingEdited asValue.
     specBeingEdited class addBindingsTo:propertyAspects
                                     for:specBeingEdited
-                                channel:currentSpecChannel.
+                                channel:specChannel.
     propertyAspects do:[:anAspect | anAspect addDependent:self ].
-    propertyList list:list.
-    propertyList selection:userSelectedProperty.
-    self modified:false.
+    self propertyList:list.
 
 
 
@@ -1273,35 +1261,30 @@
 propertySelectionChanged
     "property selection changed; switch to new property selection
     "
-    |spec index sel|
-
-    sel := propertyList selection.
-    self modified:false.
+    |plist|
 
-    (currentView isNil or:[sel isNil]) ifTrue:[
-        "/ must setup for a WindowSpec for workView (to allow entry of min- maxSize etc).
-"/        currentView isNil ifTrue:[
-"/            currentView := receiver
-"/        ].
+    self modified:false.
+    plist := self propertyList.
+
+    (plist selection isNil) ifTrue:[
         ^ self showSpec:nil
     ].
-    index := propertyList selectionIndex.
-    userSelectedProperty := sel.
+    propertySelection := plist selection.
 
-    index > propertySpecs size ifTrue:[                 "/ one of my specifications
-        (sel == self class titleOfLayoutMenu) ifTrue:[
-            ^ self showAndFetchLayout
+    currentView specClass slices do:[:slice|
+        slice first = propertySelection ifTrue:[
+            ^ self showSpec:(currentView specClass perform:(slice last))
         ]
-    ] ifFalse:[
-        spec := currentView specClass perform:(propertySpecs at:index).
     ].
-    self showSpec:spec.
+    ^ self showAndFetchLayout   "/ layout specifications
 !
 
-update:something with:aParameter from:changedObject
+update:something with:someArgument from:someone
     "any attribute changed its state in the current specification
     "
     self modified:true
+
+
 ! !
 
 !UIPropertyView methodsFor:'initialization'!
@@ -1309,7 +1292,7 @@
 in:aTopView builder:aBuilderView
     "setup property view in topview and that the builder view
     "
-    |menu y cancelButton applyButton panel|
+    |menu y cancelButton applyButton panel propertyFrame propertyList|
 
     super initialize.
     self initializeLayoutAspects.
@@ -1320,6 +1303,7 @@
     menu defaultLabel:'properties'.
     propertyFrame := View in:aTopView.
     panel := HorizontalPanelView in:aTopView.
+    panel horizontalLayout:#fitSpace.
 
     cancelButton := Button abortButtonIn:panel.
     applyButton  := Button okButtonIn:panel.
@@ -1339,8 +1323,10 @@
     propertyFrame bottomInset:y.
     panel topInset:(y negated).
 
-    builder componentAt:#cancelButton put:cancelButton.
-    builder componentAt:#applyButton  put:applyButton.
+    builder componentAt:#propertyFrame put:propertyFrame.
+    builder componentAt:#cancelButton  put:cancelButton.
+    builder componentAt:#applyButton   put:applyButton.
+    builder componentAt:#propertyList  put:propertyList.
 
     cancelButton action:[ self cancel ].
     applyButton  action:[ self apply ].
@@ -1377,89 +1363,7 @@
     "Modified: 28.2.1997 / 12:57:51 / cg"
 ! !
 
-!UIPropertyView methodsFor:'private'!
-
-aspectFor:aKey
-    "returns aspect for a key
-    "
-    |aspect|
-
-    propertyAspects notNil ifTrue:[
-        aspect := propertyAspects at:aKey ifAbsent:nil.
-        aspect notNil ifTrue:[
-            ^ aspect
-        ]
-    ].
-
-    ^ layoutAspects at:aKey ifAbsent:[super aspectFor:aKey]
-!
-
-showSpec:aSpec
-    "switch to specification
-    "
-    currentSpec ~= aSpec ifTrue:[
-        propertyFrame destroySubViews.
-
-        aSpec notNil ifTrue:[
-            builder buildFromSpec:aSpec in:propertyFrame.
-            propertyFrame realizeAllSubViews
-        ]
-    ].
-    currentSpec := aSpec.
-! !
-
-!UIPropertyView methodsFor:'private actions'!
-
-apply
-    "apply current changes and write back to current view
-    "
-    modified ifTrue:[
-        self modified:false.
-
-        self isSingleSelection ifTrue:[
-            self isLayoutSpec ifFalse:[
-                builderView updateFromSpec:specBeingEdited
-            ] ifTrue:[
-                layoutType notNil ifTrue:[
-                    self perform:(('write', layoutType asString) asSymbol)
-                ]
-            ]
-        ]
-    ]
-
-!
-
-cancel
-    "cancel all changes and read back attributes from current view
-    "
-    modified ifTrue:[
-        specBeingEdited := (builderView generateSpecFor:currentView) first.
-        self reload
-    ].
-!
-
-reload
-    "relaod all attributes from current specification and update values
-    "
-    |spec oldMod|
-
-    self modified:false.
-    modified := true.           "supress notifications"
-
-    currentSpecChannel notNil ifTrue:[
-        currentSpecChannel value:specBeingEdited.
-
-        self isSingleSelection ifTrue:[
-            self isLayoutSpec ifTrue:[
-                self showAndFetchLayout.
-            ]
-        ]
-    ].
-    modified := false.
-
-! !
-
-!UIPropertyView methodsFor:'private layout'!
+!UIPropertyView methodsFor:'layout'!
 
 layoutType
     ^ layoutType
@@ -1487,10 +1391,6 @@
 
 !
 
-selectedLayoutType
-    ^ layoutType
-!
-
 showAndFetchLayout
     "fetch and show layout specification assigned to current view
     "
@@ -1498,18 +1398,11 @@
 
     self modified:false.
     modified := true.
-
-    currentView notNil ifTrue:[
-        type := builderView class layoutType:currentView.
+    type     := builderView class layoutType:currentView.
 
-        type notNil ifTrue:[
-            self perform:(('fetch', type asString) asSymbol).
-
-            type notNil ifTrue:[
-                spec := ('specification', type asString) asSymbol.
-                spec := self class perform:spec.
-            ]
-        ]
+    type notNil ifTrue:[
+        self perform:(('fetch', type asString) asSymbol).
+        spec := self class perform:(('specification', type asString) asSymbol).
     ].
 
     type ~~ layoutType ifTrue:[
@@ -1517,11 +1410,6 @@
         self changed:#layoutType
     ].
     self showSpec:spec.
-
-    type ~~ layoutType ifTrue:[
-        layoutType := type.
-        self changed:#layoutType
-    ].
     modified := false.
 
 !
@@ -1529,7 +1417,7 @@
 updateLayout
     "layout changed but not selection
     "
-    (currentView notNil and:[modified not and:[self isLayoutSpec]]) ifTrue:[
+    (modified not and:[self isLayoutSpec]) ifTrue:[
         (builderView class layoutType:currentView) == layoutType ifTrue:[
             modified := true.
             self perform:(('fetch', layoutType asString) asSymbol).
@@ -1540,7 +1428,7 @@
     ]
 ! !
 
-!UIPropertyView methodsFor:'private layout fetch'!
+!UIPropertyView methodsFor:'layout fetch/write'!
 
 fetchAlignmentOrigin
     "fetch alignmentOrigin
@@ -1636,9 +1524,7 @@
     (layoutAspects at:#rightOffset)  value:(corner x).
     (layoutAspects at:#topOffset)    value:(origin y).
     (layoutAspects at:#bottomOffset) value:(corner y).
-! !
-
-!UIPropertyView methodsFor:'private layout write'!
+!
 
 writeAlignmentOrigin
     "write back as alignmentOrigin
@@ -1731,7 +1617,7 @@
     builderView setDimension:rectangle
 ! !
 
-!UIPropertyView methodsFor:'private make layout'!
+!UIPropertyView methodsFor:'layout relative/absolut'!
 
 makeAlignBottomCenter
     self makeAlignLeft:0.5 top:1
@@ -1890,18 +1776,127 @@
 
 ! !
 
+!UIPropertyView methodsFor:'private'!
+
+apply
+    "apply current changes and write back to current view
+    "
+    modified ifTrue:[
+        self modified:false.
+
+        self isSingleSelection ifTrue:[
+            self isLayoutSpec ifFalse:[
+                builderView updateFromSpec:specBeingEdited
+            ] ifTrue:[
+                layoutType notNil ifTrue:[
+                    self perform:(('write', layoutType asString) asSymbol)
+                ]
+            ]
+        ]
+    ]
+
+!
+
+aspectFor:aKey
+    "returns aspect for a key
+    "
+    |aspect|
+
+    propertyAspects notNil ifTrue:[
+        aspect := propertyAspects at:aKey ifAbsent:nil.
+        aspect notNil ifTrue:[
+            ^ aspect
+        ]
+    ].
+
+    ^ layoutAspects at:aKey ifAbsent:[super aspectFor:aKey]
+!
+
+cancel
+    "cancel all changes and read back attributes from current view
+    "
+    modified ifTrue:[
+        specBeingEdited := (builderView generateSpecFor:currentView) first.
+        self reload
+    ].
+!
+
+propertyList
+    "returns property list
+    "
+    ^ builder componentAt:#propertyList
+!
+
+propertyList:aList
+    "property list changed
+    "
+    |sel list plist|
+
+    aList notNil ifTrue:[
+        sel  := propertySelection.
+        list := aList
+    ] ifFalse:[
+        list := #()
+    ].
+
+    plist := self propertyList.
+    plist list:list.
+    plist selection:sel.
+    self modified:false.
+
+!
+
+reload
+    "relaod all attributes from current specification and update values
+    "
+    self modified:false.
+
+    self isSingleSelection ifTrue:[
+        modified := true.                               "/ disable notifications"
+        specChannel value:specBeingEdited.
+
+        self isLayoutSpec ifTrue:[
+            self showAndFetchLayout.
+        ].
+        modified := false.                              "/ enable notifications
+    ].
+
+!
+
+showSpec:aSpec
+    "switch to specification
+    "
+    |frame|
+
+    shownSpec ~= aSpec ifTrue:[
+        frame := builder componentAt:#propertyFrame.
+        frame destroySubViews.
+
+        aSpec notNil ifTrue:[
+            builder buildFromSpec:aSpec in:frame.
+            frame realizeAllSubViews
+        ]
+    ].
+    shownSpec := aSpec.
+! !
+
 !UIPropertyView methodsFor:'queries'!
 
 isLayoutSpec
     "returns true if current menu is a layout specification
     "
-    ^ propertyList selection == self class titleOfLayoutMenu
+    |selection|
+
+    self isSingleSelection ifTrue:[
+        ^ propertySelection == self class titleOfLayoutMenu
+    ].
+    ^ false
 !
 
 isMultiSelection
     "returns true in case of a multiple selection
     "
-    ^ builderView numberOfSelections > 1
+    ^ (currentView isNil and:[builderView numberOfSelections > 1])
 !
 
 isSingleSelection