ColorEditDialog.st
changeset 2279 f077161d5d57
parent 2274 e09282d74ec3
child 2326 f23fac376621
equal deleted inserted replaced
2278:8ff3bd6f0820 2279:f077161d5d57
   561 ! !
   561 ! !
   562 
   562 
   563 !ColorEditDialog methodsFor:'accessing'!
   563 !ColorEditDialog methodsFor:'accessing'!
   564 
   564 
   565 color
   565 color
       
   566     |colorName|
       
   567 
       
   568     colorName := self colorName.
       
   569     colorName notEmptyOrNil ifTrue:[
       
   570         ^ colorName asSymbol
       
   571     ].
   566     ^Color redByte:(red value) greenByte:(green value) blueByte:(blue value)
   572     ^Color redByte:(red value) greenByte:(green value) blueByte:(blue value)
   567 !
   573 !
   568 
   574 
   569 color:aColor 
   575 color:aColor
   570     aColor notNil ifTrue:[
   576     aColor isNil ifTrue:[
       
   577         ^ self
       
   578     ].
       
   579 
       
   580     aColor isSymbol ifTrue:[
       
   581         self colorNameHolder value:aColor
       
   582     ] ifFalse:[
   571         self red value:aColor redByte.
   583         self red value:aColor redByte.
   572         self green value:aColor greenByte.
   584         self green value:aColor greenByte.
   573         self blue value:aColor blueByte.
   585         self blue value:aColor blueByte.
   574     ]
   586     ]
   575 !
   587 !
   586 
   598 
   587 colorChanged
   599 colorChanged
   588     |clr|
   600     |clr|
   589 
   601 
   590     clr := self color.
   602     clr := self color.
   591     self setPreview:clr.
   603     clr isColor ifTrue:[
   592     self htmlColorNameHolder value:(clr htmlPrintString).
   604         "not a symbol"
       
   605         self setPreview:clr.
       
   606         self htmlColorNameHolder value:(clr htmlPrintString).
       
   607     ].
   593 !
   608 !
   594 
   609 
   595 colorNameChanged
   610 colorNameChanged
   596     "compute rgb and hls (if possible)"
   611     "compute rgb and hls (if possible)"
   597 
   612 
   600     clr := Color name:colorNameHolder value ifIllegal:nil.
   615     clr := Color name:colorNameHolder value ifIllegal:nil.
   601     clr isNil ifTrue:[
   616     clr isNil ifTrue:[
   602         ^ self
   617         ^ self
   603     ].
   618     ].
   604 
   619 
   605     red   value:clr redByte withoutNotifying:self.
   620     self red   value:clr redByte withoutNotifying:self.
   606     green value:clr greenByte withoutNotifying:self.
   621     self green value:clr greenByte withoutNotifying:self.
   607     blue  value:clr blueByte withoutNotifying:self.
   622     self blue  value:clr blueByte withoutNotifying:self.
   608 
   623 
   609     h := clr hue.
   624     h := clr hue.
   610     h notNil ifTrue:[
   625     h notNil ifTrue:[
   611         hue        value:(h rounded) withoutNotifying:self.
   626         self hue        value:(h rounded) withoutNotifying:self.
   612     ].
   627     ].
   613     light      value:(clr light rounded) withoutNotifying:self.
   628     self light      value:(clr light rounded) withoutNotifying:self.
   614     saturation value:(clr saturation rounded) withoutNotifying:self.
   629     self saturation value:(clr saturation rounded) withoutNotifying:self.
   615 
   630 
   616     self colorChanged
   631     self colorChanged
   617 !
   632 !
   618 
   633 
   619 copyColor
   634 copyColor