TabView.st
author ca
Sat, 24 May 1997 05:10:11 +0200
changeset 391 c30e362f6c7d
parent 387 5b7a8d0fe86e
child 394 df57623d2918
permissions -rw-r--r--
handle enable notification
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
     1
"
dd49faa984ce intitial checkin
ca
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG
dd49faa984ce intitial checkin
ca
parents:
diff changeset
     3
              All Rights Reserved
dd49faa984ce intitial checkin
ca
parents:
diff changeset
     4
dd49faa984ce intitial checkin
ca
parents:
diff changeset
     5
 This software is furnished under a license and may be used
dd49faa984ce intitial checkin
ca
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
dd49faa984ce intitial checkin
ca
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
dd49faa984ce intitial checkin
ca
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
dd49faa984ce intitial checkin
ca
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    10
 hereby transferred.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    11
"
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    12
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    13
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    14
View subclass:#TabView
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
    15
	instanceVariableNames:'list listHolder selection enabled action tabStyle sizeChanged
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
    16
		useIndex maxRawNr direction fitLastRow moveSelectedRow
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
    17
		enableChannel'
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    18
	classVariableNames:''
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    19
	poolDictionaries:''
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    20
	category:'Views-Interactors'
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    21
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    22
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    23
!TabView class methodsFor:'documentation'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    24
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    25
copyright
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    26
"
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    27
 COPYRIGHT (c) 1997 by eXept Software AG
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    28
              All Rights Reserved
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    29
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    30
 This software is furnished under a license and may be used
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    35
 hereby transferred.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    36
