testMode is now a ValueHolder
authorca
Fri, 23 May 1997 16:07:52 +0200
changeset 119 39acd704ad51
parent 118 bc196200ea8b
child 120 d83c307f3bf5
testMode is now a ValueHolder
UIObjectView.st
UIPainterView.st
--- a/UIObjectView.st	Fri May 23 16:06:33 1997 +0200
+++ b/UIObjectView.st	Fri May 23 16:07:52 1997 +0200
@@ -1,5 +1,5 @@
 ObjectView subclass:#UIObjectView
-	instanceVariableNames:'inputView testMode undoHistory copiedExtent copiedLayout
+	instanceVariableNames:'inputView enableChannel undoHistory copiedExtent copiedLayout
 		actionData createClass clipChildren selectionHiddenLevel
 		setOfSuperViewsSizeChanged'
 	classVariableNames:''
@@ -155,12 +155,10 @@
 
 !UIObjectView methodsFor:'accessing'!
 
-canModify
-    ^ testMode not
-!
-
-canModify:aBool
-    self testMode:(aBool not)
+enableChannel
+    "returns the channel which keeps false if running test otherwise true
+    "
+  ^ enableChannel
 !
 
 gridAlign
@@ -222,12 +220,38 @@
     "show grid
     "
     self withSelectionHiddenDo:[super showGrid]
+! !
+
+!UIObjectView methodsFor:'accessing behavior'!
+
+enabled
+    ^ enableChannel value
+!
+
+enabled:aState
+    "set the modification / test mode
+    "
+    (aState == enableChannel value) ifFalse:[
+        enableChannel value:aState.
+
+        aState ifFalse:[
+            self unselect.
+            inputView unrealize
+        ] ifTrue:[
+            inputView raise.
+            inputView realize
+        ].
+        self changed:#enabled
+    ]
+
+
+
 !
 
 testMode
     "returns true if running test
     "
-    ^ testMode
+    ^ enableChannel value not
 
 
 !
@@ -235,20 +259,7 @@
 testMode:aBoolean
     "change test mode
     "
-    (aBoolean == testMode) ifFalse:[
-        testMode := aBoolean.
-
-        testMode ifTrue:[
-            self unselect.
-            inputView unrealize
-        ] ifFalse:[
-            inputView raise.
-            inputView realize
-        ].
-        self changed:#canModify
-    ]
-
-
+    self enabled:(aBoolean not)
 ! !
 
 !UIObjectView methodsFor:'blocked'!
@@ -359,9 +370,9 @@
 
     self setDefaultActions.
 
-    undoHistory  := UndoHistory new.
-    testMode     := false.
-    clipChildren := true.
+    undoHistory          := UndoHistory new.
+    enableChannel        := true asValue.
+    clipChildren         := true.
     selectionHiddenLevel := 0.
 
     (self class gridShown) ifTrue:[
@@ -683,7 +694,7 @@
 
     |anObject|
 
-    testMode ifTrue:[^ self].
+    self enabled ifFalse:[^ self].
 
     anObject := self findObjectAt:aPoint.
     anObject notNil ifTrue:[
@@ -700,7 +711,7 @@
     "
     |aView b|
 
-    testMode ifTrue:[^ self].
+    self enabled ifFalse:[^ self].
 
     aView := self singleSelection.
 
@@ -1402,9 +1413,9 @@
 !
 
 canSelect:something
-    "returns true if something can be selected and testMode is disabled
+    "returns true if something can be selected and enabled is true
     "
-    ^ (testMode not and:[something ~~ selection])
+    ^ (self enabled and:[something ~~ selection])
 
 !
 
--- a/UIPainterView.st	Fri May 23 16:06:33 1997 +0200
+++ b/UIPainterView.st	Fri May 23 16:07:52 1997 +0200
@@ -17,6 +17,13 @@
 	category:'Interface-UIPainter'
 !
 
+MultiSelectionInList subclass:#ListHolder
+	instanceVariableNames:'painter propertyList masterElement disabledChanged'
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:UIPainterView
+!
+
 Object subclass:#ViewProperty
 	instanceVariableNames:'view spec identifier'
 	classVariableNames:'Identifier'
@@ -31,13 +38,6 @@
 	privateIn:UIPainterView
 !
 
-MultiSelectionInList subclass:#ListHolder
-	instanceVariableNames:'painter propertyList masterElement disabledChanged'
-	classVariableNames:''
-	poolDictionaries:''
-	privateIn:UIPainterView
-!
-
 !UIPainterView class methodsFor:'documentation'!
 
 copyright
@@ -179,32 +179,36 @@
                 #'submenu:'
                         #(#Menu #(
                                 #(#MenuItem
-                                        #'label:' 'align left'
                                         #'value:' #alignSelectionLeft
+                                        #'labelImage:' #( ResourceRetriever UIPainter iconAlignL 'align left' )
                                  )
                                 #(#MenuItem
-                                        #'label:' 'align right'
                                         #'value:' #alignSelectionRight
+                                        #'labelImage:' #( ResourceRetriever UIPainter iconAlignR 'align right' )
                                  )
                                 #(#MenuItem
