245
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1996 by Claus Gittinger
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
|
253
|
14 |
GeometricWrapper subclass:#StrokingWrapper
|
245
|
15 |
instanceVariableNames:'lineWidth'
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'Graphics-Display Objects'
|
|
19 |
!
|
|
20 |
|
|
21 |
!StrokingWrapper class methodsFor:'documentation'!
|
|
22 |
|
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 1996 by Claus Gittinger
|
|
26 |
All Rights Reserved
|
|
27 |
|
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
|
35 |
|
|
36 |
!
|
|
37 |
|
|
38 |
documentation
|
|
39 |
"
|
|
40 |
a wrapper for a geometric object, which is to be drawn stroked.
|
|
41 |
This allows any geometric thingy to be used as a component in a view.
|
|
42 |
|
248
|
43 |
[see also:]
|
|
44 |
FillingWrapper Geometric GraphicsContext
|
|
45 |
|
245
|
46 |
[author:]
|
|
47 |
Claus Gittinger
|
|
48 |
"
|
|
49 |
!
|
|
50 |
|
|
51 |
examples
|
|
52 |
"
|
|
53 |
[exBegin]
|
248
|
54 |
|v e component|
|
245
|
55 |
|
248
|
56 |
v := (View extent:250@250) openAndWait.
|
245
|
57 |
|
248
|
58 |
e := EllipticalArc boundingBox:(10@10 corner:90@90)
|
|
59 |
startAngle:0
|
|
60 |
sweepAngle:270.
|
|
61 |
component := StrokingWrapper on:e.
|
245
|
62 |
|
248
|
63 |
component displayOn:v.
|
245
|
64 |
[exEnd]
|
|
65 |
|
|
66 |
[exBegin]
|
248
|
67 |
|v e component|
|
245
|
68 |
|
248
|
69 |
v := View new.
|
|
70 |
v extent:250@250.
|
245
|
71 |
|
248
|
72 |
e := Rectangle origin:10@10 corner:90@90.
|
|
73 |
component := FillingWrapper on:e.
|
|
74 |
component foregroundColor:Color red.
|
245
|
75 |
|
248
|
76 |
v addComponent:component.
|
245
|
77 |
|
248
|
78 |
e := EllipticalArc boundingBox:(10@10 corner:90@90)
|
|
79 |
startAngle:0 sweepAngle:360.
|
|
80 |
component := StrokingWrapper on:e.
|
|
81 |
component lineWidth:5.
|
245
|
82 |
|
248
|
83 |
v addComponent:component.
|
245
|
84 |
|
248
|
85 |
v addComponent:(Button label:'hello').
|
245
|
86 |
|
248
|
87 |
v open
|
245
|
88 |
[exEnd]
|
|
89 |
"
|
|
90 |
! !
|
|
91 |
|
|
92 |
!StrokingWrapper methodsFor:'accessing'!
|
|
93 |
|
|
94 |
bounds
|
246
|
95 |
"return the boundary rectangle - here, must take care of the lineWidth"
|
|
96 |
|
245
|
97 |
^ component bounds + (lineWidth - 1)
|
|
98 |
|
|
99 |
"Created: 8.5.1996 / 23:22:43 / cg"
|
246
|
100 |
"Modified: 9.5.1996 / 00:09:06 / cg"
|
245
|
101 |
!
|
|
102 |
|
|
103 |
lineWidth
|
246
|
104 |
"return the lineWidth"
|
|
105 |
|
245
|
106 |
^ lineWidth
|
|
107 |
|
|
108 |
"Created: 8.5.1996 / 23:22:04 / cg"
|
246
|
109 |
"Modified: 9.5.1996 / 00:09:12 / cg"
|
245
|
110 |
!
|
|
111 |
|
|
112 |
lineWidth:aNumber
|
246
|
113 |
"set the lineWidth"
|
|
114 |
|
245
|
115 |
lineWidth := aNumber
|
|
116 |
|
|
117 |
"Created: 8.5.1996 / 23:22:13 / cg"
|
246
|
118 |
"Modified: 9.5.1996 / 00:09:17 / cg"
|
245
|
119 |
!
|
|
120 |
|
|
121 |
preferredBounds
|
246
|
122 |
"return the components bounds as preferredBounds"
|
|
123 |
|
245
|
124 |
^ self bounds
|
|
125 |
|
|
126 |
"Created: 8.5.1996 / 23:23:00 / cg"
|
246
|
127 |
"Modified: 9.5.1996 / 00:09:31 / cg"
|
245
|
128 |
! !
|
|
129 |
|
|
130 |
!StrokingWrapper methodsFor:'displaying'!
|
|
131 |
|
|
132 |
displayOn:aGC
|
246
|
133 |
"display myself - here, display the geometric object asStroked"
|
|
134 |
|
245
|
135 |
|prevLineWidth prevFg|
|
|
136 |
|
|
137 |
prevLineWidth := aGC lineWidth.
|
|
138 |
prevFg := aGC paint.
|
|
139 |
|
|
140 |
aGC lineWidth:lineWidth.
|
|
141 |
aGC paint:fgColor.
|
|
142 |
|
|
143 |
component displayStrokedOn:aGC.
|
|
144 |
|
|
145 |
aGC lineWidth:prevLineWidth.
|
|
146 |
aGC paint:prevFg.
|
|
147 |
|
|
148 |
"Created: 8.5.1996 / 23:24:04 / cg"
|
246
|
149 |
"Modified: 9.5.1996 / 00:11:17 / cg"
|
245
|
150 |
! !
|
|
151 |
|
|
152 |
!StrokingWrapper methodsFor:'initialization'!
|
|
153 |
|
|
154 |
initialize
|
246
|
155 |
"default my lineWidth to one pixel"
|
|
156 |
|
245
|
157 |
super initialize.
|
|
158 |
lineWidth := 1.
|
|
159 |
|
|
160 |
"Created: 8.5.1996 / 23:49:27 / cg"
|
246
|
161 |
"Modified: 9.5.1996 / 00:11:51 / cg"
|
245
|
162 |
! !
|
|
163 |
|
|
164 |
!StrokingWrapper class methodsFor:'documentation'!
|
|
165 |
|
|
166 |
version
|
253
|
167 |
^ '$Header: /cvs/stx/stx/libview2/StrokingWrapper.st,v 1.4 1996-05-09 08:33:21 cg Exp $'
|
245
|
168 |
! !
|