author | convert-repo |
Wed, 29 May 2019 03:28:35 +0000 | |
changeset 8695 | 63926415fec4 |
parent 8387 | bab155d58f25 |
child 8752 | 68ffb64eee84 |
permissions | -rw-r--r-- |
8290 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
6 | 4 |
COPYRIGHT (c) 1992 by Claus Gittinger |
71 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
3310 | 14 |
"{ Package: 'stx:libview' }" |
15 |
||
7015 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
Object subclass:#GraphicsContext |
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
19 |
instanceVariableNames:'device paint bgPaint function font lineStyle lineWidth joinStyle |
4027 | 20 |
capStyle mask maskOrigin transformation clipRect |
21 |
characterEncoding' |
|
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
22 |
classVariableNames:'White Black DefaultFont DrawingOnClosedDrawableSignal' |
519 | 23 |
poolDictionaries:'' |
24 |
category:'Graphics-Support' |
|
0 | 25 |
! |
26 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
27 |
!GraphicsContext class methodsFor:'documentation'! |
46 | 28 |
|
29 |
copyright |
|
30 |
" |
|
31 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
71 | 32 |
All Rights Reserved |
46 | 33 |
|
34 |
This software is furnished under a license and may be used |
|
35 |
only in accordance with the terms of that license and with the |
|
36 |
inclusion of the above copyright notice. This software may not |
|
37 |
be provided or otherwise made available to, or used by, any |
|
38 |
other person. No title to or ownership of the software is |
|
39 |
hereby transferred. |
|
40 |
" |
|
41 |
! |
|
42 |
||
43 |
documentation |
|
44 |
" |
|
45 |
this is an abstract superclass for all kinds of graphic drawables - |
|
46 |
both windows and printed pages (i.e. printers) are inheriting from |
|
47 |
this class (even drawables not at all associated with any device would do so). |
|
48 |
||
76 | 49 |
Drawing is done in paint/bgPaint colors, which can be true colors (i.e. |
50 |
directly supported by the underlying hardware) or simulated colors |
|
51 |
(i.e. dithered colors or images). |
|
52 |
The paint/bgPaint instance variables are set to the logical colors, |
|
53 |
device specific drawable may like to keep actual colors in addition. |
|
71 | 54 |
|
55 |
The transformation instance variable is typically nil, for a 1-to-1 |
|
56 |
coordinate mapping (i.e. x/y coordinates are pixels in the drawable). |
|
57 |
If nonNil, the transformation must be an instance of WindowingTransformation |
|
58 |
and offers both a scale-factor and a translation. |
|
59 |
Also, drawing in metric- or inch-units can be done using transformations. |
|
60 |
(see instance creation methods of WindowingTransformation, and examples |
|
61 |
in 'doc/coding'). |
|
46 | 62 |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
63 |
All drawing is defined upon a few basic drawing methods, which must be |
46 | 64 |
implemented by subclasses (some subclasses also redefine the others for |
65 |
more performance) |
|
66 |
||
611 | 67 |
[Instance variables:] |
46 | 68 |
|
8387 | 69 |
paint <Color> the paint used for drawing |
70 |
bgPaint <Color> the background used for drawing texts and bitmaps |
|
71 |
function <Symbol> the drawing function (i.e. #copy, #or, #xor ...) |
|
72 |
- not all Drawables support every function |
|
73 |
(i.e. paper only allows #copy) |
|
74 |
font <Font> the current font to be used for drawing |
|
75 |
lineStyle <Symbol> the lineStyle (i.e. #solid, #dashed, #doubleDashed) |
|
76 |
lineWidth <SmallInteger> the lineWidth (device dependent, usually pixels) |
|
77 |
joinStyle <Symbol> the style in which lines (in polygons) |
|
78 |
are joined (i.e. #miter, #bevel, #round) |
|
79 |
capStyle <Symbol> the style in which the last point of a line is drawn |
|
80 |
(i.e. #notLast, #butt, #round, #projecting) |
|
81 |
mask <Form> a mask used for drawing |
|
82 |
- not all Drawables support it |
|
83 |
maskOrigin <Point> the origin of the mask relative to |
|
84 |
the drawable's origin |
|
85 |
transformation |
|
86 |
<WindowingTransformation> |
|
87 |
controls scale & translation of nonNil |
|
88 |
||
89 |
clipRect <Rectangle> a clip rectangle (device dep. usually pixels or inches) |
|
90 |
or nil. |
|
46 | 91 |
|
611 | 92 |
[Class variables:[ |
93 |
||
8387 | 94 |
White <Color> cached white color - its needed so often |
95 |
Black <Color> cached black color - its needed so often |
|
96 |
||
97 |
DefaultFont <Font> default font to use |
|
46 | 98 |
|
611 | 99 |
[author:] |
8387 | 100 |
Claus Gittinger |
657 | 101 |
|
102 |
[see also:] |
|
8387 | 103 |
Color Font Form Image |
104 |
Geometric |
|
105 |
DeviceWorkstation |
|
46 | 106 |
" |
563 | 107 |
! |
108 |
||
109 |
examples |
|
110 |
" |
|
111 |
drawing uses a paint color (which may be a dithered one) which is |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
112 |
used like a `pen'. |
563 | 113 |
A few drawing operations (opaqueForm and opaqueString drawing) |
114 |
use two colors, the paint and a backgroundPaint. For example, |
|
7344 | 115 |
normal string drawing (#displayString:...) only draws the font's |
563 | 116 |
on-pixels in the current paint, leaving off-pixels unchanged. |
117 |
In contrast, #drawOpaqueString:.. also changes these to the bgPaint color. |
|
118 |
The bgPaint can be changed with #backgroundPaint: or #paint:on: (which modifies both). |
|
119 |
||
120 |
lets try it in a view: |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
121 |
[exBegin] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
122 |
|v| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
123 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
124 |
v := View new. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
125 |
v openAndWait. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
126 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
127 |
v paint:(Color red). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
128 |
v displayString:'hello' x:10 y:50 |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
129 |
[exEnd] |
563 | 130 |
|
131 |
the same using opaque drawing: |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
132 |
[exBegin] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
133 |
|v| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
134 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
135 |
v := View new. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
136 |
v openAndWait. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
137 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
138 |
v paint:(Color red) on:(Color yellow). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
139 |
v displayOpaqueString:'hello' x:10 y:50 |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
140 |
[exEnd] |
563 | 141 |
|
142 |
||
143 |
||
144 |
Lines are drawn using the paint color (if solid) or both paint and bgPaint |
|
145 |
(dashed lines). The look of the line is controlled by joinStyle, capStyle, |
|
146 |
lineWidth and lineStyle. |
|
147 |
`lineStyle' can be one of #solid, #dashed, #doubleDashed |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
148 |
where: #solid - is for solid lines, drawn with the current paint color |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
149 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
150 |
#dashed - for dashed lines, where only the on-dashes are drawn |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
151 |
with the current paint color |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
152 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
153 |
#doubleDashed - dashed lines, draws on-dashes with paint color, |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
154 |
off-dashes with bgPaint |
563 | 155 |
|
156 |
for example: |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
157 |
[exBegin] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
158 |
|v| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
159 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
160 |
v := View new. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
161 |
v openAndWait. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
162 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
163 |
v paint:(Color red) on:(Color blue). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
164 |
v displayLineFrom:(10@10) to:(90@90). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
165 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
166 |
v lineStyle:#dashed. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
167 |
v displayLineFrom:(90@10) to:(10@90). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
168 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
169 |
v lineStyle:#doubleDashed. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
170 |
v displayRectangle:((5@5) corner:(95@95)). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
171 |
[exEnd] |
563 | 172 |
|
173 |
changing the line-width: |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
174 |
[exBegin] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
175 |
|v| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
176 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
177 |
v := View new. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
178 |
v openAndWait. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
179 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
180 |
v paint:(Color red). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
181 |
v displayLineFrom:(20@20) to:(80@80). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
182 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
183 |
v lineWidth:5. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
184 |
v displayLineFrom:(80@20) to:(20@80). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
185 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
186 |
v lineWidth:8. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
187 |
v displayRectangle:((5@5) corner:(95@95)). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
188 |
[exEnd] |
563 | 189 |
|
190 |
with wide lines, the corners (of polygons or rectangles) can be |
|
191 |
one of the joinStyles: #miter, #bevel, #round. The default is #miter. |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
192 |
[exBegin] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
193 |
|v| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
194 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
195 |
v := View new extent:200@200. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
196 |
v openAndWait. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
197 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
198 |
v lineWidth:15. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
199 |
v paint:(Color red). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
200 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
201 |
v displayRectangle:((65@65) corner:(135@135)). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
202 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
203 |
v joinStyle:#bevel. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
204 |
v displayRectangle:((45@45) corner:(155@155)). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
205 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
206 |
v joinStyle:#round. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
207 |
v displayRectangle:((25@25) corner:(175@175)). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
208 |
[exEnd] |
563 | 209 |
|
210 |
||
211 |
the endPoints look is controlled with capStyle; |
|
212 |
possible values are: #notLast, #butt, #round, #projecting. |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
213 |
The default is #butt. |
563 | 214 |
#notLast is mostly useful when exoring (inverting): it will not draw the |
215 |
endPoint, to allow another line to join the previous line without inverting |
|
216 |
this point twice. (See the X manual for more info). |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
217 |
[exBegin] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
218 |
|v| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
219 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
220 |
v := View new extent:200@200. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
221 |
v openAndWait. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
222 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
223 |
v lineWidth:15. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
224 |
v paint:(Color red). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
225 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
226 |
v displayLineFrom:(25@25) to:(175@25). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
227 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
228 |
v capStyle:#round. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
229 |
v displayLineFrom:(25@55) to:(175@55). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
230 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
231 |
v capStyle:#projecting. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
232 |
v displayLineFrom:(25@85) to:(175@85). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
233 |
[exEnd] |
563 | 234 |
|
235 |
||
236 |
You can use a bitmap as a point color: |
|
237 |
(this may be slow on some graphics devices, though) |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
238 |
[exBegin] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
239 |
|v| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
240 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
241 |
v := View new extent:200@200. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
242 |
v openAndWait. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
243 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
244 |
v lineWidth:15. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
245 |
v paint:(Image fromFile:'granite_small.tiff'). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
246 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
247 |
v displayLineFrom:(25@25) to:(175@25). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
248 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
249 |
v capStyle:#round. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
250 |
v displayLineFrom:(25@55) to:(175@55). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
251 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
252 |
v capStyle:#projecting. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
253 |
v displayLineFrom:(25@85) to:(175@85). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
254 |
[exEnd] |
563 | 255 |
|
256 |
all views support a translation and scale, so you can draw in another |
|
257 |
coordinate system: |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
258 |
[exBegin] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
259 |
|v| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
260 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
261 |
v := View new extent:200@200. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
262 |
v openAndWait. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
263 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
264 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
265 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
266 |
v scale:(2@2); translation:50. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
267 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
268 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
269 |
v scale:(0.5@0.5); translation:0. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
270 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
271 |
[exEnd] |
563 | 272 |
|
273 |
if scaling is on, it is often useful to be able to draw individual |
|
274 |
things unscaled - this still translates the position, but |
|
275 |
uses the unscaled font (for example, to draw strings in a graphic): |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
276 |
[exBegin] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
277 |
|v| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
278 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
279 |
v := View new extent:200@200. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
280 |
v openAndWait. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
281 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
282 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
283 |
v displayString:'hello' x:50 y:40. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
284 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
285 |
v scale:(2@4). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
286 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
287 |
v displayUnscaledString:'hello' x:50 y:40. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
288 |
[exEnd] |
563 | 289 |
|
290 |
Filled objects are drawin using the #fillXXX methods; for example, |
|
291 |
displayRectangleXXX draws the outline, while fillRectangleXXX draws a |
|
292 |
filled one: |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
293 |
[exBegin] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
294 |
|v| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
295 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
296 |
v := View new extent:200@200. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
297 |
v openAndWait. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
298 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
299 |
v displayArcIn:(20@20 corner:50@50) from:0 angle:180. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
300 |
v paint:Color yellow. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
301 |
v fillArcIn:(120@120 corner:150@150) from:0 angle:180. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
302 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
303 |
v paint:Color red. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
304 |
v displayCircle:150@50 radius:30. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
305 |
v paint:Color blue. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
306 |
v fillCircle:50@150 radius:30. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
307 |
[exEnd] |
619 | 308 |
|
309 |
polygons: |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
310 |
[exBegin] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
311 |
|v poly1 poly2| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
312 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
313 |
poly1 := OrderedCollection new. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
314 |
poly1 add:(10 @ 10). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
315 |
poly1 add:(100 @ 50). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
316 |
poly1 add:(50 @ 50). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
317 |
poly1 add:(20 @ 100). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
318 |
poly1 add:(10 @ 100). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
319 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
320 |
poly2 := poly1 copy. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
321 |
poly2 add:(poly2 first). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
322 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
323 |
v := View new extent:200@200. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
324 |
v openAndWait. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
325 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
326 |
v scale:2. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
327 |
v paint:Color red. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
328 |
v fillPolygon:poly1. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
329 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
330 |
v scale:1. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
331 |
v paint:Color blue. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
332 |
v displayPolygon:poly2. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
333 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
334 |
v scale:0.5. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
335 |
v paint:Color yellow. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
336 |
v fillPolygon:poly1. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
337 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
338 |
[exEnd] |
563 | 339 |
" |
46 | 340 |
! ! |
341 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
342 |
!GraphicsContext class methodsFor:'initialization'! |
0 | 343 |
|
344 |
initialize |
|
345 |
"setup some defaults - these are usually redefined |
|
346 |
during startup." |
|
347 |
||
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
348 |
DrawingOnClosedDrawableSignal isNil ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
349 |
DrawingOnClosedDrawableSignal := Signal new mayProceed:true. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
350 |
DrawingOnClosedDrawableSignal nameClass:self message:#drawingOnClosedDrawableSignal. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
351 |
DrawingOnClosedDrawableSignal notifierString:'drawing attempt on closed drawable'. |
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
352 |
]. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
353 |
|
134 | 354 |
White isNil ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
355 |
Color initialize. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
356 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
357 |
Display notNil ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
358 |
White := Display whiteColor. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
359 |
Black := Display blackColor. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
360 |
] ifFalse:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
361 |
White := Color white. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
362 |
Black := Color black. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
363 |
]. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
364 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
365 |
Font initialize. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
366 |
DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
367 |
Display notNil ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
368 |
DefaultFont := DefaultFont onDevice:Display |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
369 |
] |
134 | 370 |
] |
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
371 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
372 |
"Modified: / 29.1.1998 / 12:56:18 / cg" |
0 | 373 |
! ! |
374 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
375 |
!GraphicsContext class methodsFor:'instance creation'! |
0 | 376 |
|
519 | 377 |
new |
378 |
"return a new instance of myself. Redefined to initialize |
|
379 |
the new thingy" |
|
12 | 380 |
|
519 | 381 |
^ self basicNew initialize |
382 |
! ! |
|
383 |
||
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
384 |
!GraphicsContext class methodsFor:'Signal constants'! |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
385 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
386 |
drawingOnClosedDrawableSignal |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
387 |
"return the signal which is raised, if drawing is attempted |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
388 |
on a closed drawable. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
389 |
This is especially useful, if a forked thread animates |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
390 |
a view in the background, and is not properly synchronized |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
391 |
with the window thread - i.e. the window gets closed by the user, |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
392 |
and the background process continues to draw. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
393 |
In this case, the background thread should handle this signal |
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
394 |
and terminate itself in the handler." |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
395 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
396 |
^ DrawingOnClosedDrawableSignal |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
397 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
398 |
"demonstration1: (error if closed by the windowManager): |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
399 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
400 |
|v| |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
401 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
402 |
v := StandardSystemView new openAndWait. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
403 |
[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
404 |
[true] whileTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
405 |
|x y| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
406 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
407 |
x := Random nextIntegerBetween:0 and:(v width). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
408 |
y := Random nextIntegerBetween:0 and:(v height). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
409 |
v displayString:'hello' x:x y:y. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
410 |
Delay waitForSeconds:0.5. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
411 |
] |
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
412 |
] fork. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
413 |
" |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
414 |
"demonstration2: (no error if closed by the windowManager): |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
415 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
416 |
|v| |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
417 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
418 |
v := StandardSystemView new openAndWait. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
419 |
[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
420 |
v class drawingOnClosedDrawableSignal handle:[:ex | |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
421 |
ex return |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
422 |
] do:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
423 |
[true] whileTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
424 |
|x y| |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
425 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
426 |
x := Random nextIntegerBetween:0 and:(v width). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
427 |
y := Random nextIntegerBetween:0 and:(v height). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
428 |
v displayString:'hello' x:x y:y. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
429 |
Delay waitForSeconds:0.5. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
430 |
] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
431 |
] |
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
432 |
] fork. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
433 |
" |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
434 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
435 |
"Created: / 29.1.1998 / 13:10:41 / cg" |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
436 |
"Modified: / 29.1.1998 / 13:11:14 / cg" |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
437 |
! ! |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
438 |
|
5032 | 439 |
!GraphicsContext class methodsFor:'accessing-defaults'! |
0 | 440 |
|
441 |
defaultFont |
|
12 | 442 |
"get the default font used for drawing" |
443 |
||
71 | 444 |
DefaultFont isNil ifTrue:[ |
445 |
DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12 |
|
446 |
]. |
|
0 | 447 |
^ DefaultFont |
519 | 448 |
! |
449 |
||
450 |
defaultFont:aFont |
|
451 |
"set the default font used for drawing" |
|
452 |
||
453 |
DefaultFont := aFont |
|
0 | 454 |
! ! |
455 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
456 |
!GraphicsContext class methodsFor:'constants'! |
0 | 457 |
|
519 | 458 |
capButt |
459 |
"return a constant to specify butt cap" |
|
0 | 460 |
|
519 | 461 |
^ #butt |
0 | 462 |
! |
463 |
||
464 |
capNotLast |
|
465 |
"return a constant to specify not-last cap" |
|
466 |
||
467 |
^ #notLast |
|
468 |
! |
|
469 |
||
470 |
capProjecting |
|
471 |
"return a constant to specify projecting cap" |
|
472 |
||
473 |
^ #projecting |
|
474 |
! |
|
475 |
||
476 |
capRound |
|
477 |
"return a constant to specify round cap" |
|
478 |
||
479 |
^ #round |
|
480 |
! |
|
481 |
||
519 | 482 |
joinBevel |
483 |
"return a constant to specify bevel join" |
|
484 |
||
485 |
^ #bevel |
|
486 |
! |
|
0 | 487 |
|
519 | 488 |
joinMiter |
489 |
"return a constant to specify miter join" |
|
490 |
||
491 |
^ #miter |
|
492 |
! |
|
493 |
||
494 |
joinRound |
|
495 |
"return a constant to specify round join" |
|
496 |
||
497 |
^ #round |
|
0 | 498 |
! ! |
499 |
||
7860 | 500 |
!GraphicsContext class methodsFor:'queries'! |
501 |
||
502 |
isAbstract |
|
503 |
"Return if this class is an abstract class. |
|
504 |
True is returned here for myself only; false for subclasses. |
|
505 |
Abstract subclasses must redefine this again." |
|
506 |
||
507 |
^ self == GraphicsContext. |
|
508 |
! ! |
|
509 |
||
3880 | 510 |
!GraphicsContext methodsFor:'Compatibility-ST80'! |
519 | 511 |
|
512 |
displayArc:origin radius:radius from:startAngle angle:angle |
|
513 |
"draw an arc around a point" |
|
514 |
||
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
515 |
self |
1956 | 516 |
displayArcX:(origin x - radius) |
517 |
y:(origin y - radius) |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
518 |
width:(radius * 2) |
1956 | 519 |
height:(radius * 2) |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
520 |
from:startAngle |
1956 | 521 |
angle:angle |
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
522 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
523 |
"Modified: 8.5.1996 / 08:34:43 / cg" |
519 | 524 |
! |
0 | 525 |
|
1956 | 526 |
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
527 |
"draw an arc/circle/ellipse - ST-80 compatibility" |
1956 | 528 |
|
529 |
^ self displayArcX:(boundingBox left) |
|
530 |
y:(boundingBox top) |
|
531 |
width:(boundingBox width) |
|
532 |
height:(boundingBox height) |
|
533 |
from:startAngle |
|
534 |
angle:sweepAngle |
|
535 |
||
536 |
"Created: / 14.11.1997 / 21:04:19 / cg" |
|
537 |
! |
|
538 |
||
519 | 539 |
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
540 |
"draw an arc/circle/ellipse - ST-80 compatibility" |
519 | 541 |
|
542 |
^ self displayArcX:(boundingBox left + origin x) |
|
543 |
y:(boundingBox top + origin y) |
|
544 |
width:(boundingBox width) |
|
545 |
height:(boundingBox height) |
|
546 |
from:startAngle |
|
547 |
angle:sweepAngle |
|
548 |
! |
|
549 |
||
550 |
displayLineFrom:startPoint to:endPoint translateBy:anOffset |
|
551 |
"draw a line - ST-80 compatibility" |
|
0 | 552 |
|
519 | 553 |
self displayLineFrom:(startPoint + anOffset) |
554 |
to:(endPoint + anOffset) |
|
555 |
! |
|
556 |
||
557 |
displayPolyline:aPolygon |
|
558 |
"draw a polygon - ST-80 compatibility" |
|
559 |
||
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
560 |
^ self displayPolygon:aPolygon |
519 | 561 |
! |
562 |
||
4379 | 563 |
displayRectangularBorder:aRectangle |
564 |
"draw a rectangle - ST-80 compatibility" |
|
565 |
||
566 |
self displayRectangle:aRectangle |
|
567 |
! |
|
568 |
||
519 | 569 |
displayRectangularBorder:aRectangle at:aPoint |
570 |
"draw a rectangle - ST-80 compatibility" |
|
0 | 571 |
|
519 | 572 |
self displayRectangle:(aRectangle translateBy:aPoint) |
573 |
! |
|
574 |
||
1280 | 575 |
displayWedgeBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle |
576 |
"fill an arc/circle/ellipse - ST-80 compatibility" |
|
577 |
||
578 |
^ self fillArcX:(boundingBox left) |
|
1956 | 579 |
y:(boundingBox top) |
580 |
width:(boundingBox width) |
|
581 |
height:(boundingBox height) |
|
582 |
from:startAngle |
|
583 |
angle:sweepAngle |
|
1280 | 584 |
|
585 |
"Created: 27.1.1997 / 15:50:14 / cg" |
|
586 |
! |
|
587 |
||
519 | 588 |
displayWedgeBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin |
589 |
"fill an arc/circle/ellipse - ST-80 compatibility" |
|
2 | 590 |
|
519 | 591 |
^ self fillArcX:(boundingBox left + origin x) |
592 |
y:(boundingBox top + origin y) |
|
593 |
width:(boundingBox width) |
|
594 |
height:(boundingBox height) |
|
595 |
from:startAngle |
|
596 |
angle:sweepAngle |
|
2807 | 597 |
! |
598 |
||
599 |
findFont:aFontDescription |
|
600 |
"given a fontDescription, return a device font for it |
|
601 |
on my device." |
|
602 |
||
2827 | 603 |
^ aFontDescription onDevice:device |
2807 | 604 |
|
605 |
"Modified: 28.5.1996 / 20:22:29 / cg" |
|
606 |
! |
|
607 |
||
608 |
phase |
|
609 |
"return the origin within the mask (used to draw with patterns). |
|
610 |
This is an alias for ST/X's #maskOrigin" |
|
611 |
||
612 |
^ self maskOrigin |
|
613 |
! |
|
614 |
||
615 |
phase:aPoint |
|
616 |
"set the origin within the mask (used to draw with patterns). |
|
617 |
This is an alias for ST/X's #maskOrigin:" |
|
618 |
||
619 |
^ self maskOrigin:aPoint |
|
620 |
! |
|
621 |
||
622 |
setDevicePattern:aColorOrMask |
|
623 |
"ST/X can paint in any color or image" |
|
624 |
||
625 |
self paint:aColorOrMask |
|
626 |
! |
|
627 |
||
628 |
tilePhase |
|
629 |
"return the origin within the mask (used to draw with patterns). |
|
630 |
This is an alias for ST/X's #maskOrigin" |
|
631 |
||
632 |
^ self maskOrigin |
|
633 |
||
634 |
"Created: 4.6.1996 / 15:26:39 / cg" |
|
635 |
! |
|
636 |
||
637 |
tilePhase:aPoint |
|
638 |
"set the origin within the mask (used to draw with patterns). |
|
639 |
This is an alias for ST/X's #maskOrigin" |
|
640 |
||
641 |
^ self maskOrigin:aPoint |
|
642 |
||
643 |
"Created: 4.6.1996 / 15:26:49 / cg" |
|
644 |
! |
|
645 |
||
646 |
widthOfString:aString |
|
647 |
"given a string, return its width in pixels if |
|
7240 | 648 |
drawn on the receiver's device." |
2807 | 649 |
|
2827 | 650 |
^ (font onDevice:device) widthOf:aString |
2807 | 651 |
|
652 |
"Modified: 28.5.1996 / 20:22:22 / cg" |
|
653 |
! |
|
654 |
||
655 |
widthOfString:aString from:start to:stop |
|
656 |
"given a string, return the width in pixels if |
|
7240 | 657 |
a substring is drawn on the receiver's device." |
2807 | 658 |
|
2827 | 659 |
^ (font onDevice:device) widthOf:aString from:start to:stop |
2807 | 660 |
|
661 |
"Modified: 28.5.1996 / 20:22:18 / cg" |
|
2 | 662 |
! ! |
663 |
||
3880 | 664 |
!GraphicsContext methodsFor:'Compatibility-Squeak'! |
2806 | 665 |
|
2938 | 666 |
fill:aRectangle fillColor:aColor |
667 |
"fill a rectangle with the given color color" |
|
668 |
||
669 |
|savedPaint| |
|
670 |
||
671 |
savedPaint := paint. |
|
672 |
self paint:aColor. |
|
673 |
self fillRectangle:aRectangle. |
|
674 |
self paint:savedPaint |
|
675 |
! |
|
676 |
||
3310 | 677 |
fillRectangle:aRectangle color:aColor |
678 |
"fill a rectangle with the given paint color" |
|
679 |
||
680 |
|oldPaint| |
|
681 |
||
682 |
oldPaint := paint. |
|
683 |
self paint:aColor. |
|
684 |
self fillRectangle:aRectangle. |
|
685 |
self paint:oldPaint. |
|
2806 | 686 |
! ! |
687 |
||
0 | 688 |
!GraphicsContext methodsFor:'accessing'! |
689 |
||
690 |
backgroundPaint |
|
691 |
"return the background paint color. |
|
692 |
(used for opaqueForms and opaqueStrings)" |
|
693 |
||
694 |
^ bgPaint |
|
695 |
! |
|
696 |
||
697 |
backgroundPaint:aColor |
|
698 |
"set the background painting color (which is used for |
|
699 |
opaqueForms and opaqueStrings). aColor can be a dithered one." |
|
700 |
||
678 | 701 |
bgPaint := aColor |
702 |
||
703 |
"Modified: 12.5.1996 / 22:25:17 / cg" |
|
0 | 704 |
! |
705 |
||
7503 | 706 |
basicFont |
707 |
"return the font for drawing" |
|
708 |
||
709 |
^ font |
|
710 |
||
711 |
"Created: 12.5.1996 / 11:17:59 / cg" |
|
712 |
! |
|
713 |
||
6272 | 714 |
blackColor |
7463 | 715 |
"return the black color on this device. |
716 |
This is the same as 'Color black onDevice:self device', but much faster." |
|
717 |
||
6272 | 718 |
^ device blackColor |
719 |
! |
|
720 |
||
0 | 721 |
capStyle |
4377 | 722 |
"return the current cap-style for line-drawing. |
723 |
possible styles are: #notLast, #butt, #round, #projecting" |
|
0 | 724 |
|
725 |
^ capStyle |
|
726 |
! |
|
727 |
||
728 |
capStyle:aStyleSymbol |
|
729 |
"set the cap-style for line-drawing; |
|
730 |
possible styles are: #notLast, #butt, #round, #projecting" |
|
731 |
||
678 | 732 |
aStyleSymbol isNil ifTrue:[ |
1956 | 733 |
capStyle := #butt |
678 | 734 |
] ifFalse:[ |
1956 | 735 |
capStyle := aStyleSymbol |
678 | 736 |
] |
737 |
||
738 |
"Modified: 12.5.1996 / 22:24:30 / cg" |
|
0 | 739 |
! |
740 |
||
4071
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
741 |
characterEncoding |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
742 |
"returns a symbol describing how the contents is encoded internally. |
7289 | 743 |
This is now obsolete, as we are always using unicode internally. |
4071
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
744 |
(encoding is something like #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc)" |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
745 |
|
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
746 |
^ characterEncoding |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
747 |
! |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
748 |
|
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
749 |
characterEncoding:encodingArg |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
750 |
"define how the contents is encoded internally. |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
751 |
This should normally never be required, as ST/X now assumes |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
752 |
unicode (of which iso8859-1 is a subset) encoding. |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
753 |
The possibility to change the characterEncoding is provided as |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
754 |
a backward compatibility hook for programs which want to use |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
755 |
another encoding internally. |
7289 | 756 |
One such view is the CharacterSetView, |
4071
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
757 |
which wants to show character as they are actually present in a font." |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
758 |
|
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
759 |
|encodingSymOrNil| |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
760 |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
761 |
encodingSymOrNil := encodingArg isNil |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
762 |
ifTrue:[#'iso10646-1' "unicode"] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
763 |
ifFalse:[encodingArg asSymbol]. |
4071
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
764 |
characterEncoding ~~ encodingSymOrNil ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
765 |
characterEncoding := encodingSymOrNil. |
4071
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
766 |
]. |
5841
fdcb897dbcc5
comment: #characterEncoding:
Claus Gittinger <cg@exept.de>
parents:
5780
diff
changeset
|
767 |
|
fdcb897dbcc5
comment: #characterEncoding:
Claus Gittinger <cg@exept.de>
parents:
5780
diff
changeset
|
768 |
"Modified (comment): / 25-01-2012 / 00:29:37 / cg" |
4071
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
769 |
! |
73f2f46b75d4
characterEncoding stuff moved
Claus Gittinger <cg@exept.de>
parents:
4056
diff
changeset
|
770 |
|
76 | 771 |
clippingBounds |
7015 | 772 |
"return the clip-rectangle for drawing (in logical coordinates). |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
773 |
If there is currently no active clip, return the underlying |
6216 | 774 |
medium (i.e. device) bounds. Added for ST-80 compatibility." |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
775 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
776 |
|rect| |
76 | 777 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
778 |
clipRect isNil ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
779 |
rect := 0@0 extent:(self medium extent). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
780 |
transformation notNil ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
781 |
rect := transformation applyInverseTo:rect. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
782 |
]. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
783 |
^ rect |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
784 |
]. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
785 |
transformation notNil ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
786 |
^ transformation applyInverseTo:clipRect. |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
787 |
]. |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
788 |
^ clipRect |
563 | 789 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
790 |
"Modified: 28.5.1996 / 14:05:15 / cg" |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
791 |
! |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
792 |
|
6216 | 793 |
clippingBounds:aRectangleOrNil |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
794 |
"set the clipping rectangle for drawing (in logical coordinates); |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
795 |
a nil argument turn off clipping (i.e. whole view is drawable)" |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
796 |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
797 |
(aRectangleOrNil notNil and:[transformation notNil]) ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
798 |
clipRect := transformation applyTo:aRectangleOrNil. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
799 |
] ifFalse:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
800 |
clipRect := aRectangleOrNil |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
801 |
]. |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
802 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
803 |
"Modified: 22.5.1996 / 13:12:07 / cg" |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
804 |
"Created: 28.5.1996 / 14:09:27 / cg" |
76 | 805 |
! |
806 |
||
6216 | 807 |
clippingBoundsOrNil |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
808 |
"return the clipping bounds (a Rectangle) for drawing in logical coordinates, nil if there is none." |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
809 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
810 |
clipRect isNil ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
811 |
^ nil |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
812 |
]. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
813 |
transformation notNil ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
814 |
^ transformation applyInverseTo:clipRect. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
815 |
]. |
6216 | 816 |
^ clipRect |
817 |
||
818 |
"Created: 10.4.1996 / 14:32:02 / cg" |
|
819 |
"Modified: 28.5.1996 / 14:08:19 / cg" |
|
820 |
! |
|
821 |
||
786 | 822 |
dashStyle:aDashList offset:dashOffset |
823 |
"define dashes. Each element of the dashList specifies the length |
|
824 |
of a corresponding dash. For example, setting it to [4 4] |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
825 |
defines 4on-4off dashing; |
786 | 826 |
Setting it to [1 2 4 2] defines 1on-2off-4on-2off dashes. |
827 |
The dashOffset specifies where in the dashList the dashing starts. |
|
828 |
Ignored here - this may not be supported by all graphics devices." |
|
829 |
||
830 |
^ self |
|
831 |
||
832 |
"Created: 4.6.1996 / 18:59:34 / cg" |
|
833 |
"Modified: 4.6.1996 / 19:03:38 / cg" |
|
834 |
! |
|
835 |
||
519 | 836 |
font |
837 |
"return the current drawing font" |
|
838 |
||
839 |
^ font |
|
840 |
! |
|
841 |
||
842 |
font:aFont |
|
843 |
"set the drawing font" |
|
844 |
||
845 |
^ self subclassResponsibility |
|
846 |
! |
|
847 |
||
848 |
function |
|
849 |
"return the current drawing function" |
|
850 |
||
851 |
^ function |
|
852 |
! |
|
853 |
||
854 |
function:aFunctionSymbol |
|
7912 | 855 |
"set the (bitblt) drawing function. |
856 |
The argument is one of: |
|
8297 | 857 |
#copy,#copyInverted,#xor,#and,#andReverse |
858 |
#andInverted,#or,#orReverse,#orInverted |
|
859 |
#invert,#clear,#set,#noop,#equiv,#nand. |
|
860 |
Notice: not all graphicMedia support all functions" |
|
519 | 861 |
|
862 |
^ self subclassResponsibility |
|
7912 | 863 |
|
864 |
"Modified (comment): / 17-02-2017 / 16:44:24 / cg" |
|
519 | 865 |
! |
866 |
||
735 | 867 |
graphicsContext |
868 |
"for ST-80 compatibility" |
|
869 |
||
870 |
^ self |
|
871 |
! |
|
872 |
||
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
873 |
graphicsDevice |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
874 |
"same as #device, for ST-80 compatibility" |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
875 |
|
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
876 |
^ device |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
877 |
! |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
878 |
|
519 | 879 |
joinStyle |
4377 | 880 |
"return the current join-style for polygon-drawing. |
881 |
possible styles are: #miter, #bevel, #round" |
|
519 | 882 |
|
883 |
^ joinStyle |
|
884 |
! |
|
12 | 885 |
|
519 | 886 |
joinStyle:aStyleSymbol |
887 |
"set the join-style of lines in polygon-drawing; |
|
888 |
possible styles are: #miter, #bevel, #round" |
|
889 |
||
678 | 890 |
aStyleSymbol isNil ifTrue:[ |
1956 | 891 |
joinStyle := #miter |
678 | 892 |
] ifFalse:[ |
1956 | 893 |
joinStyle := aStyleSymbol |
678 | 894 |
] |
895 |
||
896 |
"Modified: 12.5.1996 / 22:24:14 / cg" |
|
519 | 897 |
! |
898 |
||
899 |
lineStyle |
|
4377 | 900 |
"return the current line-drawing-style. |
901 |
possible styles are: #solid, #dashed, #doubleDashed, |
|
902 |
#dotted, #dashDot or #dashDotDot." |
|
519 | 903 |
|
904 |
^ lineStyle |
|
2 | 905 |
! |
906 |
||
519 | 907 |
lineStyle:aStyleSymbol |
908 |
"set the line-drawing-style; |
|
2360 | 909 |
possible styles are: #solid, #dashed, #doubleDashed, |
910 |
#dotted, #dashDot or #dashDotDot." |
|
151 | 911 |
|
678 | 912 |
aStyleSymbol isNil ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
913 |
lineStyle := #solid |
678 | 914 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
915 |
lineStyle := aStyleSymbol |
678 | 916 |
] |
917 |
||
918 |
"Modified: 12.5.1996 / 22:19:25 / cg" |
|
519 | 919 |
! |
920 |
||
921 |
lineWidth |
|
922 |
"return the current drawing linewidth" |
|
923 |
||
924 |
^ lineWidth |
|
151 | 925 |
! |
926 |
||
519 | 927 |
lineWidth:aNumber |
928 |
"set the line drawing width in pixels" |
|
929 |
||
930 |
lineWidth := aNumber |
|
931 |
! |
|
151 | 932 |
|
519 | 933 |
mask |
934 |
"return the current drawing mask" |
|
935 |
||
936 |
^ mask |
|
937 |
! |
|
938 |
||
939 |
mask:aForm |
|
940 |
"set the drawing mask" |
|
941 |
||
942 |
^ self subclassResponsibility |
|
151 | 943 |
! |
944 |
||
945 |
maskOrigin |
|
946 |
"return the origin within the mask (used to draw with patterns). |
|
947 |
Should be redefined in classes which support it. |
|
948 |
This is an alias for ST-80's #phase" |
|
949 |
||
950 |
^ maskOrigin |
|
951 |
! |
|
952 |
||
953 |
maskOrigin:aPoint |
|
954 |
"set the origin within the mask (used to draw with patterns). |
|
955 |
Should be redefined in classes which support it. |
|
956 |
This is an alias for ST-80's #phase:" |
|
957 |
||
2017 | 958 |
maskOrigin := aPoint. |
959 |
^ self |
|
960 |
||
961 |
"Modified: / 26.1.1998 / 18:59:18 / cg" |
|
151 | 962 |
! |
963 |
||
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
964 |
maskOriginX:x y:y |
151 | 965 |
"set the origin within the mask (used to draw with patterns). |
966 |
Should be redefined in classes which support it. |
|
967 |
This is an alias for ST-80's #phase:" |
|
109 | 968 |
|
2017 | 969 |
^ self maskOrigin:(x @ y) |
970 |
||
971 |
"Modified: / 26.1.1998 / 18:59:56 / cg" |
|
12 | 972 |
! |
973 |
||
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
974 |
medium |
1346 | 975 |
"return the destination medium i.e. the underlying graphics device" |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
976 |
|
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
977 |
^ device |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
978 |
|
720 | 979 |
"Modified: 28.5.1996 / 14:26:03 / cg" |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
980 |
! |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
981 |
|
519 | 982 |
paint |
983 |
"return the current paint drawing color" |
|
984 |
||
985 |
^ paint |
|
986 |
! |
|
987 |
||
988 |
paint:aColor |
|
989 |
"set the drawing painting color, aColor can be a dithered one" |
|
990 |
||
991 |
paint := aColor |
|
992 |
! |
|
993 |
||
994 |
paint:fgColor on:bgColor |
|
563 | 995 |
"set the paint and backgroundPaint, used for text and bitmaps. |
996 |
Both colors may be dithered colors" |
|
519 | 997 |
|
671 | 998 |
fgColor ~~ paint ifTrue:[ |
1956 | 999 |
self paint:fgColor. |
671 | 1000 |
]. |
519 | 1001 |
bgPaint := bgColor |
563 | 1002 |
|
671 | 1003 |
"Modified: 12.5.1996 / 19:40:43 / cg" |
519 | 1004 |
! |
1005 |
||
7703 | 1006 |
setDevice:aDevice |
1007 |
device := aDevice |
|
1008 |
! |
|
1009 |
||
519 | 1010 |
viewOrigin |
8387 | 1011 |
"return the drawable's visible origin (for scrolling)" |
519 | 1012 |
|
1013 |
^ 0@0 |
|
8387 | 1014 |
|
1015 |
"Modified (comment): / 14-06-2018 / 10:17:01 / Claus Gittinger" |
|
6272 | 1016 |
! |
1017 |
||
1018 |
whiteColor |
|
6535 | 1019 |
"return the white color on this device. |
7463 | 1020 |
This is the same as 'Color white onDevice:self device', but much faster." |
6535 | 1021 |
|
6272 | 1022 |
^ device whiteColor |
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1023 |
! ! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1024 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1025 |
!GraphicsContext methodsFor:'accessing-transformation'! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1026 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1027 |
scale |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1028 |
"return the scale factor (as point) of the transformation" |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1029 |
|
707 | 1030 |
transformation isNil ifTrue:[^ 1@1]. |
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1031 |
^ transformation scale |
707 | 1032 |
|
1033 |
"Modified: 21.5.1996 / 21:16:47 / cg" |
|
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1034 |
! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1035 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1036 |
scale:aPoint |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1037 |
"set the scale factor of the transformation" |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1038 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1039 |
transformation isNil ifTrue:[ |
1956 | 1040 |
aPoint = 1 ifTrue:[^ self]. |
1041 |
transformation := WindowingTransformation scale:aPoint translation:0 |
|
619 | 1042 |
] ifFalse:[ |
1956 | 1043 |
transformation scale:aPoint. |
619 | 1044 |
] |
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
1045 |
|
619 | 1046 |
"Modified: 27.4.1996 / 18:47:38 / cg" |
76 | 1047 |
! |
1048 |
||
7474 | 1049 |
scale:scale translation:aPoint |
1050 |
transformation isNil ifTrue:[ |
|
1051 |
(aPoint = 0 and:[scale = 1]) ifTrue:[^ self]. |
|
1052 |
transformation := WindowingTransformation scale:scale translation:aPoint |
|
1053 |
] ifFalse:[ |
|
1054 |
transformation scale:scale translation:aPoint. |
|
1055 |
] |
|
1056 |
! |
|
1057 |
||
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1058 |
transformation |
76 | 1059 |
"return the transformation" |
1060 |
||
1061 |
^ transformation |
|
1062 |
! |
|
1063 |
||
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1064 |
transformation:aTransformation |
76 | 1065 |
"set the transformation" |
1066 |
||
1067 |
transformation := aTransformation |
|
619 | 1068 |
! |
1069 |
||
1319 | 1070 |
translateBy:aPoint |
1071 |
"add to the translation offset of the transformation" |
|
1072 |
||
1073 |
transformation isNil ifTrue:[ |
|
1956 | 1074 |
aPoint = 0 ifTrue:[^ self]. |
1075 |
transformation := WindowingTransformation scale:1 translation:aPoint |
|
1319 | 1076 |
] ifFalse:[ |
1956 | 1077 |
transformation translateBy:aPoint |
1319 | 1078 |
] |
1079 |
||
1080 |
"Created: 10.2.1997 / 13:50:22 / cg" |
|
1081 |
! |
|
1082 |
||
619 | 1083 |
translation |
1084 |
"return the translation factor (as point) of the transformation" |
|
1085 |
||
1086 |
transformation isNil ifTrue:[^ 0@0]. |
|
1087 |
^ transformation translation |
|
1088 |
||
1089 |
"Created: 27.4.1996 / 18:46:41 / cg" |
|
1090 |
! |
|
1091 |
||
1092 |
translation:aPoint |
|
1093 |
"set the translation offset of the transformation" |
|
1094 |
||
1095 |
transformation isNil ifTrue:[ |
|
1956 | 1096 |
aPoint = 0 ifTrue:[^ self]. |
1097 |
transformation := WindowingTransformation scale:1 translation:aPoint |
|
619 | 1098 |
] ifFalse:[ |
1956 | 1099 |
transformation translation:aPoint. |
619 | 1100 |
] |
1101 |
||
1102 |
"Created: 27.4.1996 / 18:47:28 / cg" |
|
0 | 1103 |
! ! |
1104 |
||
4396 | 1105 |
!GraphicsContext methodsFor:'basic drawing'! |
0 | 1106 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1107 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle |
0 | 1108 |
"draw an arc in a box |
1109 |
- this could be recoded to draw using displayLine" |
|
1110 |
||
1111 |
^ self subclassResponsibility |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1112 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1113 |
"Created: 8.5.1996 / 08:47:06 / cg" |
0 | 1114 |
! |
1115 |
||
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1116 |
displayDottedRectangleX:x y:y width:w height:h |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1117 |
"draw a dotted-line rectangle |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1118 |
A general implementation is found here; deviceGC's |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1119 |
may reimplement this if directly supported by the device" |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1120 |
|
2747
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1121 |
|lastX lastY x0 y0 oldStyle| |
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1122 |
|
3535 | 1123 |
(false "(device platformName ~= 'WIN32')" |
2747
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1124 |
or:[OperatingSystem isMSWINDOWSNTlike]) ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1125 |
oldStyle := lineStyle. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1126 |
self lineStyle:#dotted. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1127 |
self displayRectangleX:x y:y width:w height:h. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1128 |
self lineStyle:oldStyle. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1129 |
^ self. |
2747
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1130 |
]. |
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1131 |
|
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1132 |
1 to:w-1 by:2 do:[:o | |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1133 |
lastX := x + o. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1134 |
self displayPointX:lastX y:y. |
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1135 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1136 |
y0 := 1. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1137 |
lastX == (x+w-1) ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1138 |
y0 := 0 |
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1139 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1140 |
y0 to:h-1 by:2 do:[:o | |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1141 |
lastY := y+o. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1142 |
self displayPointX:x+w-1 y:lastY. |
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1143 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1144 |
x0 := w-2. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1145 |
lastY == (y+h-1) ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1146 |
x0:= w-1 |
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1147 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1148 |
x0 to:0 by:-2 do:[:o | |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1149 |
lastX := x+o. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1150 |
self displayPointX:lastX y:y+h-1. |
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1151 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1152 |
y0 := h-1. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1153 |
lastX == 0 ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1154 |
y0 := h-1 |
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1155 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1156 |
y0 to:0 by:-2 do:[:o | |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1157 |
self displayPointX:x y:y+o. |
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1158 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1159 |
|
3535 | 1160 |
"Modified: / 6.11.2001 / 08:48:18 / cg" |
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1161 |
! |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1162 |
|
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1163 |
displayHorizontalWavelineFromX:x0 y:y0 toX:x1 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1164 |
"draw a horizontal wave-line from x0/y0 to x1/y0" |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1165 |
|
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1166 |
|w h pattern form x oldClip| |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1167 |
|
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1168 |
"/ pattern := #[ |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1169 |
"/ 2r00000000 2r00111100 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1170 |
"/ 2r00000000 2r11000011 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1171 |
"/ 2r11000011 2r00000000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1172 |
"/ 2r00111100 2r00000000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1173 |
"/ ]. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1174 |
"/ h := 4. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1175 |
"/ w := 16. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1176 |
|
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1177 |
"/ pattern := #[ |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1178 |
"/ 2r00000000 2r01111000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1179 |
"/ 2r00000000 2r10000100 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1180 |
"/ 2r10000001 2r00000000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1181 |
"/ 2r01000010 2r00000000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1182 |
"/ 2r00111100 2r00000000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1183 |
"/ ]. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1184 |
"/ h := 5. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1185 |
"/ w := 14. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1186 |
|
2782 | 1187 |
"/ pattern := #[ |
1188 |
"/ 2r00000001 2r11100000 |
|
1189 |
"/ 2r00000010 2r00010000 |
|
1190 |
"/ 2r10000100 2r00000000 |
|
1191 |
"/ 2r01111000 2r00000000 |
|
1192 |
"/ ]. |
|
1193 |
"/ h := 4. |
|
1194 |
"/ w := 12. |
|
1195 |
"/ |
|
1196 |
"/ pattern := #[ |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1197 |
"/ 2r00000011 |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1198 |
"/ 2r11001100 |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1199 |
"/ 2r00110000 |
2782 | 1200 |
"/ ]. |
1201 |
"/ h := 3. |
|
1202 |
"/ w := 8. |
|
1203 |
||
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1204 |
pattern := #[ |
7463 | 1205 |
2r11001100 2r11001100 2r11001100 2r11001100 |
1206 |
2r00110011 2r00110011 2r00110011 2r00110011 |
|
1207 |
]. |
|
2782 | 1208 |
h := 2. |
5777
8a5b6ccd5476
changed: #displayHorizontalWavelineFromX:y:toX:
Claus Gittinger <cg@exept.de>
parents:
5355
diff
changeset
|
1209 |
w := 32. |
2782 | 1210 |
|
5780
7acd722f9cf9
comment/format in: #displayHorizontalWavelineFromX:y:toX:
Claus Gittinger <cg@exept.de>
parents:
5777
diff
changeset
|
1211 |
"/ pattern := #[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1212 |
"/ 2r11000000 |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1213 |
"/ 2r00110000 |
5780
7acd722f9cf9
comment/format in: #displayHorizontalWavelineFromX:y:toX:
Claus Gittinger <cg@exept.de>
parents:
5777
diff
changeset
|
1214 |
"/ ]. |
7acd722f9cf9
comment/format in: #displayHorizontalWavelineFromX:y:toX:
Claus Gittinger <cg@exept.de>
parents:
5777
diff
changeset
|
1215 |
"/ h := 2. |
7acd722f9cf9
comment/format in: #displayHorizontalWavelineFromX:y:toX:
Claus Gittinger <cg@exept.de>
parents:
5777
diff
changeset
|
1216 |
"/ w := 4. |
7acd722f9cf9
comment/format in: #displayHorizontalWavelineFromX:y:toX:
Claus Gittinger <cg@exept.de>
parents:
5777
diff
changeset
|
1217 |
|
2782 | 1218 |
form := Form width:w height:h fromArray:pattern. |
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1219 |
|
7463 | 1220 |
oldClip := self clippingBoundsOrNil. |
1221 |
self clippingBounds:((x0 @ y0) corner:(x1 @ (y0+h))). |
|
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1222 |
|
2783
665caca8506e
care to use the same waveline origin
Claus Gittinger <cg@exept.de>
parents:
2782
diff
changeset
|
1223 |
x := x0 truncateTo:w. |
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1224 |
[x <= x1] whileTrue:[ |
7463 | 1225 |
self displayForm:form x:x y:y0. |
1226 |
x := x + w. |
|
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1227 |
]. |
7463 | 1228 |
self clippingBounds:oldClip |
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1229 |
|
5777
8a5b6ccd5476
changed: #displayHorizontalWavelineFromX:y:toX:
Claus Gittinger <cg@exept.de>
parents:
5355
diff
changeset
|
1230 |
"Created: / 28-10-1998 / 15:31:41 / cg" |
5780
7acd722f9cf9
comment/format in: #displayHorizontalWavelineFromX:y:toX:
Claus Gittinger <cg@exept.de>
parents:
5777
diff
changeset
|
1231 |
"Modified: / 24-07-2011 / 21:12:24 / cg" |
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1232 |
! |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1233 |
|
726 | 1234 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 |
1235 |
"draw a line from x0/y0 to x1/y1" |
|
0 | 1236 |
|
726 | 1237 |
^ self subclassResponsibility |
71 | 1238 |
|
726 | 1239 |
"Created: 28.5.1996 / 17:12:37 / cg" |
0 | 1240 |
! |
1241 |
||
26 | 1242 |
displayOpaqueForm:aForm x:x y:y |
0 | 1243 |
"draw a form at x/y; if the form has depth 1, 1's in the form are |
1244 |
drawn in current fg, 0's in current bg color. |
|
1245 |
If the form has depth ~~ 1, it is copied as is onto the receiver" |
|
1246 |
||
1247 |
^ self subclassResponsibility |
|
1248 |
! |
|
1249 |
||
1250 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y |
|
1251 |
"draw part of a string with both fg and bg at x/y in current font" |
|
1252 |
||
1253 |
^ self subclassResponsibility |
|
1254 |
! |
|
1255 |
||
8034 | 1256 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y maxWidth:maxWidth |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1257 |
"draw part of a string with both fg and bg at x/y in current font" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1258 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1259 |
^ self subclassResponsibility |
8034 | 1260 |
|
1261 |
"Created: / 24-05-2017 / 22:07:48 / mawalch" |
|
1262 |
! |
|
1263 |
||
1264 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y maxWitdh:maxWidth |
|
1265 |
<resource: #obsolete> |
|
1266 |
self obsoleteMethodWarning:'Bad spelling. Use #displayOpaqueString:from:to:x:y:maxWidth: instead.'. |
|
1267 |
^ self displayOpaqueString:aString from:index1 to:index2 x:x y:y maxWidth:maxWidth |
|
1268 |
||
1269 |
"Modified: / 24-05-2017 / 22:11:46 / mawalch" |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1270 |
! |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1271 |
|
519 | 1272 |
displayPolygon:aPolygon |
1273 |
"draw a polygon |
|
1274 |
- this could be recoded to draw using displayLine" |
|
1275 |
||
1276 |
^ self subclassResponsibility |
|
1277 |
! |
|
1278 |
||
1279 |
displayRectangleX:x y:y width:w height:h |
|
1280 |
"draw a rectangle |
|
1281 |
- this could be recoded to draw using displayLine" |
|
1282 |
||
1283 |
^ self subclassResponsibility |
|
1284 |
! |
|
1285 |
||
0 | 1286 |
displayString:aString from:index1 to:index2 x:x y:y |
1287 |
"draw part of a string with fg at x/y in current font" |
|
1288 |
||
1289 |
^ self subclassResponsibility |
|
3663 | 1290 |
! |
1291 |
||
1292 |
displayString:aString from:index1 to:index2 x:x y:y opaque:opaque |
|
1293 |
"draw part of a string with both fg and bg at x/y in current font" |
|
1294 |
||
1295 |
opaque ifTrue:[ |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1296 |
self displayOpaqueString:aString from:index1 to:index2 x:x y:y |
3663 | 1297 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1298 |
self displayString:aString from:index1 to:index2 x:x y:y |
3663 | 1299 |
]. |
0 | 1300 |
! ! |
1301 |
||
519 | 1302 |
!GraphicsContext methodsFor:'basic filling'! |
0 | 1303 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1304 |
fillArcX:x y:y width:w height:h from:start angle:angle |
519 | 1305 |
"fill an arc with current paint color" |
0 | 1306 |
|
519 | 1307 |
^ self subclassResponsibility |
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1308 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1309 |
"Created: 8.5.1996 / 08:47:44 / cg" |
0 | 1310 |
! |
1311 |
||
519 | 1312 |
fillPolygon:points |
1313 |
"fill a polygon with current paint color" |
|
0 | 1314 |
|
519 | 1315 |
^ self subclassResponsibility |
157 | 1316 |
! |
1317 |
||
519 | 1318 |
fillRectangleX:x y:y width:w height:h |
1319 |
"fill a rectangle with current paint color" |
|
0 | 1320 |
|
519 | 1321 |
^ self subclassResponsibility |
3668 | 1322 |
! |
1323 |
||
1324 |
fillRectangleX:x y:y width:w height:h color:aColor |
|
1325 |
"fill a rectangle with given color" |
|
1326 |
||
1327 |
|oldPaint| |
|
1328 |
||
1329 |
oldPaint := paint. |
|
1330 |
self paint:aColor. |
|
1331 |
self fillRectangleX:x y:y width:w height:h. |
|
1332 |
self paint:oldPaint. |
|
519 | 1333 |
! ! |
0 | 1334 |
|
519 | 1335 |
!GraphicsContext methodsFor:'drawing'! |
0 | 1336 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1337 |
display:someObject at:aPoint |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1338 |
"draw someObject - this must understand the #displayOn:at: message" |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1339 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1340 |
someObject displayOn:self at:aPoint |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1341 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1342 |
"Created: 28.5.1996 / 14:22:57 / cg" |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1343 |
! |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1344 |
|
12 | 1345 |
displayArcIn:aRectangle from:startAngle angle:angle |
1346 |
"draw an arc in a box" |
|
0 | 1347 |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1348 |
self |
1956 | 1349 |
displayArcX:(aRectangle left) |
1350 |
y:(aRectangle top) |
|
1351 |
width:(aRectangle width) |
|
1352 |
height:(aRectangle height) |
|
1353 |
from:startAngle |
|
1354 |
angle:angle |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1355 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1356 |
"Modified: 8.5.1996 / 08:35:00 / cg" |
0 | 1357 |
! |
1358 |
||
12 | 1359 |
displayArcOrigin:origin corner:corner from:startAngle angle:angle |
1360 |
"draw an arc in a box" |
|
0 | 1361 |
|
1362 |
|left top right bot| |
|
1363 |
||
1364 |
left := origin x. |
|
1365 |
top := origin y. |
|
1366 |
right := corner x. |
|
1367 |
bot := corner y. |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1368 |
self |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1369 |
displayArcX:left |
1956 | 1370 |
y:top |
1371 |
width:(right - left + 1) |
|
1372 |
height:(bot - top + 1) |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1373 |
from:startAngle |
1956 | 1374 |
angle:angle |
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1375 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1376 |
"Modified: 8.5.1996 / 08:35:25 / cg" |
0 | 1377 |
! |
1378 |
||
519 | 1379 |
displayCircle:aPoint radius:r |
1380 |
"draw a circle around a center point" |
|
1381 |
||
1382 |
self displayCircleX:(aPoint x) y:(aPoint y) radius:r |
|
1383 |
! |
|
1384 |
||
12 | 1385 |
displayCircleIn:aRectangle |
0 | 1386 |
"draw a circle in a box" |
1387 |
||
1388 |
self |
|
1956 | 1389 |
displayArcX:(aRectangle left) |
1390 |
y:(aRectangle top) |
|
1391 |
width:(aRectangle width) |
|
1392 |
height:(aRectangle height) |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1393 |
from:0 |
1956 | 1394 |
angle:360 |
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1395 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1396 |
"Modified: 8.5.1996 / 08:35:40 / cg" |
0 | 1397 |
! |
1398 |
||
12 | 1399 |
displayCircleX:x y:y radius:r |
1400 |
"draw a circle around a center point" |
|
0 | 1401 |
|
1402 |
|d| |
|
1403 |
d := 2 * r. |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1404 |
self |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1405 |
displayArcX:(x - r) |
1956 | 1406 |
y:(y - r) |
1407 |
width:d |
|
1408 |
height:d |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1409 |
from:0 |
1956 | 1410 |
angle:360 |
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1411 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1412 |
"Modified: 8.5.1996 / 08:36:03 / cg" |
519 | 1413 |
! |
1414 |
||
1953 | 1415 |
displayForm:aFormOrImage |
1416 |
"draw a form (or image) at the origin" |
|
1417 |
||
1418 |
self displayForm:aFormOrImage x:0 y:0 |
|
1419 |
||
1420 |
"Modified: / 24.4.1997 / 16:00:11 / cg" |
|
1421 |
"Created: / 9.11.1997 / 00:50:52 / cg" |
|
1422 |
! |
|
1423 |
||
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1424 |
displayForm:aFormOrImage at:aPoint |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1425 |
"draw a form (or image)" |
519 | 1426 |
|
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1427 |
self displayForm:aFormOrImage x:(aPoint x) y:(aPoint y) |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1428 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1429 |
"Modified: 24.4.1997 / 16:00:11 / cg" |
519 | 1430 |
! |
1431 |
||
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1432 |
displayForm:aFormOrImage x:x y:y |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1433 |
"draw a form (or image) at x/y; |
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1434 |
if the form has depth 1, 1's in the form are |
726 | 1435 |
drawn in current paint color, 0's are ignored. |
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1436 |
If the form has depth ~~ 1, the current fg color setting is ignored." |
726 | 1437 |
|
1438 |
|fg bg f noColor| |
|
1439 |
||
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1440 |
aFormOrImage depth > 1 ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1441 |
self displayOpaqueForm:aFormOrImage x:x y:y. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1442 |
^ self. |
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1443 |
]. |
6387 | 1444 |
"/ aFormOrImage mask notNil ifTrue:[ |
1445 |
"/self halt. |
|
1446 |
"/ ]. |
|
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1447 |
|
726 | 1448 |
fg := paint. |
1449 |
bg := bgPaint. |
|
1450 |
f := function. |
|
1451 |
||
1452 |
f ~~ #copy ifTrue:[ |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1453 |
self error:'function not supported'. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1454 |
^ self |
726 | 1455 |
]. |
1456 |
||
1457 |
noColor := Color noColor. |
|
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1458 |
|
726 | 1459 |
" |
1460 |
stamp out fg-pixels |
|
1461 |
" |
|
1462 |
self paint:noColor on:Color allColor function:#and. |
|
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1463 |
self displayOpaqueForm:aFormOrImage x:x y:y. |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1464 |
|
726 | 1465 |
" |
1466 |
or-in fg-pixels |
|
1467 |
" |
|
1468 |
self paint:fg on:Color noColor function:#or. |
|
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1469 |
self displayOpaqueForm:aFormOrImage x:x y:y. |
726 | 1470 |
self paint:fg on:fg function:f. |
1471 |
||
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1472 |
"Modified: 24.4.1997 / 16:01:43 / cg" |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1473 |
! |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1474 |
|
3663 | 1475 |
displayForm:aFormOrImage x:x y:y opaque:opaque |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1476 |
"draw a form (or image) at x/y; |
3663 | 1477 |
if the form has depth 1, 1's in the form are |
1478 |
drawn in current paint color, 0's are ignored. |
|
1479 |
If the form has depth ~~ 1, the current fg color setting is ignored." |
|
1480 |
||
1481 |
opaque ifTrue:[ |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1482 |
self displayOpaqueForm:aFormOrImage x:x y:y |
3663 | 1483 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1484 |
self displayForm:aFormOrImage x:x y:y |
3663 | 1485 |
]. |
1486 |
! |
|
1487 |
||
4171
bf0193e5a898
#displayImage for compatibility
Stefan Vogel <sv@exept.de>
parents:
4129
diff
changeset
|
1488 |
displayImage:aFormOrImage |
bf0193e5a898
#displayImage for compatibility
Stefan Vogel <sv@exept.de>
parents:
4129
diff
changeset
|
1489 |
"draw an image (or form). |
bf0193e5a898
#displayImage for compatibility
Stefan Vogel <sv@exept.de>
parents:
4129
diff
changeset
|
1490 |
Provided for ST-80 compatibilty; |
bf0193e5a898
#displayImage for compatibility
Stefan Vogel <sv@exept.de>
parents:
4129
diff
changeset
|
1491 |
in ST/X, images are also handled by #displayForm:" |
bf0193e5a898
#displayImage for compatibility
Stefan Vogel <sv@exept.de>
parents:
4129
diff
changeset
|
1492 |
|
bf0193e5a898
#displayImage for compatibility
Stefan Vogel <sv@exept.de>
parents:
4129
diff
changeset
|
1493 |
self displayForm:aFormOrImage x:0 y:0 |
bf0193e5a898
#displayImage for compatibility
Stefan Vogel <sv@exept.de>
parents:
4129
diff
changeset
|
1494 |
! |
bf0193e5a898
#displayImage for compatibility
Stefan Vogel <sv@exept.de>
parents:
4129
diff
changeset
|
1495 |
|
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1496 |
displayImage:aFormOrImage at:aPoint |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1497 |
"draw an image (or form). |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1498 |
Provided for ST-80 compatibilty; |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1499 |
in ST/X, images are also handled by #displayForm:" |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1500 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1501 |
self displayForm:aFormOrImage x:(aPoint x) y:(aPoint y) |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1502 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1503 |
"Modified: 24.4.1997 / 16:02:43 / cg" |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1504 |
! |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1505 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1506 |
displayImage:aFormOrImage x:x y:y |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1507 |
"draw an image (or form). |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1508 |
Provided for ST-80 compatibilty; |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1509 |
in ST/X, images are also handled by #displayForm:" |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1510 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1511 |
self displayForm:aFormOrImage x:x y:y |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1512 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1513 |
"Created: 24.4.1997 / 16:03:03 / cg" |
726 | 1514 |
! |
1515 |
||
519 | 1516 |
displayLineFrom:point1 to:point2 |
1517 |
"draw a line" |
|
1518 |
||
1519 |
self displayLineFromX:(point1 x) y:(point1 y) |
|
1520 |
toX:(point2 x) y:(point2 y) |
|
1521 |
! |
|
1522 |
||
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1523 |
displayLineFromX:xStart y:yStart toX:xEnd y:yEnd brush:aForm |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1524 |
"draw a line using a brush. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1525 |
Here, a slow fallback is used, drawing into a |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1526 |
temporary bitmap first, which is then displayed" |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1527 |
|
2436 | 1528 |
|deltaX deltaY dx dy px py destX destY p tempForm |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1529 |
xMin xMax yMin yMax x1 x2 y1 y2| |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1530 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1531 |
xStart < xEnd ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1532 |
xMin := xStart. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1533 |
xMax := xEnd. |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1534 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1535 |
xMin := xEnd. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1536 |
xMax := xStart |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1537 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1538 |
yStart < yEnd ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1539 |
yMin := yStart. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1540 |
yMax := yEnd. |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1541 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1542 |
yMin := yEnd. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1543 |
yMax := yStart |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1544 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1545 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1546 |
tempForm := Form width:(xMax-xMin+1+aForm width) |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1547 |
height:(yMax-yMin+1+aForm height) |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1548 |
depth:aForm depth |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1549 |
onDevice:device. |
7358 | 1550 |
tempForm isNil ifTrue:[^nil]. |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1551 |
tempForm clear. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1552 |
tempForm paint:(Color colorId:1) on:(Color colorId:0). |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1553 |
tempForm function:#or. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1554 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1555 |
((yStart = yEnd and:[xStart < xEnd]) |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1556 |
or: [yStart < yEnd]) ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1557 |
x1 := xStart. y1 := yStart. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1558 |
x2 := xEnd. y2 := yEnd. |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1559 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1560 |
x1 := xEnd. y1 := yEnd. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1561 |
x2 := xStart. y2 := yStart. |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1562 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1563 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1564 |
x1 := x1 - xMin. x2 := x2 - xMin. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1565 |
y1 := y1 - yMin. y2 := y2 - yMin. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1566 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1567 |
destX := x1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1568 |
destY := y1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1569 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1570 |
"/ bresenham ... |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1571 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1572 |
deltaX := x2 - x1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1573 |
deltaY := y2 - y1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1574 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1575 |
dx := deltaX sign. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1576 |
dy := deltaY sign. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1577 |
px := deltaY abs. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1578 |
py := deltaX abs. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1579 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1580 |
tempForm displayForm:aForm x:destX y:destY. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1581 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1582 |
py > px ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1583 |
"horizontal" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1584 |
p := py // 2. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1585 |
py timesRepeat:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1586 |
destX := destX + dx. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1587 |
(p := p - px) < 0 ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1588 |
destY := destY + dy. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1589 |
p := p + py |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1590 |
]. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1591 |
tempForm displayForm:aForm x:destX y:destY. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1592 |
] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1593 |
] ifFalse:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1594 |
"vertical" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1595 |
p := px // 2. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1596 |
px timesRepeat:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1597 |
destY := destY + dy. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1598 |
(p := p - py) < 0 ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1599 |
destX := destX + dx. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1600 |
p := p + px |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1601 |
]. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1602 |
tempForm displayForm:aForm x:destX y:destY |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1603 |
] |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1604 |
]. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1605 |
self displayForm:tempForm |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1606 |
x:xMin-aForm offset x |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1607 |
y:yMin-aForm offset y. |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1608 |
tempForm close |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1609 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1610 |
"Modified: 1.4.1997 / 21:29:06 / cg" |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1611 |
! |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1612 |
|
519 | 1613 |
displayOpaqueString:aString from:start to:stop at:aPoint |
1614 |
"draw part of a string - drawing both fg and bg" |
|
1615 |
||
1616 |
^ self displayOpaqueString:aString from:start to:stop x:aPoint x y:aPoint y |
|
1617 |
! |
|
1618 |
||
1619 |
displayOpaqueString:aString x:x y:y |
|
1620 |
"draw a string with both fg and bg" |
|
1621 |
||
1622 |
self displayOpaqueString:aString from:1 to:(aString size) x:x y:y |
|
1623 |
! |
|
1624 |
||
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1625 |
displayOpaqueString:aString x:x y:y angle:drawAngle |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1626 |
"draw a string along a (possibly non-horizontal) line, |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1627 |
drawing both fg and bg pixels. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1628 |
The angle is in degrees, clock-wise, starting with 0 for |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1629 |
a horizontal draw. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1630 |
Drawing is done by first drawing the string into a temporary bitmap, |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1631 |
which is rotated and finally drawn as usual. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1632 |
NOTICE: due to the rotation of the temporary bitmap, this is a slow |
1956 | 1633 |
operation - not to be used with cillions of strings ..." |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1634 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1635 |
self |
1956 | 1636 |
displayString:aString x:x y:y angle:drawAngle opaque:true |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1637 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1638 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1639 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1640 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1641 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1642 |
v extent:300@200. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1643 |
v openAndWait. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1644 |
0 to:360 by:45 do:[:a | |
1956 | 1645 |
v paint:Color black on:Color red. |
1646 |
v displayOpaqueString:'hello world' x:100 y:100 angle:a. |
|
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1647 |
]. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1648 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1649 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1650 |
"in contrast to non-opaque draw: |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1651 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1652 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1653 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1654 |
v extent:300@200. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1655 |
v openAndWait. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1656 |
0 to:360 by:45 do:[:a | |
1956 | 1657 |
v paint:Color black on:Color red. |
1658 |
v displayString:'hello world' x:100 y:100 angle:a. |
|
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1659 |
]. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1660 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1661 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1662 |
"Modified: 23.4.1997 / 17:50:23 / cg" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1663 |
! |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1664 |
|
519 | 1665 |
displayPoint:aPoint |
1666 |
"draw a pixel" |
|
1667 |
||
1668 |
self displayPointX:(aPoint x) y:(aPoint y) |
|
1669 |
! |
|
1670 |
||
1671 |
displayPointX:x y:y |
|
1672 |
"draw a point at x/y" |
|
1673 |
||
1674 |
self displayLineFromX:x y:y toX:x y:y |
|
1675 |
! |
|
1676 |
||
1677 |
displayRectangle:aRectangle |
|
1678 |
"draw a rectangle" |
|
1679 |
||
1680 |
self displayRectangleX:(aRectangle left) |
|
1681 |
y:(aRectangle top) |
|
1682 |
width:(aRectangle width) |
|
1683 |
height:(aRectangle height) |
|
1684 |
! |
|
1685 |
||
1686 |
displayRectangleOrigin:origin corner:corner |
|
1687 |
"draw a rectangle" |
|
1688 |
||
1689 |
|top left| |
|
1690 |
||
1691 |
left := origin x. |
|
1692 |
top := origin y. |
|
7801 | 1693 |
self displayRectangleX:left y:top width:(corner x - left) height:(corner y - top) |
563 | 1694 |
|
1695 |
"Modified: 13.4.1996 / 20:58:31 / cg" |
|
519 | 1696 |
! |
1697 |
||
2069 | 1698 |
displayRectangleOrigin:origin extent:extent |
1699 |
"draw a rectangle" |
|
1700 |
||
1701 |
self displayRectangleX:(origin x) y:(origin y) |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1702 |
width:(extent x) |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1703 |
height:(extent y) |
2069 | 1704 |
|
1705 |
"Modified: 13.4.1996 / 20:58:31 / cg" |
|
1706 |
! |
|
1707 |
||
4396 | 1708 |
displayRoundRectangleX:left y:top width:width height:height wCorner:wCorn hCorner:hCorn |
4930
d464ba6aea9b
#displayRoundRectangle:... - fix for X11
Stefan Vogel <sv@exept.de>
parents:
4911
diff
changeset
|
1709 |
|right bottom wC hC wHalf hHalf isWin32| |
4396 | 1710 |
|
4911 | 1711 |
"/ BIG KLUDGE WARNING HERE: the code below looks "good" on windows displays; |
1712 |
"/ (if you change anything under Unix, make it X-platform specific. |
|
1713 |
"/ (there seem to be drawing incompatibilities between Win- and XWorkstation) |
|
1714 |
||
6371 | 1715 |
isWin32 := device isWindowsPlatform. |
4930
d464ba6aea9b
#displayRoundRectangle:... - fix for X11
Stefan Vogel <sv@exept.de>
parents:
4911
diff
changeset
|
1716 |
|
4900 | 1717 |
right := left + width-1. |
1718 |
bottom := top + height-1. |
|
4396 | 1719 |
|
1720 |
wC := wCorn. |
|
1721 |
hC := hCorn. |
|
1722 |
||
4911 | 1723 |
self scale = 1 ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1724 |
wHalf := wC // 2. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1725 |
hHalf := hC // 2. |
4911 | 1726 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1727 |
wHalf := wC / 2. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1728 |
hHalf := hC / 2. |
4911 | 1729 |
]. |
4396 | 1730 |
|
1731 |
"top left arc" |
|
1732 |
self displayArcX:left y:top width:wC height:hC from:90 angle:90. |
|
1733 |
||
1734 |
"top right arc" |
|
4902 | 1735 |
self displayArcX:(right - wC) y:top width:wC height:hC from:0 angle:90. |
4396 | 1736 |
|
4911 | 1737 |
"bottom right arc" |
4930
d464ba6aea9b
#displayRoundRectangle:... - fix for X11
Stefan Vogel <sv@exept.de>
parents:
4911
diff
changeset
|
1738 |
(isWin32 and:[self scale = 1]) ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1739 |
self displayArcX:(right - wC+1) y:(bottom - hC+1) width:wC height:hC from:270 angle:90. |
4911 | 1740 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1741 |
self displayArcX:(right - wC) y:(bottom - hC) width:wC height:hC from:270 angle:90. |
4911 | 1742 |
]. |
1743 |
||
1744 |
"bottom left arc" |
|
1745 |
self displayArcX:left y:(bottom - hC) width:wC height:hC from:180 angle:90. |
|
1746 |
||
1747 |
"top line" |
|
4940
cbac16cbe259
dont draw round-rectangle points twice (in case of xoring)
Claus Gittinger <cg@exept.de>
parents:
4930
diff
changeset
|
1748 |
self displayLineFromX:(left + wHalf) y:top toX:(right - wHalf-1) y:top. |
4911 | 1749 |
|
1750 |
"left line" |
|
4940
cbac16cbe259
dont draw round-rectangle points twice (in case of xoring)
Claus Gittinger <cg@exept.de>
parents:
4930
diff
changeset
|
1751 |
self displayLineFromX:left y:(top + hHalf - 1) toX:left y:(bottom - hHalf - 2). |
4911 | 1752 |
|
4396 | 1753 |
"bottom line" |
4911 | 1754 |
self displayLineFromX:(left + wHalf-1) y:bottom |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1755 |
toX:(right - wHalf ) y:bottom. |
4396 | 1756 |
|
1757 |
"right line" |
|
4902 | 1758 |
self displayLineFromX:right y:(top + hHalf) toX:right y:(bottom - hHalf). |
4396 | 1759 |
|
1760 |
||
1761 |
" |
|
1762 |
|v| |
|
1763 |
||
1764 |
(v := View new) extent:200@200; openAndWait. |
|
1765 |
v displayRoundRectangleX:10 y:10 width:100 height:100 wCorner:20 hCorner:20 |
|
1766 |
" |
|
1767 |
! |
|
1768 |
||
519 | 1769 |
displayString:aString at:aPoint |
1770 |
"draw a string - drawing fg only" |
|
1771 |
||
1772 |
self displayString:aString x:aPoint x y:aPoint y |
|
1773 |
! |
|
1774 |
||
2460
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1775 |
displayString:aString centeredAtX:x y:y |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1776 |
"draw a string - drawing fg only" |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1777 |
|
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1778 |
|w h| |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1779 |
|
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1780 |
w := aString widthOn:self. |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1781 |
h := aString heightOn:self. |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1782 |
self displayString:aString x:x-(w/2) y:y-(h/2) |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1783 |
! |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1784 |
|
519 | 1785 |
displayString:aString from:start to:stop at:aPoint |
1786 |
"draw part of a string - drawing fg only" |
|
1787 |
||
1788 |
^ self displayString:aString from:start to:stop x:aPoint x y:aPoint y |
|
1789 |
! |
|
1790 |
||
1791 |
displayString:aString x:x y:y |
|
1792 |
"draw a string - drawing fg only" |
|
1793 |
||
1794 |
self displayString:aString from:1 to:(aString size) x:x y:y |
|
726 | 1795 |
! |
1796 |
||
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1797 |
displayString:aString x:x y:y angle:drawAngle |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1798 |
"draw a string along a (possibly non-horizontal) line - drawing fg only. |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1799 |
The angle is in degrees, clock-wise, starting with 0 for |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1800 |
a horizontal draw. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1801 |
Drawing is done by first drawing the string into a temporary bitmap, |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1802 |
which is rotated and finally drawn as usual. |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1803 |
NOTICE: due to the rotation of the temporary bitmap, this is a slow |
1956 | 1804 |
operation - not to be used with cillions of strings ..." |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1805 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1806 |
self |
1956 | 1807 |
displayString:aString x:x y:y angle:drawAngle opaque:false |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1808 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1809 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1810 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1811 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1812 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1813 |
v extent:300@200. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1814 |
v openAndWait. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1815 |
0 to:360 by:90 do:[:a | |
1956 | 1816 |
v paint:Color black. |
1817 |
v displayString:'hello world' x:100 y:100 angle:a. |
|
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1818 |
]. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1819 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1820 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1821 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1822 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1823 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1824 |
v extent:400@400. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1825 |
v openAndWait. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1826 |
0 to:360 by:5 do:[:a | |
1956 | 1827 |
v paint:Color black. |
1828 |
v displayString:'.........hello' x:200 y:200 angle:a. |
|
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1829 |
]. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1830 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1831 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1832 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1833 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1834 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1835 |
v extent:200@100. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1836 |
v openAndWait. |
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1837 |
v displayString:' hello' x:90 y:50 angle:0. |
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1838 |
v displayString:' hello' x:90 y:50 angle:45. |
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1839 |
v displayString:' hello' x:90 y:50 angle:90. |
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1840 |
v displayString:' hello' x:90 y:50 angle:180. |
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1841 |
v displayString:' hello' x:90 y:50 angle:270. |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1842 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1843 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1844 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1845 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1846 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1847 |
v extent:200@100. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1848 |
v openAndWait. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1849 |
v displayString:'hello' x:50 y:50 angle:0. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1850 |
v displayString:'hello' x:50 y:50 angle:45. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1851 |
v displayString:'hello' x:50 y:50 angle:90. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1852 |
v displayString:'hello' x:50 y:50 angle:135. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1853 |
v displayString:'hello' x:50 y:50 angle:180. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1854 |
v displayString:'hello' x:50 y:50 angle:225. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1855 |
v displayString:'hello' x:50 y:50 angle:270. |
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1856 |
v displayString:'hello' x:50 y:50 angle:315. |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1857 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1858 |
|
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1859 |
"Modified: 24.4.1997 / 12:51:25 / cg" |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1860 |
! |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1861 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1862 |
displayString:aString x:x y:y angle:drawAngle opaque:opaque |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1863 |
"common code to draw a string along a (possibly non-horizontal) line. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1864 |
The angle is in degrees, clock-wise, starting with 0 for |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1865 |
a horizontal draw. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1866 |
Drawing is done by first drawing the string into a temporary bitmap, |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1867 |
which is rotated and finally drawn as usual. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1868 |
NOTICE: due to the rotation of the temporary bitmap, this is a slow |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1869 |
operation - not to be used with cillions of strings ... |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1870 |
CAVEAT: if the string is not a real string (i.e. a LabelAndIcon), |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1871 |
this can (currently) only be done opaque" |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1872 |
|
3668 | 1873 |
|angle tempForm tempImage w h ascent descent a xN yN p r |
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1874 |
dX dY sin cos m| |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1875 |
|
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1876 |
angle := drawAngle. |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1877 |
angle >= 360 ifTrue:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1878 |
angle := angle - (((angle // 360)) * 360) |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1879 |
] ifFalse:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1880 |
angle < 0 ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1881 |
angle := angle - (((angle // 360)) * 360). |
4129 | 1882 |
angle := angle + 360. |
1883 |
angle >= 360 ifTrue:[ |
|
1884 |
angle := angle - (((angle // 360)) * 360) |
|
1885 |
] |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1886 |
]. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1887 |
]. |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1888 |
|
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1889 |
angle = 0 ifTrue:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1890 |
opaque ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1891 |
^ self displayOpaqueString:aString x:x y:y |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1892 |
]. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1893 |
^ self displayString:aString x:x y:y |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1894 |
]. |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1895 |
|
3717 | 1896 |
font := font onDevice:device. |
3668 | 1897 |
ascent := font ascent. |
3717 | 1898 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1899 |
aString isString ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1900 |
"/ a real string; |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1901 |
"/ do it in a monochrome form (for speed) |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1902 |
|
4954
e54b6bc479bf
angular string drawing fixed (sigh: sin wants radians)
Claus Gittinger <cg@exept.de>
parents:
4940
diff
changeset
|
1903 |
w := font widthOf:aString. |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1904 |
h := font height. |
3668 | 1905 |
descent := h - ascent. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1906 |
|
7358 | 1907 |
tempForm := Form width:w height:h depth:1 onDevice:device. |
1908 |
tempForm isNil ifTrue:[^ self]. |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1909 |
tempForm paint:(Color colorId:1) on:(Color colorId:0). |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1910 |
tempForm clear. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1911 |
tempForm font:font. |
3668 | 1912 |
tempForm displayString:aString x:0 y:ascent. |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1913 |
] ifFalse:[ |
4954
e54b6bc479bf
angular string drawing fixed (sigh: sin wants radians)
Claus Gittinger <cg@exept.de>
parents:
4940
diff
changeset
|
1914 |
"/ something weird (labelAndIcon ..) |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1915 |
"/ do it in a deep form. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1916 |
"/ CAVEAT: this can only be done opaque ... |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1917 |
|
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1918 |
w := aString widthOn:self. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1919 |
h := aString heightOn:self. |
3668 | 1920 |
descent := 0. |
1921 |
"/ ascent := font ascent max:(h // 2). |
|
1922 |
"/ descent := (h - font ascent) max:(h // 2). |
|
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1923 |
|
7358 | 1924 |
tempForm := Form width:w height:h depth:(device depth) onDevice:device. |
1925 |
tempForm isNil ifTrue:[^ self]. |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1926 |
tempForm paint:bgPaint. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1927 |
tempForm fillRectangleX:0 y:0 width:w height:h. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1928 |
tempForm paint:paint on:bgPaint. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1929 |
tempForm font:font. |
3668 | 1930 |
aString displayOn:tempForm x:0 y:ascent opaque:true. |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1931 |
]. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1932 |
tempImage := tempForm asImage rotated:angle. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1933 |
|
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1934 |
opaque ifTrue:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1935 |
m := ImageMask width:w height:h. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1936 |
m bits:(ByteArray new:(h * m bytesPerRow) withAll:16rFF). |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1937 |
m := m rotated:angle |
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1938 |
]. |
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1939 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1940 |
"/ compute final position of rotated form |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1941 |
"/ adjust position for baseline. |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1942 |
angle = 90 ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1943 |
xN := x - descent. |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1944 |
yN := y. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1945 |
] ifFalse:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1946 |
angle = 180 ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1947 |
xN := x - w. |
3668 | 1948 |
yN := y - descent "+ h - ascent". |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1949 |
] ifFalse:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1950 |
angle = 270 ifTrue:[ |
3668 | 1951 |
xN := x - ascent. |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1952 |
yN := y - w. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1953 |
] ifFalse:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1954 |
"/ sigh: since the new image has different dimensions, |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1955 |
"/ the computation is somewhat more difficult here. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1956 |
"/ remember: the image has been rotated around its center, |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1957 |
"/ then shifted towards the top-left origin. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1958 |
p := (w@h) / 2. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1959 |
r := p r. |
4107
6ff7c076616b
Use #theta inseat of obsolete #angle.
Stefan Vogel <sv@exept.de>
parents:
4071
diff
changeset
|
1960 |
a := p theta. |
4954
e54b6bc479bf
angular string drawing fixed (sigh: sin wants radians)
Claus Gittinger <cg@exept.de>
parents:
4940
diff
changeset
|
1961 |
sin := angle degreesToRadians sin. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
1962 |
cos := angle degreesToRadians cos. |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1963 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1964 |
angle < 90 ifTrue:[ |
3668 | 1965 |
dX := descent * sin. |
1966 |
dY := ascent * cos. |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1967 |
xN := x - dX. |
4954
e54b6bc479bf
angular string drawing fixed (sigh: sin wants radians)
Claus Gittinger <cg@exept.de>
parents:
4940
diff
changeset
|
1968 |
yN := y - dY. |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1969 |
] ifFalse:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1970 |
angle < 180 ifTrue:[ |
3668 | 1971 |
dX := ascent * sin. |
1972 |
dY := descent * cos. |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1973 |
xN := x + dX - (tempImage width). |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1974 |
yN := y + dY. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1975 |
] ifFalse:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1976 |
angle < 270 ifTrue:[ |
3668 | 1977 |
dX := descent * sin. |
1978 |
dY := ascent * cos. |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1979 |
xN := x - dX - (tempImage width). |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1980 |
yN := y - dY - (tempImage height) |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1981 |
] ifFalse:[ |
3668 | 1982 |
dX := ascent * sin. |
1983 |
dY := descent * cos. |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1984 |
xN := x + dX. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1985 |
yN := y + dY - (tempImage height). |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1986 |
] |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1987 |
] |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1988 |
]. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1989 |
tempImage mask:nil. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1990 |
] |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1991 |
]. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1992 |
]. |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1993 |
|
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1994 |
opaque ifTrue:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1995 |
p := paint. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1996 |
self paint:bgPaint. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1997 |
self displayForm:m x:xN y:yN. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1998 |
self paint:p. |
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1999 |
]. |
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
2000 |
self displayForm:tempImage x:xN y:yN. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
2001 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
2002 |
"Modified: / 29.1.1998 / 13:23:23 / cg" |
0 | 2003 |
! ! |
519 | 2004 |
|
2005 |
!GraphicsContext methodsFor:'drawing in device coordinates'! |
|
2006 |
||
2007 |
displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2 |
|
2008 |
"draw a line in device coordinates" |
|
2009 |
||
2010 |
|sav| |
|
2011 |
||
2012 |
sav := transformation. |
|
2013 |
transformation := nil. |
|
2014 |
self displayLineFromX:x1 y:y1 toX:x2 y:y2. |
|
2015 |
transformation := sav |
|
2016 |
! |
|
2017 |
||
4393 | 2018 |
displayDeviceRectangleX:x y:y width:w height:h |
2019 |
"draw a rectangle in device coordinates" |
|
2020 |
||
2021 |
|sav| |
|
2022 |
||
2023 |
sav := transformation. |
|
2024 |
transformation := nil. |
|
2025 |
self displayRectangleX:x y:y width:w height:h. |
|
2026 |
transformation := sav |
|
2027 |
! |
|
2028 |
||
519 | 2029 |
fillDeviceRectangleX:x y:y width:w height:h |
2030 |
"fill a rectangle with current paint color (device coordinates)" |
|
2031 |
||
2032 |
|sav| |
|
2033 |
||
2034 |
sav := transformation. |
|
2035 |
transformation := nil. |
|
2036 |
self fillRectangleX:x y:y width:w height:h. |
|
2037 |
transformation := sav |
|
2038 |
! ! |
|
2039 |
||
713 | 2040 |
!GraphicsContext methodsFor:'edge drawing'! |
2041 |
||
4215 | 2042 |
drawEdgesForX:x y:y width:w height:h level:l |
2043 |
"draw 3D edges into a rectangle" |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2044 |
self |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2045 |
drawEdgesForX:x y:y width:w height:h level:l |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2046 |
shadow:self blackColor light:self whiteColor |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2047 |
halfShadow:nil halfLight:nil |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2048 |
style:nil |
4215 | 2049 |
! |
2050 |
||
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2051 |
drawEdgesForX:x y:y width:w height:h level:lvl |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2052 |
shadow:shadowColor light:lightColor |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2053 |
halfShadow:halfShadowColor halfLight:halfLightColor |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2054 |
style:edgeStyle |
713 | 2055 |
|
2056 |
"draw 3D edges into a rectangle" |
|
2057 |
||
2058 |
|topLeftFg botRightFg topLeftHalfFg botRightHalfFg |
|
2059 |
count "{ Class: SmallInteger }" |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2060 |
r |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2061 |
b |
713 | 2062 |
xi "{ Class: SmallInteger }" |
2063 |
yi "{ Class: SmallInteger }" |
|
2064 |
run paint| |
|
2065 |
||
6535 | 2066 |
count := lvl. |
713 | 2067 |
(count < 0) ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2068 |
topLeftFg := shadowColor. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2069 |
botRightFg := lightColor. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2070 |
topLeftHalfFg := halfShadowColor. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2071 |
botRightHalfFg := halfLightColor. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2072 |
count := count negated |
713 | 2073 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2074 |
topLeftFg := lightColor. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2075 |
botRightFg := shadowColor. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2076 |
topLeftHalfFg := halfLightColor. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2077 |
botRightHalfFg := halfShadowColor. |
713 | 2078 |
]. |
2079 |
topLeftHalfFg isNil ifTrue:[ |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2080 |
topLeftHalfFg := topLeftFg |
713 | 2081 |
]. |
2082 |
botRightHalfFg isNil ifTrue:[ |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2083 |
botRightHalfFg := botRightFg |
713 | 2084 |
]. |
2085 |
||
2086 |
r := x + w - 1. "right" |
|
2087 |
b := y + h - 1. "bottom" |
|
2088 |
||
2089 |
self lineWidth:0. |
|
2090 |
||
2091 |
"top and left edges" |
|
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
2092 |
((edgeStyle == #soft or:[edgeStyle == #softWin95]) and:["l" count > 0]) ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2093 |
paint := topLeftHalfFg |
713 | 2094 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2095 |
paint := topLeftFg |
713 | 2096 |
]. |
2097 |
self paint:paint. |
|
2098 |
||
2099 |
0 to:(count - 1) do:[:i | |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2100 |
run := y + i. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2101 |
run < b ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2102 |
self displayDeviceLineFromX:x y:run toX:r y:run. "top" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2103 |
]. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2104 |
run := x + i. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2105 |
self displayDeviceLineFromX:run y:y toX:run y:b "left" |
713 | 2106 |
]. |
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
2107 |
(edgeStyle == #soft or:[edgeStyle == #softWin95]) ifTrue:[ |
713 | 2108 |
" |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2109 |
self paint:topLeftFg. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2110 |
self displayDeviceLineFromX:x y:y toX:r y:y. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2111 |
self displayDeviceLineFromX:x y:y toX:x y:b |
713 | 2112 |
" |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2113 |
(lvl > 1) ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2114 |
edgeStyle == #softWin95 ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2115 |
self paint:(Color veryLightGray). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2116 |
] ifFalse:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2117 |
(lvl > 2 and:[edgeStyle == #soft]) ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2118 |
self paint:(device blackColor). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2119 |
] ifFalse:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2120 |
self paint:halfLightColor. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2121 |
] |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2122 |
]. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2123 |
self displayDeviceLineFromX:x y:y toX:r y:y. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2124 |
self displayDeviceLineFromX:x y:y toX:x y:b. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2125 |
] |
713 | 2126 |
]. |
2127 |
||
2128 |
xi := x + 1. |
|
2129 |
yi := y + 1. |
|
2130 |
||
2131 |
"/ does not look good |
|
2132 |
"/ style == #st80 iftrue:[ |
|
2133 |
"/ yi := yi + 1 |
|
2134 |
"/ ]. |
|
2135 |
||
2136 |
"bottom and right edges" |
|
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
2137 |
((edgeStyle == #soft or:[edgeStyle == #softWin95]) |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
2138 |
"new:" and:[count > 1]) ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2139 |
paint := botRightHalfFg |
713 | 2140 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2141 |
paint := botRightFg |
713 | 2142 |
]. |
2143 |
||
2144 |
self paint:paint. |
|
2145 |
0 to:(count - 1) do:[:i | |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2146 |
run := b - i. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2147 |
run > y ifTrue:[ |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2148 |
self displayDeviceLineFromX:xi-1 y:run toX:r y:run. "bottom" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2149 |
]. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2150 |
run := r - i. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2151 |
self displayDeviceLineFromX:run y:yi-1 toX:run y:b. "right" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2152 |
xi := xi + 1. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2153 |
yi := yi + 1 |
713 | 2154 |
]. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2155 |
((edgeStyle == #soft or:[edgeStyle == #softWin95]) |
6535 | 2156 |
and:[lvl > 1]) ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2157 |
self paint:(device blackColor) "shadowColor". |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2158 |
self displayDeviceLineFromX:x y:b toX:r y:b. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2159 |
self displayDeviceLineFromX:r y:y toX:r y:b |
1443 | 2160 |
]. |
2161 |
||
2162 |
self edgeDrawn:#all |
|
2163 |
||
2273 | 2164 |
"Modified: / 24.8.1998 / 18:23:02 / cg" |
1443 | 2165 |
! |
713 | 2166 |
|
1443 | 2167 |
edgeDrawn:whichOne |
2168 |
"a redefinable hook for views which like to draw |
|
2169 |
over their edges (some checkToggles do). |
|
2170 |
Nothing done here." |
|
2171 |
||
2172 |
"Created: 7.3.1997 / 17:59:07 / cg" |
|
713 | 2173 |
! ! |
2174 |
||
519 | 2175 |
!GraphicsContext methodsFor:'filling'! |
2176 |
||
2177 |
fillArc:origin radius:r from:startAngle angle:angle |
|
2178 |
"draw a filled arc around a point" |
|
2179 |
||
2180 |
|d| |
|
2181 |
d := 2 * r. |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2182 |
self |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2183 |
fillArcX:(origin x - r) |
1956 | 2184 |
y:(origin y - r) |
2185 |
width:d |
|
2186 |
height:d |
|
2187 |
from:startAngle |
|
2188 |
angle:angle |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2189 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2190 |
"Modified: 8.5.1996 / 08:41:54 / cg" |
519 | 2191 |
! |
2192 |
||
563 | 2193 |
fillArcIn:aRectangle from:startAngle angle:angle |
2194 |
"draw a filled arc in a box" |
|
2195 |
||
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2196 |
self |
1956 | 2197 |
fillArcX:(aRectangle left) |
2198 |
y:(aRectangle top) |
|
2199 |
width:(aRectangle width) |
|
2200 |
height:(aRectangle height) |
|
2201 |
from:startAngle |
|
2202 |
angle:angle |
|
563 | 2203 |
|
2204 |
"Created: 13.4.1996 / 20:56:03 / cg" |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2205 |
"Modified: 8.5.1996 / 08:42:13 / cg" |
563 | 2206 |
! |
2207 |
||
2208 |
fillArcOrigin:origin corner:corner from:startAngle angle:angle |
|
2209 |
"draw a filled arc in a box" |
|
2210 |
||
2211 |
|left top right bot| |
|
2212 |
||
2213 |
left := origin x. |
|
2214 |
top := origin y. |
|
2215 |
right := corner x. |
|
2216 |
bot := corner y. |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2217 |
self |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2218 |
fillArcX:left |
1956 | 2219 |
y:top |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2220 |
width:(right - left + 1) |
1956 | 2221 |
height:(bot - top + 1) |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2222 |
from:startAngle |
1956 | 2223 |
angle:angle |
563 | 2224 |
|
2225 |
"Created: 13.4.1996 / 20:56:56 / cg" |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2226 |
"Modified: 8.5.1996 / 08:42:23 / cg" |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2227 |
! |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2228 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2229 |
fillArcX:x y:y width:w height:h from:startAngle to:endAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2230 |
"draw a filled arc in a box, given startAngle and endAngle." |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2231 |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2232 |
self |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2233 |
fillArcX:x |
1956 | 2234 |
y:y |
2235 |
width:w |
|
2236 |
height:h |
|
2237 |
from:startAngle |
|
2238 |
angle:(endAngle - startAngle) |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2239 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2240 |
"Created: 8.5.1996 / 08:52:41 / cg" |
563 | 2241 |
! |
2242 |
||
519 | 2243 |
fillCircle:aPoint radius:aNumber |
2244 |
"draw a filled circle around aPoint" |
|
2245 |
||
2246 |
self fillCircleX:(aPoint x) y:(aPoint y) radius:aNumber |
|
2247 |
! |
|
2248 |
||
563 | 2249 |
fillCircleIn:aRectangle |
2250 |
"draw a filled circle in a box" |
|
2251 |
||
2252 |
self |
|
1956 | 2253 |
fillArcX:(aRectangle left) |
2254 |
y:(aRectangle top) |
|
2255 |
width:(aRectangle width) |
|
2256 |
height:(aRectangle height) |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2257 |
from:0 |
1956 | 2258 |
angle:360 |
563 | 2259 |
|
2260 |
"Created: 13.4.1996 / 20:57:41 / cg" |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2261 |
"Modified: 8.5.1996 / 08:42:38 / cg" |
563 | 2262 |
! |
2263 |
||
519 | 2264 |
fillCircleX:x y:y radius:r |
2265 |
"draw a filled circle around x@y" |
|
2266 |
||
2267 |
|d| |
|
2268 |
||
2269 |
d := 2 * r. |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2270 |
self |
1956 | 2271 |
fillArcX:(x - r) |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2272 |
y:(y - r) |
1956 | 2273 |
width:d |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2274 |
height:d |
1956 | 2275 |
from:0 |
2276 |
angle:360 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2277 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2278 |
"Modified: 8.5.1996 / 08:43:02 / cg" |
519 | 2279 |
! |
2280 |
||
2281 |
fillRectangle:aRectangle |
|
2282 |
"fill a rectangle with current paint color" |
|
2283 |
||
2284 |
self fillRectangleX:(aRectangle left) |
|
2285 |
y:(aRectangle top) |
|
2286 |
width:(aRectangle width) |
|
2287 |
height:(aRectangle height) |
|
563 | 2288 |
! |
2289 |
||
3733 | 2290 |
fillRectangleLeft:left top:top right:cornerX bottom:cornerY |
2291 |
"draw a filled rectangle. |
|
2292 |
Notice: the cornerPoint itself is NOT included" |
|
2293 |
||
2294 |
self fillRectangleX:left y:top width:(cornerX - left) height:(cornerY - top) |
|
2295 |
! |
|
2296 |
||
563 | 2297 |
fillRectangleOrigin:origin corner:corner |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2298 |
"draw a filled rectangle. |
3733 | 2299 |
Notice: the cornerPoint itself is NOT included" |
563 | 2300 |
|
2301 |
|top left| |
|
2302 |
||
2303 |
left := origin x. |
|
2304 |
top := origin y. |
|
3733 | 2305 |
self fillRectangleX:left y:top width:(corner x - left) height:(corner y - top) |
563 | 2306 |
|
2307 |
"Created: 13.4.1996 / 20:58:16 / cg" |
|
3954 | 2308 |
! |
2309 |
||
2310 |
fillRectangleOrigin:origin extent:extent |
|
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2311 |
"draw a filled rectangle. |
3954 | 2312 |
Notice: the cornerPoint itself is NOT included" |
2313 |
||
2314 |
self fillRectangleX:(origin x) y:(origin y) width:(extent x) height:(extent y) |
|
4901 | 2315 |
! |
2316 |
||
8290 | 2317 |
fillRectangleOrigin:origin width:w height:h |
2318 |
"draw a filled rectangle. |
|
2319 |
Notice: the cornerPoint itself is NOT included" |
|
2320 |
||
2321 |
self fillRectangleX:(origin x) y:(origin y) width:w height:h |
|
2322 |
! |
|
2323 |
||
4901 | 2324 |
fillRoundRectangleX:left y:top width:width height:height wCorner:wCorn hCorner:hCorn |
2325 |
|right bottom wC hC wHalf hHalf| |
|
2326 |
||
2327 |
right := left + width. |
|
2328 |
bottom := top + height. |
|
2329 |
||
2330 |
wC := wCorn. |
|
2331 |
hC := hCorn. |
|
2332 |
||
2333 |
wHalf := wC / 2. |
|
2334 |
hHalf := hC / 2. |
|
2335 |
||
6371 | 2336 |
device isWindowsPlatform ifTrue:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2337 |
"/ bug workaround |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2338 |
"top left arc" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2339 |
self fillArcX:left y:top width:wC height:hC from:90 angle:90. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2340 |
"top right arc" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2341 |
self fillArcX:(right - wC - 1) y:top width:wC height:hC from:0 angle:90. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2342 |
"bottom right arc" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2343 |
self fillArcX:(right - wC - 1) y:(bottom - hC - 1) width:wC height:hC from:270 angle:90. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2344 |
"bottom left arc" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2345 |
self fillArcX:left y:(bottom - hC) width:wC height:hC-1 from:180 angle:90. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2346 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2347 |
"center rectangle" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2348 |
self fillRectangleX:(left + wHalf) y:top width:(width - wHalf - wHalf+1) height:height-1. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2349 |
"left partial rectangle" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2350 |
self fillRectangleX:left y:top+hHalf width:wHalf height:(height-hHalf-hHalf). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2351 |
"right partial rectangle" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2352 |
self fillRectangleX:right-wHalf y:top+hHalf width:wHalf-1 height:(height-hHalf-hHalf). |
4901 | 2353 |
] ifFalse:[ |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2354 |
"top left arc" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2355 |
self fillArcX:left y:top width:wC height:hC from:90 angle:90. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2356 |
"top right arc" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2357 |
self fillArcX:(right - wC) y:top width:wC height:hC from:0 angle:90. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2358 |
"bottom right arc" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2359 |
self fillArcX:(right - wC - 1) y:(bottom - hC) width:wC height:hC from:270 angle:90. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2360 |
"bottom left arc" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2361 |
self fillArcX:left y:(bottom - hC) width:wC height:hC from:180 angle:90. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2362 |
|
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2363 |
"center rectangle" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2364 |
self fillRectangleX:(left + wHalf) y:top width:(width - wHalf - wHalf+1) height:height. |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2365 |
"left partial rectangle" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2366 |
self fillRectangleX:left y:top+hHalf width:wHalf height:(height-hHalf-hHalf). |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2367 |
"right partial rectangle" |
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2368 |
self fillRectangleX:right-wHalf y:top+hHalf width:wHalf height:(height-hHalf-hHalf). |
4901 | 2369 |
]. |
2370 |
||
2371 |
||
2372 |
" |
|
2373 |
|v| |
|
2374 |
||
2375 |
(v := View new) extent:200@200; openAndWait. |
|
2376 |
v fillRoundRectangleX:10 y:10 width:100 height:100 wCorner:20 hCorner:20 |
|
2377 |
" |
|
519 | 2378 |
! ! |
2379 |
||
2380 |
!GraphicsContext methodsFor:'initialization'! |
|
2381 |
||
2382 |
initialize |
|
2383 |
"set up some useful default values" |
|
2384 |
||
952 | 2385 |
paint isNil ifTrue:[paint := Black]. |
2386 |
bgPaint isNil ifTrue:[bgPaint := White]. |
|
519 | 2387 |
function := #copy. |
2388 |
lineWidth := 1. |
|
2389 |
lineStyle := #solid. |
|
2390 |
joinStyle := #miter. |
|
2391 |
capStyle := #butt. |
|
6144 | 2392 |
font := self class defaultFont. |
7289 | 2393 |
|
2394 |
"/ this is rubbish. we are now always using unicode internaly |
|
4056 | 2395 |
characterEncoding := #'iso10646-1'. "/ aka unicode |
519 | 2396 |
! ! |
2397 |
||
2398 |
!GraphicsContext methodsFor:'misc'! |
|
2399 |
||
3033 | 2400 |
clippedTo:aRectangle do:aBlock |
2401 |
|oldClip| |
|
2402 |
||
2403 |
oldClip := clipRect. |
|
7463 | 2404 |
self clippingBounds:aRectangle. |
2405 |
aBlock ensure:[ |
|
2406 |
self clippingBounds:oldClip |
|
2407 |
]. |
|
3033 | 2408 |
! |
2409 |
||
519 | 2410 |
flush |
585 | 2411 |
"send all buffered drawing to the device." |
519 | 2412 |
|
742 | 2413 |
device flush |
585 | 2414 |
|
742 | 2415 |
"Modified: 28.5.1996 / 20:22:26 / cg" |
6268 | 2416 |
! |
2417 |
||
2418 |
sync |
|
2419 |
"send all buffered drawing to the device and wait until the device responds" |
|
2420 |
||
2421 |
device sync |
|
519 | 2422 |
! ! |
2423 |
||
6081 | 2424 |
!GraphicsContext methodsFor:'printing & storing'! |
2425 |
||
6173 | 2426 |
storeOn:aStream |
6081 | 2427 |
"blocked: ascii storeString not possible (recursive - view - subviews - container)" |
2428 |
||
6173 | 2429 |
self shouldNotImplement. |
7416
bd3b9e9edd9e
Delegate GraphicsContext objects
Stefan Vogel <sv@exept.de>
parents:
7358
diff
changeset
|
2430 |
"if proceeded from exception..." |
6173 | 2431 |
self printOn:aStream. |
6081 | 2432 |
! ! |
2433 |
||
4984 | 2434 |
!GraphicsContext methodsFor:'queries'! |
2435 |
||
2436 |
fontAscent |
|
2437 |
"answer the ascent of the current font on the current device" |
|
2438 |
||
2439 |
^ font ascentOn:device |
|
2440 |
! ! |
|
2441 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
2442 |
!GraphicsContext class methodsFor:'documentation'! |
519 | 2443 |
|
2444 |
version |
|
7015 | 2445 |
^ '$Header$' |
5355 | 2446 |
! |
2447 |
||
2448 |
version_CVS |
|
7015 | 2449 |
^ '$Header$' |
519 | 2450 |
! ! |
3733 | 2451 |
|
6081 | 2452 |
|
519 | 2453 |
GraphicsContext initialize! |