added comments & docu
authorClaus Gittinger <cg@exept.de>
Sat, 19 Apr 1997 15:44:35 +0200
changeset 546 a71c15f2330c
parent 545 0b9d704baeae
child 547 7764165d89b8
added comments & docu
DropObject.st
--- a/DropObject.st	Fri Apr 18 20:16:30 1997 +0200
+++ b/DropObject.st	Sat Apr 19 15:44:35 1997 +0200
@@ -1,3 +1,17 @@
+"
+ COPYRIGHT (c) 1997 by eXept Software AG
+              All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+
+
+
 Object subclass:#DropObject
 	instanceVariableNames:'theObject'
 	classVariableNames:''
@@ -14,14 +28,7 @@
 "
 !
 
-DropObject subclass:#File
-	instanceVariableNames:'info isHtmlFile isImageFile isPrintable'
-	classVariableNames:''
-	poolDictionaries:''
-	privateIn:DropObject
-!
-
-DropObject subclass:#Color
+DropObject subclass:#Text
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
@@ -35,13 +42,52 @@
 	privateIn:DropObject
 !
 
-DropObject subclass:#Text
+DropObject subclass:#Color
 	instanceVariableNames:''
 	classVariableNames:''
 	poolDictionaries:''
 	privateIn:DropObject
 !
 
+DropObject subclass:#File
+	instanceVariableNames:'info isHtmlFile isImageFile isPrintable'
+	classVariableNames:''
+	poolDictionaries:''
+	privateIn:DropObject
+!
+
+!DropObject class methodsFor:'documentation'!
+
+copyright
+"
+ COPYRIGHT (c) 1997 by eXept Software AG
+              All Rights Reserved
+
+ This software is furnished under a license and may be used
+ only in accordance with the terms of that license and with the
+ inclusion of the above copyright notice.   This software may not
+ be provided or otherwise made available to, or used by, any
+ other person.  No title to or ownership of the software is
+ hereby transferred.
+"
+
+
+!
+
+documentation
+"
+    instances of myself and subclasses wrap objects which are being
+    dragged (and dropped).
+    Any object can be dragged, but for some often encountered types,
+    specialized subclasses are provided, which react to certain queries.
+
+    [see also:]
+        DragAndDropManager
+
+    [author:]
+        Claus Atzkern
+"
+! !
 
 !DropObject class methodsFor:'instance creation'!
 
@@ -80,81 +126,196 @@
 !DropObject class methodsFor:'defaults'!
 
 displayObject
+    "return some object which is shown while dragging;
+     here an image based upon my displayObjectName is returned.
+     Either this method or #displayObjectName is usually redefined
+     in subclasses"
 
     DisplayObject notNil ifTrue:[
         ^ DisplayObject
     ].
     DisplayObject := Smalltalk::Image fromFile:(self displayObjectName).
     ^ DisplayObject
+
+    "Modified: 19.4.1997 / 13:04:05 / cg"
+!
+
+displayObject:aDisplayObject
+    "set the object which is shown while dragging;
+     this object must understand #displayOn:x:y: (i.e. the displayObject
+     protocol). The object is kept per class for ALL future drag operations.
+     Useful to change the default images in subclasses."
+
+    DisplayObject := aDisplayObject
+
+    "Modified: 19.4.1997 / 15:42:10 / cg"
 !
 
 displayObjectName
+    "return the name of a bitmap image file, which is used 
+     during a drag.
+     Here, a dummy file is returned."
+
     ^ 'bitmaps/xpmBitmaps/plain_pixmaps/balloon3.xpm'
 
+    "Modified: 19.4.1997 / 13:54:13 / cg"
 ! !
 
 !DropObject methodsFor:'accessing'!
 
 theObject
-    "return the value of the instance variable 'theObject' (automatically generated)"
+    "return the real object represented by the receiver"
 
-    ^ theObject!
+    ^ theObject
+
+    "Modified: 19.4.1997 / 12:53:01 / cg"
+!
 
 theObject:something
-    "set the value of the instance variable 'theObject' (automatically generated)"
+    "set the real object represented by the receiver"
 
-    theObject := something.! !
+    theObject := something.
+
+    "Modified: 19.4.1997 / 12:53:10 / cg"
+! !
 
 !DropObject methodsFor:'queries'!
 
 displayObject
     "return my graphical representation - here a default is returned"
+
     ^ self class displayObject
+
+    "Modified: 19.4.1997 / 12:52:41 / cg"
 ! !
 
 !DropObject methodsFor:'testing'!
 
 isColorObject
+    "return true, if the dropObject represents a color"
+
     ^ false
+
+    "Modified: 19.4.1997 / 12:52:36 / cg"
 !
 
 isFileObject
+    "return true, if the dropObject represents some file or directory"
+
     ^ false
+
+    "Modified: 19.4.1997 / 12:52:29 / cg"
 !
 
 isImageObject
+    "return true, if the dropObject represents some image"
+
     ^ false
+
+    "Modified: 19.4.1997 / 12:52:22 / cg"
 !
 
 isTextObject
+    "return true, if the dropObject represents some text"
+
     ^ false
