Implement #displayOn: instead of #displayString
authorStefan Vogel <sv@exept.de>
Fri, 03 Aug 2012 17:53:14 +0200
changeset 4140 267c46c27c2a
parent 4139 77a120ffc684
child 4141 08e3afdffc2b
Implement #displayOn: instead of #displayString
TreeItem.st
--- a/TreeItem.st	Fri Aug 03 17:53:01 2012 +0200
+++ b/TreeItem.st	Fri Aug 03 17:53:14 2012 +0200
@@ -675,8 +675,25 @@
     ^ self name
 !
 
-displayString
-    ^ self class name , '(' , self printString , ')'
+displayOn:aGCOrStream
+    "Compatibility
+     append a printed desription on some stream (Dolphin,  Squeak)
+     OR:
+     display the receiver in a graphicsContext at 0@0 (ST80).
+     This method allows for any object to be displayed in some view
+     (although the fallBack is to display its printString ...)"
+
+    "/ what a kludge - Dolphin and Squeak mean: printOn: a stream;
+    "/ ST/X (and some old ST80's) mean: draw-yourself on a GC.
+    aGCOrStream isStream ifFalse:[
+        ^ super displayOn:aGCOrStream.
+    ].
+
+    aGCOrStream 
+        nextPutAll:self class name;
+        nextPut:$(.
+    self printOn:aGCOrStream. 
+    aGCOrStream nextPut:$)
 !
 
 printOn:aStream
@@ -1027,11 +1044,11 @@
 !TreeItem class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/TreeItem.st,v 1.50 2010-06-14 11:02:20 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TreeItem.st,v 1.51 2012-08-03 15:53:14 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libwidg2/TreeItem.st,v 1.50 2010-06-14 11:02:20 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TreeItem.st,v 1.51 2012-08-03 15:53:14 stefan Exp $'
 ! !
 
 TreeItem initialize!