TabSpecRuler.st
changeset 342 9e7148fb27c4
parent 330 e216c5a56f88
child 365 4228b1451bc9
--- a/TabSpecRuler.st	Tue Apr 01 13:22:42 1997 +0200
+++ b/TabSpecRuler.st	Tue Apr 01 15:32:55 1997 +0200
@@ -11,9 +11,9 @@
 "
 
 SimpleView subclass:#TabSpecRuler
-	instanceVariableNames:'tabSpec titleEntry handleStyle handleCursor movedTabIndex
-		movedTabX synchronousOperation handleWidth fixedTabs
-		tabsAreVariable hiddenTabs'
+	instanceVariableNames:'tabSpec titles handleStyle handleCursor movedTabIndex movedTabX
+		synchronousOperation handleWidth fixedTabs tabsAreVariable
+		hiddenTabs'
 	classVariableNames:'DefaultHandleStyle'
 	poolDictionaries:''
 	category:'Views-Misc'
@@ -71,6 +71,26 @@
     head tabulatorSpecification:spec.
     top open.
                                                                 [exEnd]
+
+                                                                [exBegin]
+    |top head spec|
+
+    top := View new.
+    top extent:300@100.
+
+    head := TabSpecRuler in:top.
+    head width:1.0.
+    head level:1.
+    head titles:#('col1' 'col2' 'col3' 'col4' 'col5' 'col6').
+
+    spec := TabulatorSpecification new.
+    spec unit:#inch.
+    spec positions:#(0     1     2.5    3.5    4       5        ).
+    spec align:    #(#left #left #right #right #center #decimal ).
+
+    head tabulatorSpecification:spec.
+    top open.
+                                                                [exEnd]
 "
 
 ! !
@@ -168,6 +188,12 @@
     tabSpec := aTabSpec
 
     "Modified: 4.6.1996 / 22:34:31 / cg"
+!
+
+titles:aCollectionOfStrings
+    titles := aCollectionOfStrings
+
+    "Created: 1.4.1997 / 13:52:37 / cg"
 ! !
 
 !TabSpecRuler methodsFor:'event handling'!
@@ -202,6 +228,9 @@
             movedTabX := newX.
             self clearRectangleX:left+handleWidth y:0 
                            width:(right-left-handleWidth-handleWidth) height:height.
+            movedTabIndex ~~ 1 ifTrue:[
+                self redrawTitleAtIndex:(movedTabIndex - 1).
+            ].
             self redrawTabAtIndex:movedTabIndex.
             synchronousOperation == true ifTrue:[
                 self moveTabAtIndex:movedTabIndex toX:movedTabX
@@ -215,7 +244,7 @@
         ]
     ]
 
-    "Modified: 28.3.1997 / 15:17:14 / cg"
+    "Modified: 1.4.1997 / 15:21:16 / cg"
 !
 
 buttonPress:button x:x y:y
@@ -370,30 +399,58 @@
         self redrawTabAtIndex:idx.
     ]
 
-    "Modified: 28.3.1997 / 13:58:26 / cg"
+    "Modified: 1.4.1997 / 15:13:16 / cg"
 !
 
 redrawTabAtIndex:idx
     "redraw a single handle"
 
-    |x|
+    |x s|
 
     tabSpec isNil ifTrue:[^ self].
-    (hiddenTabs notNil and:[hiddenTabs includes:idx]) ifTrue:[^ self].
+    idx == movedTabIndex ifTrue:[
+        x := movedTabX
+    ] ifFalse:[
+        x := self positionOfTabAtIndex:idx.
+    ].
+
+    (hiddenTabs notNil and:[hiddenTabs includes:idx]) ifFalse:[
+        self drawHandleAtX:x type:(tabSpec typeOfTab:idx).
+    ].
+
+    titles notNil ifTrue:[
+        s := titles at:idx.
+        self paint:Color black.
+        s displayOn:self x:x+3 y:(font ascent).
+    ].
+
+    "Created: 28.3.1997 / 13:57:54 / cg"
+    "Modified: 1.4.1997 / 15:29:19 / cg"
+!
+
+redrawTitleAtIndex:idx
+    "redraw a single handle"
+
+    |x s|
+
+    tabSpec isNil ifTrue:[^ self].
+    titles isNil ifTrue:[^ self].
 
     idx == movedTabIndex ifTrue:[
         x := movedTabX
     ] ifFalse:[
         x := self positionOfTabAtIndex:idx.
     ].
-    self drawHandleAtX:x type:(tabSpec typeOfTab:idx).
 
-    "Created: 28.3.1997 / 13:57:54 / cg"
-    "Modified: 28.3.1997 / 15:37:07 / cg"
+    s := titles at:idx.
+    self paint:Color black.
+    s displayOn:self x:x+3 y:(font ascent).
+
+    "Modified: 1.4.1997 / 15:20:31 / cg"
 ! !
 
 !TabSpecRuler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/TabSpecRuler.st,v 1.10 1997-03-28 14:40:43 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/TabSpecRuler.st,v 1.11 1997-04-01 13:32:55 cg Exp $'
 ! !