--- a/ColorEditDialog.st Mon Feb 04 10:29:55 2008 +0100
+++ b/ColorEditDialog.st Mon Feb 04 16:00:39 2008 +0100
@@ -13,7 +13,7 @@
SimpleDialog subclass:#ColorEditDialog
instanceVariableNames:'red green blue hue light saturation colorNameHolder
- htmlColorNameHolder'
+ htmlColorNameHolder previewBox'
classVariableNames:''
poolDictionaries:''
category:'Interface-UIPainter'
@@ -56,6 +56,65 @@
"
! !
+!ColorEditDialog class methodsFor:'help specs'!
+
+flyByHelpSpec
+ "This resource specification was automatically generated
+ by the UIHelpTool of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the UIHelpTool may not be able to read the specification."
+
+ "
+ UIHelpTool openOnClass:ColorEditDialog
+ "
+
+ <resource: #help>
+
+ ^ super flyByHelpSpec addPairsFrom:#(
+
+#pickColor
+'Pick a Color from the Screen'
+
+)
+!
+
+helpSpec
+ "This resource specification was automatically generated
+ by the UIHelpTool of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the UIHelpTool may not be able to read the specification."
+
+ "
+ UIHelpTool openOnClass:ColorEditDialog
+ "
+
+ <resource: #help>
+
+ ^ super helpSpec addPairsFrom:#(
+
+#copyToClipboard
+'Copy the color to the clipboard'
+
+#hlsMixer
+'Mix color from hls (hue-light-saturation) components'
+
+#pasteFromClipboard
+'Paste color from the Clipboard'
+
+#rgbMixer
+'Mix color from rgb (red-green-blue) components'
+
+)
+! !
+
+!ColorEditDialog class methodsFor:'image specs'!
+
+pickColorIcon
+ ^ ToolbarIconLibrary pipette16x16Icon
+! !
+
!ColorEditDialog class methodsFor:'interface specs'!
windowSpec
@@ -82,14 +141,14 @@
name: 'Define Color'
min: (Point 440 300)
max: (Point 440 300)
- bounds: (Rectangle 0 0 436 300)
+ bounds: (Rectangle 0 0 440 300)
)
component:
(SpecCollection
collection: (
(VerticalPanelViewSpec
name: 'RGBLabelPanel'
- layout: (LayoutFrame 0 0 0 0 58 0 76 0)
+ layout: (LayoutFrame 0 0 0 0 70 0 76 0)
horizontalLayout: fit
verticalLayout: spreadSpace
horizontalSpace: 3
@@ -124,7 +183,7 @@
)
(VerticalPanelViewSpec
name: 'RGBSliderPanel'
- layout: (LayoutFrame 62 0 0 0 -177 1 76 0)
+ layout: (LayoutFrame 70 0 0 0 -177 1 76 0)
horizontalLayout: fit
verticalLayout: spreadSpace
horizontalSpace: 3
@@ -140,7 +199,7 @@
stop: 255
step: 1
backgroundColor: (Color 100.0 0.0 0.0)
- extent: (Point 197 16)
+ extent: (Point 193 16)
)
(SliderSpec
name: 'GreenSlider'
@@ -150,7 +209,7 @@
stop: 255
step: 1
backgroundColor: (Color 0.0 100.0 0.0)
- extent: (Point 197 16)
+ extent: (Point 193 16)
)
(SliderSpec
name: 'BlueSlider'
@@ -160,7 +219,7 @@
stop: 255
step: 1
backgroundColor: (Color 0.0 0.0 100.0)
- extent: (Point 197 16)
+ extent: (Point 193 16)
)
)
@@ -256,7 +315,7 @@
)
(VerticalPanelViewSpec
name: 'HLSLabelPanel'
- layout: (LayoutFrame 0 0 86 0 58 0 163 0)
+ layout: (LayoutFrame 0 0 86 0 70 0 163 0)
horizontalLayout: fit
verticalLayout: spreadSpace
horizontalSpace: 3
@@ -279,7 +338,7 @@
useDefaultExtent: true
)
(LabelSpec
- label: 'Sat:'
+ label: 'Saturation:'
name: 'Label3'
translateLabel: true
adjust: right
@@ -291,7 +350,7 @@
)
(VerticalPanelViewSpec
name: 'HLSSliderPanel'
- layout: (LayoutFrame 62 0 86 0 -177 1 163 0)
+ layout: (LayoutFrame 70 0 86 0 -177 1 163 0)
horizontalLayout: fit
verticalLayout: spreadSpace
horizontalSpace: 3
@@ -307,7 +366,7 @@
stop: 359
step: 1
keyboardStep: 1
- extent: (Point 197 16)
+ extent: (Point 193 16)
)
(SliderSpec
name: 'Slider2'
@@ -317,7 +376,7 @@
step: 1
backgroundColor: (Color 66.999313344015 66.999313344015 66.999313344015)
keyboardStep: 1
- extent: (Point 197 16)
+ extent: (Point 193 16)
)
(SliderSpec
name: 'Slider3'
@@ -327,7 +386,7 @@
step: 1
backgroundColor: (Color 66.999313344015 66.999313344015 66.999313344015)
keyboardStep: 1
- extent: (Point 197 16)
+ extent: (Point 193 16)
)
)
@@ -378,7 +437,7 @@
)
)
(ViewSpec
- name: 'Box1'
+ name: 'PreviewBoxFrame'
layout: (LayoutFrame -117 1 4 0.0 -3 1.0 -39 1.0)
level: 1
component:
@@ -390,6 +449,7 @@
layout: (LayoutFrame 2 0.0 2 0.0 -2 1.0 -2 1.0)
level: -1
translateLabel: true
+ postBuildCallback: postBuildPreviewBox:
)
)
@@ -468,6 +528,7 @@
label: 'Copy Color'
name: 'CopyColor'
layout: (LayoutFrame 12 0 236 0 100 0 258 0)
+ activeHelpKey: hlsMixer
translateLabel: true
resizeForLabel: true
tabable: true
@@ -482,6 +543,17 @@
tabable: true
model: pasteColor
)
+ (ActionButtonSpec
+ label: 'pickColorIcon'
+ name: 'Button1'
+ layout: (LayoutFrame 285 0 236 0 312 0 263 0)
+ activeHelpKey: pickColor
+ hasCharacterOrientedLabel: false
+ translateLabel: true
+ resizeForLabel: true
+ tabable: true
+ model: pickColor
+ )
)
)
@@ -513,17 +585,10 @@
!ColorEditDialog methodsFor:'actions'!
colorChanged
- |box clr|
-
- box := self componentAt: #PreviewBox.
- box isNil ifTrue:[^ self "called before setup"].
+ |clr|
clr := self color.
- box backgroundColor:clr.
- box foregroundColor:(clr brightness < 0.5
- ifTrue:[Color white]
- ifFalse:[Color black]).
-
+ self setPreview:clr.
self htmlColorNameHolder value:(clr htmlPrintString).
!
@@ -582,6 +647,15 @@
self color:copyBufferColor
!
+pickColor
+ |color|
+
+ color := Color fromUserWithFeedBack:[:clr | self setPreview:clr].
+ color notNil ifTrue:[
+ self color:color.
+ ]
+!
+
rgbSliderChanged
"compute hls"
@@ -602,6 +676,15 @@
].
self colorNameHolder value:'' withoutNotifying:self.
self colorChanged
+!
+
+setPreview:color
+ previewBox isNil ifTrue:[^ self "called before setup"].
+
+ previewBox backgroundColor:color.
+ previewBox foregroundColor:(color brightness < 0.5
+ ifTrue:[Color white]
+ ifFalse:[Color black]).
! !
!ColorEditDialog methodsFor:'aspects'!
@@ -693,6 +776,10 @@
!ColorEditDialog methodsFor:'startup & release'!
+postBuildPreviewBox:aView
+ previewBox := aView
+!
+
postBuildWith:aBuilder
super postBuildWith:aBuilder.
self colorChanged.