author | Claus Gittinger <cg@exept.de> |
Wed, 16 Aug 2000 23:23:40 +0200 | |
changeset 1808 | e8628b502a49 |
parent 1803 | ad801646be62 |
child 1816 | c4bbd0e66b5a |
permissions | -rw-r--r-- |
422 | 1 |
" |
2 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
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 |
||
14 |
||
1803 | 15 |
"{ Package: 'stx:libtool2' }" |
16 |
||
412 | 17 |
MenuPanel subclass:#ColorMenu |
664 | 18 |
instanceVariableNames:'model enabledChannel labelsAreColored' |
666 | 19 |
classVariableNames:'' |
412 | 20 |
poolDictionaries:'' |
21 |
category:'Interface-UIPainter' |
|
22 |
! |
|
23 |
||
1057 | 24 |
SimpleDialog subclass:#DefineColor |
25 |
instanceVariableNames:'red green blue' |
|
26 |
classVariableNames:'' |
|
27 |
poolDictionaries:'' |
|
28 |
privateIn:ColorMenu |
|
29 |
! |
|
30 |
||
412 | 31 |
!ColorMenu class methodsFor:'documentation'! |
32 |
||
422 | 33 |
copyright |
34 |
" |
|
35 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
36 |
All Rights Reserved |
|
37 |
||
38 |
This software is furnished under a license and may be used |
|
39 |
only in accordance with the terms of that license and with the |
|
40 |
inclusion of the above copyright notice. This software may not |
|
41 |
be provided or otherwise made available to, or used by, any |
|
42 |
other person. No title to or ownership of the software is |
|
43 |
hereby transferred. |
|
44 |
" |
|
45 |
||
46 |
||
47 |
! |
|
48 |
||
412 | 49 |
documentation |
50 |
" |
|
51 |
ColorMenu used by UIPainter |
|
52 |
||
53 |
[see also:] |
|
54 |
UIPainter |
|
55 |
ColorMenuSpec |
|
422 | 56 |
|
57 |
[author:] |
|
58 |
Claus Atzkern |
|
412 | 59 |
" |
60 |
||
61 |
! |
|
62 |
||
63 |
examples |
|
64 |
" |
|
65 |
simple example |
|
66 |
[exBegin] |
|
67 |
|tool top channel| |
|
68 |
||
69 |
top := StandardSystemView new. |
|
70 |
top extent:250@30. |
|
71 |
channel := (Color red) asValue. |
|
72 |
tool := self origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
73 |
tool model:channel. |
|
74 |
top open. |
|
75 |
[exEnd] |
|
76 |
" |
|
77 |
||
78 |
! ! |
|
79 |
||
80 |
!ColorMenu class methodsFor:'menu spec'! |
|
81 |
||
666 | 82 |
colorDefinition |
83 |
"color definitions used to build a color menu |
|
412 | 84 |
" |
583 | 85 |
|
666 | 86 |
^ #( |
668 | 87 |
#( gray |
666 | 88 |
gray: |
89 |
#( white |
|
90 |
veryLightGray |
|
91 |
lightGray |
|
92 |
gray |
|
93 |
darkGray |
|
94 |
veryDarkGray |
|
95 |
black |
|
96 |
) |
|
412 | 97 |
) |
666 | 98 |
|
668 | 99 |
#( red |
666 | 100 |
red: |
854 | 101 |
#( lightened 100 87 67 50 33) |
666 | 102 |
) |
103 |
||
668 | 104 |
#( green |
666 | 105 |
green: |
854 | 106 |
#( lightened 100 87 67 50 33) |
666 | 107 |
) |
108 |
||
668 | 109 |
#( blue |
666 | 110 |
blue: |
854 | 111 |
#( lightened 100 87 67 50 33) |
666 | 112 |
) |
113 |
||
668 | 114 |
#( cyan |
854 | 115 |
cyan: |
116 |
#( lightened 100 87 67 50 33) |
|
664 | 117 |
) |
666 | 118 |
|
668 | 119 |
#( magenta |
854 | 120 |
magenta: |
121 |
#( lightened 100 87 67 50 33) |
|
412 | 122 |
) |
666 | 123 |
|
668 | 124 |
#( yellow |
854 | 125 |
yellow: |
126 |
#( lightened 100 87 67 50 33) |
|
412 | 127 |
) |
806 | 128 |
|
412 | 129 |
) |
666 | 130 |
! |
131 |
||
132 |
colorMenu:labelAreColored value:aValue |
|
133 |
"returns a color menu |
|
134 |
" |
|
1410 | 135 |
|menu mainCol style e| |
666 | 136 |
|
137 |
menu := Menu new. |
|
1372
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
138 |
style := (labelAreColored == false) |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
139 |
ifTrue:[#backgroundColor] |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
140 |
ifFalse:[#color]. |
666 | 141 |
|
142 |
self colorDefinition do:[:aSlice| |
|
143 |
|size colOp color item smenu| |
|
144 |
||
668 | 145 |
mainCol := Color perform:(aSlice at:1). |
146 |
item := MenuItem labeled:(Text string:' ' emphasis:(#backgroundColor->mainCol)). |
|
666 | 147 |
smenu := Menu new. |
668 | 148 |
colOp := aSlice at:2. |
412 | 149 |
|
668 | 150 |
(aSlice at:3) do:[:el||sitem label| |
666 | 151 |
el isSymbol ifTrue:[ |
152 |
color := el == #lightened ifTrue:[mainCol perform:el] ifFalse:[Color perform:el]. |
|
854 | 153 |
self colorDefinition first ~~ aSlice |
154 |
ifTrue: [label := (colOp upTo: $:), ' ', el] |
|
155 |
ifFalse:[label := el]. |
|
666 | 156 |
] ifFalse:[ |
157 |
el isNumber ifTrue:[ |
|
158 |
color := Color perform:colOp with:el. |
|
159 |
label := colOp, ' ', el printString. |
|
160 |
] ifFalse:[ |
|
161 |
color := Color perform:colOp with:(el at:1) with:(el at:2) with:(el at:3). |
|
162 |
label := ''. |
|
163 |
colOp keywords keysAndValuesDo:[:i :c| label := label, ' ', c, ' ' , (el at:i) printString ]. |
|
164 |
] |
|
165 |
]. |
|
1372
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
166 |
e := style->color. |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
167 |
style == #backgroundColor ifTrue:[ |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
168 |
color brightness < 0.5 ifTrue:[ |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
169 |
e := Array with:e |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
170 |
with:(#color->Color white) |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
171 |
] |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
172 |
]. |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
173 |
sitem := MenuItem |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
174 |
labeled:(Text |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
175 |
string:('Color ', label) |
54d8812de860
care for good contrast in color-menus
Claus Gittinger <cg@exept.de>
parents:
1119
diff
changeset
|
176 |
emphasis:e). |
666 | 177 |
sitem argument:color. |
178 |
sitem value:aValue. |
|
179 |
smenu addItem:sitem. |
|
180 |
]. |
|
181 |
item submenu:smenu. |
|
182 |
item value:nil. |
|
183 |
menu addItem:item |
|
184 |
]. |
|
185 |
^ menu |
|
186 |
" |
|
187 |
(ColorMenu colorMenu:true value:nil) startUp |
|
188 |
(ColorMenu colorMenu:false value:#aSelector:) startUp |
|
189 |
" |
|
592 | 190 |
! ! |
191 |
||
1808 | 192 |
!ColorMenu methodsFor:'accepting'! |
412 | 193 |
|
194 |
accept:anItem |
|
664 | 195 |
"accept current selected item" |
196 |
||
412 | 197 |
|item holder color| |
198 |
||
1058 | 199 |
((item := super accept:anItem) notNil and: [item label ~= 'def']) |
664 | 200 |
ifTrue: |
201 |
[ |
|
202 |
(holder := self colorHolder) == item ifTrue: |
|
203 |
[ |
|
412 | 204 |
enabledChannel value ifTrue:[color := self color] |
664 | 205 |
] |
206 |
ifFalse: |
|
1057 | 207 |
[ |
666 | 208 |
color := item argument. |
692 | 209 |
holder label:(Text string:' ' emphasis:(#backgroundColor->color)). |
412 | 210 |
]. |
211 |
model notNil ifTrue:[model value:color] |
|
212 |
] |
|
213 |
! ! |
|
214 |
||
215 |
!ColorMenu methodsFor:'accessing'! |
|
216 |
||
217 |
color |
|
664 | 218 |
"get current color" |
219 |
||
220 |
|firstEmphasis| |
|
221 |
(firstEmphasis := (self colorHolder label emphasis at:1)) isAssociation ifTrue: [^firstEmphasis value]. |
|
222 |
^(firstEmphasis at: 1) value |
|
412 | 223 |
! |
224 |
||
225 |
color:aColor |
|
664 | 226 |
"set current color" |
227 |
||
412 | 228 |
|holder label| |
229 |
||
664 | 230 |
aColor isColor |
231 |
ifFalse: |
|
232 |
[ |
|
412 | 233 |
enabledChannel value:false |
664 | 234 |
] |
235 |
ifTrue: |
|
236 |
[ |
|
237 |
self disabledRedrawDo: |
|
1057 | 238 |
[ |
664 | 239 |
holder := self colorHolder. |
240 |
label := Text string: ' ' emphasis:(#backgroundColor->aColor). |
|
412 | 241 |
enabledChannel value:true. |
1057 | 242 |
holder label:label. |
243 |
model value: aColor |
|
412 | 244 |
] |
245 |
] |
|
664 | 246 |
! |
247 |
||
248 |
labelsAreColored: aBoolean |
|
249 |
"sets whether labels or their backgrounds will be colored" |
|
250 |
||
251 |
labelsAreColored := aBoolean ? false. |
|
252 |
self setupMenu |
|
253 |
||
412 | 254 |
! ! |
255 |
||
1803 | 256 |
!ColorMenu methodsFor:'accessing - channels'! |
412 | 257 |
|
258 |
model |
|
664 | 259 |
"get my color channel" |
260 |
||
261 |
^model |
|
412 | 262 |
|
263 |
||
264 |
||
265 |
! |
|
266 |
||
267 |
model:aValueHolder |
|
664 | 268 |
"set my color channel" |
269 |
||
270 |
model notNil ifTrue:[model removeDependent:self]. |
|
412 | 271 |
|
664 | 272 |
(model := aValueHolder) notNil |
273 |
ifTrue: |
|
274 |
[ |
|
412 | 275 |
model addDependent:self. |
664 | 276 |
self color: model value |
277 |
] |
|
412 | 278 |
|
279 |
||
280 |
||
281 |
! ! |
|
282 |
||
283 |
!ColorMenu methodsFor:'accessing look'! |
|
284 |
||
285 |
showSeparatingLines |
|
664 | 286 |
"no drawing of separating lines here" |
287 |
||
288 |
^true |
|
289 |
||
412 | 290 |
! ! |
291 |
||
292 |
!ColorMenu methodsFor:'change & update'! |
|
293 |
||
294 |
update:something with:aParameter from:changedObject |
|
664 | 295 |
"one of my models changed its value" |
296 |
||
297 |
changedObject == model ifTrue:[^self color: model value]. |
|
412 | 298 |
super update:something with:aParameter from:changedObject |
299 |
||
300 |
||
301 |
||
302 |
||
303 |
! ! |
|
304 |
||
305 |
!ColorMenu methodsFor:'initialization'! |
|
306 |
||
307 |
destroy |
|
664 | 308 |
"release color channel dependency" |
309 |
||
412 | 310 |
self model:nil. |
664 | 311 |
super destroy |
412 | 312 |
|
313 |
! |
|
314 |
||
315 |
initialize |
|
664 | 316 |
"setup menu" |
317 |
||
412 | 318 |
super initialize. |
664 | 319 |
labelsAreColored := false. |
412 | 320 |
self verticalLayout:false. |
321 |
self fitFirstPanel:false. |
|
895 | 322 |
enabledChannel := ValueHolder with:false. |
412 | 323 |
self setupMenu. |
895 | 324 |
|
325 |
"Modified: / 21.5.1998 / 03:07:26 / cg" |
|
412 | 326 |
! |
327 |
||
328 |
setupMenu |
|
664 | 329 |
"setup menu" |
666 | 330 |
|menu item| |
412 | 331 |
|
666 | 332 |
menu := self class colorMenu:labelsAreColored value:nil. |
333 |
menu itemsDo:[:el| el isButton:true]. |
|
1058 | 334 |
menu addItem:((MenuItem labeled:'def') value: |
1057 | 335 |
[ |
336 |
|defineColor| |
|
337 |
defineColor := DefineColor new color: self color. |
|
338 |
defineColor open. |
|
339 |
defineColor accept value ifTrue: [self color: defineColor color] |
|
340 |
||
341 |
]; isButton: true) beforeIndex:8. |
|
342 |
menu addItem:(MenuItem labeled:'') beforeIndex:8. |
|
806 | 343 |
menu addItem:(MenuItem labeled:' ') beforeIndex:5. |
344 |
menu addItem:(MenuItem labeled:' ') beforeIndex:2. |
|
345 |
menu addItem:(MenuItem labeled:' ') beforeIndex:1. |
|
346 |
||
666 | 347 |
item := MenuItem labeled:(Text string:' ' emphasis:(#backgroundColor->DefaultViewBackgroundColor)). |
348 |
item value:#selection. |
|
349 |
menu addItem:item beforeIndex:1. |
|
806 | 350 |
|
351 |
||
412 | 352 |
self menu:menu. |
353 |
||
666 | 354 |
self do:[:anItem| |
355 |
(anItem submenu) notNil ifTrue:[ |
|
412 | 356 |
anItem enabled:enabledChannel. |
666 | 357 |
] ifFalse:[ |
358 |
anItem value == #selection ifTrue:[anItem indication:enabledChannel] |
|
1057 | 359 |
ifFalse:[anItem enabled:false]. |
1058 | 360 |
anItem label = 'def' ifTrue:[anItem enabled:enabledChannel] |
412 | 361 |
] |
664 | 362 |
] |
412 | 363 |
! ! |
364 |
||
365 |
!ColorMenu methodsFor:'private'! |
|
366 |
||
367 |
colorHolder |
|
368 |
"returns the item which keeps the selected color in its label |
|
369 |
" |
|
370 |
^ self itemAt:#selection |
|
371 |
! ! |
|
372 |
||
1057 | 373 |
!ColorMenu::DefineColor class methodsFor:'interface specs'! |
374 |
||
375 |
windowSpec |
|
376 |
"This resource specification was automatically generated |
|
377 |
by the UIPainter of ST/X." |
|
378 |
||
379 |
"Do not manually edit this!! If it is corrupted, |
|
380 |
the UIPainter may not be able to read the specification." |
|
381 |
||
382 |
" |
|
383 |
UIPainter new openOnClass:ColorMenu::DefineColor andSelector:#windowSpec |
|
384 |
ColorMenu::DefineColor new openInterface:#windowSpec |
|
385 |
ColorMenu::DefineColor open |
|
386 |
" |
|
387 |
||
388 |
<resource: #canvas> |
|
389 |
||
390 |
^ |
|
391 |
||
392 |
#(#FullSpec |
|
393 |
#window: |
|
394 |
#(#WindowSpec |
|
395 |
#name: 'Define Color' |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
396 |
#layout: #(#LayoutFrame 13 0 29 0 352 0 159 0) |
1057 | 397 |
#label: 'Define Color' |
398 |
#min: #(#Point 340 110) |
|
399 |
#max: #(#Point 1152 900) |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
400 |
#bounds: #(#Rectangle 13 29 353 160) |
1057 | 401 |
#usePreferredExtent: false |
402 |
) |
|
403 |
#component: |
|
404 |
#(#SpecCollection |
|
405 |
#collection: |
|
406 |
#( |
|
407 |
#(#VerticalPanelViewSpec |
|
408 |
#name: 'VerticalPanel1' |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
409 |
#layout: #(#LayoutFrame 0 0.0 0 0.0 58 0 -40 1.0) |
1057 | 410 |
#component: |
411 |
#(#SpecCollection |
|
412 |
#collection: |
|
413 |
#( |
|
414 |
#(#LabelSpec |
|
415 |
#name: 'RedLabel' |
|
416 |
#label: 'Red:' |
|
417 |
#translateLabel: true |
|
418 |
#adjust: #right |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
419 |
#extent: #(#Point 58 26) |
1057 | 420 |
) |
421 |
#(#LabelSpec |
|
422 |
#name: 'GreenLabel' |
|
423 |
#label: 'Green:' |
|
424 |
#translateLabel: true |
|
425 |
#adjust: #right |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
426 |
#extent: #(#Point 58 27) |
1057 | 427 |
) |
428 |
#(#LabelSpec |
|
429 |
#name: 'BlueLabel' |
|
430 |
#label: 'Blue:' |
|
431 |
#translateLabel: true |
|
432 |
#adjust: #right |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
433 |
#extent: #(#Point 58 26) |
1057 | 434 |
) |
435 |
) |
|
436 |
) |
|
437 |
#horizontalLayout: #fit |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
438 |
#verticalLayout: #fitSpace |
1057 | 439 |
#horizontalSpace: 3 |
440 |
#verticalSpace: 3 |
|
441 |
) |
|
442 |
#(#VerticalPanelViewSpec |
|
443 |
#name: 'VerticalPanel2' |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
444 |
#layout: #(#LayoutFrame 60 0 0 0.0 -160 1.0 -40 1.0) |
1057 | 445 |
#component: |
446 |
#(#SpecCollection |
|
447 |
#collection: |
|
448 |
#( |
|
449 |
#(#SliderSpec |
|
450 |
#name: 'RedSlider' |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
451 |
#tabable: true |
1057 | 452 |
#model: #red |
453 |
#orientation: #horizontal |
|
454 |
#stop: 255 |
|
455 |
#step: 1 |
|
456 |
#backgroundColor: #(#Color 100.0 0.0 0.0) |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
457 |
#extent: #(#Point 118 16) |
1057 | 458 |
) |
459 |
#(#SliderSpec |
|
460 |
#name: 'GreenSlider' |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
461 |
#tabable: true |
1057 | 462 |
#model: #green |
463 |
#orientation: #horizontal |
|
464 |
#stop: 255 |
|
465 |
#step: 1 |
|
466 |
#backgroundColor: #(#Color 0.0 100.0 0.0) |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
467 |
#extent: #(#Point 118 16) |
1057 | 468 |
) |
469 |
#(#SliderSpec |
|
470 |
#name: 'BlueSlider' |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
471 |
#tabable: true |
1057 | 472 |
#model: #blue |
473 |
#orientation: #horizontal |
|
474 |
#stop: 255 |
|
475 |
#step: 1 |
|
476 |
#backgroundColor: #(#Color 0.0 0.0 100.0) |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
477 |
#extent: #(#Point 118 16) |
1057 | 478 |
) |
479 |
) |
|
480 |
) |
|
481 |
#horizontalLayout: #fit |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
482 |
#verticalLayout: #spreadSpace |
1057 | 483 |
#horizontalSpace: 3 |
484 |
#verticalSpace: 3 |
|
485 |
) |
|
486 |
#(#VerticalPanelViewSpec |
|
487 |
#name: 'VerticalPanel3' |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
488 |
#layout: #(#LayoutFrame -158 1 0 0.0 -120 1 -40 1.0) |
1057 | 489 |
#component: |
490 |
#(#SpecCollection |
|
491 |
#collection: |
|
492 |
#( |
|
493 |
#(#InputFieldSpec |
|
494 |
#name: 'RedField' |
|
495 |
#model: #red |
|
496 |
#type: #numberInRange |
|
497 |
#numChars: 3 |
|
498 |
#minValue: 0 |
|
499 |
#maxValue: 255 |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
500 |
#extent: #(#Point 38 20) |
1057 | 501 |
) |
502 |
#(#InputFieldSpec |
|
503 |
#name: 'GreenField' |
|
504 |
#model: #green |
|
505 |
#type: #numberInRange |
|
506 |
#numChars: 3 |
|
507 |
#minValue: 0 |
|
508 |
#maxValue: 255 |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
509 |
#extent: #(#Point 38 20) |
1057 | 510 |
) |
511 |
#(#InputFieldSpec |
|
512 |
#name: 'BlueField' |
|
513 |
#model: #blue |
|
514 |
#type: #numberInRange |
|
515 |
#numChars: 3 |
|
516 |
#minValue: 0 |
|
517 |
#maxValue: 255 |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
518 |
#extent: #(#Point 38 20) |
1057 | 519 |
) |
520 |
) |
|
521 |
) |
|
522 |
#horizontalLayout: #fit |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
523 |
#verticalLayout: #spreadSpace |
1057 | 524 |
#horizontalSpace: 3 |
525 |
#verticalSpace: 3 |
|
526 |
) |
|
527 |
#(#LabelSpec |
|
528 |
#name: 'PreviewBox' |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
529 |
#layout: #(#LayoutFrame -116 1 0 0.0 -2 1.0 -40 1.0) |
1057 | 530 |
#label: 'Preview' |
531 |
#translateLabel: true |
|
532 |
#level: -1 |
|
533 |
) |
|
534 |
#(#HorizontalPanelViewSpec |
|
535 |
#name: 'HorizontalPanel1' |
|
536 |
#layout: #(#LayoutFrame 0 0.0 -32 1 0 1.0 0 1.0) |
|
537 |
#component: |
|
538 |
#(#SpecCollection |
|
539 |
#collection: |
|
540 |
#( |
|
541 |
#(#ActionButtonSpec |
|
542 |
#name: 'CancelButton' |
|
543 |
#label: 'Cancel' |
|
544 |
#translateLabel: true |
|
545 |
#model: #cancel |
|
546 |
#extent: #(#Point 165 26) |
|
547 |
) |
|
548 |
#(#ActionButtonSpec |
|
549 |
#name: 'OKButton' |
|
550 |
#label: 'OK' |
|
551 |
#translateLabel: true |
|
552 |
#model: #accept |
|
553 |
#extent: #(#Point 166 26) |
|
554 |
) |
|
555 |
) |
|
556 |
) |
|
557 |
#horizontalLayout: #fitSpace |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
558 |
#verticalLayout: #centerMax |
1057 | 559 |
#horizontalSpace: 3 |
560 |
#verticalSpace: 3 |
|
561 |
) |
|
562 |
) |
|
563 |
) |
|
564 |
) |
|
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
565 |
|
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
566 |
"Modified: / 6.9.1998 / 23:04:19 / cg" |
1057 | 567 |
! ! |
568 |
||
569 |
!ColorMenu::DefineColor methodsFor:'accessing'! |
|
570 |
||
571 |
color |
|
572 |
||
573 |
^Color redByte: red value greenByte: green value blueByte: blue value |
|
574 |
||
575 |
! |
|
576 |
||
577 |
color: aColor |
|
578 |
||
579 |
aColor notNil |
|
580 |
ifTrue: |
|
581 |
[ |
|
582 |
self red value: aColor redByte. |
|
583 |
self green value: aColor greenByte. |
|
584 |
self blue value: aColor blueByte. |
|
585 |
] |
|
586 |
||
587 |
! ! |
|
588 |
||
589 |
!ColorMenu::DefineColor methodsFor:'aspects'! |
|
590 |
||
591 |
blue |
|
592 |
||
593 |
blue isNil ifTrue:[ |
|
594 |
blue := 0 asValue |
|
595 |
]. |
|
596 |
^blue |
|
597 |
! |
|
598 |
||
599 |
green |
|
600 |
||
601 |
green isNil ifTrue:[ |
|
602 |
green := 0 asValue |
|
603 |
]. |
|
604 |
^green |
|
605 |
! |
|
606 |
||
607 |
red |
|
608 |
||
609 |
red isNil ifTrue:[ |
|
610 |
red := 0 asValue |
|
611 |
]. |
|
612 |
^red |
|
613 |
! ! |
|
614 |
||
615 |
!ColorMenu::DefineColor methodsFor:'startup / release'! |
|
616 |
||
617 |
postBuildWith:aBuilder |
|
618 |
||
619 |
|updateBlock| |
|
620 |
||
621 |
super postBuildWith:aBuilder. |
|
622 |
||
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
623 |
updateBlock := [ |
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
624 |
|box clr| |
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
625 |
|
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
626 |
box := builder componentAt: #PreviewBox. |
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
627 |
clr := self color. |
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
628 |
box backgroundColor:clr. |
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
629 |
clr brightness < 0.5 ifTrue:[ |
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
630 |
box foregroundColor:Color white |
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
631 |
] ifFalse:[ |
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
632 |
box foregroundColor:Color black |
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
633 |
] |
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
634 |
]. |
1057 | 635 |
|
1676 | 636 |
red onChangeEvaluate: updateBlock. |
637 |
green onChangeEvaluate: updateBlock. |
|
638 |
blue onChangeEvaluate: updateBlock. |
|
1057 | 639 |
|
640 |
updateBlock value |
|
641 |
||
1119
11cd3ce5171b
colorMenu: change labelColor to white for dark preview colors;
Claus Gittinger <cg@exept.de>
parents:
1058
diff
changeset
|
642 |
"Modified: / 6.9.1998 / 22:55:25 / cg" |
1057 | 643 |
! ! |
644 |
||
412 | 645 |
!ColorMenu class methodsFor:'documentation'! |
646 |
||
647 |
version |
|
1808 | 648 |
^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.22 2000-08-16 21:23:09 cg Exp $' |
412 | 649 |
! ! |