MCLEntry.st
changeset 19 79ab6bc98651
child 25 e07adf47d209
equal deleted inserted replaced
18:4560fcdc40df 19:79ab6bc98651
       
     1 'From Smalltalk/X, Version:2.10.3 on 12-aug-1994 at 10:44:03 pm'!
       
     2 
       
     3 Object subclass:#MultiColListEntry
       
     4          instanceVariableNames:'strings tabSpec'
       
     5          classVariableNames:''
       
     6          poolDictionaries:''
       
     7          category:'Views-Support'
       
     8 !
       
     9 
       
    10 !MultiColListEntry methodsFor:'accessing'!
       
    11 
       
    12 colAt:index put:aString
       
    13     strings isNil ifTrue:[
       
    14         strings := OrderedCollection new:index
       
    15     ].
       
    16     strings grow:index.
       
    17     strings at:index put:aString
       
    18 
       
    19 
       
    20 
       
    21 !
       
    22 
       
    23 tabulatorSpecification:aTabSpec
       
    24     tabSpec := aTabSpec
       
    25 
       
    26 
       
    27 ! !
       
    28 
       
    29 !MultiColListEntry methodsFor:'converting'!
       
    30 
       
    31 asString
       
    32     |s tab|
       
    33 
       
    34     s := ''.
       
    35     tab := Character tab asString.
       
    36     1 to:strings size do:[:subStringIndex |
       
    37         s := s , (strings at:subStringIndex).
       
    38         subStringIndex == strings size ifFalse:[
       
    39             s := s , tab
       
    40         ]
       
    41     ].
       
    42 
       
    43     ^ s
       
    44 ! !
       
    45 
       
    46 !MultiColListEntry methodsFor:'drawing'!
       
    47 
       
    48 displayOn:aGC x:x y:y
       
    49     |xPos subString tabPos w prevString|
       
    50 
       
    51     xPos := x.
       
    52     prevString := ''.
       
    53     1 to:strings size do:[:index |
       
    54         subString := strings at:index.
       
    55 
       
    56         "
       
    57          find next tab
       
    58         "
       
    59         tabPos := tabSpec positionOfTab:index forString:subString on:aGC.
       
    60         tabPos isNil ifTrue:[
       
    61             "
       
    62              no tab - just continue where we are ...
       
    63             "
       
    64             xPos := xPos + (aGC font widthOf:prevString).
       
    65         ] ifFalse:[
       
    66             xPos := tabPos + x.
       
    67         ].
       
    68         aGC displayString:subString x:xPos y:y.
       
    69         prevString := subString.
       
    70     ].
       
    71 
       
    72     "
       
    73      |v e myList tabs|
       
    74 
       
    75      myList := OrderedCollection new.
       
    76 
       
    77      tabs := TabulatorSpecification new.
       
    78      tabs unit:#inch.
       
    79      tabs positions:#(0 3 6).
       
    80      tabs align:#(left #left #left).
       
    81 
       
    82      e := MultiColListEntry new.
       
    83      e colAt:1 put:'hello'.
       
    84      e colAt:2 put:'hallo'.
       
    85      e colAt:3 put:'salut'.
       
    86      e tabulatorSpecification:tabs.
       
    87      myList add:e.
       
    88 
       
    89      e := MultiColListEntry new.
       
    90      e colAt:1 put:'good morning'.
       
    91      e colAt:2 put:'guten Morgen'.
       
    92      e colAt:3 put:'bon jour'.
       
    93      e tabulatorSpecification:tabs.
       
    94      myList add:e.
       
    95 
       
    96      e := MultiColListEntry new.
       
    97      e colAt:1 put:'good bye'.
       
    98      e colAt:2 put:'auf Wiedersehen'.
       
    99      e colAt:3 put:'au revoir '.
       
   100      e tabulatorSpecification:tabs.
       
   101      myList add:e.
       
   102 
       
   103      v := ListView new.
       
   104      v setList:myList expandTabs:false.
       
   105      v open
       
   106     "
       
   107     "
       
   108      |v e myList tabs|
       
   109 
       
   110      myList := OrderedCollection new.
       
   111 
       
   112      tabs := TabulatorSpecification new.
       
   113      tabs unit:#cm.
       
   114      tabs positions:#(1 3 5).
       
   115      tabs align:#(#right #center #left).
       
   116 
       
   117      1 to:100 do:[:i|
       
   118          e := MultiColListEntry new.
       
   119          e colAt:1 put:i printString.
       
   120          e colAt:2 put:i squared printString.
       
   121          e colAt:3 put:i sqrt  printString.
       
   122          e tabulatorSpecification:tabs.
       
   123          myList add:e.
       
   124      ].
       
   125      v := ScrollableView for:ListView.
       
   126      v setList:myList expandTabs:false.
       
   127      v open
       
   128     "
       
   129     "
       
   130      |v e myList tabs|
       
   131 
       
   132      myList := OrderedCollection new.
       
   133 
       
   134      tabs := TabulatorSpecification new.
       
   135      tabs unit:#cm.
       
   136      tabs positions:#(1 3 6 9 12).
       
   137      tabs align:#(#right #decimal #decimal #decimal #decimal).
       
   138 
       
   139      1 to:100 do:[:i|
       
   140          e := MultiColListEntry new.
       
   141          e colAt:1 put:i printString.
       
   142          e colAt:2 put:i log printString.
       
   143          e colAt:3 put:i sqrt  printString.
       
   144          e colAt:4 put:i sin  printString.
       
   145          e colAt:5 put:i cos  printString.
       
   146          e tabulatorSpecification:tabs.
       
   147          myList add:e.
       
   148      ].
       
   149      v := ScrollableView for:ListView.
       
   150      v setList:myList expandTabs:false.
       
   151      v open
       
   152     "
       
   153     "
       
   154      |v e myList tabs|
       
   155 
       
   156      myList := OrderedCollection new.
       
   157 
       
   158      e := MultiColListEntry new.
       
   159      e colAt:1 put:'2'.
       
   160      e colAt:2 put:'3.5'.
       
   161      e colAt:3 put:'4'.
       
   162      e colAt:4 put:'6'.
       
   163      e colAt:5 put:'8'.
       
   164      e colAt:6 put:'10'.
       
   165      e colAt:7 put:'12'.
       
   166      e tabPositions:#(0 2 3.5 4 6 8 10 12); tabUnit:#inch.
       
   167      myList add:e.
       
   168 
       
   169      v := ScrollableView for:ListView.
       
   170      v setList:myList expandTabs:false.
       
   171      v open
       
   172     "
       
   173 
       
   174 
       
   175 
       
   176 
       
   177 
       
   178 
       
   179 
       
   180 
       
   181 
       
   182 
       
   183 ! !
       
   184