VRuler.st
changeset 28 ca403f4c5b86
parent 27 12e5a38bf0a8
child 33 3e68e4c73db3
equal deleted inserted replaced
27:12e5a38bf0a8 28:ca403f4c5b86
    21 COPYRIGHT (c) 1991 by Claus Gittinger
    21 COPYRIGHT (c) 1991 by Claus Gittinger
    22 	      All Rights Reserved
    22 	      All Rights Reserved
    23 
    23 
    24 a VerticalRuler for page layout.
    24 a VerticalRuler for page layout.
    25 
    25 
    26 $Header: /cvs/stx/stx/libwidg2/Attic/VRuler.st,v 1.1 1994-11-17 14:42:58 claus Exp $
    26 $Header: /cvs/stx/stx/libwidg2/Attic/VRuler.st,v 1.2 1994-11-21 16:48:22 claus Exp $
    27 
    27 
    28 written oct 91 by claus
    28 written oct 91 by claus
    29 '!
    29 '!
    30 
    30 
    31 !VerticalRuler methodsFor:'accessing'!
    31 !VerticalRuler methodsFor:'accessing'!
    49 ! !
    49 ! !
    50 
    50 
    51 !VerticalRuler methodsFor:'redrawing'!
    51 !VerticalRuler methodsFor:'redrawing'!
    52 
    52 
    53 redraw
    53 redraw
    54     "redraw scale"
    54     "redraw the scale"
    55 
    55 
    56     |y pixelPerMM pixelPerInch mod pos shortLen veryShortLen longLen charX
    56     |y pixelPerMM pixelPerInch mod pos shortLen veryShortLen longLen charX
    57      left paperHeightMM paperHeightPixel yOrigin labelBot marg fontHeight|
    57      left paperHeightMM paperHeightPixel yOrigin labelBot marg fontHeight|
    58 
    58 
    59     shown ifFalse:[^ self].
    59     shown ifFalse:[^ self].
    60 
    60 
    61 "/    self fill:viewBackground.
       
    62     self clear.
    61     self clear.
    63 
    62 
    64     yOrigin := self viewOrigin y.
    63     yOrigin := self viewOrigin y.
    65 
    64 
    66     paperHeightPixel := ((self inchToPixel:paperHeight) * scale) rounded.
    65     paperHeightPixel := ((self inchToPixel:paperHeight) * scale) rounded.
    93 	pos := 5.
    92 	pos := 5.
    94 	labelBot := marg + font height + font ascent.
    93 	labelBot := marg + font height + font ascent.
    95 
    94 
    96 	y := (pixelPerMM * pos - yOrigin) rounded.
    95 	y := (pixelPerMM * pos - yOrigin) rounded.
    97 	[(y < height) and:[pos <= paperHeightMM]] whileTrue:[
    96 	[(y < height) and:[pos <= paperHeightMM]] whileTrue:[
    98 	    (mod == 1) ifTrue:[
    97 	    |l|
    99 		self displayLineFromX:left y:y
    98 
   100 				  toX:(left + shortLen) y:y
    99 	    l := shortLen.
   101 	    ] ifFalse:[
   100 	    (mod ~~ 1) ifTrue:[
   102 		y < labelBot ifFalse:[
   101 		y < labelBot ifFalse:[
   103 		    self displayLineFromX:left y:y
   102 		    l := longLen
   104 				      toX:(left + longLen) y:y.
       
   105 		    self displayString:(pos // 10) printString
       
   106 				     x:charX
       
   107 				     y:(y + marg + fontHeight)
       
   108 		]
   103 		]
       
   104 	    ].
       
   105 	    self displayLineFromX:left y:y toX:(left + l) y:y.
       
   106 
       
   107 	    (mod ~~ 1 and:[y >= labelBot]) ifTrue:[
       
   108 		self displayString:(pos // 10) printString
       
   109 				 x:charX
       
   110 				 y:(y + marg + fontHeight)
   109 	    ].
   111 	    ].
   110 	    mod := (mod + 1) \\ 2.
   112 	    mod := (mod + 1) \\ 2.
   111 	    pos := pos + 5.
   113 	    pos := pos + 5.
   112 	    y := (pixelPerMM * pos - yOrigin) rounded 
   114 	    y := (pixelPerMM * pos - yOrigin) rounded 
   113 	].
   115 	].
   122 	labelBot := marg + (font height + font ascent).
   124 	labelBot := marg + (font height + font ascent).
   123 
   125 
   124 	y := (pixelPerInch * pos - yOrigin) rounded.
   126 	y := (pixelPerInch * pos - yOrigin) rounded.
   125 	veryShortLen := longLen // 4.
   127 	veryShortLen := longLen // 4.
   126 	[(y < height) and:[pos <= paperHeight]] whileTrue:[
   128 	[(y < height) and:[pos <= paperHeight]] whileTrue:[
       
   129 	    |l|
       
   130 
       
   131 	    l := shortLen.
   127 	    (mod == 0) ifTrue:[
   132 	    (mod == 0) ifTrue:[
   128 		y < labelBot ifFalse:[
   133 		y < labelBot ifFalse:[
   129 		    self displayLineFromX:left y:y
   134 		    l := longLen.
   130 				      toX:(left + longLen) y:y.
   135 		]
       
   136 	    ] ifFalse:[
       
   137 		(mod == 2) ifFalse:[
       
   138 		    l := veryShortLen
       
   139 		]
       
   140 	    ].
       
   141 	    self displayLineFromX:left y:y toX:(left + l) y:y.
       
   142 
       
   143 	    (mod == 0) ifTrue:[
       
   144 		y < labelBot ifFalse:[
   131 		    self displayString:pos asInteger printString
   145 		    self displayString:pos asInteger printString
   132 				     x:charX
   146 				     x:charX
   133 				     y:(y + marg + fontHeight)
   147 				     y:(y + marg + fontHeight)
   134 		]
       
   135 	    ] ifFalse:[
       
   136 		(mod == 2) ifTrue:[
       
   137 		    self displayLineFromX:left y:y
       
   138 				      toX:(left + shortLen) y:y
       
   139 		] ifFalse:[
       
   140 		    self displayLineFromX:left y:y
       
   141 				      toX:(left + veryShortLen) y:y
       
   142 		]
   148 		]
   143 	    ].
   149 	    ].
   144 	    mod := (mod + 1) \\ 4.
   150 	    mod := (mod + 1) \\ 4.
   145 	    pos := pos + 0.25.
   151 	    pos := pos + 0.25.
   146 	    y := (pixelPerInch * pos - yOrigin) rounded
   152 	    y := (pixelPerInch * pos - yOrigin) rounded