27
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1994 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
Ruler subclass:#VerticalRuler
|
161
|
14 |
instanceVariableNames:''
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Misc'
|
27
|
18 |
!
|
|
19 |
|
33
|
20 |
!VerticalRuler class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1994 by Claus Gittinger
|
|
25 |
All Rights Reserved
|
27
|
26 |
|
33
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
27
|
35 |
|
33
|
36 |
documentation
|
|
37 |
"
|
|
38 |
like a Ruler, but vertical.
|
|
39 |
see documentation in Ruler
|
|
40 |
"
|
|
41 |
! !
|
27
|
42 |
|
|
43 |
!VerticalRuler methodsFor:'accessing'!
|
|
44 |
|
|
45 |
paperHeightInch:inches
|
|
46 |
"set the width of the document"
|
|
47 |
|
|
48 |
paperHeight := inches.
|
|
49 |
shown ifTrue:[
|
|
50 |
self redraw
|
|
51 |
]
|
|
52 |
!
|
|
53 |
|
|
54 |
paperHeightMM:millis
|
|
55 |
"set the width of the document"
|
|
56 |
|
|
57 |
paperHeight := self millimeterToInch:millis.
|
|
58 |
shown ifTrue:[
|
|
59 |
self redraw
|
|
60 |
]
|
|
61 |
! !
|
|
62 |
|
161
|
63 |
!VerticalRuler methodsFor:'initialization'!
|
|
64 |
|
|
65 |
initialize
|
|
66 |
super initialize.
|
|
67 |
|
|
68 |
self width:(font widthOf:'inch').
|
|
69 |
|
|
70 |
"
|
|
71 |
VerticalRuler new open
|
|
72 |
"
|
|
73 |
! !
|
|
74 |
|
27
|
75 |
!VerticalRuler methodsFor:'redrawing'!
|
|
76 |
|
|
77 |
redraw
|
28
|
78 |
"redraw the scale"
|
27
|
79 |
|
|
80 |
|y pixelPerMM pixelPerInch mod pos shortLen veryShortLen longLen charX
|
|
81 |
left paperHeightMM paperHeightPixel yOrigin labelBot marg fontHeight|
|
|
82 |
|
|
83 |
shown ifFalse:[^ self].
|
|
84 |
|
|
85 |
self clear.
|
|
86 |
|
|
87 |
yOrigin := self viewOrigin y.
|
|
88 |
|
|
89 |
paperHeightPixel := ((self inchToPixel:paperHeight) * scale) rounded.
|
|
90 |
|
|
91 |
(yOrigin + height > paperHeightPixel) ifTrue:[
|
|
92 |
self paint:(Color darkGrey).
|
34
|
93 |
self fillRectangleX:0 y:paperHeightPixel
|
27
|
94 |
width:width
|
34
|
95 |
height:(yOrigin + height - paperHeightPixel).
|
27
|
96 |
self paint:fgColor.
|
34
|
97 |
self displayLineFromX:0 y:paperHeightPixel
|
|
98 |
toX:width y:paperHeightPixel
|
27
|
99 |
].
|
|
100 |
|
|
101 |
self paint:fgColor.
|
|
102 |
|
|
103 |
left := 0. "width - (font widthOf:'WW')"
|
|
104 |
longLen := font widthOf:'WW'.
|
|
105 |
shortLen := longLen // 2.
|
|
106 |
charX := left + shortLen.
|
|
107 |
mod := 1.
|
|
108 |
marg := 3. "character shift"
|
|
109 |
fontHeight := font height.
|
|
110 |
|
34
|
111 |
showUnit ifTrue:[
|
|
112 |
labelBot := marg + font height + font ascent + yOrigin.
|
|
113 |
] ifFalse:[
|
|
114 |
labelBot := yOrigin
|
|
115 |
].
|
|
116 |
|
27
|
117 |
(metric == #mm) ifTrue:[
|
|
118 |
"centimeter - long blibs every centimeter; short ones every half"
|
|
119 |
|
|
120 |
paperHeightMM := self inchToMillimeter:paperHeight.
|
|
121 |
pixelPerMM := (self millimeterToPixel:1) * scale.
|
|
122 |
pos := 5.
|
34
|
123 |
y := (pixelPerMM * pos) rounded.
|
|
124 |
[(y < (height+yOrigin)) and:[pos <= paperHeightMM]] whileTrue:[
|
28
|
125 |
|l|
|
|
126 |
|
|
127 |
l := shortLen.
|
|
128 |
(mod ~~ 1) ifTrue:[
|
27
|
129 |
y < labelBot ifFalse:[
|
28
|
130 |
l := longLen
|
27
|
131 |
]
|
|
132 |
].
|
28
|
133 |
self displayLineFromX:left y:y toX:(left + l) y:y.
|
|
134 |
|
|
135 |
(mod ~~ 1 and:[y >= labelBot]) ifTrue:[
|
|
136 |
self displayString:(pos // 10) printString
|
|
137 |
x:charX
|
|
138 |
y:(y + marg + fontHeight)
|
|
139 |
].
|
27
|
140 |
mod := (mod + 1) \\ 2.
|
|
141 |
pos := pos + 5.
|
34
|
142 |
y := (pixelPerMM * pos) rounded
|
27
|
143 |
].
|
33
|
144 |
showUnit ifTrue:[
|
34
|
145 |
self displayString:'cm ' x:charX y:marg + fontHeight + yOrigin.
|
33
|
146 |
]
|
27
|
147 |
].
|
|
148 |
(metric == #inch) ifTrue:[
|
|
149 |
"inches - long blibs every inch; short ones every half; very
|
|
150 |
short ones every quarter"
|
|
151 |
|
|
152 |
pixelPerInch := (self inchToPixel:1) * scale.
|
|
153 |
pos := 0.25.
|
|
154 |
|
34
|
155 |
y := (pixelPerInch * pos) rounded.
|
27
|
156 |
veryShortLen := longLen // 4.
|
34
|
157 |
[(y < (yOrigin + height)) and:[pos <= paperHeight]] whileTrue:[
|
28
|
158 |
|l|
|
|
159 |
|
|
160 |
l := shortLen.
|
27
|
161 |
(mod == 0) ifTrue:[
|
|
162 |
y < labelBot ifFalse:[
|
28
|
163 |
l := longLen.
|
|
164 |
]
|
|
165 |
] ifFalse:[
|
|
166 |
(mod == 2) ifFalse:[
|
|
167 |
l := veryShortLen
|
|
168 |
]
|
|
169 |
].
|
|
170 |
self displayLineFromX:left y:y toX:(left + l) y:y.
|
|
171 |
|
|
172 |
(mod == 0) ifTrue:[
|
|
173 |
y < labelBot ifFalse:[
|
27
|
174 |
self displayString:pos asInteger printString
|
|
175 |
x:charX
|
|
176 |
y:(y + marg + fontHeight)
|
|
177 |
]
|
|
178 |
].
|
|
179 |
mod := (mod + 1) \\ 4.
|
|
180 |
pos := pos + 0.25.
|
34
|
181 |
y := (pixelPerInch * pos) rounded
|
27
|
182 |
].
|
33
|
183 |
showUnit ifTrue:[
|
34
|
184 |
self displayString:'inch ' x:charX y:marg + fontHeight + yOrigin.
|
33
|
185 |
]
|
27
|
186 |
].
|
|
187 |
self redrawEdges
|
|
188 |
! !
|
|
189 |
|
161
|
190 |
!VerticalRuler class methodsFor:'documentation'!
|
27
|
191 |
|
161
|
192 |
version
|
|
193 |
^ '$Header: /cvs/stx/stx/libwidg2/VerticalRuler.st,v 1.7 1996-04-27 18:22:04 cg Exp $'
|
27
|
194 |
! !
|