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