src/JavaView.st
branchjk_new_structure
changeset 752 ff7bc6428c9c
child 877 f5a5b93e1c78
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/JavaView.st	Fri Apr 08 12:02:36 2011 +0000
@@ -0,0 +1,260 @@
+"
+ 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.
+"
+"{ Package: 'stx:libjava' }"
+
+View subclass:#JavaView
+	instanceVariableNames:'eventReceiver updateRegions javaPeer'
+	classVariableNames:''
+	poolDictionaries:''
+	category:'Languages-Java-Views-Support'
+!
+
+!JavaView 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
+"
+    [Author:]
+        Claus Gittinger
+"
+
+
+! !
+
+!JavaView methodsFor:'accessing'!
+
+delegate:anObject
+    super delegate:anObject.
+    eventReceiver := anObject.
+
+    "Created: 18.8.1997 / 15:22:20 / cg"
+!
+
+getNextUpdateRectangle
+    |r|
+
+    updateRegions size == 0 ifTrue:[^ nil].
+    r := updateRegions removeFirst.
+    updateRegions size == 0 ifTrue:[updateRegions := nil].
+    ^ r
+
+    "Created: 18.8.1997 / 15:37:31 / cg"
+!
+
+javaPeer
+    "for debugging support - here is a handle to the corresponding
+     javaPeer"
+
+    ^ javaPeer
+
+    "Created: 18.8.1997 / 22:34:35 / cg"
+!
+
+javaPeer:aJavaView
+    "for debugging support - here is a handle to the corresponding
+     javaPeer"
+
+    javaPeer := aJavaView
+
+    "Created: 18.8.1997 / 22:34:30 / cg"
+! !
+
+!JavaView methodsFor:'event handling'!
+
+buttonMotion:state x:x y:y
+    "/ req'd if running as embeddedApplet ...
+
+    |ev sensor|
+
+"/ 'JavaView buttonMotion' printCR.
+
+    sensor := self sensor.    
+    eventReceiver notNil ifTrue:[
+        ev := WindowEvent buttonEvent
+                 for:self
+                 type:#buttonMotion:x:y:
+                 arguments:(Array with:state with:x with:y).
+        ev hasShift:sensor shiftDown
+           ctrl:sensor ctrlDown
+           alt:sensor altDown      
+           meta:sensor metaDown
+           button1:sensor leftButtonPressed
+           button2:sensor middleButtonPressed 
+           button3:sensor rightButtonPressed.
+        eventReceiver processEvent:ev.
+    ].
+
+    "Modified: / 12.11.1998 / 16:30:50 / cg"
+    "Created: / 10.12.1998 / 19:35:40 / cg"
+!
+
+buttonPress:button x:x y:y
+    "/ req'd if running as embeddedApplet ...
+
+    |ev|
+
+"/ 'JavaView buttonPress' printCR.
+
+    eventReceiver notNil ifTrue:[
+        ev := WindowEvent buttonEvent
+                 for:self
+                 type:#buttonPress:x:y:
+                 arguments:(Array with:button with:x with:y).
+        ev hasShift:self sensor shiftDown
+           ctrl:self sensor ctrlDown
+           alt:self sensor altDown      
+           meta:self sensor metaDown
+           button1:self sensor leftButtonPressed
+           button2:self sensor middleButtonPressed 
+           button3:self sensor rightButtonPressed.
+        eventReceiver processEvent:ev.
+    ].
+
+    "Modified: / 6.2.1998 / 00:56:56 / cg"
+    "Created: / 10.12.1998 / 19:35:58 / cg"
+!
+
+buttonRelease:button x:x y:y
+    "/ req'd if running as embeddedApplet ...
+
+    |ev|
+
+"/ 'JavaView buttonRelease' printCR.
+
+    eventReceiver notNil ifTrue:[
+        ev := WindowEvent buttonEvent
+                 for:self
+                 type:#buttonRelease:x:y:
+                 arguments:(Array with:button with:x with:y).
+
+        ev hasShift:self sensor shiftDown
+           ctrl:self sensor ctrlDown
+           alt:self sensor altDown      
+           meta:self sensor metaDown
+           button1:self sensor leftButtonPressed
+           button2:self sensor middleButtonPressed 
+           button3:self sensor rightButtonPressed.
+        eventReceiver processEvent:ev.
+    ].
+
+    "Modified: / 6.2.1998 / 00:57:00 / cg"
+    "Created: / 10.12.1998 / 19:36:11 / cg"
+!
+
+exposeX:x y:y width:w height:h
+    |ev rect|
+
+    rect := Rectangle left:x top:y width:w height:h.
+
+"/ ('JavaView exposeX:' , x printString , ' y:' , y printString , ' width:' , w printString , ' height:' , h printString) printCR.
+
+    updateRegions isNil ifTrue:[
+        updateRegions := OrderedCollection new.
+    ].
+    updateRegions add:rect.
+    eventReceiver notNil ifTrue:[
+        ev := WindowEvent 
+                damageFor:self 
+                rectangle:rect. 
+        eventReceiver processEvent:ev.
+    ].
+"/    super exposeX:x y:y width:w height:h
+
+    "Created: / 18.8.1997 / 15:00:24 / cg"
+    "Modified: / 19.10.1998 / 23:10:15 / cg"
+!
+
+keyPress:key x:x y:y
+    "/ req'd if running as embeddedApplet ...
+
+    |ev|
+
+"/ 'JavaView keyPress' printCR.
+
+    eventReceiver notNil ifTrue:[
+        ev := WindowEvent keyboardEvent
+                 for:self
+                 type:#keyPress:x:y:
+                 arguments:(Array with:key with:x with:y).
+        eventReceiver processEvent:ev.
+    ].
+
+    "Modified: / 6.2.1998 / 00:57:08 / cg"
+    "Created: / 10.12.1998 / 19:36:24 / cg"
+!
+
+keyRelease:key x:x y:y
+    "/ req'd if running as embeddedApplet ...
+
+    |ev|
+
+"/ 'JavaView keyRelease' printCR.
+
+    eventReceiver notNil ifTrue:[
+        ev := WindowEvent keyboardEvent
+                 for:self
+                 type:#keyRelease:x:y:
+                 arguments:(Array with:key with:x with:y).
+        eventReceiver processEvent:ev.
+    ].
+
+    "Modified: / 6.2.1998 / 00:57:16 / cg"
+    "Created: / 10.12.1998 / 19:36:38 / cg"
+! !
+
+!JavaView methodsFor:'initialization'!
+
+initialize
+    super initialize.
+
+    self enableMotionEvents.
+    (superView notNil and:[superView isMemberOf:JavaEmbeddedFrameView])
+    ifTrue:[
+        self viewBackground:superView viewBackground
+    ]
+
+    "Created: / 21.8.1997 / 16:37:45 / cg"
+    "Modified: / 13.1.1998 / 14:29:30 / cg"
+! !
+
+!JavaView methodsFor:'queries'!
+
+isJavaView
+    ^ true
+
+    "Created: / 4.12.1998 / 14:09:30 / cg"
+! !
+
+!JavaView class methodsFor:'documentation'!
+
+version
+    ^ '$Id$'
+!
+
+version_SVN
+    ^ '$Id$'
+! !