TabView.st
author Claus Gittinger <cg@exept.de>
Sun, 02 Nov 1997 19:28:49 +0100
changeset 603 6b2fa42f9760
parent 591 03c28ff04183
child 670 6aefa9b9705c
permissions -rw-r--r--
checkin from browser
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
550
f4c65aff6387 remove:
ca
parents: 548
diff changeset
    15
	instanceVariableNames:'list listHolder selection enabled action tabStyle useIndex
f4c65aff6387 remove:
ca
parents: 548
diff changeset
    16
		maxRawNr direction fitLastRow moveSelectedRow enableChannel
f4c65aff6387 remove:
ca
parents: 548
diff changeset
    17
		oldExtent oneTabPerLine'
f4c65aff6387 remove:
ca
parents: 548
diff changeset
    18
	classVariableNames:''
f4c65aff6387 remove:
ca
parents: 548
diff changeset
    19
	poolDictionaries:''
f4c65aff6387 remove:
ca
parents: 548
diff changeset
    20
	category:'Views-Interactors'
343
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
    "
545
d01d14358b07 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   253
    |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
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   287
oneTabPerLine
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   288
    ^ oneTabPerLine
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   289
!
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   290
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   291
oneTabPerLine:aBool
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   292
    oneTabPerLine := aBool.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   293
!
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   294
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   295
useIndex
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   296
    "use index instead of name
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   297
    "
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   298
    ^ useIndex
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   299
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   300
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   301
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   302
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   303
useIndex:aBoolean
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   304
    "set/clear the useIndex flag. If set, both actionBlock and change-messages
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   305
     are passed the index(indices) of the selection as argument. 
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   306
     If clear, the value(s) (i.e. the selected string) is passed.
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   307
     Default is false."
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   308
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   309
    useIndex := aBoolean
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   310
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   311
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   312
!
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   313
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   314
viewBackground:aColor
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   315
    "update colors
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   316
    "
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   317
    super viewBackground:aColor.
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   318
    TabWidget computeColorsOn:self style:tabStyle.
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   319
    self invalidate.
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   320
! !
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   321
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   322
!TabView methodsFor:'accessing behavior'!
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   323
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   324
enabled
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   325
    "returns true if tabs are enabled
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   326
    "
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   327
    ^ enabled
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   328
!
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   329
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   330
enabled:aState
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   331
    "set enabled state
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   332
    "
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   333
    |state|
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   334
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   335
    state := aState ? true.
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   336
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   337
    enabled ~~ state ifTrue:[
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   338
        enabled := state.
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   339
        self redrawLabels.
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   340
    ]
397
06f612dc5a30 ST-80 compatibility
ca
parents: 394
diff changeset
   341
!
06f612dc5a30 ST-80 compatibility
ca
parents: 394
diff changeset
   342
06f612dc5a30 ST-80 compatibility
ca
parents: 394
diff changeset
   343
isEnabled:aState
06f612dc5a30 ST-80 compatibility
ca
parents: 394
diff changeset
   344
    "ST-80 compatibility; set enabled state
06f612dc5a30 ST-80 compatibility
ca
parents: 394
diff changeset
   345
    "
06f612dc5a30 ST-80 compatibility
ca
parents: 394
diff changeset
   346
    self enabled:aState
06f612dc5a30 ST-80 compatibility
ca
parents: 394
diff changeset
   347
06f612dc5a30 ST-80 compatibility
ca
parents: 394
diff changeset
   348
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   349
! !
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   350
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   351
!TabView methodsFor:'accessing channels/holders'!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   352
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   353
enableChannel
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   354
    "return a valueHolder for enable/disable
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   355
    "
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   356
    ^ enableChannel
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   357
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   358
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   359
enableChannel:aValueHolderForBoolean
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   360
    "set the valueHolder used for enable/disable
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   361
    "
603
6b2fa42f9760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   362
6b2fa42f9760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   363
    |prev|
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   364
603
6b2fa42f9760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   365
    prev := enableChannel.
6b2fa42f9760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   366
    enableChannel := aValueHolderForBoolean.
6b2fa42f9760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   367
    self setupChannel:aValueHolderForBoolean for:nil withOld:prev
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   368
603
6b2fa42f9760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
   369
    "Modified: / 31.10.1997 / 14:48:59 / cg"
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   370
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   371
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   372
listHolder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   373
    "returns the list holder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   374
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   375
    ^ listHolder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   376
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   377
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   378
listHolder:aValueHolder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   379
    "change the list holder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   380
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   381
    listHolder notNil ifTrue:[
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   382
        listHolder removeDependent:self. 
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   383
    ].
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   384
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   385
    listHolder := aValueHolder.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   386
    listHolder notNil ifTrue:[
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   387
        listHolder addDependent:self.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   388
        self list:listHolder value.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   389
        self selection:model value.
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   390
    ].
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   391
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   392
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   393
model:aValueHolder
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   394
    super model:aValueHolder.