-                                        #'label:' 'align left & right'
                                         #'value:' #alignSelectionLeftAndRight
+                                        #'labelImage:' #( ResourceRetriever UIPainter iconAlignLR 'align left & right' )
                                  )
                                 #(#MenuItem
-                                        #'label:' 'align top'
                                         #'value:' #alignSelectionTop
+                                        #'labelImage:' #( ResourceRetriever UIPainter iconAlignT 'align top' )
+                                 )
+                                #(#MenuItem
+                                        #'value:' #alignSelectionBottom
+                                        #'labelImage:' #( ResourceRetriever UIPainter iconAlignB 'align bottom' )
                                  )
                                 #(#MenuItem
-                                        #'label:' 'align bottom' #'value:'
-                                        #alignSelectionBottom
+                                        #'value:' #alignSelectionTopAndBottom
+                                        #'labelImage:' #( ResourceRetriever UIPainter iconAlignTB 'align top & bottom' )
                                  )
                                 #(#MenuItem
-                                        #'label:' 'align centered vertical'
                                         #'value:' #alignSelectionCenterHor
+                                        #'labelImage:' #( ResourceRetriever UIPainter iconAlignCenterH 'align centered horizontal' )
                                  )
                                 #(#MenuItem
-                                        #'label:' 'align centered horizontal'
                                         #'value:' #alignSelectionCenterVer
+                                        #'labelImage:' #( ResourceRetriever UIPainter iconAlignCenterV 'align centered vertical' )
                                  )
                                 #(#MenuItem
                                         #'label:' 'spread horizontal'
@@ -223,7 +227,7 @@
                                         #'value:' #centerSelectionVer
                                  )
                                 )
-                               #(7 2)
+                               #(8 2)
                                nil
                         )
          )
@@ -482,7 +486,7 @@
 canDrop:anObjectOrCollection
     |spec|
 
