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