initial checkin
authorca
Tue, 31 Mar 1998 09:48:29 +0200
changeset 880 26429c5ffbbe
parent 879 8f725e76fe7e
child 881 981e0791ca36
initial checkin
PropertyListDictionary.st
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PropertyListDictionary.st	Tue Mar 31 09:48:29 1998 +0200
@@ -0,0 +1,152 @@
+IdentityDictionary subclass:#PropertyListDictionary
+	instanceVariableNames:''
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Interface-Support-UI'
+!
+
+!PropertyListDictionary class methodsFor:'documentation'!
+
+documentation
+"
+    Instances are used temporarily by the UISpecification to keep dynamic
+    properties for a view.
+    For example, all the callbacks used by the drag & drop operation are
+    stored.
+
+    [author:]
+        Claus Atzkern
+
+    [see also:]
+        UISpecification
+"
+! !
+
+!PropertyListDictionary methodsFor:'accessing'!
+
+at:aKey
+    "returns the value stored under the key or nil
+    "
+    ^ self at:aKey ifAbsent:nil
+!
+
+dropSourceFor:aReceiver
+    "returns the DropSource for a receiver or nil
+    "
+    |source|
+
+    self canDrag ifTrue:[
+        source := DropSource receiver:aReceiver
+                             argument:(self at:#dragArgument:)
+                   dropObjectSelector:(self at:#dropObjectSelector:)
+                displayObjectSelector:(self at:#displayObjectSelector:)
+                     feedBackSelector:(self at:#feedBackSelector:).
+
+        source startDragSelector:(self at:#startDragSelector:).
+        ^ source
+    ].
+    ^ nil
+!
+
+dropTargetFor:aReceiver
+    "returns the DropTarget for a receiver or nil
+    "
+    |target|
+
+    self canDrop ifTrue:[
+        target := DropTarget receiver:aReceiver
+                             argument:(self at:#dropArgument:)
+                         dropSelector:(self at:#dropSelector:) 
+                      canDropSelector:(self at:#canDropSelector:).
+
+        target enterSelector:(self at:#enterSelector:).
+        target  overSelector:(self at:#overSelector:).
+        target leaveSelector:(self at:#leaveSelector:).
+      ^ target
+    ].
+    ^ nil
+
+! !
+
+!PropertyListDictionary methodsFor:'building'!
+
+actionSelectors
+    "returns the list of action selectors 
+    "
+    |list|
+
+    list := OrderedCollection new.
+
+    self keysAndValuesDo:[:aKey :aVal|
+        (aVal isSymbol and:[self isActionSelector:aKey]) ifTrue:[
+            list add:aVal
+        ]
+    ].
+    ^ list        
+!
+
+aspectSelectors
+    "returns the list of aspect selectors or nil 
+    "
+    ^ nil        
+! !
+
+!PropertyListDictionary methodsFor:'converting'!
+
+fromLiteralArrayEncoding:aLiteralEncodedArray
+    "read my values from an encoding
+    "
+    |key val|
+
+    2 to:aLiteralEncodedArray size by:2 do:[:i |
+        key := aLiteralEncodedArray at:i.
+        val := (aLiteralEncodedArray at:i+1) decodeAsLiteralArray.
+
+        self at:key put:val
+    ]
+
+!
+
+literalArrayEncoding
+    "encode myself as an array, from which a copy of the receiver
+     can be reconstructed with #decodeAsLiteralArray.
+    "
+    |coll|
+
+    coll := OrderedCollection new.
+    coll add:(self class name asSymbol).
+
+    self keysAndValuesDo:[:aKey :aVal|
+        coll add:aKey; add:(aVal literalArrayEncoding)
+    ].
+    ^ coll asArray
+
+! !
+
+!PropertyListDictionary methodsFor:'queries'!
+
+canDrag
+    "returns true if the receiver of the property list is draggable
+    "
+    ^ self includesKey:#dropObjectSelector:
+!
+
+canDrop
+    "returns true if the receiver of the property list is droppable
+    "
+    ^ self includesKey:#dropSelector:
+!
+
+isActionSelector:aKey
+    "returns true if the key is an action selector
+    "
+    ^ (     aKey ~~ #dragArgument:
+       and:[aKey ~~ #dropArgument:]
+      )
+! !
+
+!PropertyListDictionary class methodsFor:'documentation'!
+
+version
+    ^ '$Header: /cvs/stx/stx/libview2/PropertyListDictionary.st,v 1.1 1998-03-31 07:48:29 ca Exp $'
+! !