6943
|
1 |
"{ Encoding: utf8 }"
|
|
2 |
|
6942
|
3 |
"{ Package: 'stx:libview' }"
|
|
4 |
|
|
5 |
"{ NameSpace: Smalltalk }"
|
|
6 |
|
|
7 |
SimpleBorder subclass:#MacFlatButtonBorder
|
6965
|
8 |
instanceVariableNames:'backgroundColor1 backgroundColor2 imgTopLeft imgTopRight
|
|
9 |
imgBottomLeft imgBottomRight'
|
6942
|
10 |
classVariableNames:''
|
|
11 |
poolDictionaries:''
|
|
12 |
category:'Graphics-Support'
|
|
13 |
!
|
|
14 |
|
6943
|
15 |
!MacFlatButtonBorder class methodsFor:'documentation'!
|
|
16 |
|
|
17 |
documentation
|
|
18 |
"
|
|
19 |
an as yet unused and unfinished attempt to provide a mac-osx like
|
|
20 |
button border. These will look like mac buttons in yosemite (i.e. ugly old 70s retro flat style).
|
|
21 |
To be continued.
|
|
22 |
"
|
|
23 |
! !
|
6942
|
24 |
|
|
25 |
!MacFlatButtonBorder class methodsFor:'instance creation'!
|
|
26 |
|
6965
|
27 |
color:color1 backgroundColor:color2
|
|
28 |
"create a new instance of the receiver with a border of the given color."
|
|
29 |
|
|
30 |
^ self new color:color1; backgroundColor:color2
|
|
31 |
!
|
|
32 |
|
6942
|
33 |
color:color1 insideColor:color2
|
|
34 |
"create a new instance of the receiver with a border of the given color."
|
|
35 |
|
|
36 |
^ self new color:color1; insideColor:color2
|
|
37 |
! !
|
|
38 |
|
|
39 |
!MacFlatButtonBorder class methodsFor:'image specs'!
|
|
40 |
|
|
41 |
topLeftImageFilled
|
|
42 |
"This resource specification was automatically generated
|
|
43 |
by the ImageEditor of ST/X."
|
|
44 |
|
|
45 |
"Do not manually edit this!! If it is corrupted,
|
|
46 |
the ImageEditor may not be able to read the specification."
|
|
47 |
|
|
48 |
"
|
|
49 |
self topLeftImageFilled inspect
|
|
50 |
ImageEditor openOnClass:self andSelector:#topLeftImageFilled
|
|
51 |
Icon flushCachedIcons
|
|
52 |
"
|
|
53 |
|
|
54 |
<resource: #image>
|
|
55 |
|
|
56 |
^Icon
|
|
57 |
constantNamed:'MacOSXRoundButtonBorder topLeftImageFilled'
|
|
58 |
ifAbsentPut:[(Depth8Image width:4 height:4) bits:(ByteArray fromPackedString:'@@LB@PLA@P@B@P@@@P@@@@@a') colorMapFromArray:#[44 132 251 49 107 245 95 142 236 175 196 234] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\OC0<@@a'); yourself); yourself]
|
|
59 |
!
|
|
60 |
|
|
61 |
topLeftImageUnfilled
|
|
62 |
"This resource specification was automatically generated
|
|
63 |
by the ImageEditor of ST/X."
|
|
64 |
|
|
65 |
"Do not manually edit this!! If it is corrupted,
|
|
66 |
the ImageEditor may not be able to read the specification."
|
|
67 |
|
|
68 |
"
|
|
69 |
self topLeftImageUnfilled inspect
|
|
70 |
ImageEditor openOnClass:self andSelector:#topLeftImageUnfilled
|
|
71 |
Icon flushCachedIcons
|
|
72 |
"
|
|
73 |
|
|
74 |
<resource: #image>
|
|
75 |
|
|
76 |
^Icon
|
|
77 |
constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilled'
|
|
78 |
ifAbsentPut:[(Depth2Image width:4 height:4) bits:(ByteArray fromPackedString:'9HMOO0@a') colorMapFromArray:#[183 183 183 201 201 201 224 224 224 255 255 255] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\OC0<@@a'); yourself); yourself]
|
|
79 |
!
|
|
80 |
|
|
81 |
topLeftImageUnfilledMasked
|
|
82 |
"This resource specification was automatically generated
|
|
83 |
by the ImageEditor of ST/X."
|
|
84 |
|
|
85 |
"Do not manually edit this!! If it is corrupted,
|
|
86 |
the ImageEditor may not be able to read the specification."
|
|
87 |
|
|
88 |
"
|
|
89 |
self topLeftImageUnfilledMasked inspect
|
|
90 |
ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked
|
|
91 |
Icon flushCachedIcons
|
|
92 |
"
|
|
93 |
|
|
94 |
<resource: #image>
|
|
95 |
|
|
96 |
^Icon
|
|
97 |
constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilledMasked'
|
|
98 |
ifAbsentPut:[(Depth2Image width:4 height:4) bits:(ByteArray fromPackedString:'IHA@@@@a') colorMapFromArray:#[183 183 183 201 201 201 224 224 224 255 255 255] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\NC@ @@a'); yourself); yourself]
|
|
99 |
!
|
|
100 |
|
|
101 |
topLeftImageUnfilledMasked2
|
|
102 |
"This resource specification was automatically generated
|
|
103 |
by the ImageEditor of ST/X."
|
|
104 |
|
|
105 |
"Do not manually edit this!! If it is corrupted,
|
|
106 |
the ImageEditor may not be able to read the specification."
|
|
107 |
|
|
108 |
"
|
|
109 |
self topLeftImageUnfilledMasked2 inspect
|
|
110 |
ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked2
|
|
111 |
Icon flushCachedIcons
|
|
112 |
"
|
|
113 |
|
|
114 |
<resource: #image>
|
|
115 |
|
|
116 |
^Icon
|
|
117 |
constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilledMasked2'
|
|
118 |
ifAbsentPut:[(Depth2Image width:4 height:4) bits:(ByteArray fromPackedString:'IH!! @@@a') colorMapFromArray:#[183 183 183 201 201 201 224 224 224 255 255 255] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\NC@ @@a'); yourself); yourself]
|
|
119 |
!
|
|
120 |
|
|
121 |
topLeftImageUnfilledMasked3
|
|
122 |
"This resource specification was automatically generated
|
|
123 |
by the ImageEditor of ST/X."
|
|
124 |
|
|
125 |
"Do not manually edit this!! If it is corrupted,
|
|
126 |
the ImageEditor may not be able to read the specification."
|
|
127 |
|
|
128 |
"
|
|
129 |
self topLeftImageUnfilledMasked3 inspect
|
|
130 |
ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked3
|
|
131 |
Icon flushCachedIcons
|
|
132 |
"
|
|
133 |
|
|
134 |
<resource: #image>
|
|
135 |
|
|
136 |
^Icon
|
|
137 |
constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilledMasked3'
|
|
138 |
ifAbsentPut:[(Depth2Image width:4 height:4) bits:(ByteArray fromPackedString:'HH @@@a') colorMapFromArray:#[183 183 183 201 201 201 224 224 224 255 255 255] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\NC@ @@a'); yourself); yourself]
|
6965
|
139 |
!
|
|
140 |
|
|
141 |
topLeftImageUnfilledMasked4
|
|
142 |
"This resource specification was automatically generated
|
|
143 |
by the ImageEditor of ST/X."
|
|
144 |
|
|
145 |
"Do not manually edit this!! If it is corrupted,
|
|
146 |
the ImageEditor may not be able to read the specification."
|
|
147 |
|
|
148 |
"
|
|
149 |
self topLeftImageUnfilledMasked4 inspect
|
|
150 |
ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked4
|
|
151 |
Icon flushCachedIcons
|
|
152 |
"
|
|
153 |
|
|
154 |
<resource: #image>
|
|
155 |
|
|
156 |
^Icon
|
|
157 |
constantNamed:'MacFlatButtonBorder topLeftImageUnfilledMasked4'
|
6973
|
158 |
ifAbsentPut:[(Depth2Image width:4 height:4) bits:(ByteArray fromPackedString:'HH,/O0@a') colorMapFromArray:#[183 183 183 201 201 201 224 224 224 255 255 255] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\OC0<@@a'); yourself); yourself]
|
6982
|
159 |
!
|
|
160 |
|
|
161 |
topLeftImageUnfilledMasked5
|
|
162 |
"This resource specification was automatically generated
|
|
163 |
by the ImageEditor of ST/X."
|
|
164 |
|
|
165 |
"Do not manually edit this!! If it is corrupted,
|
|
166 |
the ImageEditor may not be able to read the specification."
|
|
167 |
|
|
168 |
"
|
|
169 |
self topLeftImageUnfilledMasked5 inspect
|
|
170 |
ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked5
|
|
171 |
Icon flushCachedIcons
|
|
172 |
"
|
|
173 |
|
|
174 |
<resource: #image>
|
|
175 |
|
|
176 |
^Icon
|
|
177 |
constantNamed:'MacFlatButtonBorder topLeftImageUnfilledMasked5'
|
|
178 |
ifAbsentPut:[(Depth2Image width:4 height:4) bits:(ByteArray fromPackedString:'HH<?O0@a') colorMapFromArray:#[183 183 183 201 201 201 224 224 224 255 255 255] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'\OC0<@@a'); yourself); yourself]
|
6942
|
179 |
! !
|
|
180 |
|
|
181 |
!MacFlatButtonBorder methodsFor:'accessing'!
|
|
182 |
|
6965
|
183 |
backgroundColor1
|
|
184 |
"the first gradient color"
|
|
185 |
|
|
186 |
^ backgroundColor1
|
|
187 |
!
|
|
188 |
|
6976
|
189 |
backgroundColor1:newColor
|
6965
|
190 |
"the first gradient color"
|
|
191 |
|
6976
|
192 |
backgroundColor1 ~= newColor ifTrue:[
|
|
193 |
backgroundColor1 := newColor.
|
|
194 |
imgTopLeft := imgTopRight := imgBottomLeft := imgBottomRight := nil.
|
|
195 |
]
|
6965
|
196 |
!
|
|
197 |
|
|
198 |
backgroundColor2
|
|
199 |
"the second gradient color"
|
|
200 |
|
|
201 |
^ backgroundColor2
|
|
202 |
!
|
|
203 |
|
6976
|
204 |
backgroundColor2:newColor
|
6965
|
205 |
"the second gradient color"
|
|
206 |
|
6976
|
207 |
backgroundColor2 ~= newColor ifTrue:[
|
|
208 |
backgroundColor2 := newColor.
|
|
209 |
imgTopLeft := imgTopRight := imgBottomLeft := imgBottomRight := nil.
|
|
210 |
]
|
6965
|
211 |
!
|
|
212 |
|
6942
|
213 |
color:newColor
|
6965
|
214 |
"the color of the border"
|
|
215 |
|
6942
|
216 |
color ~= newColor ifTrue:[
|
|
217 |
color := newColor.
|
|
218 |
imgTopLeft := imgTopRight := imgBottomLeft := imgBottomRight := nil.
|
|
219 |
].
|
|
220 |
! !
|
|
221 |
|
|
222 |
!MacFlatButtonBorder methodsFor:'displaying'!
|
|
223 |
|
|
224 |
displayOn:aGC forDisplayBox:aRectangle
|
|
225 |
|oldPaint boxLeft boxRight boxTop boxBottom boxWidth boxHeight|
|
|
226 |
|
|
227 |
color isNil ifTrue:[ ^ self].
|
|
228 |
|
|
229 |
oldPaint := aGC paint.
|
|
230 |
|
|
231 |
boxLeft := aRectangle left.
|
|
232 |
boxTop := aRectangle top.
|
|
233 |
boxWidth := aRectangle width.
|
|
234 |
boxHeight := aRectangle height.
|
|
235 |
|
|
236 |
boxRight := boxLeft + boxWidth.
|
|
237 |
boxBottom := boxTop + boxHeight.
|
|
238 |
|
|
239 |
imgTopLeft isNil ifTrue:[
|
|
240 |
self makeImages.
|
6965
|
241 |
imgTopLeft isNil ifTrue:[
|
|
242 |
^ self
|
|
243 |
].
|
6942
|
244 |
].
|
|
245 |
|
6965
|
246 |
aGC paint:(aGC viewBackground).
|
6973
|
247 |
aGC fillRectangleX:boxLeft y:boxTop width:2 height:2.
|
|
248 |
aGC fillRectangleX:boxRight-2 y:boxTop width:2 height:2.
|
|
249 |
aGC fillRectangleX:boxRight-2 y:boxBottom-2 width:2 height:2.
|
|
250 |
aGC fillRectangleX:boxLeft y:boxBottom-2 width:2 height:2.
|
6965
|
251 |
|
6942
|
252 |
aGC displayImage:imgTopLeft x:boxLeft y:boxTop.
|
|
253 |
aGC displayImage:imgTopRight x:boxRight-4 y:boxTop.
|
|
254 |
aGC displayImage:imgBottomRight x:boxRight-4 y:boxBottom-4.
|
|
255 |
aGC displayImage:imgBottomLeft x:boxLeft y:boxBottom-4.
|
|
256 |
|
6965
|
257 |
aGC paint:color.
|
6942
|
258 |
aGC displayLineFromX:boxLeft+4 y:boxTop toX:boxRight-4 y:boxTop.
|
|
259 |
aGC displayLineFromX:boxLeft+4 y:boxBottom-1 toX:boxRight-4 y:boxBottom-1.
|
|
260 |
aGC displayLineFromX:boxLeft y:boxTop+4 toX:boxLeft y:boxBottom-4.
|
|
261 |
aGC displayLineFromX:boxRight-1 y:boxTop+4 toX:boxRight-1 y:boxBottom-4.
|
|
262 |
|
|
263 |
aGC paint:oldPaint.
|
|
264 |
|
|
265 |
"
|
|
266 |
|v1 v2|
|
|
267 |
|
|
268 |
v1 := TopView new.
|
|
269 |
v2 := View origin:10@10 corner:100@30 in:v1.
|
6965
|
270 |
v2 border:(MacFlatButtonBorder color:Color red).
|
6942
|
271 |
v1 open.
|
|
272 |
"
|
|
273 |
"
|
|
274 |
|v1 v2|
|
|
275 |
|
|
276 |
v1 := TopView new.
|
|
277 |
v2 := View origin:10@10 corner:100@30 in:v1.
|
6965
|
278 |
v2 border:((MacFlatButtonBorder color:Color red) backgroundColor1:Color blue; backgroundColor2:Color green).
|
6942
|
279 |
v1 open.
|
|
280 |
"
|
|
281 |
! !
|
|
282 |
|
|
283 |
!MacFlatButtonBorder methodsFor:'private'!
|
|
284 |
|
|
285 |
makeImages
|
6965
|
286 |
|protoImage img hue light sat|
|
6942
|
287 |
|
|
288 |
hue := color hue.
|
|
289 |
light := color light.
|
|
290 |
sat := color saturation.
|
|
291 |
|
6982
|
292 |
protoImage := self class topLeftImageUnfilledMasked5.
|
6942
|
293 |
img := protoImage copy.
|
|
294 |
|
6965
|
295 |
img colorMap at:1 put:color.
|
|
296 |
hue notNil ifTrue:[
|
6942
|
297 |
img colorMap at:2 put:(Color hue:hue light:light+15 saturation:sat-12).
|
|
298 |
img colorMap at:3 put:(Color hue:hue light:light+30 saturation:sat-40).
|
|
299 |
].
|
|
300 |
imgTopLeft := img.
|
|
301 |
imgTopRight := img rotated:90.
|
|
302 |
imgBottomLeft := img rotated:-90.
|
|
303 |
imgBottomRight := img rotated:180.
|
6965
|
304 |
|
|
305 |
backgroundColor1 notNil ifTrue:[
|
|
306 |
imgTopLeft colorMap at:4 put:backgroundColor1.
|
|
307 |
imgTopRight colorMap at:4 put:backgroundColor1.
|
|
308 |
].
|
|
309 |
backgroundColor2 notNil ifTrue:[
|
|
310 |
imgBottomLeft colorMap at:4 put:backgroundColor2.
|
|
311 |
imgBottomRight colorMap at:4 put:backgroundColor2.
|
|
312 |
].
|
6976
|
313 |
|
|
314 |
"/ imgBottomRight colorMap at:1 put:color darkened.
|
|
315 |
"/ imgBottomRight colorMap at:2 put:color slightlyDarkened.
|
|
316 |
"/ imgBottomRight colorMap at:3 put:color slightlyDarkened.
|
6942
|
317 |
! !
|
|
318 |
|
|
319 |
!MacFlatButtonBorder class methodsFor:'documentation'!
|
|
320 |
|
|
321 |
version
|
|
322 |
^ '$Header$'
|
|
323 |
!
|
|
324 |
|
|
325 |
version_CVS
|
|
326 |
^ '$Header$'
|
|
327 |
! !
|
|
328 |
|