13 Object subclass:#Color |
13 Object subclass:#Color |
14 instanceVariableNames:'red green blue device colorId ditherForm replacementColor |
14 instanceVariableNames:'red green blue device colorId ditherForm replacementColor |
15 writable' |
15 writable' |
16 classVariableNames:'MaxValue Lobby Cells Black White LightGrey Grey DarkGrey Pseudo0 |
16 classVariableNames:'MaxValue Lobby Cells Black White LightGrey Grey DarkGrey Pseudo0 |
17 Pseudo1 PseudoAll Red Green Blue RetryAllocation DitherBits |
17 Pseudo1 PseudoAll Red Green Blue RetryAllocation DitherBits |
18 ColorAllocationFailSignal' |
18 ColorAllocationFailSignal InvalidColorNameSignal' |
19 poolDictionaries:'' |
19 poolDictionaries:'' |
20 category:'Graphics-Support' |
20 category:'Graphics-Support' |
21 ! |
21 ! |
22 |
22 |
23 !Color class methodsFor:'documentation'! |
23 !Color class methodsFor:'documentation'! |
401 initialize |
401 initialize |
402 "setup tracker of known colors and initialize classvars with |
402 "setup tracker of known colors and initialize classvars with |
403 heavily used colors" |
403 heavily used colors" |
404 |
404 |
405 ColorAllocationFailSignal isNil ifTrue:[ |
405 ColorAllocationFailSignal isNil ifTrue:[ |
406 ColorAllocationFailSignal := ErrorSignal newSignalMayProceed:true. |
406 ColorAllocationFailSignal := ErrorSignal newSignalMayProceed:true. |
407 ColorAllocationFailSignal nameClass:self message:#colorAllocationFailSignal. |
407 ColorAllocationFailSignal nameClass:self message:#colorAllocationFailSignal. |
408 ColorAllocationFailSignal notifierString:'color allocation failed'. |
408 ColorAllocationFailSignal notifierString:'color allocation failed'. |
|
409 |
|
410 InvalidColorNameSignal := ErrorSignal newSignalMayProceed:true. |
|
411 InvalidColorNameSignal nameClass:self message:#invalidColorNameSignal. |
|
412 InvalidColorNameSignal notifierString:'invalid color name'. |
409 ]. |
413 ]. |
410 |
414 |
411 Lobby isNil ifTrue:[ |
415 Lobby isNil ifTrue:[ |
412 MaxValue := 16rFFFF. |
416 MaxValue := 16rFFFF. |
413 |
417 |
414 Lobby := Registry new. |
418 Lobby := Registry new. |
415 |
419 |
416 self getPrimaryColors. |
420 self getPrimaryColors. |
417 |
421 |
418 "want to be informed when returning from snapshot" |
422 "want to be informed when returning from snapshot" |
419 ObjectMemory addDependent:self. |
423 ObjectMemory addDependent:self. |
420 |
424 |
421 RetryAllocation := true. |
425 RetryAllocation := true. |
422 |
426 |
423 DitherBits := self ditherBits |
427 DitherBits := self ditherBits |
424 ]. |
428 ]. |
425 |
429 |
426 "Modified: 11.7.1996 / 18:31:39 / cg" |
430 "Modified: 24.1.1997 / 13:37:30 / cg" |
427 ! |
431 ! |
428 |
432 |
429 update:something with:aParameter from:changedObject |
433 update:something with:aParameter from:changedObject |
430 "handle image restarts and flush any device resource handles" |
434 "handle image restarts and flush any device resource handles" |
431 |
435 |
581 common names) - use with special names (such as 'mediumGoldenRod' |
585 common names) - use with special names (such as 'mediumGoldenRod' |
582 is not recommended). Better use: #name:ifIllegal: and provide a fallBack." |
586 is not recommended). Better use: #name:ifIllegal: and provide a fallBack." |
583 |
587 |
584 ^ self |
588 ^ self |
585 name:colorName |
589 name:colorName |
586 ifIllegal:[self error:'no color named ' , colorName] |
590 ifIllegal:[InvalidColorNameSignal |
|
591 raiseRequestWith:colorName |
|
592 errorString:'invalid colorName: '] |
587 |
593 |
588 " |
594 " |
589 Color name:'brown' |
595 Color name:'brown' |
590 Color name:'foo' |
596 Color name:'foo' |
591 Color name:'snow' |
597 Color name:'snow' |
592 " |
598 " |
593 |
599 |
594 "Modified: 16.1.1997 / 23:00:20 / cg" |
600 "Modified: 24.1.1997 / 13:39:25 / cg" |
595 ! |
601 ! |
596 |
602 |
597 name:colorName ifIllegal:errorBlock |
603 name:colorName ifIllegal:errorBlock |
598 "Return a named color (either exact or dithered). |
604 "Return a named color (either exact or dithered). |
599 If aString is not a valid color name, |
605 If aString is not a valid color name, |
757 "return the signal raised when a color allocation failed." |
763 "return the signal raised when a color allocation failed." |
758 |
764 |
759 ^ ColorAllocationFailSignal |
765 ^ ColorAllocationFailSignal |
760 |
766 |
761 "Created: 12.6.1996 / 17:44:49 / cg" |
767 "Created: 12.6.1996 / 17:44:49 / cg" |
|
768 ! |
|
769 |
|
770 invalidColorNameSignal |
|
771 "return the signal raised when an invalid color name is encountered" |
|
772 |
|
773 ^ InvalidColorNameSignal |
|
774 |
|
775 "Created: 24.1.1997 / 13:36:25 / cg" |
762 ! ! |
776 ! ! |
763 |
777 |
764 !Color class methodsFor:'accessing'! |
778 !Color class methodsFor:'accessing'! |
765 |
779 |
766 allocatedColorsOn:aDevice |
780 allocatedColorsOn:aDevice |