"
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    37
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    38
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    39
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    40
documentation
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    41
"
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    42
    implements the tabs-view component of a noteBook.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    43
    May also be used on its own (without a surrounding noteBook).
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    44
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    45
    The functionality is basically the same as provided by a
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    46
    PopUpList or SelectionInListView, in that a valueHolder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    47
    gets a value assigned corresponding to the selected tab
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    48
    from a list of possible tabs.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    49
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    50
    [author:]
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    51
        Claus Atzkern
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    52
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    53
    [see also:]
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    54
        NoteBookView
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
    55
        SelectionInListView PopUpList ValueHolder TabWidget
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    56
"
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    57
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    58
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    59
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    60
examples
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    61
"
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    62
    tabs at top of a view
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    63
                                                                                [exBegin]                                      
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    64
    |top tab view inset|
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    65
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    66
    top := StandardSystemView new label:'tabs at top'; extent:250@100.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    67
    tab  := self origin:0.0 @ 0.0 corner:1.0 @ 0.0 in:top.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    68
    view := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    69
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    70
    view viewBackground:(tab styleAt:#selectedColor).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    71
    tab direction:#top.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    72
    tab list:#( 'Foo' 'Bar' 'Baz' ).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    73
    inset := tab preferredSizeXorY.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    74
    tab  bottomInset:(inset negated).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    75
    view topInset:inset.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    76
    tab action:[:aName|Transcript showCR:aName].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    77
    top open.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    78
                                                                                [exEnd]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    79
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    80
    tabs at bottom of a view; changing widget to MAC style
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    81
                                                                                [exBegin]                                      
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    82
    |top tab view inset|
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    83
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    84
    top := StandardSystemView new label:'tabs at bottom'; extent:250@100.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    85
    view := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    86
    tab  := self origin:0.0 @ 1.0 corner:1.0 @ 1.0 in:top.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    87
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    88
    view viewBackground:(tab styleAt:#selectedColor).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    89
    tab direction:#bottom.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    90
    tab tabWidget:#Mac.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    91
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    92
    tab list:#( 'Foo' 'Bar' 'Baz' ).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    93
    inset := tab preferredSizeXorY.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    94
    tab  topInset:(inset negated).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    95
    view bottomInset:inset.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    96
    tab action:[:aName|Transcript showCR:aName].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    97
    top open.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
    98
                                                                                [exEnd]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
    99
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   100
    tabs at right of a view
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   101
                                                                                [exBegin]                                      
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   102
    |top tab view inset|
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   103
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   104
    top := StandardSystemView new label:'tabs at right'; extent:100@250.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   105
    view := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   106
    tab  := self origin:1.0 @ 0.0 corner:1.0 @ 1.0 in:top.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   107
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   108
    view viewBackground:(tab styleAt:#selectedColor).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   109
    tab direction:#right.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   110
    tab list:#( 'Foo' 'Bar' 'Baz' ).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   111
    inset := tab preferredSizeXorY.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   112
    tab leftInset:(inset negated).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   113
    view rightInset:inset.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   114
    tab action:[:aName|Transcript showCR:aName].
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   115
    top open.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   116
                                                                                [exEnd]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   117
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   118
    tabs at left of a view
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   119
                                                                                [exBegin]                                      
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   120
    |top tab view inset|
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   121
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   122
    top := StandardSystemView new label:'tabs at left'; extent:100@250.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   123
    tab  := self origin:0.0 @ 0.0 corner:0.0 @ 1.0 in:top.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   124
    view := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   125
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   126
    view viewBackground:(tab styleAt:#selectedColor).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   127
    tab direction:#left.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   128
    tab list:#( 'Foo' 'Bar' 'Baz' ).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   129
    inset := tab preferredSizeXorY.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   130
    tab rightInset:(inset negated).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   131
    view leftInset:inset.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   132
    tab action:[:aName|Transcript showCR:aName].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   133
    top open.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   134
                                                                                [exEnd]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   135
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   136
    changing default style( see TabWidget class ); useing index
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   137
                                                                                [exBegin]                                      
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   138
    |top tab view|
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   139
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   140
    top := StandardSystemView new label:'example'; extent:450@300.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   141
    tab := self origin:0.0 @ 0.0 corner:1.0 @ 40 in:top.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   142
    tab horizontalInset:10.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   143
    view := NoteBookFrameView origin:0.0 @ 40  corner:1.0 @ 1.0 in:top.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   144
    view horizontalInset:10.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   145
    view bottomInset:10.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   146
    view level:2.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   147
    view viewBackground:(Image fromFile:'bitmaps/gifImages/garfield.gif').
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   148
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   149
    tab styleAt:#selectedColor    put:(view viewBackground).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   150
    tab styleAt:#unselectedColor  put:(Color grey:60).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   151
    tab styleAt:#expandSelection  put:9@7.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   152
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   153
    tab list:#( 'Foo' 'Bar' 'Baz').
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   154
    tab useIndex:true.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   155
    tab action:[:aName| Transcript showCR:aName ].
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   156
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   157
    top open.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   158
                                                                                [exEnd]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   159
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   160
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   161
    using images and text
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   162
                                                                                [exBegin]
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   163
    |top tab view list|
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   164
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   165
    top := StandardSystemView new label:'example'.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   166
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   167
    tab := self origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   168
    list := #( 'SBrowser' 'FBrowser' 'Debugger' ).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   169
    list := list collect:[:n | Image fromFile:'bitmaps/' , n , '.xbm'].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   170
    list add:'A Text'.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   171
    tab list:list.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   172
    tab action:[:indexOrNil| Transcript showCR:indexOrNil ].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   173
    top extent:(tab preferredExtent).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   174
    top open.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   175
                                                                                [exEnd]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   176
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   177
    using images and text; MAC style
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   178
                                                                                [exBegin]
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   179
    |top tab view list|
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   180
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   181
    top := StandardSystemView new label:'example'.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   182
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   183
    tab := self origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   184
    tab tabWidget:#Mac.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   185
    list := #( 'SBrowser' 'FBrowser' 'Debugger' ).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   186
    list := list collect:[:n | Image fromFile:'bitmaps/' , n , '.xbm'].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   187
    list add:'A Text'.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   188
    tab list:list.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   189
    tab action:[:indexOrNil| Transcript showCR:indexOrNil ].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   190
    top extent:(tab preferredExtent).
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   191
    top open.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   192
                                                                                [exEnd]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   193
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   194
    tabs at top of view dealing with other models
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   195
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   196
                                                                                [exBegin]
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   197
    |top sel view l top2 s top3 p|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   198
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   199
    l := SelectionInList new.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   200
    l list:#('foo' 'bar' 'baz').
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   201
    l selectionIndex:1.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   202
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   203
    top2 := StandardSystemView new.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   204
    top2 extent:100@100.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   205
    s := SelectionInListView origin:0.0@0.0 corner:1.0@1.0 in:top2.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   206
    s model:l.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   207
    top2 open.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   208
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   209
    top3 := StandardSystemView new.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   210
    top3 extent:100@100.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   211
    s := PopUpList in:top3.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   212
    s model:l.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   213
    top3 open.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   214
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   215
    top := StandardSystemView new
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   216
        label:'example';
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   217
        extent:200@50.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   218
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   219
    sel  := self origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   220
    sel useIndex:true.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   221
    sel model:(l selectionIndexHolder).
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   222
    sel listHolder:(l listHolder).
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   223
    sel action:[:indexOrNil|Transcript showCR:indexOrNil].
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   224
    top open.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   225
                                                                                [exEnd]
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   226
"
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   227
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   228
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   229
!TabView class methodsFor:'defaults'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   230
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   231
defaultTabWidget
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   232
    ^ #Window
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   233
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   234
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   235
!TabView class methodsFor:'tests'!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   236
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   237
testImages
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   238
    |topView view images top bottom left right x y xNeg yNeg last action|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   239
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   240
    topView := StandardSystemView new label:'images'; extent:(500 @ 500).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   241
    view    := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:topView.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   242
    top     := self origin:0.0 @ 0.0 corner:1.0 @ 0.0 in:topView.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   243
    bottom  := self origin:0.0 @ 1.0 corner:1.0 @ 1.0 in:topView.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   244
    left    := self origin:0.0 @ 0.0 corner:0.0 @ 1.0 in:topView.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   245
    right   := self origin:1.0 @ 0.0 corner:1.0 @ 1.0 in:topView.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   246
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   247
    view viewBackground:(top styleAt:#selectedColor).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   248
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   249
    top    direction:#top.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   250
    bottom direction:#bottom.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   251
    left   direction:#left.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   252
    right  direction:#right.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   253
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   254
    images := #( 'SBrowser' 'FBrowser' 'Debugger' ).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   255
    images := images collect:[:n| Image fromFile:'bitmaps/' , n , '.xbm'].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   256
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   257
    top    list:images.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   258
    bottom list:images.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   259
    left   list:images.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   260
    right  list:images.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   261
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   262
    x    := left preferredSizeXorY.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   263
    xNeg := x negated.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   264
    y    := top  preferredSizeXorY.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   265
    yNeg := y negated.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   266
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   267
    view  rightInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   268
    view   leftInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   269
    view bottomInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   270
    view    topInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   271
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   272
    last := top.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   273
    action := [:aTab||wdg|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   274
        last == aTab ifFalse:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   275
            last selection:nil.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   276
            last := aTab.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   277
            (aTab tabWidget) == #Mac ifTrue:[aTab tabWidget:#Window]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   278
                                    ifFalse:[aTab tabWidget:#Mac]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   279
        ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   280
    ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   281
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   282
    top bottomInset:yNeg.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   283
    top leftInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   284
    top rightInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   285
    top action:[:d|action value:top].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   286
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   287
    bottom topInset:yNeg.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   288
    bottom leftInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   289
    bottom rightInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   290
    bottom action:[:d|action value:bottom].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   291
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   292
    left rightInset:xNeg.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   293
    left topInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   294
    left bottomInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   295
    left action:[:d|action value:left].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   296
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   297
    right leftInset:xNeg.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   298
    right topInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   299
    right bottomInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   300
    right action:[:d|action value:right].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   301
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   302
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   303
    topView open.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   304
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   305
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   306
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   307
testStrings
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
   308
    "
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
   309
        TabView testStrings
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
   310
    "
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   311
    |topView view list top bottom left right x y xNeg yNeg last action|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   312
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   313
    topView := StandardSystemView new label:'strings'; extent:(400@400).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   314
    view    := View origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:topView.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   315
    top     := self origin:0.0 @ 0.0 corner:1.0 @ 0.0 in:topView.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   316
    bottom  := self origin:0.0 @ 1.0 corner:1.0 @ 1.0 in:topView.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   317
    left    := self origin:0.0 @ 0.0 corner:0.0 @ 1.0 in:topView.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   318
    right   := self origin:1.0 @ 0.0 corner:1.0 @ 1.0 in:topView.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   319
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   320
    view viewBackground:(top styleAt:#selectedColor).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   321
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   322
    top    direction:#top.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   323
    bottom direction:#bottom.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   324
    left   direction:#left.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   325
    right  direction:#right.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   326
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   327
    list := #( 'foo' 'bar' 'baz' 'gggg' ).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   328
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   329
    top    list:list.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   330
    bottom list:list.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   331
    left   list:list.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   332
    right  list:list.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   333
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   334
    x    := left preferredSizeXorY.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   335
    xNeg := x negated.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   336
    y    := top  preferredSizeXorY.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   337
    yNeg := y negated.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   338
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   339
    view  rightInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   340
    view   leftInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   341
    view bottomInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   342
    view    topInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   343
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   344
    last := top.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   345
    action := [:aTab||wdg|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   346
        last == aTab ifFalse:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   347
            last selection:nil.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   348
            last := aTab.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   349
            (aTab tabWidget) == #Mac ifTrue:[aTab tabWidget:#Window]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   350
                                    ifFalse:[aTab tabWidget:#Mac]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   351
        ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   352
    ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   353
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   354
    top bottomInset:yNeg.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   355
    top leftInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   356
    top rightInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   357
    top action:[:d|action value:top].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   358
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   359
    bottom topInset:yNeg.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   360
    bottom leftInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   361
    bottom rightInset:x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   362
    bottom action:[:d|action value:bottom].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   363
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   364
    left rightInset:xNeg.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   365
    left topInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   366
    left bottomInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   367
    left action:[:d|action value:left].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   368
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   369
    right leftInset:xNeg.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   370
    right topInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   371
    right bottomInset:y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   372
    right action:[:d|action value:right].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   373
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   374
    topView open.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   375
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   376
! !
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   377
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   378
!TabView methodsFor:'accessing'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   379
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   380
action:oneArgBlock
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   381
    "set the action block to be performed on select; the argument to
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   382
     the block is the selected index or nil in case of no selection.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   383
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   384
    action := oneArgBlock.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   385
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   386
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   387
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   388
list
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   389
    "return the list
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   390
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   391
    ^ list
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   392
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   393
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   394
list:aList
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   395
    "set the list
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   396
    "
376
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   397
    |widget redraw|
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   398
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   399
    aList size == list size ifTrue:[
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   400
        redraw := false.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   401
376
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   402
        list notNil ifTrue:[
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   403
            list keysAndValuesDo:[:aKey :aTab|
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   404
                (aTab label) = (aList at:aKey) ifFalse:[
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   405
                    redraw := true
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   406
                ]
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   407
            ]
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   408
        ].
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   409
        redraw ifFalse:[^ self ].
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   410
    ].
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   411
    self selection:nil.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   412
    list := nil.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   413
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   414
    aList size ~~ 0 ifTrue:[
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   415
        widget := tabStyle at:#widget.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   416
        list   := widget labels:aList for:self.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   417
    ].
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   418
    self shown ifTrue:[
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   419
        self recomputeList.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   420
        self redrawFull.
376
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   421
        self changed:#preferredExtent
0caf50840abd raise notification whenever list changed
ca
parents: 374
diff changeset
   422
    ].
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   423
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   424
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   425
useIndex
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   426
    "use index instead of name
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   427
    "
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   428
    ^ useIndex
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   429
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   430
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   431
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   432
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   433
useIndex:aBoolean
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   434
    "set/clear the useIndex flag. If set, both actionBlock and change-messages
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   435
     are passed the index(indices) of the selection as argument. 
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   436
     If clear, the value(s) (i.e. the selected string) is passed.
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   437
     Default is false."
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   438
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   439
    useIndex := aBoolean
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   440
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   441
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   442
! !
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   443
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   444
!TabView methodsFor:'accessing behavior'!
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   445
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   446
enabled
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   447
    "returns true if tabs are enabled
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   448
    "
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   449
    ^ enabled
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   450
!
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   451
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   452
enabled:aState
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   453
    "set enabled state
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   454
    "
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   455
    |state|
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   456
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   457
    state := aState ? true.
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   458
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   459
    enabled ~~ state ifTrue:[
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   460
        enabled := state.
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   461
        self redrawFull
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   462
    ]
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   463
! !
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   464
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   465
!TabView methodsFor:'accessing channels/holders'!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   466
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   467
enableChannel
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   468
    "return a valueHolder for enable/disable
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   469
    "
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   470
    ^ enableChannel
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   471
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   472
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   473
enableChannel:aValueHolderForBoolean
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   474
    "set the valueHolder used for enable/disable
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   475
    "
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   476
    enableChannel notNil ifTrue:[
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   477
        enableChannel removeDependent:self. 
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   478
    ].
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   479
    enableChannel := aValueHolderForBoolean.
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   480
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   481
    enableChannel notNil ifTrue:[
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   482
        enableChannel addDependent:self.
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   483
    ].
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   484
    self enabled:(enableChannel value).
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   485
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   486
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   487
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   488
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   489
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   490
listHolder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   491
    "returns the list holder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   492
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   493
    ^ listHolder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   494
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   495
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   496
listHolder:aValueHolder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   497
    "change the list holder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   498
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   499
    listHolder notNil ifTrue:[
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   500
        listHolder removeDependent:self. 
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   501
    ].
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   502
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   503
    listHolder := aValueHolder.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   504
    listHolder notNil ifTrue:[
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   505
        listHolder addDependent:self.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   506
        self list:listHolder value.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   507
        self selection:model value.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   508
    ].
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   509
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   510
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   511
model:aValueHolder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   512
    super model:aValueHolder.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   513
    model notNil ifTrue:[
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   514
        self selection:(model value)
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   515
    ]
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   516
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   517
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   518
!TabView methodsFor:'accessing dimension'!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   519
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   520
preferredExtent
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   521
    "compute max extent x/y based on one line
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   522
    "
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   523
    |x y ovl ext|
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   524
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   525
    list size == 0 ifTrue:[^ 0 @ 0 ].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   526
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   527
    ovl := tabStyle at:#rightCovered.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   528
    x   := ovl.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   529
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   530
    list do:[:aTab|
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   531
        x := x - ovl + aTab preferredExtentX
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   532
    ].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   533
    y := (tabStyle at:#maxY)
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   534
       + ((tabStyle at:#expandSelection) y)
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   535
       + (self class viewSpacing).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   536
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   537
    (self isHorizontalDirection) ifTrue:[
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   538
        ^ x @ y
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   539
    ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   540
    ^ y @ x
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   541
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   542
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   543
preferredSizeXorY
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   544
    "returns preferred size dependant on the current view layout and
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   545
     the direction of the tabs
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   546
    "
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   547
    |y|
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   548
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   549
    list size == 0 ifFalse:[
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   550
        maxRawNr isNil ifTrue:[self recomputeList].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   551
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   552
        y := (maxRawNr * (tabStyle at:#maxY))
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   553
           + ((tabStyle at:#expandSelection) y)
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   554
           + (self class viewSpacing).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   555
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   556
      ^ y
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   557
    ].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   558
    ^ 0
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   559
! !
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   560
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   561
!TabView methodsFor:'accessing style'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   562
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   563
direction
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   564
    "returns the direction of tabs as symbol. On default the value is
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   565
     set to #top. Valid symbols are:
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   566
        #top       arrange tabs to be on top of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   567
        #bottom    arrange tabs to be on bottom of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   568
        #left      arrange tabs to be on left of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   569
        #right     arrange tabs to be on right of a view
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   570
    "
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   571
    ^ direction
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   572
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   573
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   574
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   575
direction:aDirection
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   576
    "change the direction of tabs. On default the value is set to #top.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   577
     Valid symbols are:
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   578
        #top       arrange tabs to be on top of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   579
        #bottom    arrange tabs to be on bottom of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   580
        #left      arrange tabs to be on left of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   581
        #right     arrange tabs to be on right of a view
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   582
    "
374
76d08cd5b273 update notification in case of changing direction
ca
parents: 373
diff changeset
   583
    direction ~~ aDirection ifTrue:[
76d08cd5b273 update notification in case of changing direction
ca
parents: 373
diff changeset
   584
        direction := aDirection.
76d08cd5b273 update notification in case of changing direction
ca
parents: 373
diff changeset
   585
        self changed:#direction
76d08cd5b273 update notification in case of changing direction
ca
parents: 373
diff changeset
   586
    ].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   587
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   588
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   589
fitLastRow
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   590
    "in case of true, the last row is expanded to the view  size like all
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   591
     other raws. In case of false all the tabs in the last raw keep their
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   592
     preferred extent (x or y) dependant on the direction.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   593
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   594
    ^ fitLastRow
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   595
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   596
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   597
fitLastRow:aBool
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   598
    "in case of true, the last row is expanded to the view  size like all
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   599
     other raws. In case of false all the tabs in the last raw keep their
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   600
     preferred extent (x or y) dependant on the direction.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   601
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   602
    fitLastRow := aBool
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   603
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   604
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   605
moveSelectedRow
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   606
    "in case of true, the raw assigned to the tab will be moved
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   607
     to the first line (to the view). Otherwise the position of
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   608
     the view will be kept.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   609
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   610
    ^ moveSelectedRow
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   611
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   612
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   613
moveSelectedRow:aBool
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   614
    "in case of true, the raw assigned to the tab will be moved
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   615
     to the first line (to the view). Otherwise the position of
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   616
     the view will be kept.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   617
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   618
    moveSelectedRow := aBool
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   619
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   620
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   621
style
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   622
    "returns the style sheet derived from the current widget class
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   623
    "
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   624
    ^ tabStyle
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   625
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   626
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   627
styleAt:anIdentifier
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   628
    "returns a specific entry into the widget description. For more information
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   629
     see the specific widget class ( TabWidget ... ).
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   630
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   631
    ^ tabStyle at:anIdentifier
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   632
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   633
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   634
styleAt:anIdentifier put:something
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   635
    "change a specific entry from the widget description. For more information
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   636
     see the specific widget class ( TabWidget ... ).
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   637
    "
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   638
    tabStyle at:anIdentifier put:something.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   639
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   640
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   641
tabWidget
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   642
    "returns the current widget class as symbol
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   643
    "
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   644
    |widget|
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   645
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   646
    widget := tabStyle at:#widget.
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   647
    widget := widget nameWithoutPrefix asSymbol.
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   648
  ^ widget
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   649
!
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   650
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   651
tabWidget:aWidget
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   652
    "change the current widget class. An existing list will be
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   653
     recomputed and redrawn
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   654
    "
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   655
    |widget labels|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   656
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   657
    (self tabWidget) ~~ aWidget ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   658
        widget := TabWidget widgetClass:aWidget.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   659
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   660
        widget notNil ifTrue:[
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   661
            tabStyle := widget tabStyleOn:self.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   662
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   663
            list notNil ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   664
                labels := list collect:[:aTab| aTab label].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   665
                list   := widget labels:labels for:self.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   666
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   667
                self shown ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   668
                    self recomputeList.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   669
                    self redrawFull
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   670
                ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   671
            ]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   672
        ]
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   673
    ]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   674
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   675
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   676
!TabView methodsFor:'change & update'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   677
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   678
sizeChanged:how
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   679
    "size of view changed 
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   680
    "
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   681
    list notNil ifTrue:[
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   682
        self recomputeList.
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   683
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   684
        sizeChanged ifFalse:[
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   685
            sizeChanged := true.
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   686
            self changed:#preferredExtent.
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   687
            sizeChanged := false.
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   688
        ]
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   689
    ].
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   690
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   691
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   692
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   693
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   694
update:something with:aParameter from:changedObject
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   695
    "one of my models changed its value
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   696
    "
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   697
    changedObject == model         ifTrue:[^ self selection:model value].
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   698
    changedObject == listHolder    ifTrue:[^ self list:(listHolder value)].
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   699
    changedObject == enableChannel ifTrue:[^ self enabled:(enableChannel value)].
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   700
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   701
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   702
!TabView methodsFor:'drawing'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   703
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   704
paintColor:aColorSymbol
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   705
    "set the paint color derived from the symbol used as key into the current
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   706
     style sheet to access the color
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   707
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   708
    self paint:(tabStyle at:aColorSymbol)
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   709
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   710
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   711
redrawFull
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   712
    "full redraw
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   713
    "
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   714
    |oldSelect|
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   715
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   716
    (list size ~~ 0 and:[self shown]) ifTrue:[
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   717
        self paint:(self viewBackground).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   718
        self clear.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   719
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   720
        maxRawNr to:1 by:-1 do:[:i|self redrawRawAt:i].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   721
        selection notNil ifTrue:[
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   722
            oldSelect := selection.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   723
            selection := nil.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   724
            self setSelection:oldSelect.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   725
        ]
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   726
    ]
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   727
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   728
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   729
redrawRawAt:aRawNr
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   730
    "redraw raw at a number; all contained tabs are drawn unselected
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   731
    "
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   732
    list reverseDo:[:aTab|aTab lineNr == aRawNr ifTrue:[aTab redraw:false]].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   733
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   734
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   735
redrawSelection
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   736
    "redraw current selection
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   737
    "
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   738
    |tab size oldAnc newAnc oldExt newExt expSel expDlt x y|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   739
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   740
    size := list size.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   741
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   742
    (selection notNil and:[self shown and:[size ~~ 0]]) ifFalse:[
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   743
        ^ self
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   744
    ].
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   745
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   746
    tab    := list at:selection.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   747
    oldAnc := tab anchor.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   748
    oldExt := tab extent.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   749
    expSel := tabStyle at:#expandSelection.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   750
    expDlt := expSel x.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   751
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   752
    (self isHorizontalDirection) ifTrue:[
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   753
        newExt := oldExt + ( expDlt @ 0 ).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   754
        newAnc := oldAnc - ((expDlt//2) @ ((expSel y) negated)).
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   755
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   756
        (x := newAnc x) < 0 ifTrue:[
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   757
            newExt x:(newExt x + x).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   758
            newAnc x:0.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   759
            x := 0.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   760
        ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   761
        (x + newExt x) > (super extent x) ifTrue:[newExt x:((super extent x) - x)].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   762
    ] ifFalse:[
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   763
        newExt := oldExt + ( 0 @ expDlt ).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   764
        newAnc := oldAnc - (((expSel y) negated) @ (expDlt//2)).
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   765
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   766
        (y := newAnc y) < 0 ifTrue:[
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   767
            newExt y:(newExt y + y).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   768
            newAnc y:0.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   769
            y := 0.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   770
        ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   771
        (y + newExt y) > (super extent y) ifTrue:[newExt y:((super extent y) - y)].
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   772
    ].
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   773
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   774
    tab anchor:newAnc extent:newExt.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   775
    tab redraw:true.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   776
    tab anchor:oldAnc extent:oldExt.
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   777
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   778
    size := tab lineNr.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   779
    [(size := size - 1) ~~ 0] whileTrue:[self redrawRawAt:size].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   780
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   781
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   782
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   783
redrawX:x y:y width:w height:h
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   784
    "a region must be redrawn
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   785
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   786
    self redrawFull
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   787
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   788
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   789
!TabView methodsFor:'event handling'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   790
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   791
buttonPress:button x:x y:y
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   792
    "a button is pressed; find tab under point and set the selection
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   793
    "
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   794
    (self isEnabled and:[list notNil]) ifTrue:[
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   795
        self selection:(list findFirst:[:aTab|aTab containsPoint:(x@y)])
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   796
    ]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   797
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   798
346
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   799
keyPress:aKey x:x y:y
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   800
    "selection might change; look for corresponding list entry
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   801
    "
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   802
    |size newSel|
346
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   803
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   804
    (self isEnabled and:[(size := list size) ~~ 0]) ifTrue:[
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   805
        (aKey == #CursorRight or:[aKey == #CursorDown]) ifTrue:[
346
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   806
            (selection isNil or:[selection == size]) ifTrue:[
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   807
                newSel := 1
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   808
            ] ifFalse:[
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   809
                newSel := (selection + 1)
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   810
            ]
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   811
        ] ifFalse:[
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   812
            (aKey == #CursorLeft or:[aKey == #CursorUp]) ifTrue:[
346
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   813
                (selection isNil or:[selection == 1]) ifTrue:[
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   814
                    newSel := size
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   815
                ] ifFalse:[
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   816
                    newSel := (selection - 1)
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   817
                ]
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   818
            ]
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   819
        ].
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   820
        newSel notNil ifTrue:[
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   821
            self selection:newSel
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   822
        ]
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   823
        
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   824
    ].
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   825
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   826
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   827
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   828
!TabView methodsFor:'initialization'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   829
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   830
destroy
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   831
    listHolder notNil ifTrue:[
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   832
        listHolder removeDependent:self. 
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   833
    ].
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   834
    enableChannel notNil ifTrue:[
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   835
        enableChannel removeDependent:self. 
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   836
    ].
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   837
    super destroy.
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   838
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   839
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   840
initialize
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   841
    "setup default attributes
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   842
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   843
    |widget|
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   844
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   845
    super initialize.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   846
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   847
    widget          := TabWidget widgetClass:(self class defaultTabWidget).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   848
    tabStyle        := widget tabStyleOn:self.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   849
    useIndex        := false.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   850
    direction       := #top.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   851
    sizeChanged     := false.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   852
    fitLastRow      := true.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   853
    moveSelectedRow := true.
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   854
    enabled         := true.
374
76d08cd5b273 update notification in case of changing direction
ca
parents: 373
diff changeset
   855
76d08cd5b273 update notification in case of changing direction
ca
parents: 373
diff changeset
   856
    self font:(Label defaultFont).
76d08cd5b273 update notification in case of changing direction
ca
parents: 373
diff changeset
   857
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   858
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   859
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   860
!TabView methodsFor:'layout'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   861
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   862
changeRaw:aRawA with:aRawB
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   863
    "exchange positions of two raws
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   864
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   865
    |tabB tabA ancA ancB hrz|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   866
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   867
    tabA := list at:(list findFirst:[:aTab|aTab lineNr == aRawA]).
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   868
    tabB := list at:(list findFirst:[:aTab|aTab lineNr == aRawB]).
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   869
    hrz  := (self isHorizontalDirection).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   870
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   871
    hrz ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   872
        ancA := tabA anchor y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   873
        ancB := tabB anchor y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   874
    ] ifFalse:[   
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   875
        ancA := tabA anchor x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   876
        ancB := tabB anchor x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   877
    ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   878
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   879
    list do:[:aTab||ln|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   880
        (ln := aTab lineNr) == aRawB ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   881
            aTab lineNr:aRawA.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   882
            hrz ifTrue:[aTab anchor y:ancA]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   883
               ifFalse:[aTab anchor x:ancA]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   884
        ] ifFalse:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   885
            ln == aRawA ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   886
                aTab lineNr:aRawB.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   887
                hrz ifTrue:[aTab anchor y:ancB]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   888
                   ifFalse:[aTab anchor x:ancB]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   889
            ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   890
        ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   891
    ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   892
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   893
    aRawB == maxRawNr ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   894
        self fitRawAt:aRawA.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   895
        self unfitLastRaw.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   896
    ] ifFalse:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   897
        aRawA == maxRawNr ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   898
            self fitRawAt:aRawB.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   899
            self unfitLastRaw.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   900
        ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   901
    ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   902
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   903
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   904
fitRawAt:aRawNr
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   905
    "fit raw to view's size
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   906
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   907
    |last first tab ext org max size|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   908
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   909
    (aRawNr ~~ maxRawNr or:[fitLastRow]) ifFalse:[^ self].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   910
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   911
    last  := list  findLast:[:aTab| aTab lineNr == aRawNr ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   912
    first := list findFirst:[:aTab| aTab lineNr == aRawNr ].
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   913
    tab   := list at:last.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   914
    size  := last - first + 1.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   915
    org   := 0.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   916
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   917
    (self isHorizontalDirection) ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   918
        max := super extent x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   919
        ext := (max - ((tab anchor x) + (tab extent x))) // size.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   920
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   921
        ext > 1 ifTrue:[
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   922
            first to:last do:[:i|
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   923
                tab := list at:i.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   924
                tab extent x:((tab extent x) + ext).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   925
                tab anchor x:((tab anchor x) + org).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   926
                org := org + ext.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   927
            ].
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   928
            tab := list at:last.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   929
        ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   930
        tab extent x:(max - tab anchor x).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   931
    ] ifFalse:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   932
        max := super extent y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   933
        ext := (max - ((tab anchor y) + (tab extent y))) // size.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   934
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   935
        ext > 1 ifTrue:[
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   936
            first to:last do:[:i|
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   937
                tab := list at:i.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   938
                tab extent y:((tab extent y) + ext).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   939
                tab anchor y:((tab anchor y) + org).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   940
                org := org + ext.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   941
            ].
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   942
            tab := list at:last.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   943
        ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   944
        tab extent y:(max - tab anchor y).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   945
    ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   946
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   947
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   948
recomputeList
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   949
    "recompute list
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   950
    "
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   951
    |tab maxY x y maxSz ovl|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   952
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   953
    list size ~~ 0 ifTrue:[
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   954
        maxY     := tabStyle at:#maxY.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   955
        ovl      := tabStyle at:#rightCovered.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   956
        maxRawNr := 1.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   957
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   958
        (self isHorizontalDirection) ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   959
            maxSz := super extent x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   960
            x     := 0.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   961
            y     := maxY.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   962
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   963
            list do:[:aTab||eX n|
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   964
                eX := aTab preferredExtentX.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   965
                n  := eX + x - ovl.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   966
371
02b233499001 fix bug; resize of view
ca
parents: 369
diff changeset
   967
                (n > maxSz and:[x ~~ 0]) ifTrue:[
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   968
                    maxRawNr := maxRawNr + 1.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   969
                    x := 0.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   970
                    y := y  + maxY.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   971
                    n := eX - ovl.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   972
                ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   973
                aTab lineNr:maxRawNr.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   974
                aTab anchor:x@y extent:(eX @ maxY).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   975
                x := n.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   976
            ]
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   977
        ] ifFalse:[
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   978
            maxSz := super extent y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   979
            x     := maxY.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   980
            y     := 0.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   981
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   982
            list do:[:aTab||eY n|
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   983
                eY := aTab preferredExtentX.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   984
                n  := eY + y - ovl.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   985
371
02b233499001 fix bug; resize of view
ca
parents: 369
diff changeset
   986
                (n > maxSz and:[y ~~ 0]) ifTrue:[
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   987
                    maxRawNr := maxRawNr + 1.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   988
                    y := 0.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   989
                    x := x  + maxY.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   990
                    n := eY - ovl.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   991
                ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   992
                aTab lineNr:maxRawNr.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   993
                aTab anchor:x@y extent:(maxY @ eY).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   994
                y := n.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   995
            ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   996
        ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   997
     "/ fit raws to view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   998
        1 to:maxRawNr do:[:aLnNr|self fitRawAt:aLnNr].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   999
    ].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1000
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1001
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1002
unfitLastRaw
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1003
    "use the preferred extent for all tabs in the last raw
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1004
    "
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1005
    |last first tab ovl anchor extent pos offset hrz|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1006
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1007
    fitLastRow ifTrue:[^ self].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1008
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1009
    last  := list  findLast:[:aTab| aTab lineNr == maxRawNr ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1010
    first := list findFirst:[:aTab| aTab lineNr == maxRawNr ].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1011
    ovl   := tabStyle at:#rightCovered.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1012
    pos   := 0.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1013
    hrz   := (self isHorizontalDirection).
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1014
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
  1015
    first to:last do:[:i|
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1016
        tab := list at:i.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1017
        anchor := tab anchor.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1018
        extent := tab extent.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1019
        offset := tab preferredExtentX.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1020
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1021
        hrz ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1022
            extent x:offset.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1023
            anchor x:pos
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1024
        ] ifFalse:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1025
            extent y:offset.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1026
            anchor y:pos.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1027
        ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1028
        tab anchor:anchor extent:extent.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1029
        pos := pos + offset - ovl.
349
2e245c1c2870 preferredExtent and preferredHeight
ca
parents: 346
diff changeset
  1030
    ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1031
! !
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1032
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1033
!TabView methodsFor:'private'!
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1034
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1035
listIndexOf:something
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1036
    "convert something to an index into list or nil.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1037
    "
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1038
    |index|
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1039
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1040
    something isString ifTrue:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1041
        index := list findFirst:[:aTab|aTab label = something].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1042
    ] ifFalse:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1043
        index := something
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1044
    ].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1045
    index ~~ 0 ifTrue:[^ index]
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1046
              ifFalse:[^ nil]
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1047
! !
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1048
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1049
!TabView methodsFor:'queries'!
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1050
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
  1051
isEnabled
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
  1052
    "returns enabled state
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
  1053
    "
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
  1054
  ^ enabled
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
  1055
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
  1056
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1057
isHorizontalDirection
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1058
    "returns true in case of direction is #top or #bottom
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1059
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1060
    ^ (direction == #top or:[direction == #bottom])
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1061
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1062
!
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1063
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1064
isVerticalDirection
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1065
    "returns true in case of direction is #left or #right
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1066
    "
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1067
    ^ (direction == #left or:[direction == #right])
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1068
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1069
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1070
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1071
!TabView methodsFor:'selection'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1072
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1073
selection
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1074
    "return the selection index or nil
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1075
    "
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1076
    useIndex ifTrue:[
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1077
        ^ selection
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1078
    ].
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1079
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1080
    (selection notNil and:[list size >= selection]) ifTrue:[
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1081
        ^ (list at:selection) label
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1082
    ].
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1083
    ^ nil
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1084
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1085
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1086
selection:anIndexOrNil
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1087
    "change the selection to index or nil. The model and/or actionBlock is notified
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1088
    "
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1089
    |sel|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1090
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1091
    sel := selection.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1092
    self setSelection:anIndexOrNil.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1093
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1094
    (sel ~~ selection) ifTrue:[
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1095
        sel := self selection.
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1096
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1097
        model  notNil ifTrue:[model  value:sel].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1098
        action notNil ifTrue:[action value:sel]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1099
    ]
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1100
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1101
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1102
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1103
setSelection:something
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1104
    "change the selection to index or nil. No notifications are raised
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1105
    "
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1106
    |newSel lnNr tab last first exp x y w h|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1107
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1108
    list isNil ifTrue:[^ self].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1109
    newSel := self listIndexOf:something.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1110
    selection == newSel ifTrue:[^ self].
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
  1111
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1112
    self shown ifFalse:[
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1113
        selection := newSel.
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1114
      ^ self
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1115
    ].
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1116
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1117
    (newSel notNil and:[moveSelectedRow and:[(lnNr := (list at:newSel) lineNr) > 1]]) ifTrue:[
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1118
        self changeRaw:1 with:lnNr.
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1119
        selection := 1.                 "/ force a redraw
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1120
    ].
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1121
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1122
    selection notNil ifTrue:[
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1123
        maxRawNr > 1 ifTrue:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1124
            selection := nil.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1125
            self redrawFull.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1126
        ] ifFalse:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1127
            first := 1.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1128
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1129
            (selection > 2 and:[(tabStyle at:#rightCovered)]) ifTrue:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1130
                first := selection - 1
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1131
            ].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1132
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1133
            (last := selection + 1) > list size ifTrue:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1134
                last := selection
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1135
            ].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1136
            exp := (tabStyle at:#expandSelection) x.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1137
            tab := list at:selection.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1138
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1139
            self isHorizontalDirection ifTrue:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1140
                (x := tab anchor x - (exp // 2)) < 0 ifTrue:[x := 0].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1141
                w := tab extent x + exp.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1142
                h := super extent y.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1143
                y := 0.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1144
            ] ifFalse:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1145
                (y := tab anchor y - (exp // 2)) < 0 ifTrue:[y := 0].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1146
                h := tab extent y + exp.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1147
                w := super extent x.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1148
                x := 0.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1149
            ].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1150
            self paint:(self viewBackground).
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1151
            self clearRectangleX:x y:y width:w height:h.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1152
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1153
            last to:first by:-1 do:[:i|
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1154
                tab := list at:i.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1155
                tab redraw:false
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1156
            ]
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1157
        ]
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1158
    ].
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1159
    selection := newSel.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1160
    self redrawSelection.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1161
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1162
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1163
!TabView class methodsFor:'documentation'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1164
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1165
version
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
  1166
    ^ '$Header: /cvs/stx/stx/libwidg2/TabView.st,v 1.14 1997-05-24 03:10:11 ca Exp $'
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1167
! !