ColorEditDialog.st
changeset 3822 8f40c5d2a468
parent 3687 a3c56c0e4157
equal deleted inserted replaced
3821:798167a7637b 3822:8f40c5d2a468
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1995 by eXept Software AG
     4  COPYRIGHT (c) 1995 by eXept Software AG
     3               All Rights Reserved
     5               All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
   963 ! !
   965 ! !
   964 
   966 
   965 !ColorEditDialog methodsFor:'actions'!
   967 !ColorEditDialog methodsFor:'actions'!
   966 
   968 
   967 colorChanged
   969 colorChanged
   968     |clr nm|
   970     |clr nm def|
   969 
   971 
   970     clr := self colorNameOrColor.
   972     "/ clr := self color.
   971     clr isColor ifTrue:[
   973     clr := Color redByte:(red value) greenByte:(green value) blueByte:(blue value).
       
   974 
       
   975     self setPreview:clr.
       
   976     self htmlColorNameHolder value:(clr htmlPrintString) withoutNotifying:self.
       
   977 
       
   978     "/ clr := self colorNameOrColor.
       
   979     "/ clr isColor ifTrue:[
   972         "not a symbol"
   980         "not a symbol"
   973         self setPreview:clr.
   981 
   974         self htmlColorNameHolder value:(clr htmlPrintString) withoutNotifying:self.
   982         nm := Color constantNames detect:[:nm | clr = (Color perform:nm)] ifNone:nil.
   975 
       
   976         nm := #(white black
       
   977                 gray lightGray darkGray
       
   978                 red green blue 
       
   979                 yellow magenta cyan
       
   980                 orange brown) detect:[:nm | clr = (Color perform:nm)] ifNone:nil.
       
   981         nm notNil ifTrue:[
   983         nm notNil ifTrue:[
   982             self colorDefinitionStringHolder value:('Color ',nm).
   984             self colorNameHolder value:nm withoutNotifying:self.
       
   985             def := 'Color ',nm.
   983         ] ifFalse:[
   986         ] ifFalse:[
   984             self colorDefinitionStringHolder value:('Color rgbValue:16r',(clr rgbValue hexPrintString leftPaddedTo:6 with:$0)).
   987             def := 'Color rgbValue:16r%06x' printfWith:clr rgbValue.
   985         ].
   988         ].
   986         self brightnessStringHolder value:((clr brightness asFixedPoint:3) printString).
   989         self colorDefinitionStringHolder value:def withoutNotifying:self.
   987     ].
   990         self brightnessStringHolder value:((clr brightness asFixedPoint:3) printString) withoutNotifying:self.
       
   991     "/ ].
   988 
   992 
   989     "Modified: / 27-01-2011 / 12:54:04 / cg"
   993     "Modified: / 27-01-2011 / 12:54:04 / cg"
   990     "Modified: / 30-04-2019 / 15:09:48 / Claus Gittinger"
   994     "Modified: / 30-04-2019 / 15:09:48 / Claus Gittinger"
   991 !
   995 !
   992 
   996 
  1016 
  1020 
  1017     |clr|
  1021     |clr|
  1018 
  1022 
  1019     clr := Color name:(self colorName) ifIllegal:nil.
  1023     clr := Color name:(self colorName) ifIllegal:nil.
  1020     clr isNil ifTrue:[
  1024     clr isNil ifTrue:[
       
  1025         Transcript showCR:'no such color'.
  1021         ^ self
  1026         ^ self
  1022     ].
  1027     ].
  1023     self colorChangedTo:clr.
  1028     self colorChangedTo:clr.
  1024 !
  1029 !
  1025 
  1030