500
ec7b1892ae3e bug fix; in case of using index, an empty
ca
parents: 499
diff changeset
   395
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   396
    model notNil ifTrue:[
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   397
        self selection:(model value)
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   398
    ]
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   399
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   400
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   401
!TabView methodsFor:'accessing dimension'!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   402
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   403
preferredExtent
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   404
    "compute max extent x/y based on one line
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   405
    "
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   406
    |x y ovl size maxY|
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   407
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   408
    (size := list size) == 0 ifTrue:[^ 0 @ 0 ].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   409
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   410
    maxY := tabStyle at:#maxY.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   411
    y    := maxY + self viewSpacing.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   412
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   413
    oneTabPerLine ifTrue:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   414
        y := y + ((size - 1) * maxY).
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   415
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   416
        (self isHorizontalDirection) ifTrue:[x := super extent x]
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   417
                                    ifFalse:[x := super extent y]
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   418
    ] ifFalse:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   419
        x := ovl := tabStyle at:#rightCovered.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   420
        list do:[:aTab|x := x - ovl + aTab preferredExtentX]
367
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
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   423
    (self isHorizontalDirection) ifTrue:[^ x @ y]
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   424
                                ifFalse:[^ y @ x]
367
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
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   427
preferredSizeXorY
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   428
    "returns preferred size dependant on the current view layout and
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   429
     the direction of the tabs
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   430
    "
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   431
    list size == 0 ifFalse:[
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   432
        maxRawNr isNil ifTrue:[self recomputeList].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   433
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   434
        oneTabPerLine ifTrue:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   435
            self isHorizontalDirection ifTrue:[^ super extent y]
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   436
                                      ifFalse:[^ super extent x]
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   437
        ].
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   438
        ^ ((maxRawNr * (tabStyle at:#maxY)) + self viewSpacing).
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   439
    ].
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   440
    ^ 0
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   441
!
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   442
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   443
viewSpacing
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   444
    "returns my view spacing
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   445
    "
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   446
    ^ ((tabStyle at:#expandSelection) y) + (self class viewSpacing)
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   447
! !
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   448
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   449
!TabView methodsFor:'accessing style'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   450
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   451
direction
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   452
    "returns the direction of tabs as symbol. On default the value is
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   453
     set to #top. Valid symbols are:
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   454
        #top       arrange tabs to be on top of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   455
        #bottom    arrange tabs to be on bottom of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   456
        #left      arrange tabs to be on left of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   457
        #right     arrange tabs to be on right of a view
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   458
    "
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   459
    ^ direction
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   460
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   461
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   462
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   463
direction:aDirection
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   464
    "change the direction of tabs. On default the value is set to #top.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   465
     Valid symbols are:
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   466
        #top       arrange tabs to be on top of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   467
        #bottom    arrange tabs to be on bottom of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   468
        #left      arrange tabs to be on left of a view
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   469
        #right     arrange tabs to be on right of a view
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   470
    "
374
76d08cd5b273 update notification in case of changing direction
ca
parents: 373
diff changeset
   471
    direction ~~ aDirection ifTrue:[
76d08cd5b273 update notification in case of changing direction
ca
parents: 373
diff changeset
   472
        direction := aDirection.
76d08cd5b273 update notification in case of changing direction
ca
parents: 373
diff changeset
   473
        self changed:#direction
76d08cd5b273 update notification in case of changing direction
ca
parents: 373
diff changeset
   474
    ].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   475
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   476
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   477
fitLastRow
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   478
    "in case of true, the last row is expanded to the view  size like all
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   479
     other raws. In case of false all the tabs in the last raw keep their
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   480
     preferred extent (x or y) dependant on the direction.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   481
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   482
    ^ fitLastRow
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   483
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   484
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   485
fitLastRow:aBool
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   486
    "in case of true, the last row is expanded to the view  size like all
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   487
     other raws. In case of false all the tabs in the last raw keep their
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   488
     preferred extent (x or y) dependant on the direction.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   489
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   490
    fitLastRow := aBool
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   491
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   492
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   493
moveSelectedRow
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   494
    "in case of true, the raw assigned to the tab will be moved
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   495
     to the first line (to the view). Otherwise the position of
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   496
     the view will be kept.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   497
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   498
    ^ moveSelectedRow
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   499
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   500
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   501
moveSelectedRow:aBool
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   502
    "in case of true, the raw assigned to the tab will be moved
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   503
     to the first line (to the view). Otherwise the position of
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   504
     the view will be kept.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   505
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   506
    moveSelectedRow := aBool
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   507
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   508
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   509
style
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   510
    "returns the style sheet derived from the current widget class
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   511
    "
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   512
    ^ tabStyle
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   513
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   514
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   515
styleAt:anIdentifier
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   516
    "returns a specific entry into the widget description. For more information
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   517
     see the specific widget class ( TabWidget ... ).
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   518
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   519
    ^ tabStyle at:anIdentifier
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   520
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   521
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   522
styleAt:anIdentifier put:something
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   523
    "change a specific entry from the widget description. For more information
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   524
     see the specific widget class ( TabWidget ... ).
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   525
    "
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   526
    tabStyle at:anIdentifier put:something.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   527
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   528
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   529
tabWidget
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   530
    "returns the current widget class as symbol
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   531
    "
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   532
    |widget|
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   533
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   534
    widget := tabStyle at:#widget.
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   535
    widget := widget nameWithoutPrefix asSymbol.
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   536
  ^ widget
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   537
!
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   538
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   539
tabWidget:aWidget
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   540
    "change the current widget class. An existing list will be
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   541
     recomputed and redrawn
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   542
    "
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   543
    |widget labels|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   544
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   545
    (self tabWidget) ~~ aWidget ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   546
        widget := TabWidget widgetClass:aWidget.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   547
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   548
        widget notNil ifTrue:[
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   549
            tabStyle := widget tabStyleOn:self.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   550
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   551
            list notNil ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   552
                labels := list collect:[:aTab| aTab label].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   553
                list   := widget labels:labels for:self.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   554
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   555
                self shown ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   556
                    self recomputeList.
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   557
                    self invalidate.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   558
                ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   559
            ]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   560
        ]
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   561
    ]
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   562
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   563
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   564
!TabView methodsFor:'accessing tabs'!
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   565
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   566
tabAt:anIndex
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   567
    "get tab at an index or nil
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   568
    "
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   569
    (list size >= anIndex and:[anIndex ~~ 0]) ifTrue:[
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   570
        ^ list at:anIndex
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   571
    ].
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   572
  ^ nil
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   573
! !
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   574
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   575
!TabView methodsFor:'change & update'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   576
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   577
sizeChanged:how
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   578
    "size of view changed 
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   579
    "
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   580
    |extent delta|
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   581
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   582
    list size ~~ 0 ifTrue:[
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   583
        extent := super extent.
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   584
        delta  := oldExtent - extent.
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   585
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   586
        (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
   587
            oldExtent := extent.
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   588
            self recomputeList.
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   589
            self changed:#preferredExtent.
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   590
        ]
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   591
    ].
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   592
    super sizeChanged:how
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   593
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   594
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   595
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   596
update:something with:aParameter from:changedObject
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   597
    "one of my models changed its value
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   598
    "
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   599
    changedObject == model         ifTrue:[^ self selection:model value].
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   600
    changedObject == listHolder    ifTrue:[^ self list:(listHolder value)].
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   601
    changedObject == enableChannel ifTrue:[^ self enabled:(enableChannel value)].
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   602
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   603
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   604
!TabView methodsFor:'drawing'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   605
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   606
paintColor:aColorSymbol
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   607
    "set the paint color derived from the symbol used as key into the current
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   608
     style sheet to access the color
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   609
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   610
    self paint:(tabStyle at:aColorSymbol)
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   611
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   612
550
f4c65aff6387 remove:
ca
parents: 548
diff changeset
   613
redraw
f4c65aff6387 remove:
ca
parents: 548
diff changeset
   614
    "redraw"
f4c65aff6387 remove:
ca
parents: 548
diff changeset
   615
f4c65aff6387 remove:
ca
parents: 548
diff changeset
   616
    self redrawX:0 y:0 width:width height:height.
f4c65aff6387 remove:
ca
parents: 548
diff changeset
   617
f4c65aff6387 remove:
ca
parents: 548
diff changeset
   618
!
f4c65aff6387 remove:
ca
parents: 548
diff changeset
   619
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   620
redrawLabels
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   621
    "redraw all the labels
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
    |selectedTab|
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   624
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   625
    (self shown and:[list size ~~ 0]) ifTrue:[
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   626
        selection notNil ifTrue:[
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   627
            selectedTab := list at:selection.
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   628
        ].
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   629
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   630
        list reverseDo:[:aTab|
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   631
            aTab ~~ selectedTab ifTrue:[
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   632
                aTab redrawLabel
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   633
            ] ifFalse:[
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   634
                self selectedTab:aTab redrawBlock:[aTab redrawLabel]
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   635
            ]
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   636
        ]
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   637
    ].
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   638
!
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   639
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   640
redrawRawAt:aRawNr
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   641
    "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
   642
    "
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   643
    list reverseDo:[:aTab|aTab lineNr == aRawNr ifTrue:[aTab redraw:false]].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   644
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   645
548
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   646
redrawRawAt:aRawNr in:aRectangle
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   647
    "redraw raw at a number; all contained tabs are drawn unselected
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   648
    "
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   649
    list reverseDo:[:aTab|
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   650
        aTab lineNr == aRawNr ifTrue:[
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   651
            (aTab intersects:aRectangle) ifTrue:[
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   652
                aTab redraw:false
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   653
            ]
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   654
        ]
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   655
    ].
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   656
!
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   657
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   658
redrawSelection
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   659
    "redraw current selection
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   660
    "
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   661
    |tab idx|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   662
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   663
    (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
   664
        tab := list at:selection.
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   665
        idx := tab lineNr.
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   666
        self selectedTab:tab redrawBlock:[tab redraw:true].
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   667
        [(idx := idx - 1) ~~ 0] whileTrue:[self redrawRawAt:idx].
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
!
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   670
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   671
redrawX:x y:y width:w height:h
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   672
    "a region must be redrawn
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   673
    "
548
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   674
    |rectangle oldSelect prevClipArea|
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   675
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   676
    self shown ifFalse:[
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   677
        ^ self
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   678
    ].
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   679
548
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   680
    self paint:(self viewBackground).
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   681
    self clearRectangleX:x y:y width:w height:h.
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   682
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   683
    list size == 0 ifTrue:[^ self].
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   684
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   685
548
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   686
    prevClipArea := clipRect.
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   687
    clipRect     := nil.
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   688
    device setClipX:x y:y width:w height:h in:drawableId gc:gcId.
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   689
    rectangle := Rectangle left:x top:y width:w height:h.
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   690
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   691
    maxRawNr to:1 by:-1 do:[:i| self redrawRawAt:i in:rectangle].
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   692
548
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   693
    selection notNil ifTrue:[
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   694
        oldSelect := selection.
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   695
        selection := nil.
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   696
        self setSelection:oldSelect.
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   697
    ].
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   698
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   699
    prevClipArea isNil ifTrue:[device noClipIn:drawableId  gc:gcId]
db06a43229a8 redraw only demaged tabs
ca
parents: 545
diff changeset
   700
                      ifFalse:[self clippingRectangle:prevClipArea].
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   701
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   702
!
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   703
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   704
selectedTab:aTab redrawBlock:aRedrawBlock
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   705
    "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
   706
     perform a redraw action
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   707
    "
545
d01d14358b07 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   708
    |tab oldAnc newAnc oldExt newExt expSel expDlt x y|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   709
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   710
    tab    := list at:selection.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   711
    oldAnc := tab anchor.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   712
    oldExt := tab extent.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   713
    expSel := tabStyle at:#expandSelection.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   714
    expDlt := expSel x.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   715
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   716
    (self isHorizontalDirection) ifTrue:[
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   717
        newExt := oldExt + ( expDlt @ 0 ).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   718
        newAnc := oldAnc - ((expDlt//2) @ ((expSel y) negated)).
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   719
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   720
        (x := newAnc x) < 0 ifTrue:[
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   721
            newExt x:(newExt x + x).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   722
            newAnc x:0.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   723
            x := 0.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   724
        ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   725
        (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
   726
    ] ifFalse:[
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   727
        newExt := oldExt + ( 0 @ expDlt ).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   728
        newAnc := oldAnc - (((expSel y) negated) @ (expDlt//2)).
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   729
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   730
        (y := newAnc y) < 0 ifTrue:[
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   731
            newExt y:(newExt y + y).
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   732
            newAnc y:0.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   733
            y := 0.
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   734
        ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   735
        (y + newExt y) > (super extent y) ifTrue:[newExt y:((super extent y) - y)].
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   736
    ].
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   737
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   738
    tab anchor:newAnc extent:newExt.
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   739
    aRedrawBlock value.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   740
    tab anchor:oldAnc extent:oldExt.
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
   741
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   742
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   743
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   744
!TabView methodsFor:'event handling'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   745
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   746
buttonPress:button x:x y:y
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   747
    "a button is pressed; find tab under point and set the selection
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   748
    "
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   749
    |idx|
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   750
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   751
    (     self isEnabled
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   752
     and:[list notNil
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   753
     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
   754
    ) ifTrue:[
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   755
        self selection:idx
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
   756
    ].
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   757
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   758
346
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   759
keyPress:aKey x:x y:y
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   760
    "selection might change; look for corresponding list entry
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   761
    "
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   762
    |size newSel index|
346
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   763
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   764
    (self isEnabled and:[(size := list size) ~~ 0]) ifTrue:[
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   765
        (aKey == #CursorRight or:[aKey == #CursorDown]) ifTrue:[
346
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   766
            (selection isNil or:[selection == size]) ifTrue:[
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   767
                newSel := 1
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   768
            ] ifFalse:[
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   769
                newSel := (selection + 1)
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   770
            ]
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   771
        ] ifFalse:[
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   772
            (aKey == #CursorLeft or:[aKey == #CursorUp]) ifTrue:[
346
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   773
                (selection isNil or:[selection == 1]) ifTrue:[
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   774
                    newSel := size
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   775
                ] ifFalse:[
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   776
                    newSel := (selection - 1)
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   777
                ]
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   778
            ] ifFalse:[
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   779
                aKey isCharacter ifTrue:[
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   780
                    (selection isNil or:[selection == size]) ifTrue:[index := 1]
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   781
                                                            ifFalse:[index := selection + 1].
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   782
                    newSel := self findTabStartingWithKey:aKey startingAt:index.
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   783
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   784
                    (newSel == 0 and:[index ~~ 1]) ifTrue:[
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   785
                        newSel := self findTabStartingWithKey:aKey startingAt:1
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   786
                    ]
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   787
                ]
346
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   788
            ]
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   789
        ]
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   790
    ].
698695a95a8c keyPress:
ca
parents: 345
diff changeset
   791
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   792
    (newSel isNil or:[newSel == 0]) ifTrue:[
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   793
        super keyPress:aKey x:x y:y
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   794
    ].
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   795
    self selection:newSel
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   796
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   797
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   798
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   799
!TabView methodsFor:'initialization'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   800
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   801
destroy
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   802
    listHolder notNil ifTrue:[
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   803
        listHolder removeDependent:self. 
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   804
    ].
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   805
    enableChannel notNil ifTrue:[
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   806
        enableChannel removeDependent:self. 
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   807
    ].
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   808
    super destroy.
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   809
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
   810
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   811
initialize
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   812
    "setup default attributes
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   813
    "
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   814
    |widget|
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   815
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   816
    super initialize.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   817
576
08f44b433b51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   818
    self cursor:Cursor hand.
08f44b433b51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   819
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   820
    widget          := TabWidget widgetClass:(self class defaultTabWidget).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   821
    tabStyle        := widget tabStyleOn:self.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   822
    useIndex        := false.
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   823
    oneTabPerLine   := false.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   824
    direction       := #top.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   825
    fitLastRow      := true.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   826
    moveSelectedRow := true.
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
   827
    enabled         := true.
410
0982a8a41dfe model notification fixed
ca
parents: 397
diff changeset
   828
    super font:(Label defaultFont on:device).
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
   829
    oldExtent       := 0@0.
576
08f44b433b51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   830
08f44b433b51 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 551
diff changeset
   831
    "Modified: 23.10.1997 / 03:28:02 / cg"
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   832
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   833
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   834
!TabView methodsFor:'layout'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   835
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   836
changeRaw:aRawA with:aRawB
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   837
    "exchange positions of two raws
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   838
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   839
    |tabB tabA ancA ancB hrz|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   840
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   841
    tabA := list at:(list findFirst:[:aTab|aTab lineNr == aRawA]).
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   842
    tabB := list at:(list findFirst:[:aTab|aTab lineNr == aRawB]).
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   843
    hrz  := (self isHorizontalDirection).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   844
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   845
    hrz ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   846
        ancA := tabA anchor y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   847
        ancB := tabB anchor y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   848
    ] ifFalse:[   
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   849
        ancA := tabA anchor x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   850
        ancB := tabB anchor x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   851
    ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   852
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   853
    list do:[:aTab||ln|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   854
        (ln := aTab lineNr) == aRawB ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   855
            aTab lineNr:aRawA.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   856
            hrz ifTrue:[aTab anchor y:ancA]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   857
               ifFalse:[aTab anchor x:ancA]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   858
        ] ifFalse:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   859
            ln == aRawA ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   860
                aTab lineNr:aRawB.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   861
                hrz ifTrue:[aTab anchor y:ancB]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   862
                   ifFalse:[aTab anchor x:ancB]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   863
            ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   864
        ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   865
    ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   866
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   867
    oneTabPerLine ifFalse:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   868
        aRawB == maxRawNr ifTrue:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   869
            self fitRawAt:aRawA.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   870
            self unfitLastRaw.
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   871
        ] ifFalse:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   872
            aRawA == maxRawNr ifTrue:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   873
                self fitRawAt:aRawB.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   874
                self unfitLastRaw.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   875
            ]
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   876
        ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   877
    ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   878
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   879
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   880
fitRawAt:aRawNr
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   881
    "fit raw to view's size
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   882
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   883
    |last first tab ext org max size|
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   884
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   885
    (aRawNr ~~ maxRawNr or:[fitLastRow]) ifFalse:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   886
        ^ self
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   887
    ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   888
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   889
    last  := list  findLast:[:aTab| aTab lineNr == aRawNr ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   890
    first := list findFirst:[:aTab| aTab lineNr == aRawNr ].
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   891
    tab   := list at:last.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   892
    size  := last - first + 1.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   893
    org   := 0.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   894
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   895
    (self isHorizontalDirection) ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   896
        max := super extent x.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   897
        ext := (max - ((tab anchor x) + (tab extent x))) // size.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   898
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   899
        ext > 1 ifTrue:[
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   900
            first to:last do:[:i|
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   901
                tab := list at:i.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   902
                tab extent x:((tab extent x) + ext).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   903
                tab anchor x:((tab anchor x) + org).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   904
                org := org + ext.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   905
            ].
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   906
            tab := list at:last.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   907
        ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   908
        tab extent x:(max - tab anchor x).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   909
    ] ifFalse:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   910
        max := super extent y.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   911
        ext := (max - ((tab anchor y) + (tab extent y))) // size.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   912
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   913
        ext > 1 ifTrue:[
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   914
            first to:last do:[:i|
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   915
                tab := list at:i.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   916
                tab extent y:((tab extent y) + ext).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   917
                tab anchor y:((tab anchor y) + org).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   918
                org := org + ext.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   919
            ].
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
   920
            tab := list at:last.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   921
        ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   922
        tab extent y:(max - tab anchor y).
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   923
    ]
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   924
!
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   925
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   926
recomputeList
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   927
    "recompute list
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   928
    "
545
d01d14358b07 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 508
diff changeset
   929
    |maxY x y maxSz ovl|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
   930
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   931
    list size == 0 ifTrue:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   932
        ^ self
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   933
    ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   934
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   935
    maxY     := tabStyle at:#maxY.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   936
    ovl      := tabStyle at:#rightCovered.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   937
    maxRawNr := 1.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   938
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   939
    (self isHorizontalDirection) ifTrue:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   940
        maxSz := super extent x.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   941
        x     := 0.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   942
        y     := maxY.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   943
        
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   944
        oneTabPerLine ifTrue:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   945
            list do:[:aTab|
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   946
                aTab lineNr:maxRawNr.
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   947
                aTab anchor:x@y extent:(maxSz @ maxY).
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   948
                maxRawNr := maxRawNr + 1.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   949
                y := y + maxY.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   950
            ].
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   951
            ^ self
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   952
        ].
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   953
        list do:[:aTab||eX n|
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   954
            eX := aTab preferredExtentX.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   955
            n  := eX + x - ovl.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   956
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   957
            (n > maxSz and:[x ~~ 0]) ifTrue:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   958
                maxRawNr := maxRawNr + 1.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   959
                x := 0.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   960
                y := y  + maxY.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   961
                n := eX - ovl.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   962
            ].
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   963
            aTab lineNr:maxRawNr.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   964
            aTab anchor:x@y extent:(eX @ maxY).
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   965
            x := n.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   966
        ]
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   967
    ] ifFalse:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   968
        maxSz := super extent y.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   969
        x     := maxY.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   970
        y     := 0.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   971
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   972
        oneTabPerLine ifTrue:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   973
            list do:[:aTab|
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   974
                aTab lineNr:maxRawNr.
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   975
                aTab anchor:x@y extent:(maxY @ maxSz).
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   976
                maxRawNr := maxRawNr + 1.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   977
                x := x + maxY.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   978
            ].
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   979
            ^ self
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
   980
        ].
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   981
        list do:[:aTab||eY n|
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   982
            eY := aTab preferredExtentX.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   983
            n  := eY + y - ovl.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   984
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   985
            (n > maxSz and:[y ~~ 0]) ifTrue:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   986
                maxRawNr := maxRawNr + 1.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   987
                y := 0.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   988
                x := x  + maxY.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   989
                n := eY - ovl.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   990
            ].
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   991
            aTab lineNr:maxRawNr.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   992
            aTab anchor:x@y extent:(maxY @ eY).
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   993
            y := n.
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   994
        ]
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   995
    ].
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   996
 "/ fit raws to view
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
   997
    1 to:maxRawNr do:[:aLnNr|self fitRawAt:aLnNr].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   998
!
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
   999
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1000
unfitLastRaw
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1001
    "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
  1002
    "
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1003
    |last first tab ovl anchor extent pos offset hrz|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1004
508
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
  1005
    fitLastRow ifTrue:[
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
  1006
        ^ self
7e418e6b291d additional behavior
ca
parents: 500
diff changeset
  1007
    ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1008
    last  := list  findLast:[:aTab| aTab lineNr == maxRawNr ].
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1009
    first := list findFirst:[:aTab| aTab lineNr == maxRawNr ].
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1010
    ovl   := tabStyle at:#rightCovered.
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1011
    pos   := 0.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1012
    hrz   := (self isHorizontalDirection).
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1013
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
  1014
    first to:last do:[:i|
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1015
        tab := list at:i.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1016
        anchor := tab anchor.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1017
        extent := tab extent.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1018
        offset := tab preferredExtentX.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1019
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1020
        hrz ifTrue:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1021
            extent x:offset.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1022
            anchor x:pos
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1023
        ] ifFalse:[
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1024
            extent y:offset.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1025
            anchor y:pos.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1026
        ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1027
        tab anchor:anchor extent:extent.
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1028
        pos := pos + offset - ovl.
349
2e245c1c2870 preferredExtent and preferredHeight
ca
parents: 346
diff changeset
  1029
    ].
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1030
! !
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1031
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1032
!TabView methodsFor:'private'!
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1033
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1034
findTabStartingWithKey:aKey startingAt:anIndex
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1035
    "get index of tab starting its label with a key or 0
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1036
    "
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1037
    |upper lower lbl|
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1038
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1039
    (aKey isCharacter and:[anIndex <= list size]) ifFalse:[ ^ 0 ].
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1040
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1041
    upper := aKey asUppercase.
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1042
    lower := aKey asLowercase.
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1043
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1044
  ^ list findFirst:[:aTab|
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1045
        lbl := aTab label string.
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1046
        (lbl size ~~ 0 and:[lbl first == lower or:[lbl first == upper]])
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1047
    ] startingAt:anIndex
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1048
!
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1049
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1050
listIndexOf:something
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1051
    "convert something to an index into list or nil.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1052
    "
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1053
    |index|
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1054
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1055
    something isString ifTrue:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1056
        index := list findFirst:[:aTab|aTab label = something].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1057
    ] ifFalse:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1058
        index := something
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1059
    ].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1060
    index ~~ 0 ifTrue:[^ index]
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1061
              ifFalse:[^ nil]
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1062
! !
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1063
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1064
!TabView methodsFor:'queries'!
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1065
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
  1066
isEnabled
391
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
  1067
    "returns enabled state
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
  1068
    "
c30e362f6c7d handle enable notification
ca
parents: 387
diff changeset
  1069
  ^ enabled
387
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
  1070
!
5b7a8d0fe86e use index or label
ca
parents: 376
diff changeset
  1071
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1072
isHorizontalDirection
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1073
    "returns true in case of direction is #top or #bottom
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1074
    "
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1075
    ^ (direction == #top or:[direction == #bottom])
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1076
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1077
!
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1078
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1079
isVerticalDirection
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1080
    "returns true in case of direction is #left or #right
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1081
    "
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1082
    ^ (direction == #left or:[direction == #right])
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1083
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1084
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1085
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1086
!TabView methodsFor:'selection'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1087
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1088
selection
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1089
    "return the selection index or nil
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1090
    "
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1091
    useIndex ifTrue:[
500
ec7b1892ae3e bug fix; in case of using index, an empty
ca
parents: 499
diff changeset
  1092
        ^ selection ? 0
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1093
    ].
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1094
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1095
    (selection notNil and:[list size >= selection]) ifTrue:[
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1096
        ^ (list at:selection) label
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1097
    ].
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1098
    ^ nil
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1099
!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1100
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1101
selection:anIndexOrNil
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1102
    "change the selection to index or nil. The model and/or actionBlock is notified
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1103
    "
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1104
    |oldSel|
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1105
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1106
    oldSel := selection.
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1107
    self setSelection:anIndexOrNil.
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1108
    oldSel ~~ selection ifTrue:[self selectionHasChanged].
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1109
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1110
!
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1111
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1112
selectionHasChanged
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1113
    "selection might change; raise notification
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1114
    "
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1115
    |sel|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1116
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1117
    sel := self selection.
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1118
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1119
    model  notNil ifTrue:[model  value:sel].
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1120
    action notNil ifTrue:[action value:sel]
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
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1124
setSelection:something
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1125
    "change the selection to index or nil. No notifications are raised
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1126
    "
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1127
    |newSel lnNr tab last first exp x y w h|
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1128
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1129
    list size == 0 ifTrue:[^ self].
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1130
    newSel := self listIndexOf:something.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1131
    selection == newSel ifTrue:[^ self].
591
03c28ff04183 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
  1132
    newSel notNil ifTrue:[
03c28ff04183 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
  1133
        (newSel between:1 and:list size) ifFalse:[newSel := nil].
03c28ff04183 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
  1134
    ].
372
80d087722bc6 change tab ordering:
ca
parents: 371
diff changeset
  1135
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1136
    self shown ifFalse:[
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1137
        selection := newSel.
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1138
      ^ self
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1139
    ].
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1140
445
0595adddd619 recompute list
ca
parents: 418
diff changeset
  1141
    maxRawNr isNil ifTrue:[
0595adddd619 recompute list
ca
parents: 418
diff changeset
  1142
        selection := newSel.
0595adddd619 recompute list
ca
parents: 418
diff changeset
  1143
        self recomputeList.
0595adddd619 recompute list
ca
parents: 418
diff changeset
  1144
      ^ self invalidate.
0595adddd619 recompute list
ca
parents: 418
diff changeset
  1145
    ].
0595adddd619 recompute list
ca
parents: 418
diff changeset
  1146
591
03c28ff04183 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
  1147
    (newSel notNil 
03c28ff04183 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
  1148
         and:[moveSelectedRow
03c28ff04183 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
  1149
         and:[(lnNr := (list at:newSel) lineNr) > 1]]
03c28ff04183 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
  1150
    ) ifTrue:[
369
8f003e44d5ef added directions ...
ca
parents: 367
diff changeset
  1151
        self changeRaw:1 with:lnNr.
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1152
        selection := 1.                                 "/ force a redraw
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1153
    ].
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1154
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1155
    selection notNil ifTrue:[
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1156
        maxRawNr > 1 ifTrue:[
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1157
            self paint:(self viewBackground).           "/ total redraw
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1158
            self clear.
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1159
            selection := nil.
418
94d3a2f73e75 optimize redraw; colors derived from background
ca
parents: 410
diff changeset
  1160
            maxRawNr to:1 by:-1 do:[:i| self redrawRawAt:i ].
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1161
        ] ifFalse:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1162
            first := 1.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1163
499
fbf62bb89ca4 redraw only label in case of enabled state changed
ca
parents: 445
diff changeset
  1164
            (selection ~~ 1 and:[(tabStyle at:#rightCovered) == 0]) ifTrue:[
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1165
                first := selection - 1
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1166
            ].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1167
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1168
            (last := selection + 1) > list size ifTrue:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1169
                last := selection
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1170
            ].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1171
            exp := (tabStyle at:#expandSelection) x.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1172
            tab := list at:selection.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1173
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1174
            self isHorizontalDirection ifTrue:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1175
                (x := tab anchor x - (exp // 2)) < 0 ifTrue:[x := 0].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1176
                w := tab extent x + exp.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1177
                h := super extent y.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1178
                y := 0.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1179
            ] ifFalse:[
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1180
                (y := tab anchor y - (exp // 2)) < 0 ifTrue:[y := 0].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1181
                h := tab extent y + exp.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1182
                w := super extent x.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1183
                x := 0.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1184
            ].
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1185
            self paint:(self viewBackground).
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1186
            self clearRectangleX:x y:y width:w height:h.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1187
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1188
            last to:first by:-1 do:[:i|
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1189
                tab := list at:i.
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1190
                tab redraw:false
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1191
            ]
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1192
        ]
352
fbc4de042995 1. support of usedIndex
ca
parents: 349
diff changeset
  1193
    ].
373
f24a4946fce6 optimize setSelection:
ca
parents: 372
diff changeset
  1194
    selection := newSel.
367
cff1a140978f tabs at top, bottom, left and right
ca
parents: 352
diff changeset
  1195
    self redrawSelection.
591
03c28ff04183 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
  1196
03c28ff04183 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 576
diff changeset
  1197
    "Modified: / 29.10.1997 / 15:50:13 / cg"
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1198
! !
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1199
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1200
!TabView class methodsFor:'documentation'!
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1201
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1202
version
603
6b2fa42f9760 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 591
diff changeset
  1203
    ^ '$Header: /cvs/stx/stx/libwidg2/TabView.st,v 1.29 1997-11-02 18:28:49 cg Exp $'
343
dd49faa984ce intitial checkin
ca
parents:
diff changeset
  1204
! !