TabulatorSpecification.st
changeset 327 25ced24b63ea
parent 199 8a0ce1ae9ad8
child 1881 af7335c0fbd2
--- a/TabulatorSpecification.st	Fri Mar 28 14:48:38 1997 +0100
+++ b/TabulatorSpecification.st	Fri Mar 28 15:20:35 1997 +0100
@@ -10,7 +10,7 @@
  hereby transferred.
 "
 
-Object subclass:#TabulatorSpecification
+Model subclass:#TabulatorSpecification
 	instanceVariableNames:'tabUnit unitReference tabPositions tabTypes'
 	classVariableNames:''
 	poolDictionaries:''
@@ -207,6 +207,8 @@
 
         ruler := TabSpecRuler origin:0.0@0.0 corner:1.0@20 in:top.
         ruler level:0.
+        ruler tabsAreVariable:false.
+
         listView := ListView in:top.
         listView origin:0.0@0.0 corner:1.0@1.0.
         listView topInset:20.
@@ -252,6 +254,76 @@
         listView at:3 put:entry.
         top open
                                                                         [exEnd]
+
+  much like previous example, but allow some tab positions to be
+  changed (with synchronousOperation):
+                                                                        [exBegin]
+        |top ruler listView tabSpec entry|
+
+        top := StandardSystemView extent:300@300.
+
+        ruler := TabSpecRuler origin:0.0@0.0 corner:1.0@20 in:top.
+        ruler level:0.
+        ruler fixedTabs:#(1).
+        ruler synchronousOperation:true.
+
+        listView := ListView in:top.
+        listView origin:0.0@0.0 corner:1.0@1.0.
+        listView topInset:20.
+
+        tabSpec := TabulatorSpecification new.
+        tabSpec unit:#inch.
+        tabSpec positions:#(0     1     2.5    3.5    4       5        ).
+        tabSpec align:    #(#left #left #left #left #left #decimal ).
+
+        ruler tabulatorSpecification:tabSpec.
+
+        entry := MultiColListEntry new.
+        entry tabulatorSpecification:tabSpec.
+        entry colAt:1 put:'left';
+              colAt:2 put:'left';
+              colAt:3 put:'left';
+              colAt:4 put:'left';
+              colAt:5 put:'left';
+              colAt:6 put:'.decimal'.
+
+        listView at:1 put:entry.
+
+        entry := MultiColListEntry new.
+        entry tabulatorSpecification:tabSpec.
+        entry colAt:1 put:'col1';
+              colAt:2 put:'col2';
+              colAt:3 put:'col3';
+              colAt:4 put:'col4';
+              colAt:5 put:'col5';
+              colAt:6 put:'col6'.
+
+        listView at:2 put:entry.
+
+        entry := MultiColListEntry new.
+        entry tabulatorSpecification:tabSpec.
+        entry colAt:1 put:'foo';
+              colAt:2 put:'fooBar';
+              colAt:3 put:'bar';
+              colAt:4 put:'barFoo';
+              colAt:5 put:'baz';
+              colAt:6 put:'1234.56'.
+
+        listView at:3 put:entry.
+
+        entry := MultiColListEntry new.
+        entry tabulatorSpecification:tabSpec.
+        entry colAt:1 put:'hello';
+              colAt:2 put:'world';
+              colAt:3 put:'how';
+              colAt:4 put:'about';
+              colAt:5 put:'this';
+              colAt:6 put:'0.2345'.
+        listView at:4 put:entry.
+
+        tabSpec onChangeSend:#redraw to:listView.
+        top open
+                                                                        [exEnd]
 "
 ! !
 
@@ -288,6 +360,15 @@
     tabTypes := types
 !
 
+moveTabAtIndex:index to:unitPosition
+    "set an individual position"
+
+    tabPositions at:index put:unitPosition.
+    self changed:#tabPosition with:index
+
+    "Modified: 28.3.1997 / 14:55:27 / cg"
+!
+
 positions
     "return the position-vector"
 
@@ -363,12 +444,11 @@
 !TabulatorSpecification methodsFor:'queries'!
 
 pixelsPerUnitOn:aGC
+    "return the number of device pixels one unit of my tabs
+     takes on aGC"
+
     |device mm|
 
-    "
-     return the number of device pixels one unit of my tabs
-     takes on aGC
-    "
     tabUnit isNil ifTrue:[
         tabUnit := #col
     ].
@@ -394,7 +474,7 @@
     "
     ^ 1.
 
-    "Modified: 28.5.1996 / 20:25:34 / cg"
+    "Modified: 28.3.1997 / 14:52:12 / cg"
 !
 
 positionOfTab:index forString:aString on:aGC
@@ -450,10 +530,19 @@
     ].
     "default is left"
     ^ #left
+!
+
+unitsPerPixelOn:aGC
+    "return the number of units that one device pixels 
+     takes on aGC"
+
+    ^ 1 / (self pixelsPerUnitOn:aGC)
+
+    "Modified: 28.3.1997 / 14:52:01 / cg"
 ! !
 
 !TabulatorSpecification class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/TabulatorSpecification.st,v 1.13 1996-06-04 20:33:56 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TabulatorSpecification.st,v 1.14 1997-03-28 14:20:35 cg Exp $'
 ! !