Separator.st
author claus
Fri, 12 May 1995 20:34:25 +0200
changeset 56 aa651da467e2
child 62 378b60ba1200
permissions -rw-r--r--
.

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


'From Smalltalk/X, Version:2.10.5 on 11-may-1995 at 2:19:42 am'!

SimpleView subclass:#Separator
	 instanceVariableNames:'orientation'
	 classVariableNames:''
	 poolDictionaries:''
	 category:'Views-Layout'
!

!Separator class methodsFor:'documentation'!

examples
"
  a separator between two button-panels:

    |top p1 p2 sep|

    top := StandardSystemView new.
    top extent:300@300.

    p1 := VerticalPanelView origin:0.0@0.0 corner:1.0@0.5 in:top.
    p1 bottomInset:5; borderWidth:0.
    p2 := VerticalPanelView origin:0.0@0.5 corner:1.0@1.0 in:top.
    p2 topInset:5; borderWidth:0.

    (Button label:'one' in:p1) width:0.2.
    (Button label:'two' in:p1) width:0.2.
    (Button label:'three' in:p1) width:0.2.

    sep := Separator in:top.
    sep orientation:#horizontal.
    sep origin:0.0@0.5 extent:1.0@10.
    sep topInset:-5; bottomInset:-5.

    (Button label:'four' in:p2) width:0.2.
    (Button label:'five' in:p2) width:0.2.
    (Button label:'six' in:p2) width:0.2.

    top open


  vertical:

    |top p1 p2 sep|

    top := StandardSystemView new.
    top extent:300@300.

    p1 := VerticalPanelView origin:0.0@0.0 corner:0.5@1.0 in:top.
    p1 rightInset:5; borderWidth:0.
    p2 := VerticalPanelView origin:0.5@0.0 corner:1.0@1.0 in:top.
    p2 leftInset:5; borderWidth:0.

    (Button label:'one' in:p1) width:0.4.
    (Button label:'two' in:p1) width:0.4.
    (Button label:'three' in:p1) width:0.4.

    sep := Separator in:top.
    sep orientation:#vertical.
    sep origin:0.5@0.0 extent:10@1.0.
    sep leftInset:-5; rightInset:-5.

    (Button label:'four' in:p2) width:0.4.
    (Button label:'five' in:p2) width:0.4.
    (Button label:'six' in:p2) width:0.4.

    top open


  with multiple horizontal seps in a panel:

    |top p sep|

    top := StandardSystemView new.
    top extent:300@300.

    p := VerticalPanelView origin:0.0@0.0 corner:1.0@1.0 in:top.
    p verticalLayout:#spreadSpace.
    p horizontalLayout:#center.

    (Button label:'one' in:p).
    (Button label:'two' in:p).
    (Button label:'three' in:p).

    sep := Separator in:p.
    sep orientation:#horizontal.
    sep extent:0.9@10.

    (Button label:'four' in:p).
    (Button label:'five' in:p).

    sep := Separator in:p.
    sep orientation:#horizontal.
    sep extent:0.9@10.

    (Button label:'six' in:p).

    top open
"
!

copyright
"
 COPYRIGHT (c) 1995 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/libwidg2/Separator.st,v 1.1 1995-05-12 18:34:25 claus Exp $
"

!

documentation 
"
    a simple widget for a separating line. 
    To be placed between groups of other widgets.
"

! !

!Separator methodsFor:'drawing'!

redraw
    |vCenter hCenter is3D|

    self clear.
    vCenter := self height // 2.
    hCenter := self width // 2.

    is3D := StyleSheet is3D.

    self paint:shadowColor.
    orientation == #vertical ifTrue:[
        self displayLineFromX:hCenter y:0 toX:hCenter y:height-1.
        is3D ifTrue:[
            self paint:lightColor.
            self displayLineFromX:hCenter+1 y:0 toX:hCenter+1 y:height-1.
        ]
    ] ifFalse:[
        self displayLineFromX:0 y:vCenter toX:width-1 y:vCenter.
        is3D ifTrue:[
            self paint:lightColor.
            self displayLineFromX:0 y:vCenter+1 toX:width-1 y:vCenter+1.
        ]
    ]
! !

!Separator methodsFor:'accessing'!

orientation:aSymbol
    "set the orientation to one of #horizontal or #vertical"

    orientation := aSymbol
! !

!Separator methodsFor:'initialization'!

initialize
    super initialize.
    borderWidth := 0
! !