WindowEvent.st
author claus
Mon, 10 Oct 1994 03:34:45 +0100
changeset 72 3e84121988c3
parent 54 29a6b2f8e042
child 78 1c9c22df3251
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 1993 by Claus Gittinger
	      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:#WindowEvent
	 instanceVariableNames:'view type arguments'
	 classVariableNames:''
	 poolDictionaries:''
	 category:'Interface-Support'
!

WindowEvent comment:'
COPYRIGHT (c) 1993 by Claus Gittinger
	      All Rights Reserved

$Header: /cvs/stx/stx/libview/WindowEvent.st,v 1.7 1994-10-10 02:33:48 claus Exp $
'!

!WindowEvent class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1993 by Claus Gittinger
	      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.
"
!

version
"
$Header: /cvs/stx/stx/libview/WindowEvent.st,v 1.7 1994-10-10 02:33:48 claus Exp $
"
!

documentation
"
    Instances of WindowEvent are created for every event coming from
    the graphics device, to be handled by a windowGroup. 
    Usually, they are queued by a sensor, and processed in some event loop
    in the window group.
"
! !

!WindowEvent class methodsFor:'instance creation'!

for:aView type:aSymbol arguments:argArray
    "create and return a new windowEvent for sending
     aSymbol-message with arguments to aView"

    ^ (self new) for:aView type:aSymbol arguments:argArray
!

for:aView type:aSymbol
    "create and return a new windowEvent for sending
     aSymbol-message with no arguments to aView"

    ^ (self new) for:aView type:aSymbol arguments:#()
!

damageFor:aView rectangle:aRectangle
    "create and return a new damage Event for aRectangle
     in aView"

    ^ (self new) for:aView type:#damage arguments:aRectangle

! !

!WindowEvent methodsFor:'queries'!

isKeyEvent
    "return true, if this event is a keyboard event"

    ^ (type == #keyPress:x:y) or:[type == #keyRelease:x:y]
!

isDamage
    "return true, if this is a damage event"

    ^ type == #damage
! !

!WindowEvent methodsFor:'accessing'!

view
    "return the view, for which the event is for"

    ^ view
!

view:aView
    "set the view, for which the event is for"

    view := aView
!

type
    "return the type of the event"

    ^ type
!

arguments
    "return the arguments of the event"

    ^ arguments
!

arguments:anArray
    "set the arguments"

    arguments := anArray
!

rectangle
    "return the damage rectangle"

    ^ arguments "consider this a kludge"
! !

!WindowEvent methodsFor:'sending'!

sendEvent
    "forward the event represented by the receiver to the view
     or delegate"

    |delegate selector|

"/    type == #keyPress:x:y: ifTrue:[
	"/
	"/ send it via the device, which does the key-mapping
	"/
"/        view device sendKeyPress:(arguments at:1)
"/                               x:(arguments at:2)
"/                               y:(arguments at:3)
"/                              to:view 
"/    ] ifFalse:[
	delegate := view delegate.
	delegate notNil ifTrue:[
	    "what a kludge - sending to delegate needs another
	     selector and an additional argument.
	     have to edit the selector ..."

	    (type endsWith:':') ifTrue:[
		selector := (type , 'view:') asSymbol.
	    ] ifFalse:[
		selector := (type , 'View:') asSymbol.
	    ].
	    arguments isNil ifTrue:[
		delegate perform:selector with:view
	    ] ifFalse:[
		delegate perform:selector withArguments:(arguments copyWith:view)
	    ]
	] ifFalse:[
	    view perform:type withArguments:arguments
	]
"/    ]
! !

!WindowEvent methodsFor:'private accessing'!

for:aView type:aSymbol arguments:argArray
    "set the instances of the window event"

    view := aView.
    type := aSymbol.
    arguments := argArray
! !