author | Stefan Vogel <sv@exept.de> |
Wed, 27 Feb 2008 16:30:28 +0100 | |
changeset 3349 | fb7d0dea3876 |
parent 3348 | 9e04c0b42717 |
child 3350 | 5950d4d4a57c |
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 |
" |
|
2935
e3fa9d1a7a64
Moved ColorMenu and FontMenu from libtool2
Stefan Vogel <sv@exept.de>
parents:
2704
diff
changeset
|
12 |
"{ Package: 'stx:libwidg2' }" |
1803 | 13 |
|
412 | 14 |
MenuPanel subclass:#ColorMenu |
3349
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
15 |
instanceVariableNames:'enabledChannel labelsAreColored color colorName |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
16 |
allowSymbolicColors' |
3322 | 17 |
classVariableNames:'ColorMenuSpec RecentlyUsedColors' |
412 | 18 |
poolDictionaries:'' |
19 |
category:'Interface-UIPainter' |
|
20 |
! |
|
21 |
||
22 |
!ColorMenu class methodsFor:'documentation'! |
|
23 |
||
422 | 24 |
copyright |
25 |
" |
|
26 |
COPYRIGHT (c) 1995 by eXept Software AG |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
||
37 |
||
38 |
! |
|
39 |
||
412 | 40 |
documentation |
41 |
" |
|
2183
5c69691590eb
code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents:
2167
diff
changeset
|
42 |
A simple ColorMenu used by the UIPainter |
412 | 43 |
|
44 |
[see also:] |
|
45 |
UIPainter |
|
46 |
ColorMenuSpec |
|
422 | 47 |
|
48 |
[author:] |
|
49 |
Claus Atzkern |
|
412 | 50 |
" |
51 |
! |
|
52 |
||
53 |
examples |
|
54 |
" |
|
2183
5c69691590eb
code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents:
2167
diff
changeset
|
55 |
very simple example |
412 | 56 |
[exBegin] |
57 |
|tool top channel| |
|
58 |
||
59 |
top := StandardSystemView new. |
|
60 |
top extent:250@30. |
|
2183
5c69691590eb
code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents:
2167
diff
changeset
|
61 |
|
412 | 62 |
channel := (Color red) asValue. |
63 |
tool := self origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
64 |
tool model:channel. |
|
2183
5c69691590eb
code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents:
2167
diff
changeset
|
65 |
|
412 | 66 |
top open. |
67 |
[exEnd] |
|
68 |
" |
|
69 |
! ! |
|
70 |
||
3322 | 71 |
!ColorMenu class methodsFor:'instance creation'! |
72 |
||
73 |
colorMenu:labelAreColored value:aValue |
|
74 |
"returns a color menu |
|
75 |
" |
|
76 |
|menu| |
|
77 |
||
78 |
menu := Menu new. |
|
79 |
||
80 |
self colorMenu itemsDo:[:el| |
|
81 |
menu addItem:(self resolveMenuItem:el value:aValue labelAreColored:labelAreColored). |
|
82 |
]. |
|
83 |
^ menu |
|
84 |
||
85 |
" |
|
86 |
(ColorMenu colorMenu:true value:nil) startUp |
|
87 |
(ColorMenu colorMenu:false value:#aSelector:) startUp |
|
88 |
" |
|
89 |
! ! |
|
90 |
||
91 |
!ColorMenu class methodsFor:'adding & removing user defined items'! |
|
3280 | 92 |
|
3292 | 93 |
addUserDefinedColors:aColors labels:labelsOrNil title:aTitle |
3322 | 94 |
"add user colors to ALL colormenus" |
95 |
||
96 |
"cg: I think this is a bad hack, as it is too global." |
|
97 |
||
3292 | 98 |
|size submenu item label fgColor bgColor labels defLabel| |
99 |
||
100 |
submenu := self userDefinedSubmenu. |
|
101 |
size := aColors size. |
|
102 |
||
103 |
size == 0 ifTrue:[ "/ separator |
|
104 |
submenu addItem:(MenuItem label:'-'). |
|
105 |
^ self |
|
106 |
]. |
|
107 |
||
108 |
labels := labelsOrNil ? #(). |
|
109 |
bgColor := aColors first. |
|
110 |
defLabel := ' '. |
|
111 |
||
112 |
bgColor brightness < 0.5 ifTrue:[ fgColor := Color white ] |
|
113 |
ifFalse:[ fgColor := Color black ]. |
|
114 |
||
115 |
aTitle isEmptyOrNil ifTrue:[ label := labels at:1 ifAbsent:defLabel ] |
|
116 |
ifFalse:[ label := aTitle ]. |
|
3280 | 117 |
|
3294 | 118 |
label := Text string:(' ', label, ' ') foregroundColor:fgColor backgroundColor:bgColor. |
3292 | 119 |
item := MenuItem labeled:label. |
120 |
submenu addItem:item. |
|
121 |
||
122 |
size == 1 ifTrue:[ |
|
123 |
item argument:bgColor. |
|
124 |
] ifFalse:[ |
|
125 |
item submenu:(submenu := Menu new). |
|
3280 | 126 |
|
3292 | 127 |
aColors keysAndValuesDo:[:idx :aBgColor| |
128 |
aBgColor brightness < 0.5 ifTrue:[ fgColor := Color white ] |
|
129 |
ifFalse:[ fgColor := Color black ]. |
|
130 |
||
131 |
label := labels at:idx ifAbsent:defLabel. |
|
3294 | 132 |
label := Text string:(' ', label, ' ') foregroundColor:fgColor backgroundColor:aBgColor. |
3292 | 133 |
item := MenuItem labeled:label. |
3293 | 134 |
item argument:aBgColor. |
3292 | 135 |
|
136 |
submenu addItem:item. |
|
137 |
]. |
|
138 |
]. |
|
3280 | 139 |
|
140 |
" |
|
3292 | 141 |
ColorMenu removeAllUserDefinedColors. |
3280 | 142 |
|
3292 | 143 |
#( |
144 |
#( Black 16r000000 ) |
|
145 |
#( Red 16rff0000 ) |
|
146 |
nil |
|
147 |
#( Rust 16rff6600 16rff8533 16rffa366 16rffc299 16rffe0cc ) |
|
148 |
#( Tangerine 16rff9933 16rffad5c 16rffc285 16rffd6ad 16rffebd6 ) |
|
149 |
#( Sunflower 16rffcc00 16rfed633 16rfee066 16rffeb99 16rfff5cc ) |
|
150 |
#( Mango 16rffcc99 16rffd6ad 16rffe0c2 16rffebd6 16rfff5eb ) |
|
151 |
#( Buttercup 16rffff66 16rffff85 16rffffa3 16rffffc2 16rffffe0 ) |
|
152 |
#( Lemon 16rffffcc 16rffffd6 16rffffe0 16rffffeb 16rfffff5 ) |
|
3280 | 153 |
|
3292 | 154 |
) do:[:aDef| |colors title labels percentage| |
155 |
aDef isEmptyOrNil ifTrue:[ |
|
156 |
colors := labels := title := nil. |
|
157 |
] ifFalse:[ |
|
158 |
title := aDef first. |
|
159 |
colors := OrderedCollection new. |
|
160 |
labels := OrderedCollection new. |
|
161 |
percentage := 100. |
|
162 |
||
163 |
aDef from:2 do:[:rgb| |
|
164 |
colors add:(Color rgbValue:rgb). |
|
165 |
labels add:('%1 %2 %%' bindWith:title with:percentage). |
|
166 |
percentage := percentage - 20. |
|
167 |
]. |
|
168 |
]. |
|
169 |
ColorMenu addUserDefinedColors:colors labels:labels title:title. |
|
3280 | 170 |
]. |
3292 | 171 |
" |
3280 | 172 |
! |
173 |
||
3283 | 174 |
removeAllUserDefinedColors |
3322 | 175 |
"flush user defined colors" |
176 |
||
3292 | 177 |
ColorMenuSpec := nil. |
3322 | 178 |
! |
179 |
||
180 |
userDefinedSubmenu |
|
181 |
"answer the menu entry under which the userdefined color entries are placed" |
|
182 |
||
183 |
|menu submenu item icon| |
|
184 |
||
185 |
menu := self colorMenu. |
|
186 |
item := menu detectItem:[:el| (el nameKey == #userDefined and:[el submenu notNil]) ] |
|
187 |
ifNone:nil. |
|
188 |
||
189 |
item isNil ifTrue:[ |
|
3323 | 190 |
icon := ToolbarIconLibrary colorHistory16x16Icon. |
3322 | 191 |
item := MenuItem labeled:icon. |
192 |
item nameKey:#userDefined. |
|
193 |
item activeHelpKey:#userDefinedColors. |
|
194 |
menu addItem:item beforeIndex:1. |
|
195 |
]. |
|
196 |
||
197 |
(submenu := item submenu) isNil ifTrue:[ |
|
198 |
submenu := Menu new. |
|
199 |
item submenu:submenu. |
|
200 |
]. |
|
201 |
^ submenu |
|
3280 | 202 |
! ! |
203 |
||
3341 | 204 |
!ColorMenu class methodsFor:'menu specs'! |
412 | 205 |
|
3322 | 206 |
colorMenuSpec |
207 |
"color definitions used to build a color menu |
|
3292 | 208 |
" |
3322 | 209 |
" |
210 |
ColorMenuSpec := nil. |
|
211 |
" |
|
212 |
^ #( |
|
213 |
#( gray |
|
214 |
gray: |
|
215 |
#( white |
|
216 |
veryLightGray |
|
217 |
lightGray |
|
218 |
gray |
|
219 |
darkGray |
|
220 |
veryDarkGray |
|
221 |
black |
|
222 |
) |
|
223 |
) |
|
224 |
"/ nil "/ separator |
|
225 |
#( red |
|
226 |
red: |
|
227 |
#( veryLight lightened 100 87 67 50 33) |
|
228 |
) |
|
229 |
#( green |
|
230 |
green: |
|
231 |
#( veryLight lightened 100 87 67 50 33) |
|
232 |
) |
|
233 |
#( blue |
|
234 |
blue: |
|
235 |
#( veryLight lightened 100 87 67 50 33) |
|
236 |
) |
|
237 |
"/ nil "/ separator |
|
238 |
#( cyan |
|
239 |
cyan: |
|
240 |
#( veryLight lightened 100 87 67 50 33) |
|
241 |
) |
|
242 |
#( magenta |
|
243 |
magenta: |
|
244 |
#( veryLight lightened 100 87 67 50 33) |
|
245 |
) |
|
246 |
#( yellow |
|
247 |
yellow: |
|
248 |
#( veryLight lightened 100 87 67 50 33) |
|
249 |
) |
|
3292 | 250 |
|
3322 | 251 |
) |
3292 | 252 |
! ! |
253 |
||
254 |
!ColorMenu class methodsFor:'private'! |
|
255 |
||
3280 | 256 |
colorMenu |
257 |
|menuItem subItem baseColor color label getColSel submenu colorId| |
|
3292 | 258 |
|
3280 | 259 |
ColorMenuSpec notNil ifTrue:[ ^ ColorMenuSpec ]. |
260 |
||
261 |
ColorMenuSpec := Menu new. |
|
262 |
||
263 |
self colorMenuSpec do:[:aSlice| |
|
264 |
ColorMenuSpec addItem:(menuItem := MenuItem new). |
|
265 |
||
266 |
aSlice notNil ifTrue:[ |
|
267 |
colorId := aSlice at:1. |
|
268 |
getColSel := aSlice at:2. |
|
269 |
baseColor := Color perform:colorId. |
|
270 |
||
3323 | 271 |
menuItem label:(Text string:' ' emphasis:(#backgroundColor->baseColor)). |
3280 | 272 |
menuItem submenu:(submenu := Menu new). |
3292 | 273 |
menuItem isButton:true. |
3280 | 274 |
|
275 |
aSlice last do:[:el| |
|
276 |
color := label := nil. |
|
277 |
||
278 |
el isSymbol ifTrue:[ |
|
3322 | 279 |
el == #veryLight ifTrue:[ |
280 |
color := baseColor lightened lightened |
|
281 |
] ifFalse:[ el == #lightened ifTrue:[ |
|
282 |
color := baseColor perform:el |
|
283 |
] ifFalse:[ |
|
284 |
color := Color perform:el |
|
285 |
]]. |
|
3280 | 286 |
colorId == #gray ifTrue:[ label := el ]. |
287 |
] ifFalse:[ |
|
288 |
el isNumber ifTrue:[ |
|
289 |
color := Color perform:getColSel with:el. |
|
290 |
]. |
|
291 |
]. |
|
292 |
color notNil ifTrue:[ |
|
293 |
label isNil ifTrue:[ |
|
294 |
label := getColSel, ' ', el printString. |
|
295 |
]. |
|
3322 | 296 |
subItem := MenuItem label:' ',label,' '. |
3280 | 297 |
subItem argument:color. |
298 |
submenu addItem:subItem. |
|
299 |
]. |
|
300 |
] |
|
301 |
]. |
|
302 |
]. |
|
303 |
^ ColorMenuSpec |
|
304 |
! |
|
305 |
||
3292 | 306 |
resolveMenuItem:aMenuItem value:aValue labelAreColored:labelAreColored |
307 |
|menuItem label color fgColor submenu| |
|
308 |
||
309 |
label := aMenuItem rawLabel ? ''. |
|
310 |
menuItem := MenuItem label:label. |
|
311 |
menuItem isButton:(aMenuItem isButton). |
|
312 |
||
313 |
aMenuItem hasSubmenu ifFalse:[ |
|
314 |
color := aMenuItem argument. |
|
315 |
menuItem argument:color. |
|
316 |
||
317 |
(color isColor and:[label isText not]) ifTrue:[ |
|
318 |
labelAreColored ifTrue:[ |
|
319 |
label := Text string:label color:color. |
|
320 |
] ifFalse:[ |
|
321 |
color brightness < 0.5 ifTrue:[ fgColor := Color white ] |
|
322 |
ifFalse:[ fgColor := Color black ]. |
|
323 |
||
324 |
label := Text string:label foregroundColor:fgColor backgroundColor:color. |
|
325 |
]. |
|
326 |
menuItem label:label. |
|
327 |
menuItem value:aValue. |
|
328 |
]. |
|
329 |
^ menuItem |
|
330 |
]. |
|
331 |
submenu := Menu new. |
|
332 |
aMenuItem submenu itemsDo:[:el| |
|
333 |
submenu addItem:(self resolveMenuItem:el value:aValue labelAreColored:labelAreColored). |
|
334 |
]. |
|
335 |
menuItem submenu:submenu. |
|
336 |
^ menuItem |
|
592 | 337 |
! ! |
338 |
||
1808 | 339 |
!ColorMenu methodsFor:'accepting'! |
412 | 340 |
|
341 |
accept:anItem |
|
3322 | 342 |
"accept the current selected item" |
664 | 343 |
|
412 | 344 |
|item holder color| |
345 |
||
3322 | 346 |
((item := super accept:anItem) notNil |
347 |
and: [((item nameKey ? '') startsWith:'pseudo') not]) |
|
348 |
ifTrue:[ |
|
349 |
(holder := self colorHolder) == item ifTrue:[ |
|
412 | 350 |
enabledChannel value ifTrue:[color := self color] |
3322 | 351 |
] ifFalse:[ |
666 | 352 |
color := item argument. |
692 | 353 |
holder label:(Text string:' ' emphasis:(#backgroundColor->color)). |
412 | 354 |
]. |
3322 | 355 |
self choseColor:color. |
356 |
] |
|
357 |
! |
|
358 |
||
359 |
choseColor:aColor |
|
360 |
"accept the current selected item" |
|
361 |
||
362 |
model notNil ifTrue:[ |
|
363 |
model value:aColor. |
|
3323 | 364 |
aColor notNil ifTrue:[ |
365 |
RecentlyUsedColors isNil ifTrue:[ |
|
366 |
RecentlyUsedColors := OrderedCollection new. |
|
367 |
]. |
|
368 |
RecentlyUsedColors remove:aColor ifAbsent:[]. |
|
369 |
RecentlyUsedColors addFirst:aColor. |
|
370 |
RecentlyUsedColors size > 20 ifTrue:[ |
|
371 |
RecentlyUsedColors removeLast |
|
372 |
]. |
|
373 |
] |
|
412 | 374 |
] |
375 |
! ! |
|
376 |
||
377 |
!ColorMenu methodsFor:'accessing'! |
|
378 |
||
3349
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
379 |
allowSymbolicColors |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
380 |
^ allowSymbolicColors |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
381 |
! |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
382 |
|
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
383 |
allowSymbolicColors:something |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
384 |
allowSymbolicColors := something. |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
385 |
! |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
386 |
|
412 | 387 |
color |
664 | 388 |
"get current color" |
389 |
||
3349
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
390 |
^ color |
412 | 391 |
! |
392 |
||
393 |
color:aColor |
|
664 | 394 |
"set current color" |
395 |
||
3349
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
396 |
|label newColor| |
412 | 397 |
|
3344 | 398 |
(aColor isColor or:[aColor isSymbol]) ifFalse:[ |
412 | 399 |
enabledChannel value:false |
2184 | 400 |
] ifTrue:[ |
3349
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
401 |
newColor := aColor. |
3344 | 402 |
aColor isSymbol ifTrue:[ |
3349
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
403 |
allowSymbolicColors ifTrue:[ |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
404 |
label := aColor "asText emphasis:(#backgroundColor->aColor)". |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
405 |
] ifFalse:[ |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
406 |
"our caller does not handle symbolic colors (UIPainter does) - convert" |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
407 |
newColor := Color perform:aColor ifNotUnderstood:[color "keep old"]. |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
408 |
]. |
3344 | 409 |
] ifFalse:[ |
3349
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
410 |
label := Text string: ' ' emphasis:(#backgroundColor->newColor). |
3344 | 411 |
]. |
3349
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
412 |
color := newColor. |
3344 | 413 |
self disabledRedrawDo:[ |
414 |
enabledChannel value:true. |
|
415 |
self colorHolder label:label. |
|
416 |
self choseColor:aColor |
|
417 |
] |
|
412 | 418 |
] |
664 | 419 |
! |
420 |
||
421 |
labelsAreColored: aBoolean |
|
422 |
"sets whether labels or their backgrounds will be colored" |
|
423 |
||
3280 | 424 |
|bool| |
425 |
||
426 |
bool := aBoolean ? false. |
|
664 | 427 |
|
3280 | 428 |
labelsAreColored ~~ bool ifTrue:[ |
429 |
labelsAreColored := bool. |
|
430 |
self setupMenu |
|
431 |
]. |
|
412 | 432 |
! ! |
433 |
||
1818 | 434 |
!ColorMenu methodsFor:'accessing-channels'! |
412 | 435 |
|
436 |
model:aValueHolder |
|
664 | 437 |
"set my color channel" |
438 |
||
2184 | 439 |
super model:aValueHolder. |
2183
5c69691590eb
code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents:
2167
diff
changeset
|
440 |
model notNil ifTrue:[ |
2186 | 441 |
self updateFromModel |
664 | 442 |
] |
412 | 443 |
! ! |
444 |
||
445 |
!ColorMenu methodsFor:'change & update'! |
|
446 |
||
2186 | 447 |
updateFromModel |
2184 | 448 |
self color:(model value) |
412 | 449 |
! ! |
450 |
||
451 |
!ColorMenu methodsFor:'initialization'! |
|
452 |
||
3322 | 453 |
colorHistorySubmenu |
454 |
|menu| |
|
455 |
||
456 |
RecentlyUsedColors isEmptyOrNil ifTrue:[^ nil]. |
|
457 |
||
458 |
menu := Menu new. |
|
459 |
||
3344 | 460 |
RecentlyUsedColors do:[:eachRecentlyUsedColor | |
3322 | 461 |
|label fgColor item| |
462 |
||
3344 | 463 |
eachRecentlyUsedColor isSymbol ifTrue:[ |
464 |
label := eachRecentlyUsedColor . |
|
465 |
] ifFalse:[ |
|
466 |
eachRecentlyUsedColor brightness < 0.5 |
|
467 |
ifTrue:[ fgColor := Color white ] |
|
468 |
ifFalse:[ fgColor := Color black ]. |
|
3322 | 469 |
|
3344 | 470 |
label := eachRecentlyUsedColor htmlPrintString. |
471 |
label := Text string:(' ', label, ' ') foregroundColor:fgColor backgroundColor:eachRecentlyUsedColor. |
|
472 |
]. |
|
473 |
||
3322 | 474 |
item := MenuItem labeled:label. |
3344 | 475 |
item argument:eachRecentlyUsedColor. |
3322 | 476 |
|
477 |
menu addItem:item. |
|
478 |
]. |
|
479 |
||
480 |
^ menu. |
|
481 |
! |
|
482 |
||
412 | 483 |
destroy |
664 | 484 |
"release color channel dependency" |
485 |
||
412 | 486 |
self model:nil. |
664 | 487 |
super destroy |
412 | 488 |
|
489 |
! |
|
490 |
||
491 |
initialize |
|
492 |
super initialize. |
|
3322 | 493 |
labelsAreColored := true. "false." |
3349
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
494 |
verticalLayout := false. |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
495 |
allowSymbolicColors := false. |
2254 | 496 |
|
412 | 497 |
self fitFirstPanel:false. |
895 | 498 |
enabledChannel := ValueHolder with:false. |
412 | 499 |
self setupMenu. |
895 | 500 |
|
501 |
"Modified: / 21.5.1998 / 03:07:26 / cg" |
|
412 | 502 |
! |
503 |
||
504 |
setupMenu |
|
666 | 505 |
|menu item| |
412 | 506 |
|
666 | 507 |
menu := self class colorMenu:labelsAreColored value:nil. |
3280 | 508 |
|
2183
5c69691590eb
code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents:
2167
diff
changeset
|
509 |
menu |
5c69691590eb
code cleanup; now inherit model instVar.
Claus Gittinger <cg@exept.de>
parents:
2167
diff
changeset
|
510 |
addItem:( |
3322 | 511 |
(MenuItem labeled:nil) |
512 |
labelImage:(ToolbarIconLibrary palette16x16Icon); |
|
513 |
value:[ self openColorEditDialog ]; |
|
514 |
nameKey:#pseudoDef; |
|
3280 | 515 |
isButton: true). |
806 | 516 |
|
3322 | 517 |
menu |
518 |
addItem:( |
|
519 |
(MenuItem labeled:nil) |
|
520 |
labelImage:(ToolbarIconLibrary pipette16x16Icon); |
|
521 |
value:[ self pickColorFromScreen ]; |
|
522 |
nameKey:#pseudoPick; |
|
523 |
isButton: true). |
|
524 |
||
525 |
menu |
|
526 |
addItem:( |
|
527 |
(MenuItem labeled:nil) |
|
3323 | 528 |
labelImage:(ToolbarIconLibrary history16x16Icon); |
3322 | 529 |
submenuChannel:[ self colorHistorySubmenu ]; |
530 |
nameKey:#seudoHhistory; |
|
531 |
isButton: false) |
|
532 |
beforeIndex:1. |
|
533 |
||
534 |
"/ menu addItem:(MenuItem label:'') beforeIndex:1. |
|
535 |
||
536 |
item := MenuItem labeled:(Text string:' ' emphasis:(#backgroundColor->DefaultViewBackgroundColor)). |
|
666 | 537 |
item value:#selection. |
538 |
menu addItem:item beforeIndex:1. |
|
806 | 539 |
|
412 | 540 |
self menu:menu. |
541 |
||
666 | 542 |
self do:[:anItem| |
3322 | 543 |
anItem value == #selection ifTrue:[ |
544 |
anItem indication:enabledChannel |
|
666 | 545 |
] ifFalse:[ |
3322 | 546 |
anItem enabled:enabledChannel. |
412 | 547 |
] |
664 | 548 |
] |
412 | 549 |
! ! |
550 |
||
551 |
!ColorMenu methodsFor:'private'! |
|
552 |
||
553 |
colorHolder |
|
3349
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
554 |
"returns the item which keeps the selected color in its label" |
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
555 |
|
412 | 556 |
^ self itemAt:#selection |
3322 | 557 |
! |
558 |
||
559 |
openColorEditDialog |
|
560 |
|defineColorDialog| |
|
561 |
||
562 |
defineColorDialog := ColorEditDialog new color: self color. |
|
563 |
defineColorDialog open. |
|
564 |
defineColorDialog accept value ifTrue: [ |
|
565 |
self color:defineColorDialog color |
|
566 |
] |
|
567 |
! |
|
568 |
||
569 |
pickColorFromScreen |
|
570 |
|color| |
|
571 |
||
572 |
color := Color fromUser. |
|
573 |
color notNil ifTrue:[ |
|
574 |
self color:color. |
|
575 |
] |
|
412 | 576 |
! ! |
577 |
||
578 |
!ColorMenu class methodsFor:'documentation'! |
|
579 |
||
580 |
version |
|
3349
fb7d0dea3876
Configure wether symbolic colors are allowed
Stefan Vogel <sv@exept.de>
parents:
3348
diff
changeset
|
581 |
^ '$Header: /cvs/stx/stx/libwidg2/ColorMenu.st,v 1.47 2008-02-27 15:30:28 stefan Exp $' |
412 | 582 |
! ! |