author | Claus Gittinger <cg@exept.de> |
Sat, 11 Nov 1995 17:30:31 +0100 | |
changeset 86 | 4d7dbb5f1719 |
parent 71 | 9f9243f5813b |
child 161 | 5b6e284959a4 |
permissions | -rw-r--r-- |
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 |
|
14 |
instanceVariableNames:'' |
|
15 |
classVariableNames:'' |
|
16 |
poolDictionaries:'' |
|
17 |
category:'Views-Misc' |
|
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 |
version |
86
4d7dbb5f1719
uff - version methods changed to return stings
Claus Gittinger <cg@exept.de>
parents:
71
diff
changeset
|
37 |
^ '$Header: /cvs/stx/stx/libwidg2/VerticalRuler.st,v 1.6 1995-11-11 16:29:35 cg Exp $' |
33 | 38 |
! |
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
like a Ruler, but vertical. |
|
43 |
see documentation in Ruler |
|
44 |
" |
|
45 |
! ! |
|
27 | 46 |
|
47 |
!VerticalRuler methodsFor:'accessing'! |
|
48 |
||
49 |
paperHeightInch:inches |
|
50 |
"set the width of the document" |
|
51 |
||
52 |
paperHeight := inches. |
|
53 |
shown ifTrue:[ |
|
54 |
self redraw |
|
55 |
] |
|
56 |
! |
|
57 |
||
58 |
paperHeightMM:millis |
|
59 |
"set the width of the document" |
|
60 |
||
61 |
paperHeight := self millimeterToInch:millis. |
|
62 |
shown ifTrue:[ |
|
63 |
self redraw |
|
64 |
] |
|
65 |
! ! |
|
66 |
||
67 |
!VerticalRuler methodsFor:'redrawing'! |
|
68 |
||
69 |
redraw |
|
28 | 70 |
"redraw the scale" |
27 | 71 |
|
72 |
|y pixelPerMM pixelPerInch mod pos shortLen veryShortLen longLen charX |
|
73 |
left paperHeightMM paperHeightPixel yOrigin labelBot marg fontHeight| |
|
74 |
||
75 |
shown ifFalse:[^ self]. |
|
76 |
||
77 |
self clear. |
|
78 |
||
79 |
yOrigin := self viewOrigin y. |
|
80 |
||
81 |
paperHeightPixel := ((self inchToPixel:paperHeight) * scale) rounded. |
|
82 |
||
83 |
(yOrigin + height > paperHeightPixel) ifTrue:[ |
|
84 |
self paint:(Color darkGrey). |
|
34 | 85 |
self fillRectangleX:0 y:paperHeightPixel |
27 | 86 |
width:width |
34 | 87 |
height:(yOrigin + height - paperHeightPixel). |
27 | 88 |
self paint:fgColor. |
34 | 89 |
self displayLineFromX:0 y:paperHeightPixel |
90 |
toX:width y:paperHeightPixel |
|
27 | 91 |
]. |
92 |
||
93 |
self paint:fgColor. |
|
94 |
||
95 |
left := 0. "width - (font widthOf:'WW')" |
|
96 |
longLen := font widthOf:'WW'. |
|
97 |
shortLen := longLen // 2. |
|
98 |
charX := left + shortLen. |
|
99 |
mod := 1. |
|
100 |
marg := 3. "character shift" |
|
101 |
fontHeight := font height. |
|
102 |
||
34 | 103 |
showUnit ifTrue:[ |
104 |
labelBot := marg + font height + font ascent + yOrigin. |
|
105 |
] ifFalse:[ |
|
106 |
labelBot := yOrigin |
|
107 |
]. |
|
108 |
||
27 | 109 |
(metric == #mm) ifTrue:[ |
110 |
"centimeter - long blibs every centimeter; short ones every half" |
|
111 |
||
112 |
paperHeightMM := self inchToMillimeter:paperHeight. |
|
113 |
pixelPerMM := (self millimeterToPixel:1) * scale. |
|
114 |
pos := 5. |
|
34 | 115 |
y := (pixelPerMM * pos) rounded. |
116 |
[(y < (height+yOrigin)) and:[pos <= paperHeightMM]] whileTrue:[ |
|
28 | 117 |
|l| |
118 |
||
119 |
l := shortLen. |
|
120 |
(mod ~~ 1) ifTrue:[ |
|
27 | 121 |
y < labelBot ifFalse:[ |
28 | 122 |
l := longLen |
27 | 123 |
] |
124 |
]. |
|
28 | 125 |
self displayLineFromX:left y:y toX:(left + l) y:y. |
126 |
||
127 |
(mod ~~ 1 and:[y >= labelBot]) ifTrue:[ |
|
128 |
self displayString:(pos // 10) printString |
|
129 |
x:charX |
|
130 |
y:(y + marg + fontHeight) |
|
131 |
]. |
|
27 | 132 |
mod := (mod + 1) \\ 2. |
133 |
pos := pos + 5. |
|
34 | 134 |
y := (pixelPerMM * pos) rounded |
27 | 135 |
]. |
33 | 136 |
showUnit ifTrue:[ |
34 | 137 |
self displayString:'cm ' x:charX y:marg + fontHeight + yOrigin. |
33 | 138 |
] |
27 | 139 |
]. |
140 |
(metric == #inch) ifTrue:[ |
|
141 |
"inches - long blibs every inch; short ones every half; very |
|
142 |
short ones every quarter" |
|
143 |
||
144 |
pixelPerInch := (self inchToPixel:1) * scale. |
|
145 |
pos := 0.25. |
|
146 |
||
34 | 147 |
y := (pixelPerInch * pos) rounded. |
27 | 148 |
veryShortLen := longLen // 4. |
34 | 149 |
[(y < (yOrigin + height)) and:[pos <= paperHeight]] whileTrue:[ |
28 | 150 |
|l| |
151 |
||
152 |
l := shortLen. |
|
27 | 153 |
(mod == 0) ifTrue:[ |
154 |
y < labelBot ifFalse:[ |
|
28 | 155 |
l := longLen. |
156 |
] |
|
157 |
] ifFalse:[ |
|
158 |
(mod == 2) ifFalse:[ |
|
159 |
l := veryShortLen |
|
160 |
] |
|
161 |
]. |
|
162 |
self displayLineFromX:left y:y toX:(left + l) y:y. |
|
163 |
||
164 |
(mod == 0) ifTrue:[ |
|
165 |
y < labelBot ifFalse:[ |
|
27 | 166 |
self displayString:pos asInteger printString |
167 |
x:charX |
|
168 |
y:(y + marg + fontHeight) |
|
169 |
] |
|
170 |
]. |
|
171 |
mod := (mod + 1) \\ 4. |
|
172 |
pos := pos + 0.25. |
|
34 | 173 |
y := (pixelPerInch * pos) rounded |
27 | 174 |
]. |
33 | 175 |
showUnit ifTrue:[ |
34 | 176 |
self displayString:'inch ' x:charX y:marg + fontHeight + yOrigin. |
33 | 177 |
] |
27 | 178 |
]. |
179 |
self redrawEdges |
|
180 |
! ! |
|
181 |
||
182 |
!VerticalRuler methodsFor:'initialization'! |
|
183 |
||
184 |
initialize |
|
185 |
super initialize. |
|
186 |
||
187 |
self width:(font widthOf:'inch'). |
|
188 |
||
189 |
" |
|
190 |
VerticalRuler new open |
|
191 |
" |
|
192 |
! ! |
|
193 |