6942
|
1 |
"{ Package: 'stx:libview' }"
|
|
2 |
|
|
3 |
"{ NameSpace: Smalltalk }"
|
|
4 |
|
|
5 |
SimpleBorder subclass:#MacFlatButtonBorder
|
|
6 |
instanceVariableNames:'insideColor imgTopLeft imgTopRight imgBottomLeft imgBottomRight'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'Graphics-Support'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!MacFlatButtonBorder class methodsFor:'instance creation'!
|
|
14 |
|
|
15 |
color:color1 insideColor:color2
|
|
16 |
"create a new instance of the receiver with a border of the given color."
|
|
17 |
|
|
18 |
^ self new color:color1; insideColor:color2
|
|
19 |
! !
|
|
20 |
|
|
21 |
!MacFlatButtonBorder class methodsFor:'image specs'!
|
|
22 |
|
|
23 |
topLeftImageFilled
|
|
24 |
"This resource specification was automatically generated
|
|
25 |
by the ImageEditor of ST/X."
|
|
26 |
|
|
27 |
"Do not manually edit this!! If it is corrupted,
|
|
28 |
the ImageEditor may not be able to read the specification."
|
|
29 |
|
|
30 |
"
|
|
31 |
self topLeftImageFilled inspect
|
|
32 |
ImageEditor openOnClass:self andSelector:#topLeftImageFilled
|
|
33 |
Icon flushCachedIcons
|
|
34 |
"
|
|
35 |
|
|
36 |
<resource: #image>
|
|
37 |
|
|
38 |
^Icon
|
|
39 |
constantNamed:'MacOSXRoundButtonBorder topLeftImageFilled'
|
|
40 |
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]
|
|
41 |
!
|
|
42 |
|
|
43 |
topLeftImageUnfilled
|
|
44 |
"This resource specification was automatically generated
|
|
45 |
by the ImageEditor of ST/X."
|
|
46 |
|
|
47 |
"Do not manually edit this!! If it is corrupted,
|
|
48 |
the ImageEditor may not be able to read the specification."
|
|
49 |
|
|
50 |
"
|
|
51 |
self topLeftImageUnfilled inspect
|
|
52 |
ImageEditor openOnClass:self andSelector:#topLeftImageUnfilled
|
|
53 |
Icon flushCachedIcons
|
|
54 |
"
|
|
55 |
|
|
56 |
<resource: #image>
|
|
57 |
|
|
58 |
^Icon
|
|
59 |
constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilled'
|
|
60 |
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]
|
|
61 |
!
|
|
62 |
|
|
63 |
topLeftImageUnfilledMasked
|
|
64 |
"This resource specification was automatically generated
|
|
65 |
by the ImageEditor of ST/X."
|
|
66 |
|
|
67 |
"Do not manually edit this!! If it is corrupted,
|
|
68 |
the ImageEditor may not be able to read the specification."
|
|
69 |
|
|
70 |
"
|
|
71 |
self topLeftImageUnfilledMasked inspect
|
|
72 |
ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked
|
|
73 |
Icon flushCachedIcons
|
|
74 |
"
|
|
75 |
|
|
76 |
<resource: #image>
|
|
77 |
|
|
78 |
^Icon
|
|
79 |
constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilledMasked'
|
|
80 |
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]
|
|
81 |
!
|
|
82 |
|
|
83 |
topLeftImageUnfilledMasked2
|
|
84 |
"This resource specification was automatically generated
|
|
85 |
by the ImageEditor of ST/X."
|
|
86 |
|
|
87 |
"Do not manually edit this!! If it is corrupted,
|
|
88 |
the ImageEditor may not be able to read the specification."
|
|
89 |
|
|
90 |
"
|
|
91 |
self topLeftImageUnfilledMasked2 inspect
|
|
92 |
ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked2
|
|
93 |
Icon flushCachedIcons
|
|
94 |
"
|
|
95 |
|
|
96 |
<resource: #image>
|
|
97 |
|
|
98 |
^Icon
|
|
99 |
constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilledMasked2'
|
|
100 |
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]
|
|
101 |
!
|
|
102 |
|
|
103 |
topLeftImageUnfilledMasked3
|
|
104 |
"This resource specification was automatically generated
|
|
105 |
by the ImageEditor of ST/X."
|
|
106 |
|
|
107 |
"Do not manually edit this!! If it is corrupted,
|
|
108 |
the ImageEditor may not be able to read the specification."
|
|
109 |
|
|
110 |
"
|
|
111 |
self topLeftImageUnfilledMasked3 inspect
|
|
112 |
ImageEditor openOnClass:self andSelector:#topLeftImageUnfilledMasked3
|
|
113 |
Icon flushCachedIcons
|
|
114 |
"
|
|
115 |
|
|
116 |
<resource: #image>
|
|
117 |
|
|
118 |
^Icon
|
|
119 |
constantNamed:'MacOSXRoundButtonBorder topLeftImageUnfilledMasked3'
|
|
120 |
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]
|
|
121 |
! !
|
|
122 |
|
|
123 |
!MacFlatButtonBorder methodsFor:'accessing'!
|
|
124 |
|
|
125 |
color:newColor
|
|
126 |
color ~= newColor ifTrue:[
|
|
127 |
color := newColor.
|
|
128 |
imgTopLeft := imgTopRight := imgBottomLeft := imgBottomRight := nil.
|
|
129 |
].
|
|
130 |
!
|
|
131 |
|
|
132 |
insideColor:newColor
|
|
133 |
insideColor ~= newColor ifTrue:[
|
|
134 |
insideColor := newColor.
|
|
135 |
imgTopLeft := imgTopRight := imgBottomLeft := imgBottomRight := nil.
|
|
136 |
].
|
|
137 |
! !
|
|
138 |
|
|
139 |
!MacFlatButtonBorder methodsFor:'displaying'!
|
|
140 |
|
|
141 |
displayOn:aGC forDisplayBox:aRectangle
|
|
142 |
|oldPaint boxLeft boxRight boxTop boxBottom boxWidth boxHeight|
|
|
143 |
|
|
144 |
color isNil ifTrue:[ ^ self].
|
|
145 |
|
|
146 |
oldPaint := aGC paint.
|
|
147 |
aGC paint:color.
|
|
148 |
|
|
149 |
boxLeft := aRectangle left.
|
|
150 |
boxTop := aRectangle top.
|
|
151 |
boxWidth := aRectangle width.
|
|
152 |
boxHeight := aRectangle height.
|
|
153 |
|
|
154 |
boxRight := boxLeft + boxWidth.
|
|
155 |
boxBottom := boxTop + boxHeight.
|
|
156 |
|
|
157 |
imgTopLeft isNil ifTrue:[
|
|
158 |
self makeImages.
|
|
159 |
].
|
|
160 |
|
|
161 |
aGC displayImage:imgTopLeft x:boxLeft y:boxTop.
|
|
162 |
aGC displayImage:imgTopRight x:boxRight-4 y:boxTop.
|
|
163 |
aGC displayImage:imgBottomRight x:boxRight-4 y:boxBottom-4.
|
|
164 |
aGC displayImage:imgBottomLeft x:boxLeft y:boxBottom-4.
|
|
165 |
|
|
166 |
aGC displayLineFromX:boxLeft+4 y:boxTop toX:boxRight-4 y:boxTop.
|
|
167 |
aGC displayLineFromX:boxLeft+4 y:boxBottom-1 toX:boxRight-4 y:boxBottom-1.
|
|
168 |
aGC displayLineFromX:boxLeft y:boxTop+4 toX:boxLeft y:boxBottom-4.
|
|
169 |
aGC displayLineFromX:boxRight-1 y:boxTop+4 toX:boxRight-1 y:boxBottom-4.
|
|
170 |
|
|
171 |
aGC paint:oldPaint.
|
|
172 |
|
|
173 |
"
|
|
174 |
|v1 v2|
|
|
175 |
|
|
176 |
v1 := TopView new.
|
|
177 |
v2 := View origin:10@10 corner:100@30 in:v1.
|
|
178 |
v2 border:(MacOSXRoundButtonBorder color:Color red).
|
|
179 |
v1 open.
|
|
180 |
"
|
|
181 |
"
|
|
182 |
|v1 v2|
|
|
183 |
|
|
184 |
v1 := TopView new.
|
|
185 |
v2 := View origin:10@10 corner:100@30 in:v1.
|
|
186 |
v2 border:(MacOSXRoundButtonBorder color:Color red insideColor:Color blue).
|
|
187 |
v1 open.
|
|
188 |
"
|
|
189 |
! !
|
|
190 |
|
|
191 |
!MacFlatButtonBorder methodsFor:'private'!
|
|
192 |
|
|
193 |
makeImages
|
|
194 |
|protoImage img hue light sat innerHue innerLight innerSat|
|
|
195 |
|
|
196 |
hue := color hue.
|
|
197 |
light := color light.
|
|
198 |
sat := color saturation.
|
|
199 |
|
|
200 |
insideColor isNil ifTrue:[
|
|
201 |
protoImage := self class topLeftImageUnfilledMasked3.
|
|
202 |
] ifFalse:[
|
|
203 |
insideColor hue isNil ifTrue:[
|
|
204 |
protoImage := self class topLeftImageUnfilled.
|
|
205 |
] ifFalse:[
|
|
206 |
protoImage := self class topLeftImageFilled.
|
|
207 |
innerHue := insideColor hue.
|
|
208 |
innerLight := insideColor light.
|
|
209 |
innerSat := insideColor saturation.
|
|
210 |
].
|
|
211 |
].
|
|
212 |
img := protoImage copy.
|
|
213 |
|
|
214 |
innerHue notNil ifTrue:[
|
|
215 |
img colorMap at:1 put:insideColor.
|
|
216 |
img colorMap at:2 put:color.
|
|
217 |
img colorMap at:3 put:(Color hue:hue light:light+8 saturation:sat-12).
|
|
218 |
img colorMap at:4 put:(Color hue:hue light:light+20 saturation:sat-40).
|
|
219 |
] ifFalse:[
|
|
220 |
img colorMap at:1 put:color.
|
|
221 |
img colorMap at:2 put:(Color hue:hue light:light+15 saturation:sat-12).
|
|
222 |
img colorMap at:3 put:(Color hue:hue light:light+30 saturation:sat-40).
|
|
223 |
].
|
|
224 |
|
|
225 |
imgTopLeft := img.
|
|
226 |
imgTopRight := img rotated:90.
|
|
227 |
imgBottomLeft := img rotated:-90.
|
|
228 |
imgBottomRight := img rotated:180.
|
|
229 |
! !
|
|
230 |
|
|
231 |
!MacFlatButtonBorder class methodsFor:'documentation'!
|
|
232 |
|
|
233 |
version
|
|
234 |
^ '$Header$'
|
|
235 |
!
|
|
236 |
|
|
237 |
version_CVS
|
|
238 |
^ '$Header$'
|
|
239 |
! !
|
|
240 |
|