MultiColListEntry.st
author Claus Gittinger <cg@exept.de>
Wed, 18 Aug 1999 16:41:24 +0200
changeset 1478 38f08dec8e34
parent 1159 eda06596899f
child 1969 e325d38ce469
permissions -rw-r--r--
#on: -> #onDevice:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
     1
"
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
     2
 COPYRIGHT (c) 1994 by Claus Gittinger
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
     3
	      All Rights Reserved
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
     4
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
     5
 This software is furnished under a license and may be used
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
     6
 only in accordance with the terms of that license and with the
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
     8
 be provided or otherwise made available to, or used by, any
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
     9
 other person.  No title to or ownership of the software is
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    10
 hereby transferred.
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    11
"
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
    12
58
claus
parents: 36
diff changeset
    13
ListEntry subclass:#MultiColListEntry
158
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    14
	instanceVariableNames:'strings tabSpec'
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    15
	classVariableNames:'DefaultTabSpec'
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    16
	poolDictionaries:''
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    17
	category:'Views-Support'
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
    18
!
79ab6bc98651 Initial revision
claus
parents:
diff changeset
    19
329
098318898b01 comment
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
    20
!MultiColListEntry class methodsFor:'documentation'!
25
e07adf47d209 *** empty log message ***
claus
parents: 19
diff changeset
    21
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    22
copyright
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    23
"
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    24
 COPYRIGHT (c) 1994 by Claus Gittinger
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    25
	      All Rights Reserved
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    26
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    27
 This software is furnished under a license and may be used
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    28
 only in accordance with the terms of that license and with the
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    30
 be provided or otherwise made available to, or used by, any
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    31
 other person.  No title to or ownership of the software is
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    32
 hereby transferred.
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    33
"
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    34
!
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    35
25
e07adf47d209 *** empty log message ***
claus
parents: 19
diff changeset
    36
documentation
e07adf47d209 *** empty log message ***
claus
parents: 19
diff changeset
    37
"
e07adf47d209 *** empty log message ***
claus
parents: 19
diff changeset
    38
    Instances of MultiColListEntry can be used in place of strings
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    39
    as entries of the list in a ListView or SelectionInListView.
34
159147b254e1 *** empty log message ***
claus
parents: 25
diff changeset
    40
    They allow data to be presented in table (or any other) form.
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    41
    See example here and in TabulatorSpecs documentation.
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    42
    Notice, that each entry can have its own tabulator specification;
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    43
    although, usually all share a single spec.
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    44
    Also, notice that each column may align different; making these
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    45
    perfect elements to present table data.
25
e07adf47d209 *** empty log message ***
claus
parents: 19
diff changeset
    46
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    47
    MultiColListEntry and TabulatorSpec were originally created to
329
098318898b01 comment
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
    48
    support nice tabular display of file-lists in the FileBrowser
098318898b01 comment
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
    49
    (see its long list); you may find many other uses ...
158
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    50
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    51
    [author:]
431e38dfc5ab documentation
Claus Gittinger <cg@exept.de>
parents: 109
diff changeset
    52
        Claus Gittinger
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    53
"
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
    54
!
79ab6bc98651 Initial revision
claus
parents:
diff changeset
    55
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    56
examples
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
    57
"
58
claus
parents: 36
diff changeset
    58
     putting multiColListEntries into a ListView
claus
parents: 36
diff changeset
    59
     (instead of strings)'
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    60
                                                                        [exBegin]
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    61
        |v e myList tabs|
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
    62
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    63
        myList := OrderedCollection new.
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
    64
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    65
        tabs := TabulatorSpecification new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    66
        tabs unit:#inch.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    67
        tabs positions:#(0 3 4).
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    68
        tabs align:#(left #center #left).
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
    69
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    70
        e := MultiColListEntry 
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    71
                 fromString:'left centered left'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    72
        e tabulatorSpecification:tabs.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    73
        myList add:e.
58
claus
parents: 36
diff changeset
    74
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    75
        e := MultiColListEntry 
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    76
                 fromString:'| | |'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    77
        e tabulatorSpecification:tabs.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    78
        myList add:e.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    79
        myList add:''.
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
    80
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    81
        e := MultiColListEntry 
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    82
                 fromString:'hello hallo salut'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    83
        e tabulatorSpecification:tabs.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    84
        myList add:e.
