VisualComponent.st
author Claus Gittinger <cg@exept.de>
Sun, 26 May 1996 13:28:16 +0200
changeset 274 434f1bc78362
parent 266 e9d35cd74f64
child 290 d26dc55ac7e4
permissions -rw-r--r--
category changes

"
 COPYRIGHT (c) 1996 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:#VisualComponent
	instanceVariableNames:'bounds fgColor bgColor'
	classVariableNames:''
	poolDictionaries:''
	category:'Graphics-Display Objects'
!

!VisualComponent class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1996 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.
"


!

documentation
"
    abstract superclass for all kinds of visual components.
    This class and its subclasses (currently) exist mostly for
    ST-80 compatibility - to provide a home for ported PD classes,
    which depend on the VisualComponent hierarchy.

    Notice: 
        this class was implemented using protocol information
        from alpha testers and from the Hopkins/Horan book.
        - it may not be complete or compatible to the corresponding ST-80 class. 
        If you encounter any incompatibilities, please forward a note 
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
        This is still being constructed - not yet finished.

    [author:]
        Claus Gittinger

    [see also:]
        GeometricWrapper
"

! !

!VisualComponent class methodsFor:'instance creation'!

new
    ^ self basicNew initialize
! !

!VisualComponent methodsFor:'accessing'!

container:someContainer
    "ignored here"

    "Created: 9.5.1996 / 00:48:54 / cg"
!

setParentViewIn:aView
    "ignored here - for now"

    "Created: 9.5.1996 / 00:19:39 / cg"
! !

!VisualComponent methodsFor:'accessing - dimensions'!

bottom
    "return my bottom y coordinate"

    ^ self bounds bottom

    "Modified: 9.5.1996 / 00:13:12 / cg"
    "Created: 26.5.1996 / 12:56:12 / cg"
!

bounds
    "return my bounds"

    ^ bounds

    "Created: 8.5.1996 / 23:35:19 / cg"
    "Modified: 9.5.1996 / 00:12:00 / cg"
!

bounds:aRectangle
    "set my bounds"

    bounds := aRectangle

    "Created: 8.5.1996 / 23:36:07 / cg"
    "Modified: 9.5.1996 / 00:13:12 / cg"
!

left
    "return my left x coordinate"

    ^ self bounds left

    "Created: 8.5.1996 / 23:36:07 / cg"
    "Modified: 26.5.1996 / 12:56:22 / cg"
!

preferredBounds
    "return my preferredBounds"

    ^ 100@100

    "Created: 8.5.1996 / 23:36:29 / cg"
    "Modified: 9.5.1996 / 00:13:22 / cg"
!

right
    "return my right x coordinate"

    ^ self bounds right

    "Modified: 9.5.1996 / 00:13:12 / cg"
    "Created: 26.5.1996 / 12:56:25 / cg"
!

top
    "return my top y coordinate"

    ^ self bounds top

    "Modified: 9.5.1996 / 00:13:12 / cg"
    "Created: 26.5.1996 / 12:56:15 / cg"
! !

!VisualComponent methodsFor:'accessing - look'!

backgroundColor:aColor
    "set my backgroundColor"

    bgColor := aColor

    "Created: 8.5.1996 / 23:47:11 / cg"
    "Modified: 9.5.1996 / 00:13:33 / cg"
!

foregroundColor:aColor
    "set my foregroundColor"

    fgColor := aColor

    "Created: 8.5.1996 / 23:47:05 / cg"
    "Modified: 9.5.1996 / 00:13:39 / cg"
! !

!VisualComponent methodsFor:'displaying'!

displayOn:aGC x:x y:y
    |oldTranslation|

    oldTranslation := aGC translation.
    aGC translation:(x @ y).

    self displayOn:aGC.

    aGC translation:oldTranslation

    "Created: 13.5.1996 / 10:18:43 / cg"
    "Modified: 13.5.1996 / 11:18:24 / cg"
! !

!VisualComponent methodsFor:'event handling'!

buttonPress:button x:x y:y
    "button was pressed over me - ignored here"

    "Modified: 9.5.1996 / 00:14:08 / cg"
!

buttonRelease:button x:x y:y
    "button was released over me - ignored here"

    "Created: 8.5.1996 / 23:38:30 / cg"
    "Modified: 9.5.1996 / 00:14:04 / cg"
!

keyPress:key x:x y:y
    "key was pressed over me - ignored here"

    "Created: 8.5.1996 / 23:46:03 / cg"
    "Modified: 9.5.1996 / 00:14:14 / cg"
!

keyRelease:key x:x y:y
    "key was released over me - ignored here"

    "Created: 8.5.1996 / 23:46:07 / cg"
    "Modified: 9.5.1996 / 00:14:19 / cg"
! !

!VisualComponent methodsFor:'initialization'!

initialize
    fgColor := Color black.
    bgColor := Color white.

    "Created: 8.5.1996 / 23:49:54 / cg"
! !

!VisualComponent methodsFor:'queries'!

heightOn:aGC
    "return my height, if displayed on aGC;
     I assume that my height is independent of the device, and return
     the bounds height"

    ^ self bounds height

    "Modified: 13.5.1996 / 10:15:13 / cg"
!

widthOn:aGC
    "return my width, if displayed on aGC;
     I assume that my width is independent of the device, and return
     the bounds width"

    ^ self bounds width

    "Created: 13.5.1996 / 10:14:44 / cg"
    "Modified: 13.5.1996 / 10:15:17 / cg"
! !

!VisualComponent methodsFor:'testing'!

containsPoint:aPoint
    "return true, if the receiver contains aPoint"

    ^ self bounds containsPoint:aPoint

    "Created: 9.5.1996 / 00:21:44 / cg"
    "Modified: 9.5.1996 / 00:22:00 / cg"
!

hasBorder
    "return true, if the receiver shows a border"

    ^ false

    "Modified: 9.5.1996 / 00:21:29 / cg"
!

intersects:aRectangle
    "return true, if the receivers bounds intersects aRectangle"

    ^ self bounds intersects:aRectangle

    "Created: 9.5.1996 / 00:21:18 / cg"
    "Modified: 9.5.1996 / 00:22:04 / cg"
! !

!VisualComponent class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview2/VisualComponent.st,v 1.7 1996-05-26 11:28:16 cg Exp $'
! !