--- a/ObjectView.st Thu Mar 29 13:47:34 2018 +0200
+++ b/ObjectView.st Wed Apr 11 18:37:27 2018 +0200
@@ -419,9 +419,11 @@
"add something, anObject or a collection of objects to the contents
with redraw"
- self forEach:something do:[:anObject |
- self addObject:anObject
+ something doIfNotNil:[:anObject |
+ self addObject:anObject
]
+
+ "Modified: / 11-04-2018 / 18:09:37 / stefan"
!
addObject:anObject
@@ -488,9 +490,11 @@
"add something, anObject or a collection of objects to the contents
do not redraw"
- self forEach:something do:[:anObject |
- self addObjectWithoutRedraw:anObject
+ something doIfNotNil:[:anObject |
+ self addObjectWithoutRedraw:anObject
]
+
+ "Modified: / 11-04-2018 / 18:09:51 / stefan"
!
contents:aCollectionOfObjects
@@ -506,7 +510,7 @@
"
better to remove first, then redraw rest
"
- self forEach:something do:[:anObject |
+ something doIfNotNil:[:anObject |
self removeFromSelection:anObject.
contents remove:anObject.
self changed:#removeObject with:anObject.
@@ -515,11 +519,12 @@
^ self
].
- self forEach:something do:[:anObject |
+ something doIfNotNil:[:anObject |
self removeObject:anObject
]
- "Modified: / 4.7.1999 / 16:50:09 / cg"
+ "Modified: / 04-07-1999 / 16:50:09 / cg"
+ "Modified: / 11-04-2018 / 18:15:56 / stefan"
!
removeAll
@@ -575,9 +580,11 @@
"remove something, anObject or a collection of objects from the contents
do not redraw"
- self forEach:something do:[:anObject |
- self removeObjectWithoutRedraw:anObject
+ something doIfNotNil:[:anObject |
+ self removeObjectWithoutRedraw:anObject
]
+
+ "Modified: / 11-04-2018 / 18:16:03 / stefan"
! !
!ObjectView methodsFor:'cut & paste'!
@@ -1382,15 +1389,17 @@
|drawer|
rootMotion ifTrue:[
- "drag in root-window"
-
- drawer := rootView
+ "drag in root-window"
+
+ drawer := rootView
] ifFalse:[
- drawer := self
+ drawer := self
].
- self forEach:something do:[:anObject |
- anObject drawDragIn:drawer offset:anOffset
+ something doIfNotNil:[:anObject |
+ anObject drawDragIn:drawer offset:anOffset
]
+
+ "Modified: / 11-04-2018 / 18:16:59 / stefan"
!
showSelected:anObject
@@ -1965,16 +1974,18 @@
|botMost|
botMost := -999999.
- self forEach:something do:[:anObject |
- botMost := botMost max:(anObject frame bottom)
+ something doIfNotNil:[:anObject |
+ botMost := botMost max:(anObject frame bottom)
].
self withSelectionHiddenDo:[
- self forEach:something do:[:anObject |
- self moveObject:anObject to:(anObject frame left)
- @
- (botMost - (anObject frame height))
- ]
+ something doIfNotNil:[:anObject |
+ self moveObject:anObject to:(anObject frame left)
+ @
+ (botMost - (anObject frame height))
+ ]
]
+
+ "Modified: / 11-04-2018 / 18:10:14 / stefan"
!
alignHorizontal:something
@@ -1984,7 +1995,7 @@
topMost := 999999.
bottomMost := -999999.
- self forEach:something do:[:anObject |
+ something doIfNotNil:[:anObject |
|f|
f := anObject frame.
topMost := topMost min:(f top).
@@ -1993,7 +2004,7 @@
h := bottomMost - topMost.
self withSelectionHiddenDo:[
- self forEach:something do:[:anObject |
+ something doIfNotNil:[:anObject |
self moveObject:anObject
to:(anObject frame left)
@
@@ -2001,51 +2012,58 @@
]
]
- "Created: 4.6.1996 / 20:01:19 / cg"
- "Modified: 4.6.1996 / 21:19:48 / cg"
+ "Created: / 04-06-1996 / 20:01:19 / cg"
+ "Modified: / 04-06-1996 / 21:19:48 / cg"
+ "Modified: / 11-04-2018 / 18:10:39 / stefan"
!
alignLeft:something
|leftMost|
leftMost := 999999.
- self forEach:something do:[:anObject |
- leftMost := leftMost min:(anObject frame left)
+ something doIfNotNil:[:anObject |
+ leftMost := leftMost min:(anObject frame left)
].
self withSelectionHiddenDo:[
- self forEach:something do:[:anObject |
- self moveObject:anObject to:(leftMost @ (anObject frame top))
- ]
+ something doIfNotNil:[:anObject |
+ self moveObject:anObject to:(leftMost @ (anObject frame top))
+ ]
]
+
+ "Modified: / 11-04-2018 / 18:11:26 / stefan"
!
alignRight:something
|rightMost|
rightMost := -999999.
- self forEach:something do:[:anObject |
- rightMost := rightMost max:(anObject frame right)
+ something doIfNotNil:[:anObject |
+ rightMost := rightMost max:(anObject frame right)
].
self withSelectionHiddenDo:[
- self forEach:something do:[:anObject |
- self moveObject:anObject to:(rightMost - (anObject frame width))
- @ (anObject frame top)
- ]
+ something doIfNotNil:[:anObject |
+ self moveObject:anObject to:(rightMost - (anObject frame width))
+ @ (anObject frame top)
+ ]
]
+
+ "Modified: / 11-04-2018 / 18:11:39 / stefan"
!
alignTop:something
|topMost|
topMost := 999999.
- self forEach:something do:[:anObject |
- topMost := topMost min:(anObject frame top)
+ something doIfNotNil:[:anObject |
+ topMost := topMost min:(anObject frame top)
].
self withSelectionHiddenDo:[
- self forEach:something do:[:anObject |
- self moveObject:anObject to:((anObject frame left) @ topMost)
- ]
+ something doIfNotNil:[:anObject |
+ self moveObject:anObject to:((anObject frame left) @ topMost)
+ ]
]
+
+ "Modified: / 11-04-2018 / 18:11:50 / stefan"
!
alignVertical:something
@@ -2055,7 +2073,7 @@
leftMost := 999999.
rightMost := -999999.
- self forEach:something do:[:anObject |
+ something doIfNotNil:[:anObject |
|f|
f := anObject frame.
rightMost := rightMost max:(f right).
@@ -2064,7 +2082,7 @@
w := rightMost - leftMost.
self withSelectionHiddenDo:[
- self forEach:something do:[:anObject |
+ something doIfNotNil:[:anObject |
self moveObject:anObject
to:(leftMost + ((w - anObject frame width) // 2))
@
@@ -2072,8 +2090,9 @@
]
]
- "Created: 4.6.1996 / 19:59:16 / cg"
- "Modified: 4.6.1996 / 21:19:58 / cg"
+ "Created: / 04-06-1996 / 19:59:16 / cg"
+ "Modified: / 04-06-1996 / 21:19:58 / cg"
+ "Modified: / 11-04-2018 / 18:12:01 / stefan"
!
move:something by:delta
@@ -2081,12 +2100,14 @@
by delta, aPoint"
(delta x == 0) ifTrue:[
- (delta y == 0) ifTrue:[^ self]
+ (delta y == 0) ifTrue:[^ self]
].
- self forEach:something do:[:anObject |
- self moveObject:anObject by:delta
+ something doIfNotNil:[:anObject |
+ self moveObject:anObject by:delta
]
+
+ "Modified: / 11-04-2018 / 18:15:21 / stefan"
!
move:something to:aPoint in:aView
@@ -2295,17 +2316,21 @@
toBack:something
"bring the argument, anObject or a collection of objects to back"
- self forEach:something do:[:anObject |
- self objectToBack:anObject
+ something doIfNotNil:[:anObject |
+ self objectToBack:anObject
]
+
+ "Modified: / 11-04-2018 / 18:17:33 / stefan"
!
toFront:something
"bring the argument, anObject or a collection of objects to front"
- self forEach:something do:[:anObject |
- self objectToFront:anObject
+ something doIfNotNil:[:anObject |
+ self objectToFront:anObject
]
+
+ "Modified: / 11-04-2018 / 18:17:41 / stefan"
! !
!ObjectView methodsFor:'misc'!
@@ -2328,22 +2353,6 @@
"Modified: 31.5.1996 / 19:44:08 / cg"
!
-forEach:aCollection do:aBlock
- "apply block to every object in a collectioni;
- (adds a check for non-collection)"
-
- aCollection isNil ifTrue:[^self].
- aCollection isCollection ifTrue:[
- aCollection do:[:object |
- object notNil ifTrue:[
- aBlock value:object
- ]
- ]
- ] ifFalse: [
- aBlock value:aCollection
- ]
-!
-
hitDelta
"when clicking an object, allow for hitDelta pixels around object.
We compensate for any scaling here, to get a constant physical
@@ -2745,12 +2754,13 @@
aStream binary.
self topView withWriteCursorDo:[
- self forEach:contents do:[:theObject |
+ contents doIfNotNil:[:theObject |
theObject storeBinaryOn:aStream.
].
]
"Modified: / 27-07-2012 / 09:45:31 / cg"
+ "Modified: / 11-04-2018 / 18:17:09 / stefan"
!
storeContentsOn:aStream
@@ -2763,7 +2773,7 @@
self topView withWriteCursorDo:[
excla := aStream class chunkSeparator.
- self forEach:contents do:[:theObject |
+ contents doIfNotNil:[:theObject |
theObject storeOn:aStream.
aStream nextPut:excla.
aStream cr
@@ -2772,6 +2782,7 @@
]
"Modified: / 27-07-2012 / 09:45:23 / cg"
+ "Modified: / 11-04-2018 / 18:17:20 / stefan"
!
withoutRedrawFileInContentsFrom:aStream
@@ -2911,7 +2922,7 @@
aSelection notNil ifTrue:[
self clippedTo:nil do:[
self xoring:[
- self forEach:aSelection do:[:anObject |
+ aSelection doIfNotNil:[:anObject |
(anObject respondsTo:#handlesDo:) ifTrue:[
self drawHandlesFor:anObject
] ifFalse:[
@@ -2921,6 +2932,8 @@
]
]
]
+
+ "Modified: / 11-04-2018 / 18:14:50 / stefan"
!
object:anObject hasHandleAt:aPoint
@@ -2936,13 +2949,15 @@
!
selectionHandlesDo:aBlock
- self forEach:selection do:[:theObject |
+ selection doIfNotNil:[:theObject |
(theObject respondsTo:#handlesDo:) ifTrue:[
self handlesOf:theObject do:[:handlePoint |
aBlock value:theObject value:handlePoint
]
]
]
+
+ "Modified: / 11-04-2018 / 18:16:50 / stefan"
! !
!ObjectView methodsFor:'selections'!
@@ -3093,7 +3108,9 @@
selectionDo:aBlock
"apply block to every object in selection"
- self forEach:selection do:aBlock
+ selection doIfNotNil:aBlock
+
+ "Modified: / 11-04-2018 / 18:16:30 / stefan"
!
showSelection
@@ -3155,30 +3172,26 @@
canMove:something
"return true, if the argument, anObject or a collection can be moved"
- something isCollection ifTrue:[
- self forEach:something do:[:theObject |
- (theObject perform:#canBeMoved ifNotUnderstood:true) ifFalse:[^ false]
- ].
- ^ true
+ something doIfNotNil:[:theObject |
+ (theObject perform:#canBeMoved ifNotUnderstood:true) ifFalse:[^ false]
].
- ^ something perform:#canBeMoved ifNotUnderstood:true
+ ^ true
+
+ "Modified: / 11-04-2018 / 18:13:04 / stefan"
!
canSelect:something
"return true, if the argument, anObject or a collection can be selected"
- something isCollection ifTrue:[
- self forEach:something do:[:theObject |
- theObject isView ifFalse:[
- (theObject perform:#canBeSelected ifNotUnderstood:true) ifFalse:[^ false]
- ]
- ].
- ^ true
+ something doIfNotNil:[:theObject |
+ theObject isView ifFalse:[
+ (theObject perform:#canBeSelected ifNotUnderstood:true) ifFalse:[^ false]
+ ]
].
- something isView ifTrue:[^ true].
- ^ something perform:#canBeSelected ifNotUnderstood:true
-
- "Created: / 4.7.1999 / 18:51:29 / cg"
+ ^ true
+
+ "Created: / 04-07-1999 / 18:51:29 / cg"
+ "Modified: / 11-04-2018 / 18:14:02 / stefan"
!
findNearestObjectAt:aPoint
@@ -3279,7 +3292,7 @@
anObjectOrCollection isNil ifTrue:[^ nil ].
first := true.
- self forEach:anObjectOrCollection do:[:theObject |
+ anObjectOrCollection doIfNotNil:[:theObject |
first ifTrue:[
frameAll := theObject frame.
first := false
@@ -3290,18 +3303,21 @@
^ frameAll
"Modified: / 27-10-2006 / 17:02:16 / cg"
+ "Modified: / 11-04-2018 / 18:14:35 / stefan"
!
isObscured:something
"return true, if the argument something, anObject or a collection of
objects is obscured (partially or whole) by any other object"
- self forEach:something do:[:anObject |
- (self objectIsObscured:anObject) ifTrue:[
- ^ true
- ]
+ something doIfNotNil:[:anObject |
+ (self objectIsObscured:anObject) ifTrue:[
+ ^ true
+ ]
].
^ false
+
+ "Modified: / 11-04-2018 / 18:15:07 / stefan"
!
isSelected:anObject