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