TabulatorSpecification.st
changeset 327 25ced24b63ea
parent 199 8a0ce1ae9ad8
child 1881 af7335c0fbd2
equal deleted inserted replaced
326:7abb145cb6f4 327:25ced24b63ea
     8  be provided or otherwise made available to, or used by, any
     8  be provided or otherwise made available to, or used by, any
     9  other person.  No title to or ownership of the software is
     9  other person.  No title to or ownership of the software is
    10  hereby transferred.
    10  hereby transferred.
    11 "
    11 "
    12 
    12 
    13 Object subclass:#TabulatorSpecification
    13 Model subclass:#TabulatorSpecification
    14 	instanceVariableNames:'tabUnit unitReference tabPositions tabTypes'
    14 	instanceVariableNames:'tabUnit unitReference tabPositions tabTypes'
    15 	classVariableNames:''
    15 	classVariableNames:''
    16 	poolDictionaries:''
    16 	poolDictionaries:''
    17 	category:'Views-Support'
    17 	category:'Views-Support'
    18 !
    18 !
   205 
   205 
   206         top := StandardSystemView extent:300@300.
   206         top := StandardSystemView extent:300@300.
   207 
   207 
   208         ruler := TabSpecRuler origin:0.0@0.0 corner:1.0@20 in:top.
   208         ruler := TabSpecRuler origin:0.0@0.0 corner:1.0@20 in:top.
   209         ruler level:0.
   209         ruler level:0.
       
   210         ruler tabsAreVariable:false.
       
   211 
   210         listView := ListView in:top.
   212         listView := ListView in:top.
   211         listView origin:0.0@0.0 corner:1.0@1.0.
   213         listView origin:0.0@0.0 corner:1.0@1.0.
   212         listView topInset:20.
   214         listView topInset:20.
   213 
   215 
   214         tabSpec := TabulatorSpecification new.
   216         tabSpec := TabulatorSpecification new.
   250               colAt:6 put:'1234.56'.
   252               colAt:6 put:'1234.56'.
   251 
   253 
   252         listView at:3 put:entry.
   254         listView at:3 put:entry.
   253         top open
   255         top open
   254                                                                         [exEnd]
   256                                                                         [exEnd]
       
   257 
       
   258   much like previous example, but allow some tab positions to be
       
   259   changed (with synchronousOperation):
       
   260                                                                         [exBegin]
       
   261         |top ruler listView tabSpec entry|
       
   262 
       
   263         top := StandardSystemView extent:300@300.
       
   264 
       
   265         ruler := TabSpecRuler origin:0.0@0.0 corner:1.0@20 in:top.
       
   266         ruler level:0.
       
   267         ruler fixedTabs:#(1).
       
   268         ruler synchronousOperation:true.
       
   269 
       
   270         listView := ListView in:top.
       
   271         listView origin:0.0@0.0 corner:1.0@1.0.
       
   272         listView topInset:20.
       
   273 
       
   274         tabSpec := TabulatorSpecification new.
       
   275         tabSpec unit:#inch.
       
   276         tabSpec positions:#(0     1     2.5    3.5    4       5        ).
       
   277         tabSpec align:    #(#left #left #left #left #left #decimal ).
       
   278 
       
   279         ruler tabulatorSpecification:tabSpec.
       
   280 
       
   281         entry := MultiColListEntry new.
       
   282         entry tabulatorSpecification:tabSpec.
       
   283         entry colAt:1 put:'left';
       
   284               colAt:2 put:'left';
       
   285               colAt:3 put:'left';
       
   286               colAt:4 put:'left';
       
   287               colAt:5 put:'left';
       
   288               colAt:6 put:'.decimal'.
       
   289 
       
   290         listView at:1 put:entry.
       
   291 
       
   292         entry := MultiColListEntry new.
       
   293         entry tabulatorSpecification:tabSpec.
       
   294         entry colAt:1 put:'col1';
       
   295               colAt:2 put:'col2';
       
   296               colAt:3 put:'col3';
       
   297               colAt:4 put:'col4';
       
   298               colAt:5 put:'col5';
       
   299               colAt:6 put:'col6'.
       
   300 
       
   301         listView at:2 put:entry.
       
   302 
       
   303         entry := MultiColListEntry new.
       
   304         entry tabulatorSpecification:tabSpec.
       
   305         entry colAt:1 put:'foo';
       
   306               colAt:2 put:'fooBar';
       
   307               colAt:3 put:'bar';
       
   308               colAt:4 put:'barFoo';
       
   309               colAt:5 put:'baz';
       
   310               colAt:6 put:'1234.56'.
       
   311 
       
   312         listView at:3 put:entry.
       
   313 
       
   314         entry := MultiColListEntry new.
       
   315         entry tabulatorSpecification:tabSpec.
       
   316         entry colAt:1 put:'hello';
       
   317               colAt:2 put:'world';
       
   318               colAt:3 put:'how';
       
   319               colAt:4 put:'about';
       
   320               colAt:5 put:'this';
       
   321               colAt:6 put:'0.2345'.
       
   322         listView at:4 put:entry.
       
   323 
       
   324         tabSpec onChangeSend:#redraw to:listView.
       
   325         top open
       
   326                                                                         [exEnd]
   255 "
   327 "
   256 ! !
   328 ! !
   257 
   329 
   258 !TabulatorSpecification class methodsFor:'instance creation'!
   330 !TabulatorSpecification class methodsFor:'instance creation'!
   259 
   331 
   286 
   358 
   287     "
   359     "
   288     tabTypes := types
   360     tabTypes := types
   289 !
   361 !
   290 
   362 
       
   363 moveTabAtIndex:index to:unitPosition
       
   364     "set an individual position"
       
   365 
       
   366     tabPositions at:index put:unitPosition.
       
   367     self changed:#tabPosition with:index
       
   368 
       
   369     "Modified: 28.3.1997 / 14:55:27 / cg"
       
   370 !
       
   371 
   291 positions
   372 positions
   292     "return the position-vector"
   373     "return the position-vector"
   293 
   374 
   294     ^ tabPositions
   375     ^ tabPositions
   295 !
   376 !
   361 ! !
   442 ! !
   362 
   443 
   363 !TabulatorSpecification methodsFor:'queries'!
   444 !TabulatorSpecification methodsFor:'queries'!
   364 
   445 
   365 pixelsPerUnitOn:aGC
   446 pixelsPerUnitOn:aGC
       
   447     "return the number of device pixels one unit of my tabs
       
   448      takes on aGC"
       
   449 
   366     |device mm|
   450     |device mm|
   367 
   451 
   368     "
       
   369      return the number of device pixels one unit of my tabs
       
   370      takes on aGC
       
   371     "
       
   372     tabUnit isNil ifTrue:[
   452     tabUnit isNil ifTrue:[
   373         tabUnit := #col
   453         tabUnit := #col
   374     ].
   454     ].
   375     tabUnit == #relative ifTrue:[
   455     tabUnit == #relative ifTrue:[
   376         ^ unitReference width
   456         ^ unitReference width
   392     "
   472     "
   393      assume pixels
   473      assume pixels
   394     "
   474     "
   395     ^ 1.
   475     ^ 1.
   396 
   476 
   397     "Modified: 28.5.1996 / 20:25:34 / cg"
   477     "Modified: 28.3.1997 / 14:52:12 / cg"
   398 !
   478 !
   399 
   479 
   400 positionOfTab:index forString:aString on:aGC
   480 positionOfTab:index forString:aString on:aGC
   401     "return the position (in device units) of the string to be drawn
   481     "return the position (in device units) of the string to be drawn
   402      at position index."
   482      at position index."
   448 	].
   528 	].
   449 	^ tabTypes at:index.
   529 	^ tabTypes at:index.
   450     ].
   530     ].
   451     "default is left"
   531     "default is left"
   452     ^ #left
   532     ^ #left
       
   533 !
       
   534 
       
   535 unitsPerPixelOn:aGC
       
   536     "return the number of units that one device pixels 
       
   537      takes on aGC"
       
   538 
       
   539     ^ 1 / (self pixelsPerUnitOn:aGC)
       
   540 
       
   541     "Modified: 28.3.1997 / 14:52:01 / cg"
   453 ! !
   542 ! !
   454 
   543 
   455 !TabulatorSpecification class methodsFor:'documentation'!
   544 !TabulatorSpecification class methodsFor:'documentation'!
   456 
   545 
   457 version
   546 version
   458     ^ '$Header: /cvs/stx/stx/libwidg2/TabulatorSpecification.st,v 1.13 1996-06-04 20:33:56 cg Exp $'
   547     ^ '$Header: /cvs/stx/stx/libwidg2/TabulatorSpecification.st,v 1.14 1997-03-28 14:20:35 cg Exp $'
   459 ! !
   548 ! !