-    testMode ifFalse:[
+    self enabled ifTrue:[
         anObjectOrCollection size == 1 ifTrue:[
             spec := (anObjectOrCollection at:1) theObject.
             ^ (spec isKindOf:UISpecification)
@@ -993,7 +997,7 @@
     "
     |menu canPaste|
 
-    testMode ifTrue:[^ nil ].
+    self enabled ifFalse:[^ nil ].
     menu := MenuPanel fromSpec:(self class menu) receiver:self.
 
     canPaste := self canPaste:(self getSelection).
@@ -1595,138 +1599,6 @@
 
 ! !
 
-!UIPainterView::ViewProperty class methodsFor:'documentation'!
-
-version
-    ^ '$Header$'
-! !
-
-!UIPainterView::ViewProperty class methodsFor:'instance creation'!
-
-new
-    Identifier notNil ifTrue:[Identifier := Identifier + 1]
-                     ifFalse:[Identifier := 1].
-
-  ^ self basicNew initialize
-! !
-
-!UIPainterView::ViewProperty methodsFor:'accessing'!
-
-group
-    ^ nil
-!
-
-identifier
-    "return the unique identifier assigned to property
-    "
-    ^ identifier
-!
-
-spec
-    "return the value of the instance variable 'spec' (automatically generated)"
-
-    ^ spec!
-
-spec:something
-    "set the value of the instance variable 'spec' (automatically generated)"
-
-    spec := something.!
-
-view
-    "return the value of the instance variable 'view' (automatically generated)"
-
-    ^ view!
-
-view:something
-    "set the value of the instance variable 'view' (automatically generated)"
-
-    view := something.! !
-
-!UIPainterView::ViewProperty methodsFor:'initialization'!
-
-initialize
-    super initialize.
-    identifier := Identifier
-! !
-
-!UIPainterView::ViewProperty methodsFor:'misc'!
-
-extractNumberStartingAt:anIndex
-    "return the number from the name starting at anIndex or 0.
-    "
-    |val|
-
-    val := 0.
-
-    self name from:anIndex do:[:c|
-        c isDigit ifTrue:[val := val * 10 + c digitValue]
-                 ifFalse:[^ 0]
-    ].
-    ^ val
-        
-! !
-
-!UIPainterView::ViewProperty methodsFor:'spec messages'!
-
-doesNotUnderstand:aMessage
-    spec notNil ifTrue:[
-        (spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec]
-    ].
-    ^ nil
-!
-
-layout
-    spec layout
-!
-
-layout:aLayout
-    spec layout:aLayout
-!
-
-name
-    ^ spec name
-!
-
-name:aName
-    spec name:aName
-! !
-
-!UIPainterView::GroupProperties methodsFor:'accessing'!
-
-controlledObjects
-    "return the value of the instance variable 'controlledObjects' (automatically generated)"
-
-    ^ controlledObjects!
-
-controlledObjects:something
-    "set the value of the instance variable 'controlledObjects' (automatically generated)"
-
-    controlledObjects := something.!
-
-group
-    "return the value of the instance variable 'group'
-    "
-    ^ group
-!
-
-group:something
-    "set the value of the instance variable 'group'
-    "
-    group := something.
-!
-
-name
-    "return the value of the group name
-    "
-    ^ name
-!
-
-name:aName
-    "set the value of the group name
-    "
-    name := aName
-! !
-
 !UIPainterView::ListHolder class methodsFor:'instance creation'!
 
 for:aPainter
@@ -1735,10 +1607,6 @@
 
 !UIPainterView::ListHolder methodsFor:'accessing'!
 
-canModify
-    ^ (painter notNil and:[painter testMode not])
-!
-
 painter
     "returns painter
     "
@@ -1869,6 +1737,7 @@
 for:aPainter
     "initialize for a painter
     "
+    painter := aPainter.
     self list:(OrderedCollection new).
     propertyList := OrderedCollection new.
     self selection:#().
@@ -2017,7 +1886,7 @@
     "
     |start end sel size|
 
-    self canModify ifTrue:[
+    painter enabled ifTrue:[
         (start := self masterElement) ~~ 0 ifTrue:[
             end  := self lastInGroupStartingAt:start.
             size := end - start + 1.
@@ -2052,8 +1921,8 @@
 selectionIndex:aList
     |masterIndex aSel|
 
-    self canModify ifTrue:[aSel := aList]
-                  ifFalse:[aSel := nil].
+    painter enabled ifTrue:[aSel := aList]
+                   ifFalse:[aSel := nil].
 
     aSel size ~~ 0 ifTrue:[masterIndex := aSel at:1]
                   ifFalse:[masterIndex := 0].
@@ -2062,6 +1931,138 @@
     super selectionIndex:aSel
 ! !
 
+!UIPainterView::ViewProperty class methodsFor:'documentation'!
+
+version
+    ^ '$Header$'
+! !
+
+!UIPainterView::ViewProperty class methodsFor:'instance creation'!
+
+new
+    Identifier notNil ifTrue:[Identifier := Identifier + 1]
+                     ifFalse:[Identifier := 1].
+
+  ^ self basicNew initialize
+! !
+
+!UIPainterView::ViewProperty methodsFor:'accessing'!
+
+group
+    ^ nil
+!
+
+identifier
+    "return the unique identifier assigned to property
+    "
+    ^ identifier
+!
+
+spec
+    "return the value of the instance variable 'spec' (automatically generated)"
+
+    ^ spec!
+
+spec:something
+    "set the value of the instance variable 'spec' (automatically generated)"
+
+    spec := something.!
+
+view
+    "return the value of the instance variable 'view' (automatically generated)"
+
+    ^ view!
+
+view:something
+    "set the value of the instance variable 'view' (automatically generated)"
+
+    view := something.! !
+
+!UIPainterView::ViewProperty methodsFor:'initialization'!
+
+initialize
+    super initialize.
+    identifier := Identifier
+! !
+
+!UIPainterView::ViewProperty methodsFor:'misc'!
+
+extractNumberStartingAt:anIndex
+    "return the number from the name starting at anIndex or 0.
+    "
+    |val|
+
+    val := 0.
+
+    self name from:anIndex do:[:c|
+        c isDigit ifTrue:[val := val * 10 + c digitValue]
+                 ifFalse:[^ 0]
+    ].
+    ^ val
+        
+! !
+
+!UIPainterView::ViewProperty methodsFor:'spec messages'!
+
+doesNotUnderstand:aMessage
+    spec notNil ifTrue:[
+        (spec respondsTo:(aMessage selector)) ifTrue:[^ aMessage sendTo:spec]
+    ].
+    ^ nil
+!
+
+layout
+    spec layout
+!
+
+layout:aLayout
+    spec layout:aLayout
+!
+
+name
+    ^ spec name
+!
+
+name:aName
+    spec name:aName
+! !
+
+!UIPainterView::GroupProperties methodsFor:'accessing'!
+
+controlledObjects
+    "return the value of the instance variable 'controlledObjects' (automatically generated)"
+
+    ^ controlledObjects!
+
+controlledObjects:something
+    "set the value of the instance variable 'controlledObjects' (automatically generated)"
+
+    controlledObjects := something.!
+
+group
+    "return the value of the instance variable 'group'
+    "
+    ^ group
+!
+
+group:something
+    "set the value of the instance variable 'group'
+    "
+    group := something.
+!
+
+name
+    "return the value of the group name
+    "
+    ^ name
+!
+
+name:aName
+    "set the value of the group name
+    "
+    name := aName
+! !
+
 !UIPainterView class methodsFor:'documentation'!
 
 version