58
claus
parents: 36
diff changeset
    85
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    86
        e := MultiColListEntry 
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    87
                 fromString:'good morning,guten Morgen,bon jour'
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    88
                 separatedBy:$,.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    89
        e tabulatorSpecification:tabs.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    90
        myList add:e.
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
    91
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    92
        e := MultiColListEntry new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    93
        e colAt:1 put:'good bye'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    94
        e colAt:2 put:'auf Wiedersehen'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    95
        e colAt:3 put:'au revoir '.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    96
        e tabulatorSpecification:tabs.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    97
        myList add:e.
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
    98
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
    99
        v := ListView new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   100
        v setList:myList expandTabs:false.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   101
        v extent:500@100.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   102
        v open
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   103
                                                                        [exEnd]
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   104
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   105
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   106
58
claus
parents: 36
diff changeset
   107
     many multiColListEntries in a scrollable ListView
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   108
                                                                        [exBegin]
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   109
        |v l e myList tabs|
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   110
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   111
        myList := OrderedCollection new.
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
   112
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   113
        tabs := TabulatorSpecification new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   114
        tabs unit:#cm.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   115
        tabs positions:#(1 3 5).
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   116
        tabs align:#(#right #center #left).
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
   117
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   118
        1 to:100 do:[:i|
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   119
            e := MultiColListEntry new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   120
            e colAt:1 put:i printString.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   121
            e colAt:2 put:i squared printString.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   122
            e colAt:3 put:i sqrt  printString.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   123
            e tabulatorSpecification:tabs.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   124
            myList add:e.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   125
        ].
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   126
        l := ListView new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   127
        l setList:myList expandTabs:false.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   128
        v := ScrollableView forView:l.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   129
        v extent:300@200.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   130
        v open
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   131
                                                                        [exEnd]
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   132
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   133
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   134
58
claus
parents: 36
diff changeset
   135
     like above, but uses nicer decimal alignments
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   136
                                                                        [exBegin]
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   137
        |v l e myList tabs|
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   138
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   139
        myList := OrderedCollection new.
58
claus
parents: 36
diff changeset
   140
        
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   141
        tabs := TabulatorSpecification new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   142
        tabs unit:#cm.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   143
        tabs positions:#(1 3 6 9 12).
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   144
        tabs align:#(#right #decimal #decimal #decimal #decimal).
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
   145
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   146
        1 to:100 do:[:i|
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   147
            e := MultiColListEntry new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   148
            e colAt:1 put:i printString.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   149
            e colAt:2 put:i log printString.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   150
            e colAt:3 put:i sqrt  printString.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   151
            e colAt:4 put:i sin  printString.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   152
            e colAt:5 put:i cos  printString.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   153
            e tabulatorSpecification:tabs.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   154
            myList add:e.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   155
        ].
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   156
        l := ListView new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   157
        l setList:myList expandTabs:false.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   158
        v := ScrollableView forView:l.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   159
        v extent:600@200.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   160
        v open
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   161
                                                                        [exEnd]
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   162
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   163
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   164
58
claus
parents: 36
diff changeset
   165
     specifying tabs in inches
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   166
                                                                        [exBegin]
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   167
        |v l e myList tabs|
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
   168
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   169
        myList := OrderedCollection new.
19
79ab6bc98651 Initial revision
claus
parents:
diff changeset
   170
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   171
        tabs := TabulatorSpecification new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   172
        tabs unit:#inch.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   173
        tabs positions:#(0 2 3.5 4 6 8 10 12).
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   174
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   175
        e := MultiColListEntry new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   176
        e colAt:1 put:'2'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   177
        e colAt:2 put:'3.5'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   178
        e colAt:3 put:'4'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   179
        e colAt:4 put:'6'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   180
        e colAt:5 put:'8'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   181
        e colAt:6 put:'10'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   182
        e colAt:7 put:'12'.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   183
        e tabulatorSpecification:tabs.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   184
        myList add:e.
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   185
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   186
        myList add:((MultiColListEntry fromString:'| | | | | | |')
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   187
                         tabulatorSpecification:tabs).
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   188
        myList add:((MultiColListEntry fromString:'xxx xxx xxx xxx xxx xxx xxx')
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   189
                         tabulatorSpecification:tabs).