+
+    "Modified: 19.4.1997 / 12:52:17 / cg"
+! !
+
+!DropObject::Text class methodsFor:'defaults'!
+
+displayObjectName
+    ^ 'bitmaps/xpmBitmaps/document_images/yellow_file_text_grab.xpm'
+
+    "Modified: 19.4.1997 / 15:40:33 / cg"
+! !
+
+!DropObject::Text methodsFor:'testing'!
+
+isTextObject
+    "return true, if the dropObject represents some text"
+
+    ^ true
+
+    "Modified: 19.4.1997 / 12:52:08 / cg"
+! !
+
+!DropObject::Image class methodsFor:'defaults'!
+
+displayObjectName
+    "return the name of a bitmap image file, which is used 
+     during a drag."
+
+    ^ 'bitmaps/xpmBitmaps/misc_tools/picture.xpm'
+
+    "Modified: 19.4.1997 / 15:38:02 / cg"
+! !
+
+!DropObject::Image methodsFor:'testing'!
+
+isImageObject
+    "return true, if the dropObject represents an image"
+
+    ^ true
+
+    "Modified: 19.4.1997 / 12:51:28 / cg"
+! !
+
+!DropObject::Color class methodsFor:'defaults'!
+
+displayObjectName
+    "return the name of a bitmap image file, which is used 
+     during a drag."
+
+    ^ 'bitmaps/xpmBitmaps/misc_tools/color_wheel.xpm'
+
+    "Modified: 19.4.1997 / 15:38:12 / cg"
+! !
+
+!DropObject::Color methodsFor:'testing'!
+
+isColorObject
+    "return true, if the dropObject represents a color"
+
+    ^ true
+
+    "Modified: 19.4.1997 / 12:51:57 / cg"
 ! !
 
 !DropObject::File class methodsFor:'defaults'!
 
 displayObjectName
-    ^ 'bitmaps/xpmBitmaps/plain_pixmaps/xfm_file.xpm'
+    "return the name of a bitmap image file, which is used 
+     during a drag."
 
+    ^ 'bitmaps/xpmBitmaps/document_images/xfm_file.xpm'
 
+    "Modified: 19.4.1997 / 15:38:07 / cg"
 ! !
 
 !DropObject::File methodsFor:'accessing'!
 
 theObject:aPathname
-    |path|
+    |f path|
 
-    path := OperatingSystem pathNameOf:(aPathname asString).
-    info := OperatingSystem infoOf:path.
+    f := aPathname asFilename.
+    path := f pathName.
+    info := f info.
 
-    super theObject:(path asFilename)
+    super theObject:f
+
+    "Modified: 19.4.1997 / 12:49:17 / cg"
 ! !
 
 !DropObject::File methodsFor:'queries'!
 
 exists
-    "returns true if file exists
+    "returns true if the file or directory exists
     "
     ^ info notNil
+
+    "Modified: 19.4.1997 / 12:49:30 / cg"
 !
 
 isDirectory
@@ -164,7 +325,7 @@
 !
 
 isHtmlFile
-    "checks whether file is a html file
+    "checks whether file is an html file
     "
     |suffixes pathName|
 
@@ -178,24 +339,26 @@
         ]
     ].
     ^ isHtmlFile
+
+    "Modified: 19.4.1997 / 12:49:37 / cg"
 !
 
 isImageFile
-    "returns true if file is assigned to an image
+    "returns true if file is an image file
     "
-    |suffixes pathName|
+    |pathName|
 
     isImageFile isNil ifTrue:[
         (info isNil or:[self isDirectory]) ifTrue:[
             isImageFile := false
         ] ifFalse:[
             pathName    := theObject asString.
-            suffixes    := #( '.xpm' '.xbm' '.tiff' '.gif' '.bmp' '.ico' '.icon' ).
-            isImageFile := (suffixes findFirst:[:el|pathName endsWith:el]) ~~ 0
+            isImageFile := Image isImageFileSuffix:(pathName asFilename suffix).
         ]
     ].
     ^ isImageFile
 
+    "Modified: 19.4.1997 / 12:50:58 / cg"
 !
 
 isPrintable
@@ -228,61 +391,15 @@
 !DropObject::File methodsFor:'testing'!
 
 isFileObject
-    ^ true
-! !
-
-!DropObject::Color class methodsFor:'defaults'!
-
-displayObjectName
-    ^ 'bitmaps/xpmBitmaps/plain_pixmaps/paint2.xpm'
-
-
-
-
-
-! !
-
-!DropObject::Color methodsFor:'testing'!
+    "return true, if the dropObject represents a file- or directory"
 
-isColorObject
-    ^ true
-! !
-
-!DropObject::Image class methodsFor:'defaults'!
-
-displayObjectName
-    ^ 'bitmaps/xpmBitmaps/plain_pixmaps/hobbes.xpm'
-
-
-! !
-
-!DropObject::Image methodsFor:'testing'!
-
-isImageObject
     ^ true
 
-
-! !
-
-!DropObject::Text class methodsFor:'defaults'!
-
-displayObjectName
-    ^ 'bitmaps/xpmBitmaps/plain_pixmaps/xfm_text.xpm'
-
-
-
-! !
-
-!DropObject::Text methodsFor:'testing'!
-
-isTextObject
-    ^ true
-
-
+    "Modified: 19.4.1997 / 12:51:49 / cg"
 ! !
 
 !DropObject class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/DropObject.st,v 1.3 1997-02-03 09:12:22 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/DropObject.st,v 1.4 1997-04-19 13:44:35 cg Exp $'
 ! !