ImageEditor.st
changeset 2339 a06d19fe7b32
parent 2308 60722577a10a
child 2354 15be12f5e320
--- a/ImageEditor.st	Mon May 19 16:50:19 2008 +0200
+++ b/ImageEditor.st	Mon May 19 21:16:33 2008 +0200
@@ -2907,12 +2907,16 @@
 imagePreView
     "returns the preview of the image"
 
+    |imagePreViewSubViews|
+
+    imagePreViewSubViews := (self componentAt: #imagePreView) subViews.
+
     "subViews is an empty array at closing image Editor"
-    (self componentAt: #imagePreView) subViews isEmptyOrNil ifTrue:[
+    imagePreViewSubViews isEmptyOrNil ifTrue:[
         ^ nil
     ].
 
-    ^ (self componentAt: #imagePreView) subViews first 
+    ^ imagePreViewSubViews first 
 ! !
 
 !ImageEditor methodsFor:'aspects'!
@@ -3440,6 +3444,42 @@
     ^ aColor
 ! !
 
+!ImageEditor methodsFor:'drag & drop'!
+
+canDropObjects:aCollectionOfDropObjects in:aWidget
+    ^ (aCollectionOfDropObjects size == 1) 
+      and:[ aCollectionOfDropObjects 
+                contains:[:dropObject | dropObject isFileObject]]
+!
+
+dropObjects:aCollectionOfDropObjects in:aWidget at:position
+    |dropObject|
+
+    dropObject := aCollectionOfDropObjects first.
+    dropObject isFileObject ifTrue:[
+        self loadFromFile:dropObject asFilename.
+    ]
+! !
+
+!ImageEditor methodsFor:'event handling'!
+
+processEvent:anEvent
+    "Return true, if I have eaten the event"
+
+    |p|
+
+    anEvent view == self imagePreView ifTrue:[
+        ((anEvent isButtonPressEvent and:[ anEvent button == 1 ])
+        or:[ anEvent isButtonMotionEvent and:[ anEvent hasButton1 ]])  ifTrue:[
+            p := anEvent x @ anEvent y.
+            p := anEvent view transformation applyInverseTo:p.
+            self imageEditView scrollToMakeVisible:p.    
+            ^ true.
+        ].
+    ].
+    ^ false.
+! !
+
 !ImageEditor methodsFor:'help'!
 
 defaultInfoLabel
@@ -3495,7 +3535,7 @@
     "Modified: / 16.3.1999 / 21:44:41 / cg"
 !
 
-loadFromFile: aFileName
+loadFromFile:aFileName
     "loads an image from aFileName and sets up color map list and other info labels"
 
     self withCursor:Cursor wait do:[
@@ -3798,8 +3838,7 @@
     super postOpenWith:aBuilder.
 
     aBuilder keyboardProcessor menuBar:nil.
-
-    "Modified: / 10.2.2000 / 23:17:43 / cg"
+    self windowGroup addPreEventHook:self.
 ! !
 
 !ImageEditor methodsFor:'user actions-colormap'!