58
claus
parents: 36
diff changeset
   190
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   191
        l := ListView new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   192
        l setList:myList expandTabs:false.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   193
        v := HVScrollableView forView:l.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   194
        v extent:600@200.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   195
        v open
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   196
                                                                        [exEnd]
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   197
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   198
58
claus
parents: 36
diff changeset
   199
     if you have the columns available as a collection, 
claus
parents: 36
diff changeset
   200
     setup can be done easier
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   201
                                                                        [exBegin]
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   202
        |v l e myList tabs|
58
claus
parents: 36
diff changeset
   203
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   204
        myList := OrderedCollection new.
58
claus
parents: 36
diff changeset
   205
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   206
        tabs := TabulatorSpecification new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   207
        tabs unit:#inch.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   208
        tabs positions:#(0 2 3.5 4 6 8 10 12).
58
claus
parents: 36
diff changeset
   209
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   210
        e := MultiColListEntry new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   211
        e strings:#('2' '3.5' '4' '6' '8' '10' '12').
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   212
        e tabulatorSpecification:tabs.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   213
        myList add:e.
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   214
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   215
        l := ListView new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   216
        l setList:myList expandTabs:false.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   217
        v := HVScrollableView forView:l.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   218
        v extent:600@200.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   219
        v open
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   220
                                                                        [exEnd]
58
claus
parents: 36
diff changeset
   221
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   222
357
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   223
     using icons instead of strings:
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   224
                                                                        [exBegin]
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   225
        |v l e myList tabs i1 i2 i3|
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   226
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   227
        myList := OrderedCollection new.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   228
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   229
        tabs := TabulatorSpecification new.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   230
        tabs unit:#cm.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   231
        tabs positions:#(1 3 5).
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   232
        tabs align:#(#left #left #left).
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   233
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   234
        i1 := Image fromFile:'bitmaps/xpmBitmaps/document_images/small_dir.xpm'.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   235
        i2 := Image fromFile:'bitmaps/xpmBitmaps/document_images/small_file.xpm'.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   236
        i3 := Image fromFile:'bitmaps/xpmBitmaps/document_images/small_file_binary.xpm'.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   237
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   238
        1 to:100 do:[:i|
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   239
            e := MultiColListEntry new.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   240
            i odd ifTrue:[
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   241
                e colAt:1 put:i1.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   242
            ] ifFalse:[
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   243
                e colAt:1 put:i2
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   244
            ].
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   245
            e colAt:2 put:i printString.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   246
            e colAt:3 put:i3.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   247
            e tabulatorSpecification:tabs.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   248
            myList add:e.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   249
        ].
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   250
        l := SelectionInListView new.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   251
        l setList:myList expandTabs:false.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   252
        v := ScrollableView forView:l.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   253
        v extent:300@200.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   254
        v open
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   255
                                                                        [exEnd]
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   256
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   257
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   258
58
claus
parents: 36
diff changeset
   259
    concrete example, show /etc/passwd in a table:
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   260
                                                                        [exBegin]
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   261
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   262
        |v l s myList line e htabs tabs fingerEntry|
58
claus
parents: 36
diff changeset
   263
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   264
        tabs := TabulatorSpecification new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   265
        tabs unit:#inch.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   266
        tabs positions:#(0    2      3.5  4.5   5    8    11).
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   267
        tabs align:    #(left left right right left left left).
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   268
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   269
        htabs := TabulatorSpecification new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   270
        htabs unit:#inch.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   271
        htabs positions:#(0    2      3.5      4.5    5    8    11).
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   272
        htabs align:    #(left center center center left left left).
58
claus
parents: 36
diff changeset
   273
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   274
        myList := OrderedCollection new.
58
claus
parents: 36
diff changeset
   275
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   276
        e := MultiColListEntry 
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   277
                    fromString:'login-name:password:uid:gid:finger-entry:home-dir:shell' 
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   278
                    separatedBy:$:.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   279
        e tabulatorSpecification:htabs.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   280
        myList add:e.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   281
        myList add:''.
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   282
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   283
        s := '/etc/passwd' asFilename readStream.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   284
        [s atEnd] whileFalse:[
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   285
            line := s nextLine.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   286
            e := MultiColListEntry 
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   287
                        fromString:line
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   288
                        separatedBy:$:.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   289
            fingerEntry := e colAt:5.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   290
            e colAt:5 put:(fingerEntry asCollectionOfSubstringsSeparatedBy:$,) first.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   291
            e tabulatorSpecification:tabs.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   292
            myList add:e.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   293
        ].
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   294
        s close.
