JavaView.st
author cg
Fri, 29 Jan 1999 15:30:31 +0000
changeset 545 6a841644c5e9
parent 491 5623ece3bf3c
child 563 a449d76e4182
permissions -rw-r--r--
checkin from browser

"
 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.
"



View subclass:#JavaView
	instanceVariableNames:'eventReceiver updateRegions javaPeer'
	classVariableNames:''
	poolDictionaries:''
	category:'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|

"/ 'JavaView buttonMotion' printCR.

    eventReceiver notNil ifTrue:[
        ev := WindowEvent buttonEvent
                 for:self
                 type:#buttonMotion:x:y:
                 arguments:(Array with:state with:x with:y).
        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).
        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).
        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 expose' 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
    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaView.st,v 1.18 1999/01/29 15:30:29 cg Exp $'
! !