StrokingWrapper.st
author Claus Gittinger <cg@exept.de>
Thu, 09 May 1996 00:02:28 +0200
changeset 245 8d7f9a8d2c78
child 246 9f80dbcbcd34
permissions -rw-r--r--
intitial checkin

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


Wrapper subclass:#StrokingWrapper
	instanceVariableNames:'lineWidth'
	classVariableNames:''
	poolDictionaries:''
	category:'Graphics-Display Objects'
!

!StrokingWrapper 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
"
    a wrapper for a geometric object, which is to be drawn stroked.
    This allows any geometric thingy to be used as a component in a view.

    [author:]
        Claus Gittinger
"

!

examples
"
                                                                        [exBegin]
        |v e component|

        v := (View extent:250@250) openAndWait.

        e := EllipticalArc boundingBox:(10@10 corner:90@90)
                            startAngle:0 
                            sweepAngle:270.
        component := StrokingWrapper on:e.

        component displayOn:v.
                                                                        [exEnd]

                                                                        [exBegin]
        |v e component|

        v := View new.
        v extent:250@250.

        e := Rectangle origin:10@10 corner:90@90.
        component := FillingWrapper on:e.
        component foregroundColor:Color red.

        v addComponent:component.

        e := EllipticalArc boundingBox:(10@10 corner:90@90)
                         startAngle:0 sweepAngle:270.
        component := StrokingWrapper on:e.
        component lineWidth:5.

        v addComponent:component.

        v addComponent:(Button label:'hello').

        v open
                                                                        [exEnd]
"
! !

!StrokingWrapper methodsFor:'accessing'!

bounds
    ^ component bounds + (lineWidth - 1)

    "Created: 8.5.1996 / 23:22:43 / cg"
!

lineWidth
    ^ lineWidth

    "Created: 8.5.1996 / 23:22:04 / cg"
!

lineWidth:aNumber
    lineWidth := aNumber

    "Created: 8.5.1996 / 23:22:13 / cg"
!

preferredBounds
    ^ self bounds

    "Created: 8.5.1996 / 23:23:00 / cg"
! !

!StrokingWrapper methodsFor:'displaying'!

displayOn:aGC
    |prevLineWidth prevFg|

    prevLineWidth := aGC lineWidth.
    prevFg := aGC paint.

    aGC lineWidth:lineWidth.
    aGC paint:fgColor.

    component displayStrokedOn:aGC.

    aGC lineWidth:prevLineWidth.
    aGC paint:prevFg.

    "Created: 8.5.1996 / 23:24:04 / cg"
    "Modified: 8.5.1996 / 23:54:22 / cg"
! !

!StrokingWrapper methodsFor:'initialization'!

initialize
    super initialize.
    lineWidth := 1.

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

!StrokingWrapper class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview2/StrokingWrapper.st,v 1.1 1996-05-08 22:02:04 cg Exp $'
! !