58
claus
parents: 36
diff changeset
   295
        
161
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   296
        l := ListView new.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   297
        l setList:myList expandTabs:false.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   298
        v := HVScrollableView forView:l.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   299
        v extent:600@200.
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   300
        v open
5b6e284959a4 examples
Claus Gittinger <cg@exept.de>
parents: 158
diff changeset
   301
                                                                        [exEnd]
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   302
"
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   303
! !
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   304
329
098318898b01 comment
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
   305
!MultiColListEntry class methodsFor:'instance creation'!
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   306
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   307
fromString:aString
1159
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   308
    "create and return a new listEntry with columns taken
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   309
     from the words of aString. Assumes that columns are
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   310
     separated by spaces in the string"
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   311
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   312
    ^ self fromString:aString separatedBy:Character space
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   313
!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   314
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   315
fromString:aString separatedBy:separatorCharacter
1159
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   316
    "create and return a new listEntry with columns taken
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   317
     from the words of aString. Assumes that columns are
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   318
     separated by separatorCharacter in the string"
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   319
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   320
    |subStrings e|
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   321
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   322
    e := self new.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   323
    subStrings := aString asCollectionOfSubstringsSeparatedBy:separatorCharacter.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   324
    subStrings keysAndValuesDo:[:i :sub |
1159
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   325
        e colAt:i put:sub.
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   326
    ].
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   327
    ^ e
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   328
!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   329
70
claus
parents: 62
diff changeset
   330
new:numberOfColumns
1159
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   331
    "create and return a new listEntry with numberOfColumns empty columns"
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   332
70
claus
parents: 62
diff changeset
   333
    |e|
claus
parents: 62
diff changeset
   334
claus
parents: 62
diff changeset
   335
    e := self new.
claus
parents: 62
diff changeset
   336
    1 to:numberOfColumns do:[:i |
1159
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   337
        e colAt:i put:''.
70
claus
parents: 62
diff changeset
   338
    ].
claus
parents: 62
diff changeset
   339
    ^ e
claus
parents: 62
diff changeset
   340
claus
parents: 62
diff changeset
   341
    "Modified: 30.8.1995 / 16:33:53 / claus"
claus
parents: 62
diff changeset
   342
!
claus
parents: 62
diff changeset
   343
claus
parents: 62
diff changeset
   344
new:numberOfColumns tabulatorSpecification:aTabSpec
1159
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   345
    "create and return a new listEntry with numberOfColumns empty columns
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   346
     and the given tab-specification"
eda06596899f comments
Claus Gittinger <cg@exept.de>
parents: 366
diff changeset
   347
70
claus
parents: 62
diff changeset
   348
    ^ (self new:numberOfColumns) tabulatorSpecification:aTabSpec
claus
parents: 62
diff changeset
   349
claus
parents: 62
diff changeset
   350
    "Modified: 30.8.1995 / 16:34:23 / claus"
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   351
! !
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   352
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   353
!MultiColListEntry methodsFor:'accessing'!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   354
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   355
colAt:index
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   356
    "return the substring at column index"
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   357
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   358
    index > strings size ifTrue:[^ nil].
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   359
    ^ strings at:index
70
claus
parents: 62
diff changeset
   360
!
claus
parents: 62
diff changeset
   361
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   362
colAt:index put:aString
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   363
    "replace the substring at column index"
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   364
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   365
    strings isNil ifTrue:[
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   366
	strings := OrderedCollection new:index
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   367
    ].
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   368
    index > strings size ifTrue:[strings grow:index].
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   369
    strings at:index put:aString
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   370
!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   371
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   372
strings:aCollectionOfStrings
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   373
    "replace all substrings"
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   374
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   375
    strings := OrderedCollection withAll:aCollectionOfStrings. 
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   376
!
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   377
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   378
tabulatorSpecification:aTabSpec
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   379
    "set the tabulator spec"
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   380
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   381
    tabSpec := aTabSpec
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   382
! !
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   383
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   384
!MultiColListEntry methodsFor:'converting'!
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   385
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   386
asString
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   387
    "return the receiver as a string with embedded tabs"
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   388
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   389
    |s sub tab 
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   390
     nSub "{ Class: SmallInteger }"|
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   391
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   392
    s := ''.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   393
    tab := Character tab asString.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   394
    nSub := strings size.
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   395
    1 to:nSub do:[:subStringIndex |
363
c025abf2d73c care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   396
        sub := strings at:subStringIndex.
c025abf2d73c care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   397
        sub notNil ifTrue:[
c025abf2d73c care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   398
            sub isString ifTrue:[
c025abf2d73c care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   399
                s := s , sub.
c025abf2d73c care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   400
            ]
c025abf2d73c care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   401
        ].
c025abf2d73c care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   402
        subStringIndex == nSub ifFalse:[
c025abf2d73c care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   403
            s := s , tab
c025abf2d73c care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   404
        ]
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   405
    ].
