cg@1840: " cg@1840: COPYRIGHT (c) 1995 by eXept Software AG cg@1840: All Rights Reserved cg@1840: cg@1840: This software is furnished under a license and may be used cg@1840: only in accordance with the terms of that license and with the cg@1840: inclusion of the above copyright notice. This software may not cg@1840: be provided or otherwise made available to, or used by, any cg@1840: other person. No title to or ownership of the software is cg@1840: hereby transferred. cg@1840: " cg@1840: "{ Package: 'stx:libtool2' }" cg@1840: cg@1840: SimpleDialog subclass:#ColorEditDialog cg@2224: instanceVariableNames:'red green blue hue light saturation colorNameHolder cg@2831: htmlColorNameHolder colorDefinitionStringHolder previewBox cg@2831: brightnessStringHolder' cg@1840: classVariableNames:'' cg@1840: poolDictionaries:'' cg@1840: category:'Interface-UIPainter' cg@1840: ! cg@1840: cg@1840: !ColorEditDialog class methodsFor:'documentation'! cg@1840: cg@1840: copyright cg@1840: " cg@1840: COPYRIGHT (c) 1995 by eXept Software AG cg@1840: All Rights Reserved cg@1840: cg@1840: This software is furnished under a license and may be used cg@1840: only in accordance with the terms of that license and with the cg@1840: inclusion of the above copyright notice. This software may not cg@1840: be provided or otherwise made available to, or used by, any cg@1840: other person. No title to or ownership of the software is cg@1840: hereby transferred. cg@1840: " cg@1840: ! cg@1840: cg@1840: documentation cg@1840: " cg@1840: An edit-dialog for colors. cg@1840: " cg@1840: ! cg@1840: cg@1840: examples cg@1840: " cg@1840: [exBegin] cg@1840: |editor color| cg@1840: cg@1846: editor := ColorEditDialog new. cg@1840: editor color:(Color green). cg@1840: editor open. cg@1840: editor accepted ifTrue:[ cg@1840: editor color inspect. cg@1840: ] cg@1840: [exEnd] cg@1840: " cg@1840: ! ! cg@1840: cg@2266: !ColorEditDialog class methodsFor:'help specs'! cg@2266: cg@2266: flyByHelpSpec cg@2266: "This resource specification was automatically generated cg@2266: by the UIHelpTool of ST/X." cg@2266: cg@2266: "Do not manually edit this!! If it is corrupted, cg@2266: the UIHelpTool may not be able to read the specification." cg@2266: cg@2266: " cg@2266: UIHelpTool openOnClass:ColorEditDialog cg@2266: " cg@2266: cg@2266: cg@2266: cg@2266: ^ super flyByHelpSpec addPairsFrom:#( cg@2266: cg@2266: #pickColor cg@2266: 'Pick a Color from the Screen' cg@2266: cg@2266: ) cg@2266: ! cg@2266: cg@2266: helpSpec cg@2266: "This resource specification was automatically generated cg@2266: by the UIHelpTool of ST/X." cg@2266: cg@2266: "Do not manually edit this!! If it is corrupted, cg@2266: the UIHelpTool may not be able to read the specification." cg@2266: cg@2266: " cg@2266: UIHelpTool openOnClass:ColorEditDialog cg@2266: " cg@2266: cg@2266: cg@2266: cg@2266: ^ super helpSpec addPairsFrom:#( cg@2266: cg@2831: #brightness cg@2831: 'The Color''s brightness value (0..1)' cg@2831: cg@2831: #colorDefinitionString cg@2831: 'A Smalltalk expression to construct the color.' cg@2831: cg@2831: #colorName cg@2831: 'The standard colorname (as used in the X-Window System), if known' cg@2831: cg@2266: #copyToClipboard cg@2266: 'Copy the color to the clipboard' cg@2266: cg@2266: #hlsMixer cg@2266: 'Mix color from hls (hue-light-saturation) components' cg@2266: cg@2831: #htmlColorName cg@2831: 'The color as used in an HTML page.' cg@2831: cg@2266: #pasteFromClipboard cg@2266: 'Paste color from the Clipboard' cg@2266: cg@2266: #rgbMixer cg@2266: 'Mix color from rgb (red-green-blue) components' cg@2266: cg@2266: ) cg@2266: ! ! cg@2266: cg@2266: !ColorEditDialog class methodsFor:'image specs'! cg@2266: cg@2266: pickColorIcon cg@2266: ^ ToolbarIconLibrary pipette16x16Icon cg@2266: ! ! cg@2266: cg@1840: !ColorEditDialog class methodsFor:'interface specs'! cg@1840: cg@1840: windowSpec cg@1840: "This resource specification was automatically generated cg@1840: by the UIPainter of ST/X." cg@1840: cg@1840: "Do not manually edit this!! If it is corrupted, cg@1840: the UIPainter may not be able to read the specification." cg@1840: cg@1840: " cg@2224: UIPainter new openOnClass:ColorEditDialog andSelector:#windowSpec cg@2224: ColorEditDialog new openInterface:#windowSpec cg@2224: ColorEditDialog open cg@1840: " cg@1840: cg@1840: cg@1840: cg@1840: ^ cg@1840: #(FullSpec cg@1840: name: windowSpec cg@1840: window: cg@1840: (WindowSpec cg@1840: label: 'Define Color' cg@1840: name: 'Define Color' cg@2831: min: (Point 440 360) cg@2831: max: (Point 440 360) cg@2831: bounds: (Rectangle 0 0 440 360) cg@1840: ) cg@1840: component: cg@1840: (SpecCollection cg@1840: collection: ( cg@1840: (VerticalPanelViewSpec cg@1840: name: 'RGBLabelPanel' cg@2266: layout: (LayoutFrame 0 0 0 0 70 0 76 0) cg@1840: horizontalLayout: fit cg@1840: verticalLayout: spreadSpace cg@1840: horizontalSpace: 3 cg@1840: verticalSpace: 3 cg@1840: component: cg@1840: (SpecCollection cg@1840: collection: ( cg@1840: (LabelSpec cg@1840: label: 'Red:' cg@1840: name: 'RedLabel' cg@1840: translateLabel: true cg@1840: adjust: right cg@1840: useDefaultExtent: true cg@1840: ) cg@1840: (LabelSpec cg@1840: label: 'Green:' cg@1840: name: 'GreenLabel' cg@1840: translateLabel: true cg@1840: adjust: right cg@1840: useDefaultExtent: true cg@1840: ) cg@1840: (LabelSpec cg@1840: label: 'Blue:' cg@1840: name: 'BlueLabel' cg@1840: translateLabel: true cg@1840: adjust: right cg@1840: useDefaultExtent: true cg@1840: ) cg@1840: ) cg@1840: cg@1840: ) cg@1840: ) cg@1840: (VerticalPanelViewSpec cg@1840: name: 'RGBSliderPanel' cg@2266: layout: (LayoutFrame 70 0 0 0 -177 1 76 0) cg@1840: horizontalLayout: fit cg@1840: verticalLayout: spreadSpace cg@1840: horizontalSpace: 3 cg@1840: verticalSpace: 3 cg@1840: component: cg@1840: (SpecCollection cg@1840: collection: ( cg@1840: (SliderSpec cg@1840: name: 'RedSlider' cg@1840: tabable: false cg@1840: model: red cg@1840: orientation: horizontal cg@1840: stop: 255 cg@1840: step: 1 cg@1840: backgroundColor: (Color 100.0 0.0 0.0) cg@2266: extent: (Point 193 16) cg@1840: ) cg@1840: (SliderSpec cg@1840: name: 'GreenSlider' cg@1840: tabable: false cg@1840: model: green cg@1840: orientation: horizontal cg@1840: stop: 255 cg@1840: step: 1 cg@1840: backgroundColor: (Color 0.0 100.0 0.0) cg@2266: extent: (Point 193 16) cg@1840: ) cg@1840: (SliderSpec cg@1840: name: 'BlueSlider' cg@1840: tabable: false cg@1840: model: blue cg@1840: orientation: horizontal cg@1840: stop: 255 cg@1840: step: 1 cg@1840: backgroundColor: (Color 0.0 0.0 100.0) cg@2266: extent: (Point 193 16) cg@1840: ) cg@1840: ) cg@1840: cg@1840: ) cg@1840: ) cg@1840: (VerticalPanelViewSpec cg@1840: name: 'RGBFieldPanel' cg@2224: layout: (LayoutFrame -173 1 0 0 -143 1 76 0) cg@1840: horizontalLayout: fit cg@1840: verticalLayout: spreadSpace cg@1840: horizontalSpace: 3 cg@1840: verticalSpace: 3 cg@1840: component: cg@1840: (SpecCollection cg@1840: collection: ( cg@1840: (InputFieldSpec cg@1840: name: 'RedField' cg@1840: model: red cg@1840: type: numberInRange cg@1840: numChars: 3 cg@1840: minValue: 0 cg@1840: maxValue: 255 cg@1840: acceptOnPointerLeave: false cg@2831: extent: (Point 28 20) cg@1840: ) cg@1840: (InputFieldSpec cg@1840: name: 'GreenField' cg@1840: model: green cg@1840: type: numberInRange cg@1840: numChars: 3 cg@1840: minValue: 0 cg@1840: maxValue: 255 cg@1840: acceptOnPointerLeave: false cg@2831: extent: (Point 28 20) cg@1840: ) cg@1840: (InputFieldSpec cg@1840: name: 'BlueField' cg@1840: model: blue cg@1840: type: numberInRange cg@1840: numChars: 3 cg@1840: minValue: 0 cg@1840: maxValue: 255 cg@1840: acceptOnPointerLeave: false cg@2831: extent: (Point 28 20) cg@2224: ) cg@2224: ) cg@2224: cg@2224: ) cg@2224: ) cg@2224: (VerticalPanelViewSpec cg@2224: name: 'RGBFieldPanelHex' cg@2274: layout: (LayoutFrame -141 1 0 0 -119 1 76 0) cg@2224: horizontalLayout: fit cg@2224: verticalLayout: spreadSpace cg@2224: horizontalSpace: 3 cg@2224: verticalSpace: 3 cg@2224: component: cg@2224: (SpecCollection cg@2224: collection: ( cg@2224: (InputFieldSpec cg@2224: name: 'EntryField4' cg@2224: model: red cg@2224: type: hexIntegerInRange cg@2224: numChars: 3 cg@2224: minValue: 0 cg@2224: maxValue: 255 cg@2224: acceptOnPointerLeave: false cg@2831: extent: (Point 20 20) cg@2224: ) cg@2224: (InputFieldSpec cg@2224: name: 'EntryField5' cg@2224: model: green cg@2224: type: hexIntegerInRange cg@2224: numChars: 3 cg@2224: minValue: 0 cg@2224: maxValue: 255 cg@2224: acceptOnPointerLeave: false cg@2831: extent: (Point 20 20) cg@2224: ) cg@2224: (InputFieldSpec cg@2224: name: 'EntryField6' cg@2224: model: blue cg@2224: type: hexIntegerInRange cg@2224: numChars: 3 cg@2224: minValue: 0 cg@2224: maxValue: 255 cg@2224: acceptOnPointerLeave: false cg@2831: extent: (Point 20 20) cg@1840: ) cg@1840: ) cg@1840: cg@1840: ) cg@1840: ) cg@1840: (VerticalPanelViewSpec cg@1840: name: 'HLSLabelPanel' cg@2266: layout: (LayoutFrame 0 0 86 0 70 0 163 0) cg@1840: horizontalLayout: fit cg@1840: verticalLayout: spreadSpace cg@1840: horizontalSpace: 3 cg@1840: verticalSpace: 3 cg@1840: component: cg@1840: (SpecCollection cg@1840: collection: ( cg@1840: (LabelSpec cg@1840: label: 'Hue:' cg@1840: name: 'Label1' cg@1840: translateLabel: true cg@1840: adjust: right cg@1840: useDefaultExtent: true cg@1840: ) cg@1840: (LabelSpec cg@1840: label: 'Light:' cg@1840: name: 'Label2' cg@1840: translateLabel: true cg@1840: adjust: right cg@1840: useDefaultExtent: true cg@1840: ) cg@1840: (LabelSpec cg@2266: label: 'Saturation:' cg@1840: name: 'Label3' cg@1840: translateLabel: true cg@1840: adjust: right cg@1840: useDefaultExtent: true cg@1840: ) cg@1840: ) cg@1840: cg@1840: ) cg@1840: ) cg@1840: (VerticalPanelViewSpec cg@1840: name: 'HLSSliderPanel' cg@2266: layout: (LayoutFrame 70 0 86 0 -177 1 163 0) cg@1840: horizontalLayout: fit cg@1840: verticalLayout: spreadSpace cg@1840: horizontalSpace: 3 cg@1840: verticalSpace: 3 cg@1840: component: cg@1840: (SpecCollection cg@1840: collection: ( cg@1840: (SliderSpec cg@1840: name: 'Slider1' cg@1840: tabable: false cg@1840: model: hue cg@1840: orientation: horizontal cg@1840: stop: 359 cg@1840: step: 1 cg@1840: keyboardStep: 1 cg@2266: extent: (Point 193 16) cg@1840: ) cg@1840: (SliderSpec cg@1840: name: 'Slider2' cg@1840: tabable: false cg@1840: model: light cg@1840: orientation: horizontal cg@1840: step: 1 cg@2831: backgroundColor: (Color 66.9993133440146 66.9993133440146 66.9993133440146) cg@1840: keyboardStep: 1 cg@2266: extent: (Point 193 16) cg@1840: ) cg@1840: (SliderSpec cg@1840: name: 'Slider3' cg@1840: tabable: false cg@1840: model: saturation cg@1840: orientation: horizontal cg@1840: step: 1 cg@2831: backgroundColor: (Color 66.9993133440146 66.9993133440146 66.9993133440146) cg@1840: keyboardStep: 1 cg@2266: extent: (Point 193 16) cg@1840: ) cg@1840: ) cg@1840: cg@1840: ) cg@1840: ) cg@1840: (VerticalPanelViewSpec cg@1840: name: 'HLSFieldPanel' cg@2224: layout: (LayoutFrame -173 1 86 0 -143 1 163 0) cg@1840: horizontalLayout: fit cg@1840: verticalLayout: spreadSpace cg@1840: horizontalSpace: 3 cg@1840: verticalSpace: 3 cg@1840: component: cg@1840: (SpecCollection cg@1840: collection: ( cg@1840: (InputFieldSpec cg@1840: name: 'EntryField1' cg@1840: model: hue cg@1840: type: numberInRange cg@1840: numChars: 3 cg@1840: minValue: 0 cg@1840: maxValue: 359 cg@1840: acceptOnPointerLeave: false cg@2831: extent: (Point 28 20) cg@1840: ) cg@1840: (InputFieldSpec cg@1840: name: 'EntryField2' cg@1840: model: light cg@1840: type: numberInRange cg@1840: numChars: 3 cg@1840: minValue: 0 cg@1840: maxValue: 100 cg@1840: acceptOnPointerLeave: false cg@2831: extent: (Point 28 20) cg@1840: ) cg@1840: (InputFieldSpec cg@1840: name: 'EntryField3' cg@1840: model: saturation cg@1840: type: numberInRange cg@1840: numChars: 3 cg@1840: minValue: 0 cg@1840: maxValue: 100 cg@1840: acceptOnPointerLeave: false cg@2831: extent: (Point 28 20) cg@1840: ) cg@1840: ) cg@1840: cg@1840: ) cg@1840: ) cg@1840: (ViewSpec cg@2266: name: 'PreviewBoxFrame' cg@1840: layout: (LayoutFrame -117 1 4 0.0 -3 1.0 -39 1.0) cg@1840: level: 1 cg@1840: component: cg@1840: (SpecCollection cg@1840: collection: ( cg@1840: (LabelSpec cg@1840: label: 'Preview' cg@1840: name: 'PreviewBox' cg@1840: layout: (LayoutFrame 2 0.0 2 0.0 -2 1.0 -2 1.0) cg@1840: level: -1 cg@1840: translateLabel: true cg@2266: postBuildCallback: postBuildPreviewBox: cg@1840: ) cg@1840: ) cg@1840: cg@1840: ) cg@1840: ) cg@1840: (LabelSpec cg@2831: label: 'Brightness:' cg@2831: name: 'Label5' cg@2831: layout: (LayoutFrame 0 0 175 0 70 0 197 0) cg@2831: activeHelpKey: brightness cg@2831: translateLabel: true cg@2831: adjust: right cg@2831: ) cg@2831: (InputFieldSpec cg@2831: name: 'EntryField8' cg@2831: layout: (LayoutFrame 71 0 175 0 -296 1 197 0) cg@2831: activeHelpKey: brightness cg@2831: model: brightnessStringHolder cg@2831: isReadOnly: true cg@2831: immediateAccept: false cg@2831: acceptOnReturn: true cg@2831: acceptOnTab: true cg@2831: acceptOnLostFocus: true cg@2831: acceptOnPointerLeave: true cg@2831: ) cg@2831: (LabelSpec cg@1840: label: 'Color Name:' cg@1840: name: 'ColorNameLabel' cg@2831: layout: (LayoutFrame 2 0 214 0 115 0 236 0) cg@2831: activeHelpKey: colorName cg@1840: translateLabel: true cg@1840: adjust: right cg@1840: ) cg@1840: (InputFieldSpec cg@1840: name: 'ColorNameField' cg@2831: layout: (LayoutFrame 117 0 214 0 -122 1 236 0) cg@2831: activeHelpKey: colorName cg@1840: model: colorNameHolder cg@2326: immediateAccept: false cg@2326: acceptOnReturn: true cg@2326: acceptOnTab: true cg@2326: acceptOnLostFocus: true cg@2326: acceptOnPointerLeave: true cg@2326: ) cg@2326: (LabelSpec cg@2326: label: 'HTML Color Name:' cg@2326: name: 'HTMLColorNameLabel' cg@2831: layout: (LayoutFrame 2 0 240 0 115 0 262 0) cg@2831: activeHelpKey: htmlColorName cg@2326: translateLabel: true cg@2326: adjust: right cg@2326: ) cg@2326: (InputFieldSpec cg@2326: name: 'MLHTColorNameFieldField' cg@2831: layout: (LayoutFrame 117 0 240 0 -122 1 262 0) cg@2831: activeHelpKey: htmlColorName cg@2326: model: htmlColorNameHolder cg@2326: immediateAccept: false cg@1840: acceptOnReturn: true cg@1840: acceptOnTab: true cg@1840: acceptOnLostFocus: true cg@2326: acceptOnPointerLeave: true cg@2326: ) cg@2831: (LabelSpec cg@2831: label: 'Color Definition:' cg@2831: name: 'Label4' cg@2831: layout: (LayoutFrame 2 0 266 0 115 0 288 0) cg@2831: activeHelpKey: colorDefinitionString cg@2831: translateLabel: true cg@2831: adjust: right cg@2831: ) cg@2831: (InputFieldSpec cg@2831: name: 'EntryField7' cg@2831: layout: (LayoutFrame 117 0 266 0 -122 1 288 0) cg@2831: activeHelpKey: colorDefinitionString cg@2831: model: colorDefinitionStringHolder cg@2831: isReadOnly: true cg@2831: immediateAccept: false cg@2831: acceptOnReturn: true cg@2831: acceptOnTab: true cg@2831: acceptOnLostFocus: true cg@2831: acceptOnPointerLeave: true cg@2831: ) cg@2326: (ActionButtonSpec cg@2326: label: 'Copy Color' cg@2326: name: 'CopyColor' cg@2831: layout: (LayoutFrame 12 0 298 0 100 0 320 0) cg@2326: activeHelpKey: hlsMixer cg@2326: translateLabel: true cg@2326: resizeForLabel: true cg@2326: tabable: true cg@2326: model: copyColor cg@2326: ) cg@2326: (ActionButtonSpec cg@2326: label: 'Paste Color' cg@2326: name: 'PasteColor' cg@2831: layout: (LayoutFrame 108 0 298 0 196 0 320 0) cg@2326: translateLabel: true cg@2326: resizeForLabel: true cg@2326: tabable: true cg@2326: model: pasteColor cg@2326: ) cg@2326: (ActionButtonSpec cg@2326: label: 'pickColorIcon' cg@2326: name: 'Button1' cg@2831: layout: (LayoutFrame 285 0 298 0 312 0 325 0) cg@2326: activeHelpKey: pickColor cg@2326: hasCharacterOrientedLabel: false cg@2326: translateLabel: true cg@2326: resizeForLabel: true cg@2326: tabable: true cg@2326: model: pickColor cg@1840: ) cg@1840: (HorizontalPanelViewSpec cg@1840: name: 'HorizontalPanel1' cg@1840: layout: (LayoutFrame 0 0.0 -32 1 0 1.0 0 1.0) cg@1840: horizontalLayout: fitSpace cg@1840: verticalLayout: centerMax cg@1840: horizontalSpace: 3 cg@1840: verticalSpace: 3 cg@1840: reverseOrderIfOKAtLeft: true cg@1840: component: cg@1840: (SpecCollection cg@1840: collection: ( cg@1840: (ActionButtonSpec cg@1840: label: 'Cancel' cg@1840: name: 'CancelButton' cg@1840: translateLabel: true cg@1840: resizeForLabel: false cg@1840: tabable: true cg@1840: model: cancel cg@1840: useDefaultExtent: true cg@1840: ) cg@1840: (ActionButtonSpec cg@1840: label: 'OK' cg@1840: name: 'OKButton' cg@1840: translateLabel: true cg@1840: resizeForLabel: false cg@1840: tabable: true cg@1840: model: accept cg@1840: isDefault: true cg@1840: defaultable: true cg@1840: useDefaultExtent: true cg@1840: ) cg@1840: ) cg@1840: cg@1840: ) cg@1840: ) cg@1840: ) cg@1840: cg@1840: ) cg@1840: ) cg@1840: ! ! cg@1840: cg@2347: !ColorEditDialog class methodsFor:'startup'! cg@2347: cg@2347: openOn:aColor cg@2347: ^ self new cg@2347: color:aColor; cg@2347: open; cg@2347: yourself cg@2347: cg@2347: " cg@2347: self openOn:Color red cg@2347: " cg@2347: ! ! cg@2347: cg@1840: !ColorEditDialog methodsFor:'accessing'! cg@1840: cg@1840: color sv@2279: |colorName| sv@2279: sv@2279: colorName := self colorName. sv@2279: colorName notEmptyOrNil ifTrue:[ cg@2574: ^ Color name:(colorName asSymbol) sv@2279: ]. cg@2326: ^ Color redByte:(red value) greenByte:(green value) blueByte:(blue value) cg@1840: ! cg@1840: sv@2279: color:aColor sv@2279: aColor isNil ifTrue:[ sv@2279: ^ self sv@2279: ]. sv@2279: sv@2279: aColor isSymbol ifTrue:[ sv@2279: self colorNameHolder value:aColor sv@2279: ] ifFalse:[ cg@1840: self red value:aColor redByte. cg@1840: self green value:aColor greenByte. cg@1840: self blue value:aColor blueByte. cg@1840: ] cg@1840: ! cg@1840: cg@1840: colorName cg@1840: ^ colorNameHolder value cg@2224: ! cg@2224: cg@2574: colorNameOrColor cg@2574: |colorName| cg@2574: cg@2574: colorName := self colorName. cg@2574: colorName notEmptyOrNil ifTrue:[ cg@2574: "/ ^ Color name:(colorName asSymbol) cg@2574: ^ colorName asSymbol cg@2574: ]. cg@2574: ^ Color redByte:(red value) greenByte:(green value) blueByte:(blue value) cg@2574: ! cg@2574: cg@2224: htmlColorName cg@2224: ^ htmlColorNameHolder value cg@1840: ! ! cg@1840: cg@1840: !ColorEditDialog methodsFor:'actions'! cg@1840: cg@1840: colorChanged cg@2831: |clr nm| cg@1840: cg@2574: clr := self colorNameOrColor. sv@2279: clr isColor ifTrue:[ sv@2279: "not a symbol" sv@2279: self setPreview:clr. cg@2326: self htmlColorNameHolder value:(clr htmlPrintString) withoutNotifying:self. cg@2831: cg@2831: nm := #(white red green blue black) detect:[:nm | clr = (Color perform:nm)] ifNone:nil. cg@2831: nm notNil ifTrue:[ cg@2831: self colorDefinitionStringHolder value:('Color ',nm). cg@2831: ] ifFalse:[ cg@2831: self colorDefinitionStringHolder value:('Color rgbValue:16r',(clr rgbValue hexPrintString leftPaddedTo:6 with:$0)). cg@2831: ]. cg@2831: self brightnessStringHolder value:((clr brightness asFixedPoint:3) printString). sv@2279: ]. cg@2831: cg@2831: "Modified: / 27-01-2011 / 12:54:04 / cg" cg@1840: ! cg@1840: cg@2326: colorChangedTo:clr cg@1840: "compute rgb and hls (if possible)" cg@1840: cg@2326: |h| cg@1840: sv@2279: self red value:clr redByte withoutNotifying:self. sv@2279: self green value:clr greenByte withoutNotifying:self. sv@2279: self blue value:clr blueByte withoutNotifying:self. cg@1840: cg@1840: h := clr hue. cg@1840: h notNil ifTrue:[ sv@2279: self hue value:(h rounded) withoutNotifying:self. cg@1840: ]. sv@2279: self light value:(clr light rounded) withoutNotifying:self. sv@2279: self saturation value:(clr saturation rounded) withoutNotifying:self. cg@1840: cg@1840: self colorChanged cg@2831: cg@2831: "Modified: / 27-01-2011 / 12:48:28 / cg" cg@1840: ! cg@1840: cg@2326: colorNameChanged cg@2326: "compute rgb and hls (if possible)" cg@2326: cg@2326: |clr| cg@2326: cg@2326: clr := Color name:colorNameHolder value ifIllegal:nil. cg@2326: clr isNil ifTrue:[ cg@2326: ^ self cg@2326: ]. cg@2326: self colorChangedTo:clr. cg@2326: ! cg@2326: cg@2224: copyColor cg@2224: self window setClipboardObject:self color cg@2224: ! cg@2224: cg@2224: copyColorName cg@2224: self window setClipboardText:self htmlColorName cg@2224: ! cg@2224: cg@1840: hlsSliderChanged cg@1840: "compute rgb" cg@1840: cg@1840: Color withRGBFromHue:hue value light:light value saturation:saturation value do:[:r :g :b | cg@1840: red value:(r * 255 / 100) rounded withoutNotifying:self. cg@1840: green value:(g * 255 / 100) rounded withoutNotifying:self. cg@1840: blue value:(b * 255 / 100) rounded withoutNotifying:self. cg@1840: ]. cg@1840: colorNameHolder value:'' withoutNotifying:self. cg@1840: self colorChanged cg@1840: ! cg@1840: cg@2326: htmlColorNameChanged cg@2326: "compute rgb and hls (if possible)" cg@2326: cg@2326: |clr| cg@2326: sv@2417: htmlColorNameHolder value isEmptyOrNil ifTrue:[ sv@2417: ^ self. sv@2417: ]. sv@2417: cg@2326: clr := Color rgbValue:(Integer cg@2326: readFrom:(htmlColorNameHolder value copyFrom:2) cg@2326: radix:16 cg@2326: onError:nil). cg@2326: clr isNil ifTrue:[ cg@2326: ^ self cg@2326: ]. cg@2326: self colorNameHolder value:'' withoutNotifying:self. cg@2326: self colorChangedTo:clr. cg@2326: ! cg@2326: cg@2224: pasteColor cg@2224: |copyBufferColor| cg@2224: cg@2224: copyBufferColor := self window getClipboardObject. cg@2224: copyBufferColor isColor ifFalse:[ cg@2521: UserPreferences current beepInEditor ifTrue:[ cg@2521: self window beep. cg@2521: ]. cg@2224: ^ self cg@2224: ]. cg@2224: self color:copyBufferColor cg@2224: ! cg@2224: cg@2266: pickColor cg@2266: |color| cg@2266: cg@2266: color := Color fromUserWithFeedBack:[:clr | self setPreview:clr]. cg@2266: color notNil ifTrue:[ cg@2266: self color:color. cg@2266: ] cg@2266: ! cg@2266: cg@1840: rgbSliderChanged cg@1840: "compute hls" cg@1840: cg@1840: |r g b| cg@1840: cg@1840: r := self red value. cg@1840: g := self green value. cg@1840: b := self blue value. cg@1840: cg@1840: Color withHLSFromRed:(r * 100 / 255) green:(g * 100 / 255) blue:(b * 100 / 255) do:[:h :l :s | cg@1840: h isNil ifTrue:[ cg@1840: "/ achromatic cg@1840: ] ifFalse:[ cg@1840: self hue value:(h rounded) withoutNotifying:self. cg@1840: ]. cg@1840: self light value:(l rounded) withoutNotifying:self. cg@1840: self saturation value:(s rounded) withoutNotifying:self. cg@1840: ]. cg@1840: self colorNameHolder value:'' withoutNotifying:self. cg@1840: self colorChanged cg@2266: ! cg@2266: cg@2266: setPreview:color cg@2266: previewBox isNil ifTrue:[^ self "called before setup"]. cg@2266: cg@2266: previewBox backgroundColor:color. cg@2266: previewBox foregroundColor:(color brightness < 0.5 cg@2266: ifTrue:[Color white] cg@2266: ifFalse:[Color black]). cg@1840: ! ! cg@1840: cg@1840: !ColorEditDialog methodsFor:'aspects'! cg@1840: cg@1840: blue cg@1840: blue isNil ifTrue:[ cg@1840: blue := 0 asValue. cg@1840: blue addDependent:self. cg@1840: ]. cg@1840: ^blue cg@1840: ! cg@1840: cg@2831: brightnessStringHolder cg@2831: brightnessStringHolder isNil ifTrue:[ cg@2831: brightnessStringHolder := 0 asValue. cg@2831: "/ brightness addDependent:self. cg@2831: ]. cg@2831: ^ brightnessStringHolder cg@2831: cg@2831: "Created: / 27-01-2011 / 12:48:00 / cg" cg@2831: ! cg@2831: cg@2831: colorDefinitionStringHolder cg@2831: colorDefinitionStringHolder isNil ifTrue:[ cg@2831: colorDefinitionStringHolder := '' asValue. cg@2831: "/ colorDefinitionStringHolder addDependent:self. cg@2831: ]. cg@2831: ^colorDefinitionStringHolder cg@2831: cg@2831: "Created: / 27-01-2011 / 12:38:12 / cg" cg@2831: ! cg@2831: cg@1840: colorNameHolder cg@1840: colorNameHolder isNil ifTrue:[ cg@1840: colorNameHolder := '' asValue. cg@1840: colorNameHolder addDependent:self. cg@1840: ]. cg@1840: ^colorNameHolder cg@1840: ! cg@1840: cg@1840: green cg@1840: green isNil ifTrue:[ cg@1840: green := 0 asValue. cg@1840: green addDependent:self. cg@1840: ]. cg@1840: ^green cg@1840: ! cg@1840: cg@2224: htmlColorNameHolder cg@2224: htmlColorNameHolder isNil ifTrue:[ cg@2224: htmlColorNameHolder := '' asValue. cg@2326: htmlColorNameHolder addDependent:self. cg@2224: ]. cg@2224: ^htmlColorNameHolder cg@2224: ! cg@2224: cg@1840: hue cg@1840: hue isNil ifTrue:[ cg@1840: hue := 0 asValue. cg@1840: hue addDependent:self. cg@1840: ]. cg@1840: ^hue cg@1840: ! cg@1840: cg@1840: light cg@1840: light isNil ifTrue:[ cg@1840: light := 0 asValue. cg@1840: light addDependent:self. cg@1840: ]. cg@1840: ^light cg@1840: ! cg@1840: cg@1840: red cg@1840: red isNil ifTrue:[ cg@1840: red := 0 asValue. cg@1840: red addDependent:self. cg@1840: ]. cg@1840: ^red cg@1840: ! cg@1840: cg@1840: saturation cg@1840: saturation isNil ifTrue:[ cg@1840: saturation := 0 asValue. cg@1840: saturation addDependent:self. cg@1840: ]. cg@1840: ^saturation cg@1840: ! ! cg@1840: cg@1840: !ColorEditDialog methodsFor:'change & update'! cg@1840: cg@1840: update:something with:aParameter from:changedObject cg@1840: (changedObject == red cg@1840: or:[changedObject == green cg@1840: or:[changedObject == blue]]) ifTrue:[ cg@2326: self rgbSliderChanged. cg@2326: ^ self cg@1840: ]. cg@1840: cg@1840: (changedObject == hue cg@1840: or:[changedObject == light cg@1840: or:[changedObject == saturation]]) ifTrue:[ cg@2326: self hlsSliderChanged. cg@2326: ^ self cg@1840: ]. cg@1840: cg@1840: (changedObject == colorNameHolder) ifTrue:[ cg@2326: self colorNameChanged. cg@2326: ^ self cg@2326: ]. cg@2326: (changedObject == htmlColorNameHolder) ifTrue:[ cg@2326: self htmlColorNameChanged. cg@2326: ^ self cg@1840: ]. cg@1840: cg@2326: super update:something with:aParameter from:changedObject cg@1840: ! ! cg@1840: cg@1840: !ColorEditDialog methodsFor:'startup & release'! cg@1840: cg@2266: postBuildPreviewBox:aView cg@2266: previewBox := aView cg@2266: ! cg@2266: cg@1840: postBuildWith:aBuilder cg@1840: super postBuildWith:aBuilder. cg@1840: self colorChanged. cg@1840: cg@1840: "Modified: / 6.9.1998 / 22:55:25 / cg" cg@1840: ! ! cg@1840: cg@1840: !ColorEditDialog class methodsFor:'documentation'! cg@1840: cg@1840: version cg@1840: ^ '$Header$' cg@2831: ! cg@2831: cg@2831: version_CVS cg@2831: ^ '$Header$' cg@1840: ! !