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