97
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   406
306cb0aa67be checkin from browser
Claus Gittinger <cg@exept.de>
parents: 89
diff changeset
   407
    ^ s
103
f950776fd4e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   408
f950776fd4e6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 98
diff changeset
   409
    "Created: 24.11.1995 / 18:54:27 / cg"
363
c025abf2d73c care for non-string entries in #asString.
Claus Gittinger <cg@exept.de>
parents: 357
diff changeset
   410
    "Modified: 17.4.1997 / 03:21:13 / cg"
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   411
! !
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   412
89
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   413
!MultiColListEntry methodsFor:'defaults'!
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   414
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   415
defaultTabSpec
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   416
    "the default tabulators are 1 inch apart"
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   417
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   418
    |spec|
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   419
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   420
    spec := DefaultTabSpec.
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   421
    spec isNil ifTrue:[
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   422
	spec := TabulatorSpecification new.
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   423
	spec unit:#inch.
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   424
	spec positions:(0 to:20).
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   425
	spec align:    #left.
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   426
	DefaultTabSpec := spec.
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   427
    ].
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   428
    ^ spec.
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   429
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   430
    "Created: 17.11.1995 / 12:23:29 / cg"
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   431
    "Modified: 17.11.1995 / 12:24:20 / cg"
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   432
! !
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   433
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   434
!MultiColListEntry methodsFor:'drawing'!
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   435
108
b228b94be590 displayOpaque fixes
Claus Gittinger <cg@exept.de>
parents: 103
diff changeset
   436
displayOn:aGC x:x y:y opaque:opaque
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   437
    "display the receiver on a GC"
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   438
357
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   439
    |xPos spec tabPos prevString y0|
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   440
89
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   441
    spec := tabSpec.
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   442
    spec isNil ifTrue:[
211
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   443
        spec := self defaultTabSpec
89
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   444
    ].
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   445
    xPos := x.
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   446
    prevString := ''.
364
38653918fee7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   447
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1159
diff changeset
   448
    aGC font:(aGC font onDevice:aGC device).
366
34e1870524f1 fetch device font before querying
Claus Gittinger <cg@exept.de>
parents: 364
diff changeset
   449
34e1870524f1 fetch device font before querying
Claus Gittinger <cg@exept.de>
parents: 364
diff changeset
   450
    y0 := y - aGC font ascent.
357
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   451
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   452
    strings keysAndValuesDo:[:index :subString |
357
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   453
        |item|
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   454
211
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   455
        subString notNil ifTrue:[
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   456
            "
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   457
             find next tab
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   458
            "
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   459
            tabPos := spec positionOfTab:index forString:subString on:aGC.
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   460
            tabPos isNil ifTrue:[
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   461
                "
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   462
                 no tab - just continue where we are ...
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   463
                "
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   464
                xPos := xPos + (prevString widthOn:aGC). "/ (aGC font widthOf:prevString).
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   465
            ] ifFalse:[
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   466
                xPos := tabPos + x.
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   467
            ].
357
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   468
            subString isString ifFalse:[
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   469
                item := subString.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   470
                item isImage ifTrue:[
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   471
                    strings at:index put:(item := item on:aGC device)
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   472
                ].
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   473
                item displayOn:aGC x:xPos y:y0
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   474
            ] ifTrue:[
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   475
                opaque ifTrue:[    
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   476
                    aGC displayOpaqueString:subString x:xPos y:y.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   477
                ] ifFalse:[    
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   478
                    aGC displayString:subString x:xPos y:y.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   479
                ].    
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   480
            ].
211
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   481
            prevString := subString.
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   482
        ]
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   483
    ].
