author | mawalch |
Thu, 07 Jul 2016 20:21:22 +0200 | |
changeset 7403 | 9a4c5d6da62c |
parent 7040 | 9de35e2b291f |
child 7835 | 019761925559 |
child 8595 | 7f9b84978a2e |
permissions | -rw-r--r-- |
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] |
|
6985
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
179 |
! |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
180 |
|
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
181 |
topLeftImageUnfilledMasked6 |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
182 |
"This resource specification was automatically generated |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
183 |
by the ImageEditor of ST/X." |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
184 |
|
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
185 |
"Do not manually edit this!! If it is corrupted, |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
186 |
the ImageEditor may not be able to read the specification." |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
187 |
|
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
188 |
" |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
189 |
self topLeftImageUnfilledMasked6 inspect |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
190 |
ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked6 |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
191 |
Icon flushCachedIcons |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
192 |
" |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
193 |
|
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
194 |
<resource: #image> |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
195 |
|
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
196 |
^Icon |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
197 |
constantNamed:'MacFlatButtonBorder topLeftImageUnfilledMasked6' |
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
198 |
ifAbsentPut:[(Depth2Image width:4 height:4) bits:(ByteArray fromPackedString:'@@<?O0@a') colorMapFromArray:#[183 183 183 201 201 201 224 224 224 255 255 255] mask:((ImageMask width:4 height:4) bits:(ByteArray fromPackedString:'LGC0<@@a'); yourself); yourself] |
6942 | 199 |
! ! |
200 |
||
201 |
!MacFlatButtonBorder methodsFor:'accessing'! |
|
202 |
||
6965 | 203 |
backgroundColor1 |
204 |
"the first gradient color" |
|
205 |
||
206 |
^ backgroundColor1 |
|
207 |
! |
|
208 |
||
6976 | 209 |
backgroundColor1:newColor |
6965 | 210 |
"the first gradient color" |
211 |
||
6976 | 212 |
backgroundColor1 ~= newColor ifTrue:[ |
213 |
backgroundColor1 := newColor. |
|
214 |
imgTopLeft := imgTopRight := imgBottomLeft := imgBottomRight := nil. |
|
215 |
] |
|
6965 | 216 |
! |
217 |
||
218 |
backgroundColor2 |
|
219 |
"the second gradient color" |
|
220 |
||
221 |
^ backgroundColor2 |
|
222 |
! |
|
223 |
||
6976 | 224 |
backgroundColor2:newColor |
6965 | 225 |
"the second gradient color" |
226 |
||
6976 | 227 |
backgroundColor2 ~= newColor ifTrue:[ |
228 |
backgroundColor2 := newColor. |
|
229 |
imgTopLeft := imgTopRight := imgBottomLeft := imgBottomRight := nil. |
|
230 |
] |
|
6965 | 231 |
! |
232 |
||
6942 | 233 |
color:newColor |
6965 | 234 |
"the color of the border" |
235 |
||
6942 | 236 |
color ~= newColor ifTrue:[ |
237 |
color := newColor. |
|
238 |
imgTopLeft := imgTopRight := imgBottomLeft := imgBottomRight := nil. |
|
239 |
]. |
|
240 |
! ! |
|
241 |
||
242 |
!MacFlatButtonBorder methodsFor:'displaying'! |
|
243 |
||
244 |
displayOn:aGC forDisplayBox:aRectangle |
|
245 |
|oldPaint boxLeft boxRight boxTop boxBottom boxWidth boxHeight| |
|
246 |
||
247 |
color isNil ifTrue:[ ^ self]. |
|
248 |
||
249 |
oldPaint := aGC paint. |
|
250 |
||
251 |
boxLeft := aRectangle left. |
|
252 |
boxTop := aRectangle top. |
|
253 |
boxWidth := aRectangle width. |
|
254 |
boxHeight := aRectangle height. |
|
255 |
||
256 |
boxRight := boxLeft + boxWidth. |
|
257 |
boxBottom := boxTop + boxHeight. |
|
258 |
||
259 |
imgTopLeft isNil ifTrue:[ |
|
260 |
self makeImages. |
|
6965 | 261 |
imgTopLeft isNil ifTrue:[ |
262 |
^ self |
|
263 |
]. |
|
6942 | 264 |
]. |
7040 | 265 |
aGC container isNil ifTrue:[ |
266 |
aGC paint:(aGC viewBackground). |
|
267 |
] ifFalse:[ |
|
268 |
aGC paint:(aGC container viewBackground). |
|
269 |
]. |
|
6973 | 270 |
aGC fillRectangleX:boxLeft y:boxTop width:2 height:2. |
271 |
aGC fillRectangleX:boxRight-2 y:boxTop width:2 height:2. |
|
272 |
aGC fillRectangleX:boxRight-2 y:boxBottom-2 width:2 height:2. |
|
273 |
aGC fillRectangleX:boxLeft y:boxBottom-2 width:2 height:2. |
|
6965 | 274 |
|
6942 | 275 |
aGC displayImage:imgTopLeft x:boxLeft y:boxTop. |
276 |
aGC displayImage:imgTopRight x:boxRight-4 y:boxTop. |
|
277 |
aGC displayImage:imgBottomRight x:boxRight-4 y:boxBottom-4. |
|
278 |
aGC displayImage:imgBottomLeft x:boxLeft y:boxBottom-4. |
|
279 |
||
6965 | 280 |
aGC paint:color. |
6942 | 281 |
aGC displayLineFromX:boxLeft+4 y:boxTop toX:boxRight-4 y:boxTop. |
282 |
aGC displayLineFromX:boxLeft+4 y:boxBottom-1 toX:boxRight-4 y:boxBottom-1. |
|
283 |
aGC displayLineFromX:boxLeft y:boxTop+4 toX:boxLeft y:boxBottom-4. |
|
284 |
aGC displayLineFromX:boxRight-1 y:boxTop+4 toX:boxRight-1 y:boxBottom-4. |
|
285 |
||
286 |
aGC paint:oldPaint. |
|
287 |
||
288 |
" |
|
289 |
|v1 v2| |
|
290 |
||
291 |
v1 := TopView new. |
|
292 |
v2 := View origin:10@10 corner:100@30 in:v1. |
|
6965 | 293 |
v2 border:(MacFlatButtonBorder color:Color red). |
6942 | 294 |
v1 open. |
295 |
" |
|
296 |
" |
|
297 |
|v1 v2| |
|
298 |
||
299 |
v1 := TopView new. |
|
300 |
v2 := View origin:10@10 corner:100@30 in:v1. |
|
6965 | 301 |
v2 border:((MacFlatButtonBorder color:Color red) backgroundColor1:Color blue; backgroundColor2:Color green). |
6942 | 302 |
v1 open. |
303 |
" |
|
304 |
! ! |
|
305 |
||
306 |
!MacFlatButtonBorder methodsFor:'private'! |
|
307 |
||
308 |
makeImages |
|
6965 | 309 |
|protoImage img hue light sat| |
6942 | 310 |
|
311 |
hue := color hue. |
|
312 |
light := color light. |
|
313 |
sat := color saturation. |
|
314 |
||
6985
d5f5ff0cae1a
viewbackground from container
Claus Gittinger <cg@exept.de>
parents:
6982
diff
changeset
|
315 |
protoImage := self class topLeftImageUnfilledMasked6. |
6942 | 316 |
img := protoImage copy. |
317 |
||
6965 | 318 |
img colorMap at:1 put:color. |
319 |
hue notNil ifTrue:[ |
|
6942 | 320 |
img colorMap at:2 put:(Color hue:hue light:light+15 saturation:sat-12). |
321 |
img colorMap at:3 put:(Color hue:hue light:light+30 saturation:sat-40). |
|
322 |
]. |
|
323 |
imgTopLeft := img. |
|
324 |
imgTopRight := img rotated:90. |
|
325 |
imgBottomLeft := img rotated:-90. |
|
326 |
imgBottomRight := img rotated:180. |
|
6965 | 327 |
|
328 |
backgroundColor1 notNil ifTrue:[ |
|
329 |
imgTopLeft colorMap at:4 put:backgroundColor1. |
|
330 |
imgTopRight colorMap at:4 put:backgroundColor1. |
|
331 |
]. |
|
332 |
backgroundColor2 notNil ifTrue:[ |
|
333 |
imgBottomLeft colorMap at:4 put:backgroundColor2. |
|
334 |
imgBottomRight colorMap at:4 put:backgroundColor2. |
|
335 |
]. |
|
6976 | 336 |
|
337 |
"/ imgBottomRight colorMap at:1 put:color darkened. |
|
338 |
"/ imgBottomRight colorMap at:2 put:color slightlyDarkened. |
|
339 |
"/ imgBottomRight colorMap at:3 put:color slightlyDarkened. |
|
6942 | 340 |
! ! |
341 |
||
342 |
!MacFlatButtonBorder class methodsFor:'documentation'! |
|
343 |
||
344 |
version |
|
345 |
^ '$Header$' |
|
346 |
! |
|
347 |
||
348 |
version_CVS |
|
349 |
^ '$Header$' |
|
350 |
! ! |
|
351 |