TabView.st
author Claus Gittinger <cg@exept.de>
Tue, 01 Jul 2003 10:51:51 +0200
changeset 2531 2f38bbea4b36
parent 1401 e92d55efca08
child 3902 ff89bd4a8992
permissions -rw-r--r--
*** empty log message ***

"
 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:libwidg2' }"

NoteBookView subclass:#TabView
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Views-Interactors'
!

!TabView 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
"
    implements the tabs-view component of a noteBook.
    May also be used on its own (without a surrounding noteBook).

    The functionality is basically the same as provided by a
    PopUpList or SelectionInListView, in that a valueHolder
    gets a value assigned corresponding to the selected tab
    from a list of possible tabs.

    [author:]
	Claus Atzkern

    [see also:]
	NoteBookView
	SelectionInListView PopUpList ValueHolder TabWidget
"

!

examples
"
    tabs at top of a view
                                                                                [exBegin]                                      
    |top tab view inset|

    top := StandardSystemView new label:'tabs at top'; extent:250@100.
    tab  := TabView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
    ' view := View    origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.                     '. 

    tab direction:#top.
    tab list:#( 'Foo' 'Bar' 'Baz' ).
    ' inset := tab preferredSizeXorY .  '.
    ' tab  bottomInset:(inset negated). '.
    ' view topInset:inset.              '.
    tab action:[:aName|Transcript showCR:aName].
    top open.
                                                                                [exEnd]

    tabs at bottom of a view; changing widget to MAC style
                                                                                [exBegin]                                      
    |top tab view inset|

    top := StandardSystemView new label:'tabs at bottom'; extent:250@100.
    view := View    origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
    tab  := TabView origin:0.0 @ 1.0 corner:1.0 @ 1.0 in:top.

    view viewBackground:(tab styleAt:#selectedColor).
    tab direction:#bottom.
    tab tabWidget:#Mac.

    tab list:#( 'Foo' 'Bar' 'Baz' ).
    inset := tab preferredSizeXorY.
    tab  topInset:(inset negated).
    view bottomInset:inset.
    tab action:[:aName|Transcript showCR:aName].
    top open.
                                                                                [exEnd]

    tabs at right of a view
                                                                                [exBegin]                                      
    |top tab view inset|

    top := StandardSystemView new label:'tabs at right'; extent:100@250.
    view := View    origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
    tab  := TabView origin:1.0 @ 0.0 corner:1.0 @ 1.0 in:top.

    view viewBackground:(tab styleAt:#selectedColor).
    tab direction:#right.
    tab list:#( 'Foo' 'Bar' 'Baz' ).
    inset := tab preferredSizeXorY.
    tab leftInset:(inset negated).
    view rightInset:inset.
    tab action:[:aName|Transcript showCR:aName].
    top open.
                                                                                [exEnd]

    tabs at left of a view
                                                                                [exBegin]                                      
    |top tab view inset|

    top := StandardSystemView new label:'tabs at left'; extent:100@250.
    tab  := TabView origin:0.0 @ 0.0 corner:0.0 @ 1.0 in:top.
    view := View    origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.

    view viewBackground:(tab styleAt:#selectedColor).
    tab direction:#left.
    tab list:#( 'Foo' 'Bar' 'Baz' ).
    inset := tab preferredSizeXorY.
    tab rightInset:(inset negated).
    view leftInset:inset.
    tab action:[:aName|Transcript showCR:aName].
    top open.
                                                                                [exEnd]

    changing default style( see TabWidget class ); useing index
                                                                                [exBegin]                                      
    |top tab view|

    top := StandardSystemView new label:'example'; extent:450@300.
    tab := TabView origin:0.0 @ 0.0 corner:1.0 @ 40 in:top.
    tab horizontalInset:10.
    view := NoteBookFrameView origin:0.0 @ 40  corner:1.0 @ 1.0 in:top.
    view horizontalInset:10.
    view bottomInset:10.
    view level:2.
    view viewBackground:(Image fromFile:'bitmaps/gifImages/garfield.gif').

    tab styleAt:#selectedColor    put:(view viewBackground).
    tab styleAt:#unselectedColor  put:(Color grey:60).
    tab styleAt:#expandSelection  put:9@7.

    tab list:#( 'Foo' 'Bar' 'Baz').
    tab useIndex:true.
    tab action:[:aName| Transcript showCR:aName ].

    top open.
                                                                                [exEnd]


    using images and text
                                                                                [exBegin]
    |top tab view list|

    top := StandardSystemView new label:'example'.
    tab := TabView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
    list := #( 'SBrowser' 'FBrowser' 'Debugger' ).
    list := list collect:[:n | Image fromFile:'bitmaps/' , n , '.xbm'].
    list add:'A Text'.
    tab list:list.
    tab action:[:indexOrNil| Transcript showCR:indexOrNil ].
    top extent:(tab preferredExtent).
    top open.
                                                                                [exEnd]

    using images and text; MAC style
                                                                                [exBegin]
    |top tab view list|

    top := StandardSystemView new label:'example'.
    tab := TabView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
    tab tabWidget:#Mac.
    list := #( 'SBrowser' 'FBrowser' 'Debugger' ).
    list := list collect:[:n | Image fromFile:'bitmaps/' , n , '.xbm'].
    list add:'A Text'.
    tab list:list.
    tab action:[:indexOrNil| Transcript showCR:indexOrNil ].
    top extent:(tab preferredExtent).
    top open.
                                                                                [exEnd]

    tabs at top of view dealing with other models

                                                                                [exBegin]
    |top sel view l top2 s top3 p|

    l := SelectionInList new.
    l list:#('foo' 'bar' 'baz').
    l selectionIndex:1.

    top2 := StandardSystemView new.
    top2 extent:100@100.
    s := SelectionInListView origin:0.0@0.0 corner:1.0@1.0 in:top2.
    s model:l.
    top2 open.

    top3 := StandardSystemView new.
    top3 extent:100@100.
    s := PopUpList in:top3.
    s model:l.
    top3 open.

    top := StandardSystemView new label:'example'; extent:200@50.
    sel := TabView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
    sel useIndex:true.
    sel model:(l selectionIndexHolder).
    sel listHolder:(l listHolder).
    sel action:[:indexOrNil|Transcript showCR:indexOrNil].
    top open.
                                                                                [exEnd]
"
! !

!TabView methodsFor:'initialization'!

initStyle
    "setup style attributes
    "

    super initStyle.
    tabModus := true.


! !

!TabView class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libwidg2/TabView.st,v 1.47 2003-07-01 08:51:51 cg Exp $'
! !