Border.st
author Claus Gittinger <cg@exept.de>
Wed, 02 Feb 2011 01:42:47 +0100
changeset 5696 30f4730112b7
parent 5457 c763a1cd9286
child 6714 08b320104918
permissions -rw-r--r--
automatically generated by 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.
"
"{ Package: 'stx:libview' }"

AbstractBorder subclass:#Border
	instanceVariableNames:'leftColor rightColor topColor bottomColor'
	classVariableNames:''
	poolDictionaries:''
	category:'Graphics-Support'
!

!Border 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
"
    a border holds the values of a view's (or component's) border.
    We have only recently started to change the system to use borders instead of separate
    borderWidth, borderColor, level, shadow- and lightColors.
    Expect more changes here in the near future..

    [see also:]
        SimpleView

    [author:]
        Claus Gittinger
"
!

examples
"
							[exBegin]
     |v b|

     v := StandardSystemView extent:10@10.
     v openAndWait.

     b := Border width:2 color:Color red.
     b displayOn:v forDisplayBox:(0@0 corner:9@9).

     Delay waitForSeconds:1.
     b setLeftColor:Color blue.
     b displayOn:v forDisplayBox:(0@0 corner:9@9).
     Delay waitForSeconds:1.
     b setTopColor:Color green.
     b displayOn:v forDisplayBox:(0@0 corner:9@9).
     Delay waitForSeconds:1.
     b setRightColor:Color magenta.
     b displayOn:v forDisplayBox:(0@0 corner:9@9).
							[exEnd]

							[exBegin]
     |v b|

     v := StandardSystemView extent:100@100.
     v openAndWait.

     b := Border width:2 color:Color red.
     b displayOn:v forDisplayBox:(0@0 corner:99@99).

     Delay waitForSeconds:1.
     b setLeft:5.
     v clear.
     b displayOn:v forDisplayBox:(0@0 corner:99@99).
     Delay waitForSeconds:1.
     b setTop:3.
     v clear.
     b displayOn:v forDisplayBox:(0@0 corner:99@99).
     Delay waitForSeconds:1.
     b setRight:1.
     v clear.
     b displayOn:v forDisplayBox:(0@0 corner:99@99).
							[exEnd]

							[exBegin]
     |v sub1 sub2 sub3|

     v := StandardSystemView extent:200@200.
     v openAndWait.

     sub1 := (View in:v) origin:10@10; corner:90@90.
     sub1 border:(SimpleBorder width:1 color:Color red ).
     sub2 := (View in:v) origin:110@10; corner:190@90.
     sub2 border:(Border new width:1; color:Color blue; leftColor:Color red rightColor:Color red ).
     sub3 := (View in:v) origin:110@110; corner:190@190.
     sub3 border:(SimpleBorder width:1 color:Color green ).

     v open.
							[exEnd]
"
! !

!Border methodsFor:'accessing'!

bottomColor
    "return the value of the instance variable 'bottomColor' (automatically generated)"

    ^ bottomColor

    "Created: 10.2.1997 / 14:51:34 / cg"
!

bottomColor:aColor
    "set the bottomColor"

    bottomColor := aColor

    "Created: 10.2.1997 / 15:37:51 / cg"
!

color:newColor
    "set all four colors"

     leftColor := rightColor := topColor := bottomColor := newColor

    "Created: 10.2.1997 / 15:27:01 / cg"
!

leftColor
    "return the value of the instance variable 'leftColor' (automatically generated)"

    ^ leftColor

    "Created: 10.2.1997 / 14:51:34 / cg"
!

leftColor:aColor
    "set the leftColor"

    leftColor := aColor

    "Created: 10.2.1997 / 15:38:02 / cg"
!

rightColor
    "return the value of the instance variable 'rightColor' (automatically generated)"

    ^ rightColor

    "Created: 10.2.1997 / 14:51:34 / cg"
!

rightColor:aColor
    "set the rightColor"

    rightColor := aColor

    "Created: 10.2.1997 / 15:38:08 / cg"
!

topColor
    "return the value of the instance variable 'topColor' (automatically generated)"

    ^ topColor

    "Created: 10.2.1997 / 14:51:34 / cg"
!

topColor:aColor
    "set the topColor"

    topColor := aColor

    "Created: 10.2.1997 / 15:38:17 / cg"
! !

!Border methodsFor:'displaying'!

displayOn:aGC forDisplayBox:aRectangle
    "display the border represented by the receiver in the given rectangle.
     colorSource is ignored here, but subclasses (i.e. 3D-borders) may use
     it to ask for shadow/lightColors.
     The gc's state is restored after the drawing."

    |paint oldPaint
     t r l b rL rR rT rB rW rH|

    width == 0 ifTrue:[ ^ self ].

    oldPaint := aGC paint.
    r := aRectangle copy.

    rL := aRectangle left.
    rT := aRectangle top.
    rR := aRectangle right.
    rB := aRectangle bottom.
    rH := aRectangle height.
    rW := aRectangle width.

    leftColor notNil ifTrue:[
        aGC paint:leftColor.
        aGC fillRectangleX:rL y:rT width:width height:rH + 1 - b
    ].

    topColor notNil ifTrue:[
        aGC paint:topColor.
        aGC fillRectangleX:(rL + l) y:rT width:rW - l height:width
    ].

    rightColor notNil ifTrue:[
        aGC paint:rightColor.
        aGC fillRectangleX:(rR - r) y:(rT + t) width:width height:rH + 1 - t
    ].

    bottomColor notNil ifTrue:[
        aGC paint:paint.
        aGC fillRectangleX:(rL) y:(rB + 1 - b) width:rW - r height:width
    ].

    aGC paint: oldPaint

    "Modified: 10.2.1997 / 15:55:04 / cg"
! !

!Border class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.9 2009-11-04 11:23:14 cg Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.9 2009-11-04 11:23:14 cg Exp $'
! !