diff -r 7cddff46d0ad -r 6ec083adc6bf ColorEditDialog.st --- a/ColorEditDialog.st Tue Jan 08 15:35:12 2008 +0100 +++ b/ColorEditDialog.st Tue Jan 08 21:08:27 2008 +0100 @@ -9,11 +9,11 @@ other person. No title to or ownership of the software is hereby transferred. " - "{ Package: 'stx:libtool2' }" SimpleDialog subclass:#ColorEditDialog - instanceVariableNames:'red green blue hue light saturation colorNameHolder' + instanceVariableNames:'red green blue hue light saturation colorNameHolder + htmlColorNameHolder' classVariableNames:'' poolDictionaries:'' category:'Interface-UIPainter' @@ -66,9 +66,9 @@ the UIPainter may not be able to read the specification." " - UIPainter new openOnClass:ColorEditor andSelector:#windowSpec - ColorEditor new openInterface:#windowSpec - ColorEditor open + UIPainter new openOnClass:ColorEditDialog andSelector:#windowSpec + ColorEditDialog new openInterface:#windowSpec + ColorEditDialog open " @@ -80,9 +80,9 @@ (WindowSpec label: 'Define Color' name: 'Define Color' - min: (Point 340 260) - max: (Point nil 260) - bounds: (Rectangle 0 0 453 260) + min: (Point 440 300) + max: (Point 440 300) + bounds: (Rectangle 0 0 436 300) ) component: (SpecCollection @@ -124,7 +124,7 @@ ) (VerticalPanelViewSpec name: 'RGBSliderPanel' - layout: (LayoutFrame 62 0 0 0 -166 1 76 0) + layout: (LayoutFrame 62 0 0 0 -177 1 76 0) horizontalLayout: fit verticalLayout: spreadSpace horizontalSpace: 3 @@ -140,7 +140,7 @@ stop: 255 step: 1 backgroundColor: (Color 100.0 0.0 0.0) - extent: (Point 225 16) + extent: (Point 197 16) ) (SliderSpec name: 'GreenSlider' @@ -150,7 +150,7 @@ stop: 255 step: 1 backgroundColor: (Color 0.0 100.0 0.0) - extent: (Point 225 16) + extent: (Point 197 16) ) (SliderSpec name: 'BlueSlider' @@ -160,7 +160,7 @@ stop: 255 step: 1 backgroundColor: (Color 0.0 0.0 100.0) - extent: (Point 225 16) + extent: (Point 197 16) ) ) @@ -168,7 +168,7 @@ ) (VerticalPanelViewSpec name: 'RGBFieldPanel' - layout: (LayoutFrame -161 1 0 0 -123 1 76 0) + layout: (LayoutFrame -173 1 0 0 -143 1 76 0) horizontalLayout: fit verticalLayout: spreadSpace horizontalSpace: 3 @@ -184,7 +184,7 @@ minValue: 0 maxValue: 255 acceptOnPointerLeave: false - extent: (Point 38 20) + extent: (Point 30 20) ) (InputFieldSpec name: 'GreenField' @@ -194,7 +194,7 @@ minValue: 0 maxValue: 255 acceptOnPointerLeave: false - extent: (Point 38 20) + extent: (Point 30 20) ) (InputFieldSpec name: 'BlueField' @@ -204,7 +204,51 @@ minValue: 0 maxValue: 255 acceptOnPointerLeave: false - extent: (Point 38 20) + extent: (Point 30 20) + ) + ) + + ) + ) + (VerticalPanelViewSpec + name: 'RGBFieldPanelHex' + layout: (LayoutFrame -141 1 0 0 -121 1 76 0) + horizontalLayout: fit + verticalLayout: spreadSpace + horizontalSpace: 3 + verticalSpace: 3 + component: + (SpecCollection + collection: ( + (InputFieldSpec + name: 'EntryField4' + model: red + type: hexIntegerInRange + numChars: 3 + minValue: 0 + maxValue: 255 + acceptOnPointerLeave: false + extent: (Point 20 20) + ) + (InputFieldSpec + name: 'EntryField5' + model: green + type: hexIntegerInRange + numChars: 3 + minValue: 0 + maxValue: 255 + acceptOnPointerLeave: false + extent: (Point 20 20) + ) + (InputFieldSpec + name: 'EntryField6' + model: blue + type: hexIntegerInRange + numChars: 3 + minValue: 0 + maxValue: 255 + acceptOnPointerLeave: false + extent: (Point 20 20) ) ) @@ -247,7 +291,7 @@ ) (VerticalPanelViewSpec name: 'HLSSliderPanel' - layout: (LayoutFrame 62 0 86 0 -166 1 163 0) + layout: (LayoutFrame 62 0 86 0 -177 1 163 0) horizontalLayout: fit verticalLayout: spreadSpace horizontalSpace: 3 @@ -263,7 +307,7 @@ stop: 359 step: 1 keyboardStep: 1 - extent: (Point 225 16) + extent: (Point 197 16) ) (SliderSpec name: 'Slider2' @@ -271,9 +315,9 @@ model: light orientation: horizontal step: 1 - backgroundColor: (Color 66.9993 66.9993 66.9993) + backgroundColor: (Color 66.999313344015 66.999313344015 66.999313344015) keyboardStep: 1 - extent: (Point 225 16) + extent: (Point 197 16) ) (SliderSpec name: 'Slider3' @@ -281,9 +325,9 @@ model: saturation orientation: horizontal step: 1 - backgroundColor: (Color 66.9993 66.9993 66.9993) + backgroundColor: (Color 66.999313344015 66.999313344015 66.999313344015) keyboardStep: 1 - extent: (Point 225 16) + extent: (Point 197 16) ) ) @@ -291,7 +335,7 @@ ) (VerticalPanelViewSpec name: 'HLSFieldPanel' - layout: (LayoutFrame -161 1 86 0 -123 1 163 0) + layout: (LayoutFrame -173 1 86 0 -143 1 163 0) horizontalLayout: fit verticalLayout: spreadSpace horizontalSpace: 3 @@ -307,7 +351,7 @@ minValue: 0 maxValue: 359 acceptOnPointerLeave: false - extent: (Point 38 20) + extent: (Point 30 20) ) (InputFieldSpec name: 'EntryField2' @@ -317,7 +361,7 @@ minValue: 0 maxValue: 100 acceptOnPointerLeave: false - extent: (Point 38 20) + extent: (Point 30 20) ) (InputFieldSpec name: 'EntryField3' @@ -327,7 +371,7 @@ minValue: 0 maxValue: 100 acceptOnPointerLeave: false - extent: (Point 38 20) + extent: (Point 30 20) ) ) @@ -354,13 +398,13 @@ (LabelSpec label: 'Color Name:' name: 'ColorNameLabel' - layout: (LayoutFrame 0 0 190 0 106 0 212 0) + layout: (LayoutFrame 0 0 176 0 106 0 198 0) translateLabel: true adjust: right ) (InputFieldSpec name: 'ColorNameField' - layout: (LayoutFrame 110 0 190 0 -123 1 212 0) + layout: (LayoutFrame 108 0 176 0 -162 1 198 0) model: colorNameHolder immediateAccept: true acceptOnReturn: true @@ -403,6 +447,41 @@ ) ) + (LabelSpec + label: 'HTML Color Name:' + name: 'HTMLColorNameLabel' + layout: (LayoutFrame 4 0 204 0 110 0 226 0) + translateLabel: true + adjust: right + ) + (InputFieldSpec + name: 'MLHTColorNameFieldField' + layout: (LayoutFrame 108 0 204 0 -162 1 226 0) + model: htmlColorNameHolder + immediateAccept: true + acceptOnReturn: true + acceptOnTab: true + acceptOnLostFocus: true + acceptOnPointerLeave: false + ) + (ActionButtonSpec + label: 'Copy Color' + name: 'CopyColor' + layout: (LayoutFrame 12 0 236 0 100 0 258 0) + translateLabel: true + resizeForLabel: true + tabable: true + model: copyColor + ) + (ActionButtonSpec + label: 'Paste Color' + name: 'PasteColor' + layout: (LayoutFrame 108 0 236 0 196 0 258 0) + translateLabel: true + resizeForLabel: true + tabable: true + model: pasteColor + ) ) ) @@ -425,6 +504,10 @@ colorName ^ colorNameHolder value +! + +htmlColorName + ^ htmlColorNameHolder value ! ! !ColorEditDialog methodsFor:'actions'! @@ -440,6 +523,8 @@ box foregroundColor:(clr brightness < 0.5 ifTrue:[Color white] ifFalse:[Color black]). + + self htmlColorNameHolder value:('#',clr hex). ! colorNameChanged @@ -466,6 +551,14 @@ self colorChanged ! +copyColor + self window setClipboardObject:self color +! + +copyColorName + self window setClipboardText:self htmlColorName +! + hlsSliderChanged "compute rgb" @@ -478,6 +571,17 @@ self colorChanged ! +pasteColor + |copyBufferColor| + + copyBufferColor := self window getClipboardObject. + copyBufferColor isColor ifFalse:[ + self window beep. + ^ self + ]. + self color:copyBufferColor +! + rgbSliderChanged "compute hls" @@ -526,6 +630,13 @@ ^green ! +htmlColorNameHolder + htmlColorNameHolder isNil ifTrue:[ + htmlColorNameHolder := '' asValue. + ]. + ^htmlColorNameHolder +! + hue hue isNil ifTrue:[ hue := 0 asValue.