89
eec056360d03 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 86
diff changeset
   484
366
34e1870524f1 fetch device font before querying
Claus Gittinger <cg@exept.de>
parents: 364
diff changeset
   485
    "Modified: 19.4.1997 / 09:54:56 / cg"
58
claus
parents: 36
diff changeset
   486
! !
36
160b8f0dfd7d *** empty log message ***
claus
parents: 34
diff changeset
   487
58
claus
parents: 36
diff changeset
   488
!MultiColListEntry methodsFor:'queries'!
claus
parents: 36
diff changeset
   489
357
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   490
heightOn:aGC
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   491
    "return the height of the receiver when displayed in aGC"
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   492
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   493
    |hMax|
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   494
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   495
    hMax := 0.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   496
    strings keysAndValuesDo:[:index :subString |
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   497
        |h|
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   498
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   499
        subString notNil ifTrue:[
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   500
            h := subString heightOn:aGC.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   501
            hMax := hMax max:h.
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   502
        ]
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   503
    ].
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   504
    ^ hMax
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   505
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   506
    "Created: 15.4.1997 / 09:39:07 / cg"
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   507
!
658764fa1f0f handle non-string items
Claus Gittinger <cg@exept.de>
parents: 329
diff changeset
   508
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   509
widthOn:aGC
58
claus
parents: 36
diff changeset
   510
    "return the width of the receiver when displayed in aGC"
claus
parents: 36
diff changeset
   511
62
claus
parents: 58
diff changeset
   512
    |xPos xMax tabPos prevLen|
58
claus
parents: 36
diff changeset
   513
claus
parents: 36
diff changeset
   514
    "just to make certain:
claus
parents: 36
diff changeset
   515
     do not assume, that the last col is the rightmost one ...
claus
parents: 36
diff changeset
   516
    "
claus
parents: 36
diff changeset
   517
    xPos := 0.
claus
parents: 36
diff changeset
   518
    xMax := 0.
claus
parents: 36
diff changeset
   519
    prevLen := 0.
claus
parents: 36
diff changeset
   520
    strings keysAndValuesDo:[:index :subString |
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   521
        |w|
62
claus
parents: 58
diff changeset
   522
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   523
        subString notNil ifTrue:[
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   524
            "
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   525
             find next tab
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   526
            "
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   527
            tabPos := tabSpec positionOfTab:index forString:subString on:aGC.
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   528
            tabPos isNil ifTrue:[
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   529
                "
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   530
                 no tab - just continue where we are ...
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   531
                "
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   532
                xPos := xPos + prevLen.
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   533
            ] ifFalse:[
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   534
                xPos := tabPos.
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   535
            ].
211
f6e9378de69f allow columns to consist of Text instances
Claus Gittinger <cg@exept.de>
parents: 173
diff changeset
   536
            w := prevLen := subString widthOn:aGC. "/ aGC font widthOf:subString.
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   537
            xMax := xMax max:(xPos + w).
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   538
        ]
58
claus
parents: 36
diff changeset
   539
    ].
364
38653918fee7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   540
    xMax isInteger ifFalse:[
38653918fee7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   541
        ^ xMax truncated + 1
38653918fee7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   542
    ].
58
claus
parents: 36
diff changeset
   543
    ^ xMax
173
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   544
d111da00daa9 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 161
diff changeset
   545
    "Created: 12.5.1996 / 20:38:38 / cg"
364
38653918fee7 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 363
diff changeset
   546
    "Modified: 17.4.1997 / 12:52:00 / cg"
58
claus
parents: 36
diff changeset
   547
! !
claus
parents: 36
diff changeset
   548
329
098318898b01 comment
Claus Gittinger <cg@exept.de>
parents: 211
diff changeset
   549
!MultiColListEntry class methodsFor:'documentation'!
98
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   550
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   551
version
1478
38f08dec8e34 #on: -> #onDevice:
Claus Gittinger <cg@exept.de>
parents: 1159
diff changeset
   552
    ^ '$Header: /cvs/stx/stx/libwidg2/MultiColListEntry.st,v 1.25 1999-08-18 14:40:25 cg Exp $'
98
de14b996ee80 version at the end
Claus Gittinger <cg@exept.de>
parents: 97
diff changeset
   553
! !