Index: main/default_images/res/colorslider.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = image/png Index: main/default_images/res/colorslider.png =================================================================== --- main/default_images/res/colorslider.png (revision 1232786) +++ main/default_images/res/colorslider.png (working copy) Property changes on: main/default_images/res/colorslider.png ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* Added: svn:mime-type ## -0,0 +1 ## +image/png Index: main/cui/source/uno/services/makefile.mk =================================================================== --- main/cui/source/uno/services/makefile.mk (revision 0) +++ main/cui/source/uno/services/makefile.mk (working copy) @@ -0,0 +1,39 @@ +#************************************************************** +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +#************************************************************** + +PRJ=..$/..$/.. +PRJNAME=cui +TARGET=services +ENABLE_EXCEPTIONS=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES+=\ + $(SLO)$/services.obj + +# --- Targets ------------------------------------------------------- + +.INCLUDE : target.mk Property changes on: main/cui/source/uno/services/makefile.mk ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* Index: main/cui/source/uno/services/services.cxx =================================================================== --- main/cui/source/uno/services/services.cxx (revision 0) +++ main/cui/source/uno/services/services.cxx (working copy) @@ -0,0 +1,59 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cui.hxx" + +#include +#include "sal/types.h" +#include "cppuhelper/factory.hxx" +#include + +using rtl::OUString; +using namespace com::sun::star; + +namespace cui { +extern rtl::OUString SAL_CALL ColorPicker_getImplementationName(); +extern uno::Reference< uno::XInterface > SAL_CALL ColorPicker_createInstance( uno::Reference< uno::XComponentContext > const & ) SAL_THROW( (uno::Exception) ); +extern uno::Sequence< rtl::OUString > SAL_CALL ColorPicker_getSupportedServiceNames() throw( uno::RuntimeException ); +} + +namespace +{ + + cppu::ImplementationEntry entries[] = { + { &::cui::ColorPicker_createInstance, &::cui::ColorPicker_getImplementationName, &::cui::ColorPicker_getSupportedServiceNames, &cppu::createSingleComponentFactory, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } + }; +} + +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( char const * implName, void * serviceManager, void * registryKey) +{ + return cppu::component_getFactoryHelper(implName, serviceManager, registryKey, entries); +} + + +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment ( const sal_Char ** ppEnvTypeName, uno_Environment ** ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} + +// eof Property changes on: main/cui/source/uno/services/services.cxx ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* Index: main/cui/source/dialogs/colorpicker.src =================================================================== --- main/cui/source/dialogs/colorpicker.src (revision 0) +++ main/cui/source/dialogs/colorpicker.src (working copy) @@ -0,0 +1,482 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +#include "colorpicker.hrc" + +#define DLG_WIDTH 295 +#define DLG_HEIGHT 216 + +#define BUTTON_WIDTH 50 +#define BUTTON_HEIGHT 14 + +#define METRIC_WIDTH 30 +#define METRIC_HEIGHT 12 + +#define RADIO_WIDTH 8 +#define RADIO_HEIGHT 8 + +#define LABEL_WIDTH 50 +#define LABEL_HEIGHT 10 + +#define SLIDER_WIDTH 22 +#define PREVIEW_HEIGHT 16 + +#define LINE_WIDTH (3 + RADIO_WIDTH + 2 + LABEL_WIDTH + 3 + METRIC_WIDTH + 3) +#define LINE_HEIGHT 8 + +#define CONTROL_AREA_X (DLG_WIDTH - LINE_WIDTH - 6) +#define CONTROL_AREA_X_RADIO (CONTROL_AREA_X + 3) +#define CONTROL_AREA_X_LABEL (CONTROL_AREA_X + 3 + RADIO_WIDTH + 2) +#define CONTROL_AREA_X_METRIC (CONTROL_AREA_X + 3 + RADIO_WIDTH + 2 + LABEL_WIDTH + 3) + +#define CHOOSER_SIZE (CONTROL_AREA_X - 6 - SLIDER_WIDTH - 2 - 2 ) + +#define BOTTOMLINE_Y (DLG_HEIGHT - 3 - 3 - 8 - 14) +#define BUTTON_LINE_Y (BOTTOMLINE_Y + 8 + 3) + +#define RGB_Y1 (6 + LINE_HEIGHT + 1) +#define RGB_Y2 (RGB_Y1 + METRIC_HEIGHT + 2) +#define RGB_Y3 (RGB_Y2 + METRIC_HEIGHT + 2) +#define RGB_Y4 (RGB_Y3 + METRIC_HEIGHT + 4) +#define HSB_Y0 (RGB_Y4 + METRIC_HEIGHT + 1) +#define HSB_Y1 (HSB_Y0 + LINE_HEIGHT + 2) +#define HSB_Y2 (HSB_Y1 + METRIC_HEIGHT + 2) +#define HSB_Y3 (HSB_Y2 + METRIC_HEIGHT + 2) +#define CMYK_Y0 (HSB_Y3 + METRIC_HEIGHT + 1) +#define CMYK_Y1 (CMYK_Y0 + LINE_HEIGHT + 1) +#define CMYK_Y2 (CMYK_Y1 + METRIC_HEIGHT + 2) +#define CMYK_Y3 (CMYK_Y2 + METRIC_HEIGHT + 2) +#define CMYK_Y4 (CMYK_Y3 + METRIC_HEIGHT + 2) + + + +ModalDialog RID_CUI_DIALOG_COLORPICKER +{ + HelpID = "cui:ModalDialog:ColorPicker"; + + OutputSize = TRUE ; + SvLook = TRUE ; + Moveable = TRUE ; + Size = MAP_APPFONT ( DLG_WIDTH , DLG_HEIGHT ) ; + + Text [ en-US ] = "Color Picker" ; + + Control CT_COLORFIELD + { + HelpID = "cui:Control:ColorPicker:ColorField"; + Pos = MAP_APPFONT ( 6 , 6 ) ; + Size = MAP_APPFONT ( CHOOSER_SIZE , CHOOSER_SIZE ) ; + Border = TRUE; + TabStop = TRUE ; + }; + + Control CT_COLORSLIDER + { + HelpID = "cui:Control:ColorPicker:ColorSlider"; + Pos = MAP_APPFONT ( CONTROL_AREA_X - 2 - SLIDER_WIDTH + 4 , 6 ) ; + Size = MAP_APPFONT ( SLIDER_WIDTH - 8 , CHOOSER_SIZE ) ; + Border = TRUE; + TabStop = TRUE ; + }; + + Control CT_PREVIEW + { + HelpID = "cui:Control:ColorPicker:ColorPreview"; + Pos = MAP_APPFONT ( 6 , 6 + CHOOSER_SIZE + 3 ) ; + Size = MAP_APPFONT ( CHOOSER_SIZE , PREVIEW_HEIGHT ) ; + Border = FALSE; + }; + + Control CT_PREVIOUS + { + HelpID = "cui:Control:ColorPicker:ColorPrevious"; + Pos = MAP_APPFONT ( 6 + (CHOOSER_SIZE/2), 6 + CHOOSER_SIZE + 3 ) ; + Size = MAP_APPFONT ( CHOOSER_SIZE/2 , PREVIEW_HEIGHT ) ; + Border = FALSE; + Hide = TRUE; + }; + + FixedImage CT_LEFT_SLIDER + { + }; + + FixedImage CT_RIGHT_SLIDER + { + }; + + Image CT_SLIDERIMG + { + ImageBitmap = Bitmap { File = "colorslider.png" ; }; + MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; }; + }; + +#if 0 + ImageButton PB_PICKER + { + HelpID = "cui:ImageButton:ColorPicker:Picker"; + Pos = MAP_APPFONT ( CONTROL_AREA_X - 2 - SLIDER_WIDTH + 4, 6 + CHOOSER_SIZE + 3 ) ; + Size = MAP_APPFONT( SLIDER_WIDTH - 8, PREVIEW_HEIGHT ); + TabStop = TRUE ; + QuickHelpText [ en-US ] = "Pick a color from the document" ; + ButtonImage = Image + { + ImageBitmap = Bitmap { File = "pipette.png" ; }; + MaskColor = Color { Red = 0xFFFF; Green = 0x0000; Blue = 0xFFFF; } ; + }; + }; +#endif + + FixedLine FL_RGB + { + Pos = MAP_APPFONT ( CONTROL_AREA_X , 6 ) ; + Size = MAP_APPFONT ( LINE_WIDTH , LINE_HEIGHT ) ; + Text [ en-US ] = "RGB" ; + }; + + RadioButton CT_RED + { + HelpID = "cui:RadioButton:ColorPicker:Red"; + Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , RGB_Y1+2 ) ; + Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ; + Group = TRUE; + }; + + RadioButton CT_GREEN + { + HelpID = "cui:RadioButton:ColorPicker:Green"; + Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , RGB_Y2+2 ) ; + Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ; + }; + + RadioButton CT_BLUE + { + HelpID = "cui:RadioButton:ColorPicker:Blue"; + Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , RGB_Y3+2 ) ; + Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ; + }; + + RadioButton CT_HUE + { + HelpID = "cui:RadioButton:ColorPicker:Hue"; + Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , HSB_Y1+2 ) ; + Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ; + Check = TRUE ; + }; + + RadioButton CT_SATURATION + { + HelpID = "cui:RadioButton:ColorPicker:Saturation"; + Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , HSB_Y2+2 ) ; + Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ; + }; + + RadioButton CT_BRIGHTNESS + { + HelpID = "cui:RadioButton:ColorPicker:Brightness"; + Pos = MAP_APPFONT ( CONTROL_AREA_X_RADIO , HSB_Y3+2 ) ; + Size = MAP_APPFONT ( RADIO_WIDTH , RADIO_HEIGHT ) ; + }; + + FixedText CT_RED + { + Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , RGB_Y1+1 ) ; + Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ; + Text [ en-US ] = "~Red" ; + }; + + MetricField CT_RED + { + HelpID = "cui:MetricField:ColorPicker:Red"; + Border = TRUE ; + Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , RGB_Y1 ) ; + Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Maximum = 255 ; + Last = 255 ; + }; + + FixedText CT_GREEN + { + Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , RGB_Y2+1 ) ; + Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ; + Text [ en-US ] = "~Green" ; + }; + + MetricField CT_GREEN + { + HelpID = "cui:MetricField:ColorPicker:Green"; + Border = TRUE ; + Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , RGB_Y2 ) ; + Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Maximum = 255 ; + Last = 255 ; + }; + + FixedText CT_BLUE + { + Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , RGB_Y3+1 ) ; + Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ; + Text [ en-US ] = "~Blue" ; + }; + + MetricField CT_BLUE + { + HelpID = "cui:MetricField:ColorPicker:Blue"; + Border = TRUE ; + Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , RGB_Y3 ) ; + Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Maximum = 255 ; + Last = 255 ; + }; + + FixedText CT_HEX + { + Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , RGB_Y4+1 ) ; + Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ; + Text [ en-US ] = "Hex ~#" ; + }; + + Edit CT_HEX + { + HelpID = "cui:MetricField:ColorPicker:Hex"; + Border = TRUE ; + Left = TRUE ; + Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , RGB_Y4 ) ; + Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ; + TabStop = TRUE ; + }; + +// ------------------------------------------------------------------------- +// HSB +// ------------------------------------------------------------------------- + + FixedLine FL_HSB + { + Pos = MAP_APPFONT ( CONTROL_AREA_X , HSB_Y0 ) ; + Size = MAP_APPFONT ( LINE_WIDTH , LINE_HEIGHT ) ; + Text [ en-US ] = "HSB" ; + }; + + FixedText CT_HUE + { + Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , HSB_Y1+1 ) ; + Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ; + Text [ en-US ] = "H~ue" ; + }; + + MetricField CT_HUE + { + HelpID = "cui:MetricField:ColorPicker:Hue"; + Border = TRUE ; + Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , HSB_Y1 ) ; + Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Maximum = 360 ; + Last = 360 ; + Unit = FUNIT_CUSTOM ; + }; + + FixedText CT_SATURATION + { + Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , HSB_Y2+1 ) ; + Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ; + Text [ en-US ] = "~Saturation" ; + }; + + MetricField CT_SATURATION + { + HelpID = "cui:MetricField:ColorPicker:Saturation"; + Border = TRUE ; + Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , HSB_Y2 ) ; + Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Maximum = 100 ; + Last = 100 ; + Unit = FUNIT_CUSTOM ; + CustomUnitText = " %" ; + }; + + FixedText CT_BRIGHTNESS + { + Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , HSB_Y3+1 ) ; + Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ; + Text [ en-US ] = "Bright~ness" ; + }; + + MetricField CT_BRIGHTNESS + { + HelpID = "cui:MetricField:ColorPicker:Brightness"; + Border = TRUE ; + Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , HSB_Y3 ) ; + Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Maximum = 100 ; + Last = 100 ; + Unit = FUNIT_CUSTOM ; + CustomUnitText = " %" ; + }; + +// ------------------------------------------------------------------------- +// CMYK +// ------------------------------------------------------------------------- + + FixedLine FL_CMYK + { + Pos = MAP_APPFONT ( CONTROL_AREA_X , CMYK_Y0 ) ; + Size = MAP_APPFONT ( LINE_WIDTH , LINE_HEIGHT ) ; + Text [ en-US ] = "CMYK" ; + }; + + FixedText CT_CYAN + { + Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , CMYK_Y1+1 ) ; + Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ; + Text [ en-US ] = "~Cyan" ; + }; + + MetricField CT_CYAN + { + HelpID = "cui:MetricField:ColorPicker:Cyan"; + Border = TRUE ; + Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , CMYK_Y1 ) ; + Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Maximum = 100 ; + Last = 100 ; + Unit = FUNIT_CUSTOM ; + CustomUnitText = " %" ; + }; + + FixedText CT_MAGENTA + { + Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , CMYK_Y2+1 ) ; + Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ; + Text [ en-US ] = "~Magenta" ; + }; + + MetricField CT_MAGENTA + { + HelpID = "cui:MetricField:ColorPicker:Magenta"; + Border = TRUE ; + Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , CMYK_Y2 ) ; + Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Maximum = 100 ; + Last = 100 ; + Unit = FUNIT_CUSTOM ; + CustomUnitText = " %" ; + }; + + FixedText CT_YELLOW + { + Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , CMYK_Y3+1 ) ; + Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ; + Text [ en-US ] = "~Yellow" ; + }; + + MetricField CT_YELLOW + { + HelpID = "cui:MetricField:ColorPicker:Yellow"; + Border = TRUE ; + Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , CMYK_Y3 ) ; + Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Maximum = 100 ; + Last = 100 ; + Unit = FUNIT_CUSTOM ; + CustomUnitText = " %" ; + }; + + FixedText CT_KEY + { + Pos = MAP_APPFONT ( CONTROL_AREA_X_LABEL , CMYK_Y4+1 ) ; + Size = MAP_APPFONT ( LABEL_WIDTH , LABEL_HEIGHT ) ; + Text [ en-US ] = "~Key" ; + }; + + MetricField CT_KEY + { + HelpID = "cui:MetricField:ColorPicker:Key"; + Border = TRUE ; + Pos = MAP_APPFONT ( CONTROL_AREA_X_METRIC , CMYK_Y4 ) ; + Size = MAP_APPFONT ( METRIC_WIDTH , METRIC_HEIGHT ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Maximum = 100 ; + Last = 100 ; + Unit = FUNIT_CUSTOM ; + CustomUnitText = " %" ; + }; + + // ------------------------------------------------------ + // bottom buttons + // ------------------------------------------------------ + + FixedLine FT_BOTTOMLINE + { + Pos = MAP_APPFONT ( 0 , BOTTOMLINE_Y ) ; + Size = MAP_APPFONT ( DLG_WIDTH , 8 ) ; + }; + + HelpButton BTN_HELP + { + Pos = MAP_APPFONT ( 3 , BUTTON_LINE_Y ) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + TabStop = TRUE ; + }; + + OKButton BTN_OK + { + Pos = MAP_APPFONT ( DLG_WIDTH - 3 - BUTTON_WIDTH - 3 - BUTTON_WIDTH, BUTTON_LINE_Y ) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + TabStop = TRUE ; + DefButton = TRUE ; + }; + CancelButton BTN_CANCEL + { + Pos = MAP_APPFONT ( DLG_WIDTH - 3 - BUTTON_WIDTH, BUTTON_LINE_Y ) ; + Size = MAP_APPFONT ( BUTTON_WIDTH , BUTTON_HEIGHT ) ; + TabStop = TRUE ; + }; +}; + +// eof Property changes on: main/cui/source/dialogs/colorpicker.src ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* Index: main/cui/source/dialogs/makefile.mk =================================================================== --- main/cui/source/dialogs/makefile.mk (revision 1232786) +++ main/cui/source/dialogs/makefile.mk (working copy) @@ -43,6 +43,7 @@ SRS1NAME=dialogs SRC1FILES = \ about.src \ + colorpicker.src \ charmap.src \ commonlingui.src \ cuiimapdlg.src \ @@ -74,6 +75,7 @@ SLOFILES+=\ $(SLO)$/about.obj \ + $(SLO)$/colorpicker.obj \ $(SLO)$/commonlingui.obj \ $(SLO)$/cuicharmap.obj \ $(SLO)$/cuifmsearch.obj \ Index: main/cui/source/dialogs/colorpicker.hrc =================================================================== --- main/cui/source/dialogs/colorpicker.hrc (revision 0) +++ main/cui/source/dialogs/colorpicker.hrc (working copy) @@ -0,0 +1,63 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +#ifndef _CUI_COLORPICKER_HRC_ +#define _CUI_COLORPICKER_HRC_ + +#include + +#define FT_BOTTOMLINE 1 +#define BTN_OK 2 +#define BTN_CANCEL 3 +#define BTN_HELP 4 + +#define CT_COLORFIELD 5 +#define CT_COLORSLIDER 6 +#define CT_PREVIEW 7 +#define CT_PREVIOUS 8 + +#define FL_RGB 9 +#define CT_RED 10 +#define CT_GREEN 11 +#define CT_BLUE 12 +#define CT_HEX 13 + +#define FL_HSB 14 +#define CT_HUE 15 +#define CT_SATURATION 16 +#define CT_BRIGHTNESS 17 + +#define FL_CMYK 18 +#define CT_CYAN 19 +#define CT_MAGENTA 20 +#define CT_YELLOW 21 +#define CT_KEY 22 + +#define PB_PICKER 23 + +#define CT_LEFT_SLIDER 24 +#define CT_RIGHT_SLIDER 25 + +#define CT_SLIDERIMG 26 + +#endif + +// eof Property changes on: main/cui/source/dialogs/colorpicker.hrc ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* Index: main/cui/source/dialogs/colorpicker.cxx =================================================================== --- main/cui/source/dialogs/colorpicker.cxx (revision 0) +++ main/cui/source/dialogs/colorpicker.cxx (working copy) @@ -0,0 +1,1710 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_cui.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "dialmgr.hxx" +#include "colorpicker.hrc" +#include +#include + +using rtl::OUString; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::ui::dialogs; +using namespace ::com::sun::star::beans; + +namespace cui +{ +const sal_uInt16 COLORMODE_RGB = 0x10; +const sal_uInt16 COLORMODE_HSV = 0x20; +const sal_uInt16 COLORMODE_CMYK = 0x40; + +const sal_uInt16 COLORCOMP_RED = 0x10; +const sal_uInt16 COLORCOMP_GREEN = 0x11; +const sal_uInt16 COLORCOMP_BLUE = 0x12; + +const sal_uInt16 COLORCOMP_HUE = 0x20; +const sal_uInt16 COLORCOMP_SAT = 0x21; +const sal_uInt16 COLORCOMP_BRI = 0x22; + +const sal_uInt16 COLORCOMP_CYAN = 0x40; +const sal_uInt16 COLORCOMP_YELLOW = 0x41; +const sal_uInt16 COLORCOMP_MAGENTA = 0x42; +const sal_uInt16 COLORCOMP_KEY = 0x43; + +// ----------------------------------------------------------------------- +// color space conversion +// RGB = 0 .. 1 +// H = 0 .. 360 +// SV = 0 .. 1 +// CMYK = 0 .. 1 +// ----------------------------------------------------------------------- + +static bool equals( double a, double b ) +{ + return (a == b) || (abs(a-b) < std::numeric_limits::epsilon()); +} + +static void RGBtoHSV( double dR, double dG, double dB, double& dH, double& dS, double& dV ) +{ + // Brightness = max(R, G, B); + dV = std::max( dR, std::max( dG, dB ) ); + + double cDelta = dV - std::min( dR, std::min( dG, dB ) ); + + // Saturation = max - min / max + if( dV > 0 ) + dS = cDelta / dV; + else + dS = 0.0; + + dH = 0.0; + + if( !equals( dS, 0.0 ) ) + { + if( equals( dR, dV ) ) + { + dH = ( dG - dB ) / cDelta; + } + else if( equals( dG, dV ) ) + { + dH = 2.0 + ( dB - dR ) / cDelta; + } + else if ( equals( dB, dV ) ) + { + dH = 4.0 + ( dR - dG ) / cDelta; + } + dH *= 60.0; + + if( dH < 0.0 ) + dH += 360.0; + } +} + +static void HSVtoRGB(double dH, double dS, double dV, double& dR, double& dG, double& dB ) +{ + if( equals( dS, 0.0 ) ) + { + dR = dV; + dG = dV; + dB = dV; + } + else + { + if( equals( dH, 360.0 ) ) + dH = 0.0; + else + dH /= 60.0; + + sal_uInt16 n = (sal_uInt16) dH; + double f = dH - n; + + double a = dV * ( 1.0 - dS ); + double b = dV * ( 1.0 - ( dS * f ) ); + double c = dV * ( 1.0 - ( dS * ( 1.0 - f ) ) ); + + switch( n ) + { + case 0: dR = dV; dG = c; dB = a; break; + case 1: dR = b; dG = dV; dB = a; break; + case 2: dR = a; dG = dV; dB = c; break; + case 3: dR = a; dG = b; dB = dV; break; + case 4: dR = c; dG = a; dB = dV; break; + case 5: dR = dV; dG = a; dB = b; break; + } + } +} + +// ----------------------------------------------------------------------- + +// CMYK values from 0 to 1 +static void CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKey, double& dR, double& dG, double& dB ) +{ + fCyan = (fCyan * ( 1.0 - fKey )) + fKey; + fMagenta = (fMagenta * ( 1.0 - fKey )) + fKey; + fYellow = (fYellow * ( 1.0 - fKey )) + fKey; + + dR = std::max( std::min( ( 1.0 - fCyan ), 1.0), 0.0 ); + dG = std::max( std::min( ( 1.0 - fMagenta ), 1.0), 0.0 ); + dB = std::max( std::min( ( 1.0 - fYellow ), 1.0), 0.0 ); +} + +// ----------------------------------------------------------------------- + +// CMY results from 0 to 1 +static void RGBtoCMYK( double dR, double dG, double dB, double& fCyan, double& fMagenta, double& fYellow, double& fKey ) +{ + fCyan = 1 - dR; + fMagenta = 1 - dG; + fYellow = 1 - dB; + + //CMYK and CMY values from 0 to 1 + fKey = 1.0; + if( fCyan < fKey ) fKey = fCyan; + if( fMagenta < fKey ) fKey = fMagenta; + if( fYellow < fKey ) fKey = fYellow; + + if( equals( fKey, 1.0 ) ) + { + //Black + fCyan = 0.0; + fMagenta = 0.0; + fYellow = 0.0; + } + else + { + fCyan = ( fCyan - fKey ) / ( 1.0 - fKey ); + fMagenta = ( fMagenta - fKey ) / ( 1.0 - fKey ); + fYellow = ( fYellow - fKey ) / ( 1.0 - fKey ); + } +} + +// ==================================================================== + +class HexColorControl : public Edit +{ +public: + HexColorControl( Window* pParent, const ResId& rResId ); + + virtual long PreNotify( NotifyEvent& rNEvt ); + virtual void Paste(); + + void SetColor( sal_Int32 nColor ); + sal_Int32 GetColor(); + +private: + bool ImplProcessKeyInput( const KeyEvent& rKEv ); +}; + +HexColorControl::HexColorControl( Window* pParent, const ResId& rResId ) +: Edit( pParent, rResId ) +{ + SetMaxTextLen( 6 ); +} + +// ----------------------------------------------------------------------- + +void HexColorControl::SetColor( sal_Int32 nColor ) +{ + ::rtl::OUStringBuffer aBuffer; + sax::Converter::convertColor( aBuffer, nColor ); + SetText( aBuffer.makeStringAndClear().copy(1) ); +} + +// ----------------------------------------------------------------------- + +sal_Int32 HexColorControl::GetColor() +{ + sal_Int32 nColor = -1; + + OUString aStr( RTL_CONSTASCII_USTRINGPARAM( "#" ) ); + aStr += GetText(); + sal_Int32 nLen = aStr.getLength(); + if( nLen < 7 ) + { + static const sal_Char* pNullStr = "000000"; + aStr += OUString::createFromAscii( &pNullStr[nLen-1] ); + } + + sax::Converter::convertColor( nColor, aStr ); + + if( nColor == -1 ) + SetControlBackground( Color( COL_RED ) ); + else + SetControlBackground(); + + return nColor; +} + +// ----------------------------------------------------------------------- + +long HexColorControl::PreNotify( NotifyEvent& rNEvt ) +{ + if ( (rNEvt.GetType() == EVENT_KEYINPUT) && !rNEvt.GetKeyEvent()->GetKeyCode().IsMod2() ) + { + if ( ImplProcessKeyInput( *rNEvt.GetKeyEvent() ) ) + return 1; + } + + return Edit::PreNotify( rNEvt ); +} + +// ----------------------------------------------------------------------- + +void HexColorControl::Paste() +{ + ::com::sun::star::uno::Reference aClipboard(GetClipboard()); + if ( aClipboard.is() ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xDataObj; + + const sal_uInt32 nRef = Application::ReleaseSolarMutex(); + + try + { + xDataObj = aClipboard->getContents(); + } + catch( const ::com::sun::star::uno::Exception& ) + { + } + + Application::AcquireSolarMutex( nRef ); + + if ( xDataObj.is() ) + { + ::com::sun::star::datatransfer::DataFlavor aFlavor; + SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor ); + try + { + ::com::sun::star::uno::Any aData = xDataObj->getTransferData( aFlavor ); + ::rtl::OUString aText; + aData >>= aText; + + if( aText.getLength() && aText.matchAsciiL( "#", 1, 0 ) ) + aText = aText.copy(1); + + if( aText.getLength() > 6 ) + aText = aText.copy( 0, 6 ); + + SetText( aText ); + } + catch( const ::com::sun::star::uno::Exception& ) + { + } + } + } +} + +// ----------------------------------------------------------------------- + +bool HexColorControl::ImplProcessKeyInput( const KeyEvent& rKEv ) +{ + const KeyCode& rKeyCode = rKEv.GetKeyCode(); + + if( rKeyCode.GetGroup() == KEYGROUP_ALPHA && !rKeyCode.IsMod1() && !rKeyCode.IsMod2() ) + { + if( (rKeyCode.GetCode() < KEY_A) || (rKeyCode.GetCode() > KEY_F) ) + { + Sound::Beep(); + return true; + } + } + else if( rKeyCode.GetGroup() == KEYGROUP_NUM ) + { + if( rKeyCode.IsShift() ) + { + Sound::Beep(); + return true; + } + } + return false; +} + +// ==================================================================== + +class ColorPreviewControl : public Control +{ +public: + ColorPreviewControl( Window* pParent, const ResId& rResId ); + + virtual void Paint( const Rectangle& rRect ); + + void SetColor( const Color& rColor ); +private: + Color maColor; +}; + +// ----------------------------------------------------------------------- + +ColorPreviewControl::ColorPreviewControl( Window* pParent, const ResId& rResId ) +: Control( pParent, rResId ) +{ + SetFillColor( maColor ); + SetLineColor( maColor ); +} + +// ----------------------------------------------------------------------- + +void ColorPreviewControl::SetColor( const Color& rCol ) +{ + if( rCol != maColor ) + { + maColor = rCol; + SetFillColor( maColor ); + SetLineColor( maColor ); + Invalidate(); + } +} + +// ----------------------------------------------------------------------- + +void ColorPreviewControl::Paint( const Rectangle& rRect ) +{ + DrawRect( rRect ); +} + +// ==================================================================== + +enum ColorMode { HUE, SATURATION, BRIGHTNESS, RED, GREEN, BLUE }; +const ColorMode DefaultMode = HUE; + +class ColorFieldControl : public Control +{ +public: + ColorFieldControl( Window* pParent, const ResId& rResId ); + ~ColorFieldControl(); + + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Resize(); + + void UpdateBitmap(); + void ShowPosition( const Point& rPos, bool bUpdate ); + void UpdatePosition(); + void Modify(); + + void SetValues( Color aColor, ColorMode eMode, double x, double y ); + double GetX(); + double GetY(); + + void KeyMove( int dx, int dy ); + + void SetModifyHdl( Link& rLink ) { maModifyHdl = rLink; } + +private: + Link maModifyHdl; + ColorMode meMode; + Color maColor; + double mdX; + double mdY; + Point maPosition; + Bitmap* mpBitmap; + std::vector< sal_uInt8 > maRGB_Horiz; + std::vector< sal_uInt16 > maGrad_Horiz; + std::vector< sal_uInt16 > maPercent_Horiz; + std::vector< sal_uInt8 > maRGB_Vert; + std::vector< sal_uInt16 > maPercent_Vert; + bool mbInit; +}; + +// ----------------------------------------------------------------------- + +ColorFieldControl::ColorFieldControl( Window* pParent, const ResId& rResId ) +: Control( pParent, rResId ) +, meMode( DefaultMode ) +, mdX( -1.0 ) +, mdY( -1.0 ) +, mpBitmap( 0 ) +, mbInit( false ) +{ + SetControlBackground(); +} + +// ----------------------------------------------------------------------- + +ColorFieldControl::~ColorFieldControl() +{ + delete mpBitmap; +} + +// ----------------------------------------------------------------------- + +void ColorFieldControl::UpdateBitmap() +{ + const Size aSize( GetOutputSizePixel() ); + + if( mpBitmap && mpBitmap->GetSizePixel() != aSize ) + delete mpBitmap, mpBitmap = NULL; + + const sal_Int32 nWidth = aSize.Width(); + const sal_Int32 nHeight = aSize.Height(); + + if( !mpBitmap ) + { + mpBitmap = new Bitmap( aSize, 24 ); + + maRGB_Horiz.resize( nWidth ); + maGrad_Horiz.resize( nWidth ); + maPercent_Horiz.resize( nWidth ); + + sal_uInt8* pRGB = &(*maRGB_Horiz.begin()); + sal_uInt16* pGrad = &(*maGrad_Horiz.begin()); + sal_uInt16* pPercent = &(*maPercent_Horiz.begin()); + + for( sal_Int32 x = 0; x < nWidth; x++ ) + { + *pRGB++ = static_cast< sal_uInt8 >( (x * 256) / nWidth ); + *pGrad++ = static_cast< sal_uInt16 >( (x * 359) / nWidth ); + *pPercent++ = static_cast< sal_uInt16 >( (x * 100) / nWidth ); + } + + maRGB_Vert.resize( nHeight ); + maPercent_Vert.resize( nHeight ); + + pRGB = &(*maRGB_Vert.begin()); + pPercent = &(*maPercent_Vert.begin()); + + sal_Int32 y = nHeight; + while( y-- ) + { + *pRGB++ = static_cast< sal_uInt8 >( (y * 256) / nHeight ); + *pPercent++ = static_cast< sal_uInt16 >( (y * 100) / nHeight ); + } + } + + sal_uInt8* pRGB_Horiz = &(*maRGB_Horiz.begin()); + sal_uInt16* pGrad_Horiz = &(*maGrad_Horiz.begin()); + sal_uInt16* pPercent_Horiz = &(*maPercent_Horiz.begin()); + sal_uInt8* pRGB_Vert = &(*maRGB_Vert.begin()); + sal_uInt16* pPercent_Vert = &(*maPercent_Vert.begin()); + + BitmapWriteAccess* pWriteAccess = mpBitmap->AcquireWriteAccess(); + if( pWriteAccess ) + { + BitmapColor aBitmapColor( maColor ); + + sal_uInt16 nHue, nSat, nBri; + maColor.RGBtoHSB( nHue, nSat, nBri ); + + // this has been unlooped for performance reason, please do not merge back! + + sal_uInt16 y = nHeight,x; + + switch( meMode ) + { + case HUE: + while( y-- ) + { + nBri = pPercent_Vert[y]; + x = nWidth; + while( x-- ) + { + nSat = pPercent_Horiz[x]; + pWriteAccess->SetPixel( y, x, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) ); + } + } + break; + case SATURATION: + while( y-- ) + { + nBri = pPercent_Vert[y]; + x = nWidth; + while( x-- ) + { + nHue = pGrad_Horiz[x]; + pWriteAccess->SetPixel( y, x, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) ); + } + } + break; + case BRIGHTNESS: + while( y-- ) + { + nSat = pPercent_Vert[y]; + x = nWidth; + while( x-- ) + { + nHue = pGrad_Horiz[x]; + pWriteAccess->SetPixel( y, x, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) ); + } + } + break; + case RED: + while( y-- ) + { + aBitmapColor.SetGreen( pRGB_Vert[y] ); + x = nWidth; + while( x-- ) + { + aBitmapColor.SetBlue( pRGB_Horiz[x] ); + pWriteAccess->SetPixel( y, x, aBitmapColor ); + } + } + break; + case GREEN: + while( y-- ) + { + aBitmapColor.SetRed( pRGB_Vert[y] ); + x = nWidth; + while( x-- ) + { + aBitmapColor.SetBlue( pRGB_Horiz[x] ); + pWriteAccess->SetPixel( y, x, aBitmapColor ); + } + } + break; + case BLUE: + while( y-- ) + { + aBitmapColor.SetGreen( pRGB_Vert[y] ); + x = nWidth; + while( x-- ) + { + aBitmapColor.SetRed( pRGB_Horiz[x] ); + pWriteAccess->SetPixel( y, x, aBitmapColor ); + } + } + break; + } + + mpBitmap->ReleaseAccess( pWriteAccess ); + } +} + +// ----------------------------------------------------------------------- + +void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate ) +{ + if( !mpBitmap ) + { + UpdateBitmap(); + Invalidate(); + } + + const Size aSize( mpBitmap->GetSizePixel() ); + + long nX = rPos.X(); + long nY = rPos.Y(); + if( nX < 0L ) + nX = 0L; + else if( nX >= aSize.Width() ) + nX = aSize.Width() - 1L; + + if( nY < 0L ) + nY= 0L; + else if( nY >= aSize.Height() ) + nY = aSize.Height() - 1L; + + Point aPos = maPosition; + maPosition.X() = nX - 5; + maPosition.Y() = nY - 5; + Invalidate( Rectangle( aPos, Size( 11, 11) ) ); + Invalidate( Rectangle( maPosition, Size( 11, 11) ) ); + + if( bUpdate ) + { + mdX = (double)nX / (double)(aSize.Width()-1); + mdY = (double)(aSize.Height()-1-nY) / (double)(aSize.Height()-1); + + BitmapReadAccess* pReadAccess = mpBitmap->AcquireReadAccess(); + if( pReadAccess != NULL ) + { + // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe + maColor = pReadAccess->GetPixel( nY, nX ); + mpBitmap->ReleaseAccess( pReadAccess ); + pReadAccess = NULL; + } + } +} +// ----------------------------------------------------------------------- + +void ColorFieldControl::MouseMove( const MouseEvent& rMEvt ) +{ + if( rMEvt.IsLeft() ) + { + ShowPosition( rMEvt.GetPosPixel(), true ); + Modify(); + } +} + +// ----------------------------------------------------------------------- +void ColorFieldControl::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if( rMEvt.IsLeft() && !rMEvt.IsShift() ) + { + CaptureMouse(); + ShowPosition( rMEvt.GetPosPixel(), true ); + Modify(); + } +} + +// ----------------------------------------------------------------------- +void ColorFieldControl::MouseButtonUp( const MouseEvent& ) +{ + if( IsMouseCaptured() ) + ReleaseMouse(); +} + +// ----------------------------------------------------------------------- + +void ColorFieldControl::KeyMove( int dx, int dy ) +{ + Size aSize( GetOutputSizePixel() ); + Point aPos( mdX * aSize.Width(), (1.0 - mdY) * aSize.Height() ); + aPos.X() += dx; + aPos.Y() += dy; + if( aPos.X() < 0 ) + aPos.X() += aSize.Width(); + else if( aPos.X() >= aSize.Width() ) + aPos.X() -= aSize.Width(); + + if( aPos.Y() < 0 ) + aPos.Y() += aSize.Height(); + else if( aPos.Y() >= aSize.Height() ) + aPos.Y() -= aSize.Height(); + + ShowPosition( aPos, true ); + Modify(); +} + +// ----------------------------------------------------------------------- + +void ColorFieldControl::KeyInput( const KeyEvent& rKEvt ) +{ + bool bShift = rKEvt.GetKeyCode().IsShift(); + bool bCtrl = rKEvt.GetKeyCode().IsMod1(); + bool bAlt = rKEvt.GetKeyCode().IsMod2(); + + if ( !bAlt && !bShift ) + { + switch( rKEvt.GetKeyCode().GetCode() ) + { + case KEY_DOWN: KeyMove( 0, bCtrl ? 5 : 1 ); return; + case KEY_UP: KeyMove( 0, bCtrl ? -5 : -1 ); return; + case KEY_LEFT: KeyMove( bCtrl ? -5 : -1, 0 ); return; + case KEY_RIGHT: KeyMove( bCtrl ? 5 : 1, 0 ); return; + } + } + Control::KeyInput( rKEvt ); +} + +// ----------------------------------------------------------------------- + +void ColorFieldControl::Paint( const Rectangle& rRect ) +{ + if( !mpBitmap ) + UpdateBitmap(); + + Bitmap aOutputBitmap( *mpBitmap ); + + if( GetBitCount() <= 8 ) + aOutputBitmap.Dither(); + + DrawBitmap( rRect.TopLeft(), rRect.GetSize(), rRect.TopLeft(), rRect.GetSize(), aOutputBitmap ); + + // draw circle around current color + if( maColor.IsDark() ) + SetLineColor( COL_WHITE ); + else + SetLineColor( COL_BLACK ); + + SetFillColor(); + + DrawEllipse( Rectangle( maPosition, Size( 11, 11) ) ); +} + +// ----------------------------------------------------------------------- + +void ColorFieldControl::Resize() +{ + UpdateBitmap(); + Control::Resize(); +} + +// ----------------------------------------------------------------------- + +void ColorFieldControl::Modify() +{ + maModifyHdl.Call( this ); +} + +// ----------------------------------------------------------------------- + +void ColorFieldControl::SetValues( Color aColor, ColorMode eMode, double x, double y ) +{ + bool bUpdateBitmap = (maColor!= aColor) || (meMode != eMode); + if( bUpdateBitmap || (mdX != x) || (mdY != y) ) + { + maColor = aColor; + meMode = eMode; + mdX = x; + mdY = y; + + if( bUpdateBitmap ) + UpdateBitmap(); + UpdatePosition(); + if( bUpdateBitmap ) + Invalidate(); + } +} + +// ----------------------------------------------------------------------- + +double ColorFieldControl::GetX() +{ + return mdX; +} + +// ----------------------------------------------------------------------- + +double ColorFieldControl::GetY() +{ + return mdY; +} + +// ----------------------------------------------------------------------- + +void ColorFieldControl::UpdatePosition() +{ + Size aSize( GetOutputSizePixel() ); + ShowPosition( Point( mdX * aSize.Width(), (1.0 - mdY) * aSize.Height() ), false ); +} + +// ==================================================================== + +class ColorSliderControl : public Control +{ +public: + ColorSliderControl( Window* pParent, const ResId& rResId ); + ~ColorSliderControl(); + + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void Paint( const Rectangle& rRect ); + virtual void Resize(); + + void UpdateBitmap(); + void ChangePosition( long nY ); + void Modify(); + + void SetValue( const Color& rColor, ColorMode eMode, double dValue ); + double GetValue() const { return mdValue; } + + void KeyMove( int dy ); + + void SetModifyHdl( Link& rLink ) { maModifyHdl = rLink; } + + sal_Int16 GetLevel() const { return mnLevel; } + +private: + Link maModifyHdl; + Color maColor; + ColorMode meMode; + Bitmap* mpBitmap; + sal_Int16 mnLevel; + double mdValue; +}; + +// ----------------------------------------------------------------------- + +ColorSliderControl::ColorSliderControl( Window* pParent, const ResId& rResId ) +: Control( pParent, rResId ) +, meMode( DefaultMode ) +, mpBitmap( 0 ) +, mnLevel( 0 ) +, mdValue( -1.0 ) +{ + SetControlBackground(); +} + +// ----------------------------------------------------------------------- + +ColorSliderControl::~ColorSliderControl() +{ + delete mpBitmap; +} + +// ----------------------------------------------------------------------- + +void ColorSliderControl::UpdateBitmap() +{ + Size aSize( 1, GetOutputSizePixel().Height() ); + + if( mpBitmap && mpBitmap->GetSizePixel() != aSize ) + delete mpBitmap, mpBitmap = NULL; + + if( !mpBitmap ) + mpBitmap = new Bitmap( aSize, 24 ); + + BitmapWriteAccess* pWriteAccess = mpBitmap->AcquireWriteAccess(); + + if( pWriteAccess ) + { + const long nY = aSize.Height()-1; + + BitmapColor aBitmapColor( maColor ); + + sal_uInt16 nHue, nSat, nBri; + maColor.RGBtoHSB( nHue, nSat, nBri ); + + // this has been unlooped for performance reason, please do not merge back! + + switch( meMode ) + { + case HUE: + nSat = 100; + nBri = 100; + for( long y = 0; y <= nY; y++ ) + { + nHue = static_cast< sal_uInt16 >( (359 * y) / nY ); + aBitmapColor = BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ); + pWriteAccess->SetPixel( nY-y, 0, aBitmapColor ); + } + break; + + case SATURATION: + nBri = std::max( (sal_uInt16)32, nBri ); + for( long y = 0; y <= nY; y++ ) + { + nSat = static_cast< sal_uInt16 >( (100 * y) / nY ); + pWriteAccess->SetPixel( nY-y, 0, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) ); + } + break; + + case BRIGHTNESS: + for( long y = 0; y <= nY; y++ ) + { + nBri = static_cast< sal_uInt16 >( (100 * y) / nY ); + pWriteAccess->SetPixel( nY-y, 0, BitmapColor( Color( Color::HSBtoRGB( nHue, nSat, nBri ) ) ) ); + } + break; + + case RED: + for( long y = 0; y <= nY; y++ ) + { + aBitmapColor.SetRed( sal_uInt8( ((long)255 * y) / nY ) ); + pWriteAccess->SetPixel( nY-y, 0, aBitmapColor ); + } + break; + + case GREEN: + for( long y = 0; y <= nY; y++ ) + { + aBitmapColor.SetGreen( sal_uInt8( ((long)255 * y) / nY ) ); + pWriteAccess->SetPixel( nY-y, 0, aBitmapColor ); + } + break; + + case BLUE: + for( long y = 0; y <= nY; y++ ) + { + aBitmapColor.SetBlue( sal_uInt8( ((long)255 * y) / nY ) ); + pWriteAccess->SetPixel( nY-y, 0, aBitmapColor ); + } + break; + } + + mpBitmap->ReleaseAccess( pWriteAccess ); + } +} + +// ----------------------------------------------------------------------- + +void ColorSliderControl::ChangePosition( long nY ) +{ + const long nHeight = GetOutputSizePixel().Height() - 1; + + if( nY < 0L ) + nY = 0; + else if( nY > nHeight ) + nY = nHeight; + + mnLevel = nY; + mdValue = ((double)(nHeight - nY)) / (double)nHeight; +} + +// ----------------------------------------------------------------------- + +void ColorSliderControl::MouseMove( const MouseEvent& rMEvt ) +{ + if( rMEvt.IsLeft() ) + { + ChangePosition( rMEvt.GetPosPixel().Y() ); + Modify(); + } +} + +// ----------------------------------------------------------------------- +void ColorSliderControl::MouseButtonDown( const MouseEvent& rMEvt ) +{ + if( rMEvt.IsLeft() && !rMEvt.IsShift() ) + { + CaptureMouse(); + ChangePosition( rMEvt.GetPosPixel().Y() ); + Modify(); + } +} + +// ----------------------------------------------------------------------- +void ColorSliderControl::MouseButtonUp( const MouseEvent& ) +{ + if( IsMouseCaptured() ) + ReleaseMouse(); +} + +// ----------------------------------------------------------------------- + +void ColorSliderControl::KeyMove( int dy ) +{ + ChangePosition( mnLevel + dy ); + Modify(); +} + +// ----------------------------------------------------------------------- + +void ColorSliderControl::KeyInput( const KeyEvent& rKEvt ) +{ + if ( !rKEvt.GetKeyCode().IsMod2() && !rKEvt.GetKeyCode().IsShift() ) + { + switch( rKEvt.GetKeyCode().GetCode() ) + { + case KEY_DOWN: KeyMove( rKEvt.GetKeyCode().IsMod1() ? 5 : 1 ); return; + case KEY_UP: KeyMove( rKEvt.GetKeyCode().IsMod1() ? -5 : -1 ); return; + } + } + + Control::KeyInput( rKEvt ); +} +// ----------------------------------------------------------------------- + +void ColorSliderControl::Paint( const Rectangle& /*rRect*/ ) +{ + if( !mpBitmap ) + UpdateBitmap(); + + const Size aSize( GetOutputSizePixel() ); + + Bitmap aOutputBitmap( *mpBitmap ); + + if( GetBitCount() <= 8 ) + aOutputBitmap.Dither(); + + Point aPos; + int x = aSize.Width(); + while( x-- ) + { + DrawBitmap( aPos, aOutputBitmap ); + aPos.X() += 1; + } +} + +// ----------------------------------------------------------------------- + +void ColorSliderControl::Resize() +{ + UpdateBitmap(); + Control::Resize(); +} + +// ----------------------------------------------------------------------- + +void ColorSliderControl::Modify() +{ + maModifyHdl.Call( this ); +} + +// ----------------------------------------------------------------------- + +void ColorSliderControl::SetValue( const Color& rColor, ColorMode eMode, double dValue ) +{ + bool bUpdateBitmap = (rColor != maColor) || (eMode != meMode); + if( bUpdateBitmap || (mdValue != dValue)) + { + maColor = rColor; + mdValue = dValue; + mnLevel = (1.0-dValue) * GetOutputSizePixel().Height(); + meMode = eMode; + if( bUpdateBitmap ) + UpdateBitmap(); + Invalidate(); + } +} + +// ==================================================================== + +const sal_uInt16 UPDATE_RGB = 0x01; +const sal_uInt16 UPDATE_CMYK = 0x02; +const sal_uInt16 UPDATE_HSB = 0x04; +const sal_uInt16 UPDATE_COLORCHOOSER = 0x08; +const sal_uInt16 UPDATE_COLORSLIDER = 0x10; +const sal_uInt16 UPDATE_HEX = 0x20; +const sal_uInt16 UPDATE_ALL = 0xff; + +class ColorPickerDialog : public ModalDialog +{ +public: + ColorPickerDialog( Window* pParent, sal_Int32 nColor, sal_Int16 nMode ); + + void update_color( sal_uInt16 n = UPDATE_ALL ); + + DECL_LINK( ColorModifyHdl, void * ); + DECL_LINK( ModeModifyHdl, void * ); + + sal_Int32 GetColor() const; + + void setColorComponent( sal_uInt16 nComp, double dValue ); + +private: + Color maPreviousColor; + sal_Int16 mnDialogMode; + ColorMode meMode; + + double mdRed, mdGreen, mdBlue; + double mdHue, mdSat, mdBri; + double mdCyan, mdMagenta, mdYellow, mdKey; + +private: + ColorFieldControl maColorField; + ColorSliderControl maColorSlider; + ColorPreviewControl maColorPreview; + ColorPreviewControl maColorPrevious; + + FixedImage maFISliderLeft; + FixedImage maFISliderRight; + Image maSliderImage; + +#if 0 + ImageButton maBtnPicker; +#endif + + FixedLine maFLRGB; + + RadioButton maRBRed; + RadioButton maRBGreen; + RadioButton maRBBlue; + RadioButton maRBHue; + RadioButton maRBSaturation; + RadioButton maRBBrightness; + + FixedText maFTRed; + MetricField maMFRed; + FixedText maFTGreen; + MetricField maMFGreen; + FixedText maFTBlue; + MetricField maMFBlue; + FixedText maFTHex; + HexColorControl maEDHex; + + FixedLine maFLHSB; + FixedText maFTHue; + MetricField maMFHue; + FixedText maFTSaturation; + MetricField maMFSaturation; + FixedText maFTBrightness; + MetricField maMFBrightness; + + FixedLine maFLCMYK; + FixedText maFTCyan; + MetricField maMFCyan; + FixedText maFTMagenta; + MetricField maMFMagenta; + FixedText maFTYellow; + MetricField maMFYellow; + FixedText maFTKey; + MetricField maMFKey; + + FixedLine maFLBottmLine; + HelpButton maBTNHelp; + OKButton maBTNOk; + CancelButton maBTNCancel; +}; + +// -------------------------------------------------------------------- + +ColorPickerDialog::ColorPickerDialog( Window* pParent, sal_Int32 nColor, sal_Int16 nMode ) +: ModalDialog( pParent, CUI_RES( RID_CUI_DIALOG_COLORPICKER ) ) +, maPreviousColor( nColor ) +, mnDialogMode( nMode ) +, meMode( DefaultMode ) +, maColorField( this, CUI_RES( CT_COLORFIELD ) ) +, maColorSlider( this, CUI_RES( CT_COLORSLIDER ) ) +, maColorPreview( this, CUI_RES( CT_PREVIEW ) ) +, maColorPrevious( this, CUI_RES( CT_PREVIOUS ) ) +, maFISliderLeft( this, CUI_RES( CT_LEFT_SLIDER ) ) +, maFISliderRight( this, CUI_RES( CT_RIGHT_SLIDER ) ) +, maSliderImage( CUI_RES( CT_SLIDERIMG ) ) +#if 0 +, maBtnPicker( this, CUI_RES( PB_PICKER ) ) +#endif +, maFLRGB( this, CUI_RES( FL_RGB ) ) +, maRBRed( this, CUI_RES( CT_RED ) ) +, maRBGreen( this, CUI_RES( CT_GREEN ) ) +, maRBBlue( this, CUI_RES( CT_BLUE ) ) +, maRBHue( this, CUI_RES( CT_HUE ) ) +, maRBSaturation( this, CUI_RES( CT_SATURATION ) ) +, maRBBrightness( this, CUI_RES( CT_BRIGHTNESS ) ) +, maFTRed( this, CUI_RES( CT_RED ) ) +, maMFRed( this, CUI_RES( CT_RED ) ) +, maFTGreen( this, CUI_RES( CT_GREEN ) ) +, maMFGreen( this, CUI_RES( CT_GREEN ) ) +, maFTBlue( this, CUI_RES( CT_BLUE ) ) +, maMFBlue( this, CUI_RES( CT_BLUE ) ) +, maFTHex( this, CUI_RES( CT_HEX ) ) +, maEDHex( this, CUI_RES( CT_HEX ) ) +, maFLHSB( this, CUI_RES( FL_HSB ) ) +, maFTHue( this, CUI_RES( CT_HUE ) ) +, maMFHue( this, CUI_RES( CT_HUE ) ) +, maFTSaturation( this, CUI_RES( CT_SATURATION ) ) +, maMFSaturation( this, CUI_RES( CT_SATURATION ) ) +, maFTBrightness( this, CUI_RES( CT_BRIGHTNESS ) ) +, maMFBrightness( this, CUI_RES( CT_BRIGHTNESS ) ) +, maFLCMYK( this, CUI_RES( FL_CMYK ) ) +, maFTCyan( this, CUI_RES( CT_CYAN ) ) +, maMFCyan( this, CUI_RES( CT_CYAN ) ) +, maFTMagenta( this, CUI_RES( CT_MAGENTA ) ) +, maMFMagenta( this, CUI_RES( CT_MAGENTA ) ) +, maFTYellow( this, CUI_RES( CT_YELLOW ) ) +, maMFYellow( this, CUI_RES( CT_YELLOW ) ) +, maFTKey( this, CUI_RES( CT_KEY ) ) +, maMFKey( this, CUI_RES( CT_KEY ) ) + +, maFLBottmLine( this, CUI_RES( FT_BOTTOMLINE ) ) +, maBTNHelp( this, CUI_RES( BTN_HELP ) ) +, maBTNOk( this, CUI_RES( BTN_OK ) ) +, maBTNCancel( this, CUI_RES( BTN_CANCEL ) ) +{ + FreeResource(); + + String sUnitText; + sUnitText.Append( ' ' ); + sUnitText.Append( (sal_Unicode) 0xb0 ); + + maMFHue.SetCustomUnitText( sUnitText ); + + Link aLink( LINK( this, ColorPickerDialog, ColorModifyHdl ) ); + maColorField.SetModifyHdl( aLink ); + maColorSlider.SetModifyHdl( aLink ); + + maMFRed.SetModifyHdl( aLink ); + maMFGreen.SetModifyHdl( aLink ); + maMFBlue.SetModifyHdl( aLink ); + + maMFCyan.SetModifyHdl( aLink ); + maMFMagenta.SetModifyHdl( aLink ); + maMFYellow.SetModifyHdl( aLink ); + maMFKey.SetModifyHdl( aLink ); + + maMFHue.SetModifyHdl( aLink ); + maMFSaturation.SetModifyHdl( aLink ); + maMFBrightness.SetModifyHdl( aLink ); + + maEDHex.SetModifyHdl( aLink ); + + aLink = LINK( this, ColorPickerDialog, ModeModifyHdl ); + maRBRed.SetToggleHdl( aLink ); + maRBGreen.SetToggleHdl( aLink ); + maRBBlue.SetToggleHdl( aLink ); + maRBHue.SetToggleHdl( aLink ); + maRBSaturation.SetToggleHdl( aLink ); + maRBBrightness.SetToggleHdl( aLink ); + + Image aSliderImage( maSliderImage ); + + maFISliderLeft.SetImage( aSliderImage ); + + BitmapEx aTmpBmp( maSliderImage.GetBitmapEx() ); + aTmpBmp.Mirror( BMP_MIRROR_HORZ ); + maFISliderRight.SetImage( Image( aTmpBmp ) ); + + Size aSize( maSliderImage.GetSizePixel() ); + maFISliderLeft.SetSizePixel( aSize ); + maFISliderRight.SetSizePixel( aSize ); + + Point aPos( maColorSlider.GetPosPixel() ); + + aPos.X() -= aSize.Width(); + aPos.Y() -= aSize.Height() / 2; + maFISliderLeft.SetPosPixel( aPos ); + + aPos.X() += aSize.Width() + maColorSlider.GetSizePixel().Width(); + maFISliderRight.SetPosPixel( aPos ); + + Color aColor( nColor ); + + // modify + if( mnDialogMode == 2 ) + { + maColorPreview.SetSizePixel( maColorPrevious.GetSizePixel() ); + maColorPrevious.SetColor( aColor ); + maColorPrevious.Show( true ); + } + + mdRed = ((double)aColor.GetRed()) / 255.0; + mdGreen = ((double)aColor.GetGreen()) / 255.0; + mdBlue = ((double)aColor.GetBlue()) / 255.0; + + RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri ); + RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey ); + + update_color(); +} + +// -------------------------------------------------------------------- + +static int toInt( double dValue, double bRange ) +{ + return static_cast< int >( std::floor((dValue * bRange) + 0.5 ) ); +} + +sal_Int32 ColorPickerDialog::GetColor() const +{ + return Color( toInt(mdRed,255.0), toInt(mdGreen,255.0), toInt(mdBlue,255.0) ).GetColor(); +} + +void ColorPickerDialog::update_color( sal_uInt16 n ) +{ + sal_uInt8 nRed = toInt(mdRed,255.0); + sal_uInt8 nGreen = toInt(mdGreen,255.0); + sal_uInt8 nBlue = toInt(mdBlue,255.0); + + Color aColor( nRed, nGreen, nBlue ); + + if( n & UPDATE_RGB ) // update RGB + { + maMFRed.SetValue( nRed ); + maMFGreen.SetValue( nGreen ); + maMFBlue.SetValue( nBlue ); + } + + if( n & UPDATE_CMYK ) // update CMYK + { + maMFCyan.SetValue( toInt( mdCyan, 100.0 ) ); + maMFMagenta.SetValue( toInt( mdMagenta, 100.0 ) ); + maMFYellow.SetValue( toInt( mdYellow, 100.0 ) ); + maMFKey.SetValue( toInt( mdKey, 100.0 ) ); + } + + if( n & UPDATE_HSB ) // update HSB + { + maMFHue.SetValue( toInt( mdHue, 1.0 ) ); + maMFSaturation.SetValue( toInt( mdSat, 100.0 ) ); + maMFBrightness.SetValue( toInt( mdBri, 100.0 ) ); + } + + if( n & UPDATE_COLORCHOOSER ) // update Color Chooser 1 + { + switch( meMode ) + { + case HUE: maColorField.SetValues( aColor, meMode, mdSat, mdBri ); break; + case SATURATION: maColorField.SetValues( aColor, meMode, mdHue / 360.0, mdBri ); break; + case BRIGHTNESS: maColorField.SetValues( aColor, meMode, mdHue / 360.0, mdSat ); break; + case RED: maColorField.SetValues( aColor, meMode, mdBlue, mdGreen ); break; + case GREEN: maColorField.SetValues( aColor, meMode, mdBlue, mdRed ); break; + case BLUE: maColorField.SetValues( aColor, meMode, mdRed, mdGreen ); break; + } + } + + if( n & UPDATE_COLORSLIDER ) // update Color Chooser 2 + { + switch( meMode ) + { + case HUE: maColorSlider.SetValue( aColor, meMode, mdHue / 360.0 ); break; + case SATURATION: maColorSlider.SetValue( aColor, meMode, mdSat ); break; + case BRIGHTNESS: maColorSlider.SetValue( aColor, meMode, mdBri ); break; + case RED: maColorSlider.SetValue( aColor, meMode, mdRed ); break; + case GREEN: maColorSlider.SetValue( aColor, meMode, mdGreen ); break; + case BLUE: maColorSlider.SetValue( aColor, meMode, mdBlue ); break; + } + } + + if( n & UPDATE_HEX ) // update hex + { + maEDHex.SetColor( aColor.GetColor() ); + } + + { + Point aPos( 0, maColorSlider.GetLevel() + maColorSlider.GetPosPixel().Y() - 1 ); + + aPos.X() = maFISliderLeft.GetPosPixel().X(); + if( aPos != maFISliderLeft.GetPosPixel() ) + { + maFISliderLeft.SetPosPixel( aPos ); + + aPos.X() = maFISliderRight.GetPosPixel().X(); + maFISliderRight.SetPosPixel( aPos ); + } + } + + maColorPreview.SetColor( aColor ); +} + +// -------------------------------------------------------------------- + +IMPL_LINK( ColorPickerDialog, ColorModifyHdl, void *, p ) +{ + sal_uInt16 n = 0; + + if( p == &maColorField ) + { + double x = maColorField.GetX(); + double y = maColorField.GetY(); + + switch( meMode ) + { + case HUE: mdSat = x; setColorComponent( COLORCOMP_BRI, y ); break; + case SATURATION: mdHue = x * 360.0; setColorComponent( COLORCOMP_BRI, y ); break; + case BRIGHTNESS: mdHue = x * 360.0; setColorComponent( COLORCOMP_SAT, y ); break; + case RED: mdBlue = x; setColorComponent( COLORCOMP_GREEN, y ); break; + case GREEN: mdBlue = x; setColorComponent( COLORCOMP_RED, y ); break; + case BLUE: mdRed = x; setColorComponent( COLORCOMP_GREEN, y ); break; + } + + n = UPDATE_ALL&~(UPDATE_COLORCHOOSER); + } + else if( p == &maColorSlider ) + { + double dValue = maColorSlider.GetValue(); + switch( meMode ) + { + case HUE: setColorComponent( COLORCOMP_HUE, dValue * 360.0 ); break; + case SATURATION: setColorComponent( COLORCOMP_SAT, dValue ); break; + case BRIGHTNESS: setColorComponent( COLORCOMP_BRI, dValue ); break; + case RED: setColorComponent( COLORCOMP_RED, dValue ); break; + case GREEN: setColorComponent( COLORCOMP_GREEN, dValue ); break; + case BLUE: setColorComponent( COLORCOMP_BLUE, dValue ); break; + } + + n = UPDATE_ALL&~(UPDATE_COLORSLIDER); + } + else if( p == &maMFRed ) + { + setColorComponent( COLORCOMP_RED, ((double)maMFRed.GetValue()) / 255.0 ); + n = UPDATE_ALL&~(UPDATE_RGB); + } + else if( p == &maMFGreen ) + { + setColorComponent( COLORCOMP_GREEN, ((double)maMFGreen.GetValue()) / 255.0 ); + n = UPDATE_ALL&~(UPDATE_RGB); + } + else if( p == &maMFBlue ) + { + setColorComponent( COLORCOMP_BLUE, ((double)maMFBlue.GetValue()) / 255.0 ); + n = UPDATE_ALL&~(UPDATE_RGB); + } + else if( p == &maMFHue ) + { + setColorComponent( COLORCOMP_HUE, (double)maMFHue.GetValue() ); + n = UPDATE_ALL&~(UPDATE_HSB); + } + else if( p == &maMFSaturation ) + { + setColorComponent( COLORCOMP_SAT, ((double)maMFSaturation.GetValue()) / 100.0 ); + n = UPDATE_ALL&~(UPDATE_HSB); + } + else if( p == &maMFBrightness ) + { + setColorComponent( COLORCOMP_BRI, ((double)maMFBrightness.GetValue()) / 100.0 ); + n = UPDATE_ALL&~(UPDATE_HSB); + } + else if( p == &maMFCyan ) + { + setColorComponent( COLORCOMP_CYAN, ((double)maMFCyan.GetValue()) / 100.0 ); + n = UPDATE_ALL&~(UPDATE_CMYK); + } + else if( p == &maMFMagenta ) + { + setColorComponent( COLORCOMP_MAGENTA, ((double)maMFMagenta.GetValue()) / 100.0 ); + n = UPDATE_ALL&~(UPDATE_CMYK); + } + else if( p == &maMFYellow ) + { + setColorComponent( COLORCOMP_YELLOW, ((double)maMFYellow.GetValue()) / 100.0 ); + n = UPDATE_ALL&~(UPDATE_CMYK); + } + else if( p == &maMFKey ) + { + setColorComponent( COLORCOMP_KEY, ((double)maMFKey.GetValue()) / 100.0 ); + n = UPDATE_ALL&~(UPDATE_CMYK); + } + else if( p == &maEDHex ) + { + sal_Int32 nColor = maEDHex.GetColor(); + + if( nColor != -1 ) + { + Color aColor( nColor ); + + if( aColor != GetColor() ) + { + mdRed = ((double)aColor.GetRed()) / 255.0; + mdGreen = ((double)aColor.GetRed()) / 255.0; + mdBlue = ((double)aColor.GetRed()) / 255.0; + + RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri ); + RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey ); + n = UPDATE_ALL&~(UPDATE_HEX); + } + } + } + + if( n ) + update_color( n ); + + return 0; +} + +// -------------------------------------------------------------------- + +IMPL_LINK( ColorPickerDialog, ModeModifyHdl, void *, EMPTYARG ) +{ + ColorMode eMode = HUE; + + if( maRBRed.IsChecked() ) + { + eMode = RED; + } + else if( maRBGreen.IsChecked() ) + { + eMode = GREEN; + } + else if( maRBBlue.IsChecked() ) + { + eMode = BLUE; + } + else if( maRBSaturation.IsChecked() ) + { + eMode = SATURATION; + } + else if( maRBBrightness.IsChecked() ) + { + eMode = BRIGHTNESS; + } + + if( meMode != eMode ) + { + meMode = eMode; + update_color( UPDATE_COLORCHOOSER | UPDATE_COLORSLIDER ); + } + + return 0; +} + +// -------------------------------------------------------------------- + +void ColorPickerDialog::setColorComponent( sal_uInt16 nComp, double dValue ) +{ + switch( nComp ) + { + case COLORCOMP_RED: mdRed = dValue; break; + case COLORCOMP_GREEN: mdGreen = dValue; break; + case COLORCOMP_BLUE: mdBlue = dValue; break; + case COLORCOMP_HUE: mdHue = dValue; break; + case COLORCOMP_SAT: mdSat = dValue; break; + case COLORCOMP_BRI: mdBri = dValue; break; + case COLORCOMP_CYAN: mdCyan = dValue; break; + case COLORCOMP_YELLOW: mdYellow = dValue; break; + case COLORCOMP_MAGENTA: mdMagenta = dValue; break; + case COLORCOMP_KEY: mdKey = dValue; break; + } + + if( nComp & COLORMODE_RGB ) + { + RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri ); + RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey ); + } + else if( nComp & COLORMODE_HSV ) + { + HSVtoRGB( mdHue, mdSat, mdBri, mdRed, mdGreen, mdBlue ); + RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey ); + } + else + { + CMYKtoRGB( mdCyan, mdMagenta, mdYellow, mdKey, mdRed, mdGreen, mdBlue ); + RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri ); + } +} + +// -------------------------------------------------------------------- + +typedef ::cppu::WeakComponentImplHelper4< XServiceInfo, XExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase; + +class ColorPicker : protected ::comphelper::OBaseMutex, // Struct for right initalization of mutex member! Must be first of baseclasses. + public ColorPickerBase +{ +public: + ColorPicker( Reference< XComponentContext > const & xContext ); + + // XInitialization + virtual void SAL_CALL initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException); + + // XInitialization + virtual OUString SAL_CALL getImplementationName( ) throw (RuntimeException); + virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw (RuntimeException); + virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw (RuntimeException); + + // XPropertyAccess + virtual Sequence< PropertyValue > SAL_CALL getPropertyValues( ) throw (RuntimeException); + virtual void SAL_CALL setPropertyValues( const Sequence< PropertyValue >& aProps ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException); + + // XExecutableDialog + virtual void SAL_CALL setTitle( const OUString& aTitle ) throw (RuntimeException); + virtual sal_Int16 SAL_CALL execute( ) throw (RuntimeException); + +private: + Reference< XComponentContext > mxContext; + OUString msTitle; + const OUString msColorKey; + const OUString msModeKey; + sal_Int32 mnColor; + sal_Int16 mnMode; + Reference< ::com::sun::star::awt::XWindow > mxParent; +}; + +// -------------------------------------------------------------------- + +OUString SAL_CALL ColorPicker_getImplementationName() +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.cui.ColorPicker" ) ); +} + +// -------------------------------------------------------------------- + +Reference< XInterface > SAL_CALL ColorPicker_createInstance( Reference< XComponentContext > const & xContext ) SAL_THROW( (Exception) ) +{ + return static_cast( new ColorPicker( xContext ) ); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL ColorPicker_getSupportedServiceNames() throw( RuntimeException ) +{ + Sequence< OUString > seq(1); + seq[0] = OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.ColorPicker" ) ); + return seq; +} + +// -------------------------------------------------------------------- + +ColorPicker::ColorPicker( Reference< XComponentContext > const & xContext ) +: ColorPickerBase( m_aMutex ) +, mxContext( xContext ) +, msColorKey( RTL_CONSTASCII_USTRINGPARAM( "Color" ) ) +, msModeKey( RTL_CONSTASCII_USTRINGPARAM( "Mode" ) ) +, mnColor( 0 ) +, mnMode( 0 ) +{ +} + +// -------------------------------------------------------------------- + +// XInitialization +void SAL_CALL ColorPicker::initialize( const Sequence< Any >& aArguments ) throw (Exception, RuntimeException) +{ + if( aArguments.getLength() == 1 ) + { + aArguments[0] >>= mxParent; + } +} + +// -------------------------------------------------------------------- + +// XInitialization +OUString SAL_CALL ColorPicker::getImplementationName( ) throw (RuntimeException) +{ + return ColorPicker_getImplementationName(); +} + +// -------------------------------------------------------------------- + +sal_Bool SAL_CALL ColorPicker::supportsService( const OUString& sServiceName ) throw (RuntimeException) +{ + return sServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "com.sun.star.ui.dialogs.ColorPicker" ) ); +} + +// -------------------------------------------------------------------- + +Sequence< OUString > SAL_CALL ColorPicker::getSupportedServiceNames( ) throw (RuntimeException) +{ + return ColorPicker_getSupportedServiceNames(); +} + +// -------------------------------------------------------------------- + +// XPropertyAccess +Sequence< PropertyValue > SAL_CALL ColorPicker::getPropertyValues( ) throw (RuntimeException) +{ + Sequence< PropertyValue > props(1); + props[0].Name = msColorKey; + props[0].Value <<= mnColor; + return props; +} + +// -------------------------------------------------------------------- + +void SAL_CALL ColorPicker::setPropertyValues( const Sequence< PropertyValue >& aProps ) throw (UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException, RuntimeException) +{ + for( sal_Int32 n = 0; n < aProps.getLength(); n++ ) + { + if( aProps[n].Name.equals( msColorKey ) ) + { + aProps[n].Value >>= mnColor; + } + else if( aProps[n].Name.equals( msModeKey ) ) + { + aProps[n].Value >>= mnMode; + } + } +} + +// -------------------------------------------------------------------- + +// XExecutableDialog +void SAL_CALL ColorPicker::setTitle( const OUString& sTitle ) throw (RuntimeException) +{ + msTitle = sTitle; +} + +// -------------------------------------------------------------------- + +sal_Int16 SAL_CALL ColorPicker::execute( ) throw (RuntimeException) +{ + ColorPickerDialog aDlg( VCLUnoHelper::GetWindow( mxParent ), mnColor, mnMode ); + sal_Int16 ret = aDlg.Execute(); + if( ret ) + mnColor = aDlg.GetColor(); + + return ret; +} + +// -------------------------------------------------------------------- + +} + +// eof Property changes on: main/cui/source/dialogs/colorpicker.cxx ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* Index: main/cui/source/tabpages/tpcolor.cxx =================================================================== --- main/cui/source/tabpages/tpcolor.cxx (revision 1232786) +++ main/cui/source/tabpages/tpcolor.cxx (working copy) @@ -643,6 +643,7 @@ ConvertColorValues (aTmpColor, CM_RGB); pColorDlg->SetColor (aTmpColor); + pColorDlg->SetMode( svtools::ColorPickerMode_MODIFY ); if( pColorDlg->Execute() == RET_OK ) { Index: main/cui/source/inc/cuires.hrc =================================================================== --- main/cui/source/inc/cuires.hrc (revision 1232786) +++ main/cui/source/inc/cuires.hrc (working copy) @@ -434,5 +434,7 @@ #define RID_SVXSTR_EVENT_RIGHTCLICK (RID_SVX_START + 1192) #define RID_SVXSTR_EVENT_CALCULATE (RID_SVX_START + 1193) #define RID_SVXSTR_EVENT_CONTENTCHANGED (RID_SVX_START + 1194) + +#define RID_CUI_DIALOG_COLORPICKER (RID_SVX_START + 3) #endif Index: main/cui/prj/build.lst =================================================================== --- main/cui/prj/build.lst (revision 1232786) +++ main/cui/prj/build.lst (working copy) @@ -1,4 +1,4 @@ -cu cui : svx NULL +cu cui : svx sax sot NULL cu cui usr1 - all cui_mkout NULL cu cui\inc nmake - all cui_inc NULL cu cui\source\options nmake - all cui_options cui_inc NULL @@ -6,4 +6,5 @@ cu cui\source\dialogs nmake - all cui_dialogs cui_inc NULL cu cui\source\tabpages nmake - all cui_tabpages cui_inc NULL cu cui\source\factory nmake - all cui_factory cui_inc NULL -cu cui\util nmake - all cui_util cui_factory cui_tabpages cui_dialogs cui_customize cui_options NULL +cu cui\source\uno\services nmake - all cui_uno_services cui_inc NULL +cu cui\util nmake - all cui_util cui_factory cui_tabpages cui_dialogs cui_customize cui_options cui_uno_services NULL Index: main/cui/prj/d.lst =================================================================== --- main/cui/prj/d.lst (revision 1232786) +++ main/cui/prj/d.lst (working copy) @@ -6,3 +6,5 @@ ..\%COMMON_OUTDIR%\misc\*.hid %COMMON_DEST%\bin%_EXT%\hid\*.hid ..\%__SRC%\lib\lib*.* %_DEST%\lib%_EXT%\lib*.* +mkdir: %COMMON_DEST%\xml%_EXT%\component\cui\util +..\%__SRC%\misc\cui.component %_DEST%\xml%_EXT%\component\cui\util\cui.component Index: main/cui/util/cui.component =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/xml Index: main/cui/util/cui.component =================================================================== --- main/cui/util/cui.component (revision 1232786) +++ main/cui/util/cui.component (working copy) Property changes on: main/cui/util/cui.component ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* Added: svn:mime-type ## -0,0 +1 ## +application/xml Index: main/cui/util/makefile.mk =================================================================== --- main/cui/util/makefile.mk (revision 1232786) +++ main/cui/util/makefile.mk (working copy) @@ -48,10 +48,13 @@ $(SLB)$/customize.lib \ $(SLB)$/dialogs.lib \ $(SLB)$/tabpages.lib \ - $(SLB)$/factory.lib + $(SLB)$/factory.lib \ + $(SLB)$/services.lib SHL1STDLIBS= \ + $(SAXLIB) \ + $(SOTLIB) \ $(EDITENGLIB) \ $(SVXCORELIB) \ $(SVXLIB) \ @@ -98,5 +101,13 @@ # --- Targets ------------------------------------------------------- +ALLTAR : $(MISC)/cui.component + +$(MISC)/cui.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + cui.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_BASIS_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt cui.component + .INCLUDE : target.mk Index: main/cui/util/cui.map =================================================================== --- main/cui/util/cui.map (revision 1232786) +++ main/cui/util/cui.map (working copy) @@ -1,7 +1,9 @@ UDK_3_0_0 { global: CreateDialogFactory; - GetSpecialCharsForEdit; + GetSpecialCharsForEdit; + component_getImplementationEnvironment; + component_getFactory; local: *; }; Index: main/tools/source/generic/color.cxx =================================================================== --- main/tools/source/generic/color.cxx (revision 1232786) +++ main/tools/source/generic/color.cxx (working copy) @@ -259,6 +259,53 @@ // ----------------------------------------------------------------------- +// CMYK values from 0 to 1 +ColorData Color::CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKey ) +{ + fCyan = (fCyan * ( 1.0 - fKey )) + fKey; + fMagenta = (fMagenta * ( 1.0 - fKey )) + fKey; + fYellow = (fYellow * ( 1.0 - fKey )) + fKey; + + sal_uInt8 nRed = static_cast< sal_uInt8 >( std::max( std::min( ( 1.0 - fCyan ) * 255.0, 255.0), 0.0 ) ); + sal_uInt8 nGreen = static_cast< sal_uInt8 >( std::max( std::min( ( 1.0 - fMagenta ) * 255.0, 255.0), 0.0 ) ); + sal_uInt8 nBlue = static_cast< sal_uInt8 >( std::max( std::min( ( 1.0 - fYellow ) * 255.0, 255.0), 0.0 ) ); + + return RGB_COLORDATA( nRed, nGreen, nBlue ); +} + +// ----------------------------------------------------------------------- + +// RGB values from 0 to 255 +// CMY results from 0 to 1 +void Color::RGBtoCMYK( double& fCyan, double& fMagenta, double& fYellow, double& fKey ) +{ + fCyan = 1 - ( GetRed() / 255.0 ); + fMagenta = 1 - ( GetGreen() / 255.0 ); + fYellow = 1 - ( GetBlue() / 255.0 ); + + //CMYK and CMY values from 0 to 1 + fKey = 1.0; + if( fCyan < fKey ) fKey = fCyan; + if( fMagenta < fKey ) fKey = fMagenta; + if( fYellow < fKey ) fKey = fYellow; + + if ( fKey == 1.0 ) + { + //Black + fCyan = 0.0; + fMagenta = 0.0; + fYellow = 0.0; + } + else + { + fCyan = ( fCyan - fKey ) / ( 1.0 - fKey ); + fMagenta = ( fMagenta - fKey ) / ( 1.0 - fKey ); + fYellow = ( fYellow - fKey ) / ( 1.0 - fKey ); + } +} + +// ----------------------------------------------------------------------- + SvStream& Color::Read( SvStream& rIStm, sal_Bool bNewFormat ) { if ( bNewFormat ) Index: main/tools/inc/tools/color.hxx =================================================================== --- main/tools/inc/tools/color.hxx (revision 1232786) +++ main/tools/inc/tools/color.hxx (working copy) @@ -174,10 +174,14 @@ static ColorData HSBtoRGB( sal_uInt16 nHue, sal_uInt16 nSat, sal_uInt16 nBri ); void RGBtoHSB( sal_uInt16& nHue, sal_uInt16& nSat, sal_uInt16& nBri ) const; - sal_Bool operator==( const Color& rColor ) const - { return (mnColor == rColor.mnColor); } - sal_Bool operator!=( const Color& rColor ) const - { return !(Color::operator==( rColor )); } + // the range for cymk is 0 to 1.0 + static ColorData CMYKtoRGB( double fCyan, double fMagenta, double fYellow, double fKey ); + void RGBtoCMYK( double& fCyan, double& fMagenta, double& fYellow, double& fKey ); + + sal_Bool operator==( const Color& rColor ) const + { return (mnColor == rColor.mnColor); } + sal_Bool operator!=( const Color& rColor ) const + { return !(Color::operator==( rColor )); } SvStream& Read( SvStream& rIStm, sal_Bool bNewFormat = sal_True ); SvStream& Write( SvStream& rOStm, sal_Bool bNewFormat = sal_True ); Index: main/postprocess/packcomponents/makefile.mk =================================================================== --- main/postprocess/packcomponents/makefile.mk (revision 1232786) +++ main/postprocess/packcomponents/makefile.mk (working copy) @@ -51,6 +51,7 @@ charttools \ chartview \ component/comphelper/util/comphelp \ + component/cui/util/cui \ component/drawinglayer/drawinglayer \ component/framework/util/fwk \ component/framework/util/fwl \ Index: main/svtools/Package_inc.mk =================================================================== --- main/svtools/Package_inc.mk (revision 1232786) +++ main/svtools/Package_inc.mk (working copy) @@ -38,7 +38,6 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/brwhead.hxx,svtools/brwhead.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/calendar.hxx,svtools/calendar.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/cliplistener.hxx,svtools/cliplistener.hxx)) -$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/colctrl.hxx,svtools/colctrl.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/collatorres.hxx,svtools/collatorres.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/colorcfg.hxx,svtools/colorcfg.hxx)) $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/colrdlg.hxx,svtools/colrdlg.hxx)) Index: main/svtools/AllLangResTarget_svt.mk =================================================================== --- main/svtools/AllLangResTarget_svt.mk (revision 1232786) +++ main/svtools/AllLangResTarget_svt.mk (working copy) @@ -50,7 +50,6 @@ svtools/source/control/ctrltool.src \ svtools/source/control/filectrl.src \ svtools/source/dialogs/addresstemplate.src \ - svtools/source/dialogs/colrdlg.src \ svtools/source/dialogs/filedlg2.src \ svtools/source/dialogs/formats.src \ svtools/source/dialogs/prnsetup.src \ Index: main/svtools/Library_svt.mk =================================================================== --- main/svtools/Library_svt.mk (revision 1232786) +++ main/svtools/Library_svt.mk (working copy) @@ -150,7 +150,6 @@ svtools/source/control/valueacc \ svtools/source/control/valueset \ svtools/source/dialogs/addresstemplate \ - svtools/source/dialogs/colctrl \ svtools/source/dialogs/colrdlg \ svtools/source/dialogs/filedlg \ svtools/source/dialogs/filedlg2 \ Index: main/svtools/source/dialogs/colrdlg.cxx =================================================================== --- main/svtools/source/dialogs/colrdlg.cxx (revision 1232786) +++ main/svtools/source/dialogs/colrdlg.cxx (working copy) @@ -26,299 +26,103 @@ #ifndef GCC #endif -#include -#include "colrdlg.hrc" -#include +#include +#include +#include +#include +#include +#include +#include -// --------------- -// - ColorDialog - -// --------------- +using rtl::OUString; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::ui::dialogs; -SvColorDialog::SvColorDialog( Window* pWindow ) : - ModalDialog ( pWindow, SvtResId( DLG_COLOR ) ), - maColMixCtrl ( this, SvtResId( VAL_SET_COLOR ), 8, 8 ), - maBtn1 ( this, SvtResId( BTN_1 ) ), - maBtn2 ( this, SvtResId( BTN_2 ) ), - //maBtn3 ( this, SvtResId( BTN_3 ) ), - //maBtn4 ( this, SvtResId( BTN_4 ) ), - //maFtRGB ( this, SvtResId( FT_RGB ) ), - maCtlColor ( this, SvtResId( CTL_COLOR ) ), +// --------------- +// - ColorDialog - +// --------------- - maFtCyan ( this, SvtResId( FT_CYAN ) ), - maNumCyan ( this, SvtResId( NUM_CYAN ) ), - maFtMagenta ( this, SvtResId( FT_MAGENTA ) ), - maNumMagenta ( this, SvtResId( NUM_MAGENTA ) ), - maFtYellow ( this, SvtResId( FT_YELLOW ) ), - maNumYellow ( this, SvtResId( NUM_YELLOW ) ), - maFtKey ( this, SvtResId( FT_KEY ) ), - maNumKey ( this, SvtResId( NUM_KEY ) ), - - maFtRed ( this, SvtResId( FT_RED ) ), - maNumRed ( this, SvtResId( NUM_RED ) ), - maFtGreen ( this, SvtResId( FT_GREEN ) ), - maNumGreen ( this, SvtResId( NUM_GREEN ) ), - maFtBlue ( this, SvtResId( FT_BLUE ) ), - maNumBlue ( this, SvtResId( NUM_BLUE ) ), - - maFtHue ( this, SvtResId( FT_HUE ) ), - maNumHue ( this, SvtResId( NUM_HUE ) ), - maFtSaturation ( this, SvtResId( FT_SATURATION ) ), - maNumSaturation ( this, SvtResId( NUM_SATURATION ) ), - maFtLuminance ( this, SvtResId( FT_LUMINANCE ) ), - maNumLuminance ( this, SvtResId( NUM_LUMINANCE ) ), - - maCtlPreview ( this, SvtResId( CTL_PREVIEW ) ), - maCtlPreviewOld ( this, SvtResId( CTL_PREVIEW_OLD ) ), - - maBtnOK ( this, SvtResId( BTN_OK ) ), - maBtnCancel ( this, SvtResId( BTN_CANCEL ) ), - maBtnHelp ( this, SvtResId( BTN_HELP ) ) +SvColorDialog::SvColorDialog( Window* pWindow ) +: mpParent( pWindow ) +, meMode( svtools::ColorPickerMode_SELECT ) { - FreeResource(); - - maColMixCtrl.SetDoubleClickHdl( LINK( this, SvColorDialog, ClickMixCtrlHdl ) ); - maColMixCtrl.SetSelectHdl( LINK( this, SvColorDialog, SelectMixCtrlHdl ) ); - - Link aLink( LINK( this, SvColorDialog, ColorModifyHdl ) ); - maCtlColor.SetModifyHdl( aLink ); - - maNumRed.SetModifyHdl( aLink ); - maNumGreen.SetModifyHdl( aLink ); - maNumBlue.SetModifyHdl( aLink ); - - maNumCyan.SetModifyHdl( aLink ); - maNumMagenta.SetModifyHdl( aLink ); - maNumYellow.SetModifyHdl( aLink ); - maNumKey.SetModifyHdl( aLink ); - - maNumHue.SetModifyHdl( aLink ); - maNumSaturation.SetModifyHdl( aLink ); - maNumLuminance.SetModifyHdl( aLink ); - - aLink = ( LINK( this, SvColorDialog, ClickBtnHdl ) ); - maBtn1.SetClickHdl( aLink ); - maBtn2.SetClickHdl( aLink ); - //maBtn3.SetClickHdl( aLink ); - //maBtn4.SetClickHdl( aLink ); - - maColMixCtrl.SetExtraSpacing( 0 ); } - // ----------------------------------------------------------------------- -SvColorDialog::~SvColorDialog() -{ -} -// ----------------------------------------------------------------------- -void SvColorDialog::Initialize() -{ - maNumRed.SetValue( maColor.GetRed() ); - maNumGreen.SetValue( maColor.GetGreen() ); - maNumBlue.SetValue( maColor.GetBlue() ); - - ColorCMYK aColorCMYK( maColor ); - - long aCyan = (long) ( (double)aColorCMYK.GetCyan() * 100.0 / 255.0 + 0.5 ); - long aMagenta = (long) ( (double)aColorCMYK.GetMagenta() * 100.0 / 255.0 + 0.5 ); - long aYellow = (long) ( (double)aColorCMYK.GetYellow() * 100.0 / 255.0 + 0.5 ); - long aKey = (long) ( (double)aColorCMYK.GetKey() * 100.0 / 255.0 + 0.5 ); - maNumCyan.SetValue( aCyan ); - maNumMagenta.SetValue( aMagenta ); - maNumYellow.SetValue( aYellow ); - maNumKey.SetValue( aKey ); - - ColorHSB aColorHSB( maColor ); - maNumHue.SetValue( aColorHSB.GetHue() ); - maNumSaturation.SetValue( aColorHSB.GetSat() ); - maNumLuminance.SetValue( aColorHSB.GetBri() ); - - maCtlColor.SetColor( aColorHSB ); - - maColMixCtrl.SelectItem( 1 ); - - maCtlPreview.SetColor( maColor ); - maCtlPreviewOld.SetColor( maColor ); -} - -// ----------------------------------------------------------------------- void SvColorDialog::SetColor( const Color& rColor ) { maColor = rColor; } // ----------------------------------------------------------------------- + const Color& SvColorDialog::GetColor() const { - return( maColor ); + return maColor; } // ----------------------------------------------------------------------- -IMPL_LINK( SvColorDialog, ColorModifyHdl, void *, p ) -{ - sal_uInt16 n = 0x00; // 1 == RGB, 2 == CMYK, 4 == HSB - - if( p == &maCtlColor ) - { - maColor = maCtlColor.GetColor(); - maNumRed.SetValue( maColor.GetRed() ); - maNumGreen.SetValue( maColor.GetGreen() ); - maNumBlue.SetValue( maColor.GetBlue() ); - - n = 7; - } - else if( p == &maNumRed ) - { - maColor.SetRed( (sal_uInt8)maNumRed.GetValue() ); - maCtlColor.SetColor( maColor ); - n = 6; - } - else if( p == &maNumGreen ) - { - maColor.SetGreen( (sal_uInt8)maNumGreen.GetValue() ); - maCtlColor.SetColor( maColor ); - n = 6; - } - else if( p == &maNumBlue ) - { - maColor.SetBlue( (sal_uInt8)maNumBlue.GetValue() ); - maCtlColor.SetColor( maColor ); - n = 6; - } - else if( p == &maNumHue || - p == &maNumSaturation || - p == &maNumLuminance ) - { - - ColorHSB aColorHSB( (sal_uInt16) maNumHue.GetValue(), - (sal_uInt16) maNumSaturation.GetValue(), - (sal_uInt16) maNumLuminance.GetValue() ); - maCtlColor.SetColor( aColorHSB ); - maColor = maCtlColor.GetColor(); - n = 3; - } - else if( p == &maNumCyan || - p == &maNumMagenta || - p == &maNumYellow || - p == &maNumKey ) - { - long aCyan = (long) ( (double)maNumCyan.GetValue() * 255.0 / 100.0 + 0.5 ); - long aMagenta = (long) ( (double)maNumMagenta.GetValue() * 255.0 / 100.0 + 0.5 ); - long aYellow = (long) ( (double)maNumYellow.GetValue() * 255.0 / 100.0 + 0.5 ); - long aKey = (long) ( (double)maNumKey.GetValue() * 255.0 / 100.0 + 0.5 ); - - ColorCMYK aColorCMYK( (sal_uInt16) aCyan, - (sal_uInt16) aMagenta, - (sal_uInt16) aYellow, - (sal_uInt16) aKey ); - maColor = aColorCMYK.GetRGB(); - maCtlColor.SetColor( maColor ); - n = 5; - } - - if( n & 1 ) // RGB setzen - { - maNumRed.SetValue( maColor.GetRed() ); - maNumGreen.SetValue( maColor.GetGreen() ); - maNumBlue.SetValue( maColor.GetBlue() ); - } - if( n & 2 ) // CMYK setzen - { - ColorCMYK aColorCMYK( maColor ); - long aCyan = (long) ( (double)aColorCMYK.GetCyan() * 100.0 / 255.0 + 0.5 ); - long aMagenta = (long) ( (double)aColorCMYK.GetMagenta() * 100.0 / 255.0 + 0.5 ); - long aYellow = (long) ( (double)aColorCMYK.GetYellow() * 100.0 / 255.0 + 0.5 ); - long aKey = (long) ( (double)aColorCMYK.GetKey() * 100.0 / 255.0 + 0.5 ); - maNumCyan.SetValue( aCyan ); - maNumMagenta.SetValue( aMagenta ); - maNumYellow.SetValue( aYellow ); - maNumKey.SetValue( aKey ); - } - if( n & 4 ) // HSB setzen - { - ColorHSB aColorHSB( maColor ); - maNumHue.SetValue( aColorHSB.GetHue() ); - maNumSaturation.SetValue( aColorHSB.GetSat() ); - maNumLuminance.SetValue( aColorHSB.GetBri() ); - } - - maCtlPreview.SetColor( maColor ); - - return 0; + +void SvColorDialog::SetMode( sal_Int16 eMode ) +{ + meMode = eMode; } // ----------------------------------------------------------------------- -IMPL_LINK( SvColorDialog, ClickBtnHdl, void *, p ) -{ - /* - Color aColor = maCtlColor.GetColor(); - if( p == &maBtn1 ) - maColMixCtrl.SetColor( CMC_TOPLEFT, aColor ); - if( p == &maBtn2 ) - maColMixCtrl.SetColor( CMC_TOPRIGHT, aColor ); - if( p == &maBtn3 ) - maColMixCtrl.SetColor( CMC_BOTTOMLEFT, aColor ); - if( p == &maBtn4 ) - maColMixCtrl.SetColor( CMC_BOTTOMRIGHT, aColor ); - */ - - if( p == &maBtn1 ) + +short SvColorDialog::Execute() +{ + short ret = 0; + try { - CMCPosition ePos = maColMixCtrl.GetCMCPosition(); - if( ePos != CMC_OTHER ) - maColMixCtrl.SetColor( ePos, maColor ); + const OUString sColor( RTL_CONSTASCII_USTRINGPARAM( "Color" ) ); + Reference< XMultiServiceFactory > xSMGR( ::comphelper::getProcessServiceFactory(), UNO_QUERY_THROW ); + + Reference< com::sun::star::awt::XWindow > xParent( VCLUnoHelper::GetInterface( mpParent ) ); + + Sequence< Any > args(1); + args[0] = Any( xParent ); + + Reference< XExecutableDialog > xDialog( xSMGR->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.cui.ColorPicker"), args), UNO_QUERY_THROW ); + Reference< XPropertyAccess > xPropertyAccess( xDialog, UNO_QUERY_THROW ); + + Sequence< PropertyValue > props( 2 ); + props[0].Name = sColor; + props[0].Value <<= (sal_Int32) maColor.GetColor(); + props[1].Name = OUString( RTL_CONSTASCII_USTRINGPARAM( "Mode" ) ); + props[1].Value <<= (sal_Int16) meMode; + + xPropertyAccess->setPropertyValues( props ); + + ret = xDialog->execute(); + + if( ret ) + { + props = xPropertyAccess->getPropertyValues(); + for( sal_Int32 n = 0; n < props.getLength(); n++ ) + { + if( props[n].Name.equals( sColor ) ) + { + sal_Int32 nColor = 0; + if( props[n].Value >>= nColor ) + { + maColor.SetColor( nColor ); + } + + } + } + } } - else if( p == &maBtn2 ) + catch(Exception&) { - sal_uInt16 nPos = maColMixCtrl.GetSelectItemId(); - maColor = maColMixCtrl.GetItemColor( nPos ); - maCtlColor.SetColor( maColor ); - ColorModifyHdl( &maCtlColor ); + OSL_ASSERT(false); } - - return 0; + + return ret; } // ----------------------------------------------------------------------- -IMPL_LINK( SvColorDialog, ClickMixCtrlHdl, void *, EMPTYARG ) -{ - sal_uInt16 nPos = maColMixCtrl.GetSelectItemId(); - CMCPosition ePos = maColMixCtrl.GetCMCPosition(); - - if( ePos != CMC_OTHER ) - maColMixCtrl.SetColor( ePos, maColor ); - else - { - maColor = maColMixCtrl.GetItemColor( nPos ); - maCtlColor.SetColor( maColor ); - ColorModifyHdl( &maCtlColor ); - } - - return 0; -} - -// ----------------------------------------------------------------------- -IMPL_LINK( SvColorDialog, SelectMixCtrlHdl, void *, EMPTYARG ) -{ - //sal_uInt16 nPos = maColMixCtrl.GetSelectItemId(); - //maFtRGB.SetText( maColMixCtrl.GetItemText( nPos ) ); - - CMCPosition ePos = maColMixCtrl.GetCMCPosition(); - if( ePos == CMC_OTHER ) - maBtn1.Enable( sal_False ); - else - maBtn1.Enable(); - - return 0; -} - -// ----------------------------------------------------------------------- -short SvColorDialog::Execute() -{ - Initialize(); - - short nRet = ModalDialog::Execute(); - - return( nRet ); -} - +// eof Index: main/svtools/source/dialogs/colrdlg.hrc =================================================================== --- main/svtools/source/dialogs/colrdlg.hrc (revision 1232786) +++ main/svtools/source/dialogs/colrdlg.hrc (working copy) @@ -1,65 +0,0 @@ -/************************************************************** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - *************************************************************/ - - -#define DLG_COLOR 996 - -#define VAL_SET_COLOR 2 -#define BTN_1 1 -#define BTN_2 2 -#define BTN_3 3 -#define BTN_4 4 -#define FT_RGB 12 - -#define CTL_COLOR 1 - -#define FT_RED 1 -#define NUM_RED 1 -#define FT_GREEN 2 -#define NUM_GREEN 2 -#define FT_BLUE 3 -#define NUM_BLUE 3 - -#define FT_CYAN 7 -#define NUM_CYAN 7 -#define FT_MAGENTA 8 -#define NUM_MAGENTA 8 -#define FT_YELLOW 9 -#define NUM_YELLOW 9 -#define FT_KEY 10 -#define NUM_KEY 10 - -#define FT_HUE 4 -#define NUM_HUE 4 -#define FT_SATURATION 5 -#define NUM_SATURATION 5 -#define FT_LUMINANCE 6 -#define NUM_LUMINANCE 6 - -#define CTL_PREVIEW 3 -#define CTL_PREVIEW_OLD 4 - -#define BTN_OK 1 -#define BTN_CANCEL 1 -#define BTN_HELP 1 - -//IAccessibility2 Implementation 2009----- -#define STR_COLORDES 3001 Index: main/svtools/source/dialogs/colctrl.cxx =================================================================== --- main/svtools/source/dialogs/colctrl.cxx (revision 1232786) +++ main/svtools/source/dialogs/colctrl.cxx (working copy) @@ -1,686 +0,0 @@ -/************************************************************** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - *************************************************************/ - - - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_svtools.hxx" - - -#include -#include - -#include - -// ---------------- -// - ColorControl - -// ---------------- - -SvColorControl::SvColorControl( Window* pParent, WinBits nStyle ) : - Control ( pParent, nStyle ), - mpBitmap ( NULL ), - mpReadAccess ( NULL ), - mnLuminance ( 50 ) -{ - Initialize(); -} - -// ----------------------------------------------------------------------- -SvColorControl::SvColorControl( Window* pParent, const ResId& rResId ) : - Control ( pParent, rResId ), - mpBitmap ( NULL ), - mpReadAccess ( NULL ), - mnLuminance ( 50 ) -{ - Initialize(); -} - - -// ----------------------------------------------------------------------- -SvColorControl::~SvColorControl() -{ - delete mpBitmap; -} - -// ----------------------------------------------------------------------- -void SvColorControl::Initialize() -{ - SetLineColor( Color( COL_BLACK ) ); -} - -// ----------------------------------------------------------------------- -void SvColorControl::CreateBitmap() -{ - const Size aSize( GetOutputSizePixel() ); - - if( mpBitmap && mpBitmap->GetSizePixel() != aSize ) - delete mpBitmap, mpBitmap = NULL; - - if( !mpBitmap ) - mpBitmap = new Bitmap( aSize, 24 ); - - BitmapWriteAccess* pWriteAccess = mpBitmap->AcquireWriteAccess(); - - if( pWriteAccess ) - { - sal_uInt16 nX = (sal_uInt16) aSize.Width(); - sal_uInt16 nY = (sal_uInt16) aSize.Height(); - - sal_uInt16 nHue, nSat; - ColorHSB aColHSB( 0, 0, mnLuminance ); - - for( sal_uInt16 i = 0; i < nY; i++ ) - { - nSat = (sal_uInt16) FRound( 100 - ( 100.0 * i + 0.5 ) / nY ); - - for( sal_uInt16 j = 0; j < nX; j++ ) - { - nHue = (sal_uInt16) FRound( ( 360.0 * j + 0.5 ) / nX ); - - aColHSB.SetHue( nHue ); - aColHSB.SetSat( nSat ); - - // mpBitmap always has a bit count of 24 => use of SetPixel(...) is safe - pWriteAccess->SetPixel( i, j, BitmapColor( aColHSB.GetRGB() ) ); - } - } - - mpBitmap->ReleaseAccess( pWriteAccess ); - } - - SetColor( maColor ); -} - -// ----------------------------------------------------------------------- -void SvColorControl::ShowPosition( const Point& rPos ) -{ - // Explizites Abfragen des Bereichs, da schon mal ein Wert < 0 vorhanden ist - if( mpBitmap ) - { - long nX = rPos.X(); - long nY = rPos.Y(); - if( nX < 0L ) - nX = 0L; - else if( nX >= mpBitmap->GetSizePixel().Width() ) - nX = mpBitmap->GetSizePixel().Width() - 1L; - - if( nY < 0L ) - nY= 0L; - else if( nY >= mpBitmap->GetSizePixel().Height() ) - nY = mpBitmap->GetSizePixel().Height() - 1L; - - Point aPos = maPosition; - maPosition.X() = nX - 2; - maPosition.Y() = nY - 2; - Invalidate( Rectangle( aPos, Size( 5, 5) ) ); - Invalidate( Rectangle( maPosition, Size( 5, 5) ) ); - - if( ( mpReadAccess = mpBitmap->AcquireReadAccess() ) != NULL ) - { - // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe - maColor = mpReadAccess->GetPixel( nY, nX ); - mpBitmap->ReleaseAccess( mpReadAccess ); - mpReadAccess = NULL; - } - } -} -// ----------------------------------------------------------------------- -void SvColorControl::MouseMove( const MouseEvent& rMEvt ) -{ - if( rMEvt.IsLeft() ) - { - ShowPosition( rMEvt.GetPosPixel() ); - Modify(); - } -} - -// ----------------------------------------------------------------------- -void SvColorControl::MouseButtonDown( const MouseEvent& rMEvt ) -{ - if( rMEvt.IsLeft() && !rMEvt.IsShift() ) - { - //ShowPointer( sal_False ); - CaptureMouse(); - ShowPosition( rMEvt.GetPosPixel() ); - Modify(); - } -} - -// ----------------------------------------------------------------------- -void SvColorControl::MouseButtonUp( const MouseEvent& ) -{ - //ShowPointer( sal_True ); - if( IsMouseCaptured() ) - ReleaseMouse(); -} - -// ----------------------------------------------------------------------- -void SvColorControl::Paint( const Rectangle& rRect ) -{ - if( !mpBitmap ) - CreateBitmap(); - - Bitmap aOutputBitmap( *mpBitmap ); - - if( GetBitCount() <= 8 ) - aOutputBitmap.Dither(); - - DrawBitmap( rRect.TopLeft(), rRect.GetSize(), rRect.TopLeft(), rRect.GetSize(), aOutputBitmap ); - - // Positions-Control (Fadenkreuz oder Aehnliches) - Point aPos1( maPosition ); - Point aPos2( maPosition ); - aPos2.X() += 4; - DrawLine( aPos1, aPos2 ); - aPos2.X() -= 4; - aPos2.Y() += 4; - DrawLine( aPos1, aPos2 ); - aPos1.Y() += 4; - aPos2.X() += 4; - DrawLine( aPos1, aPos2 ); - aPos1.X() += 4; - aPos2.Y() -= 4; - DrawLine( aPos1, aPos2 ); -} - -// ----------------------------------------------------------------------- -void SvColorControl::Resize() -{ - CreateBitmap(); - Control::Resize(); -} - -// ----------------------------------------------------------------------- -void SvColorControl::Modify() -{ - maModifyHdl.Call( this ); -} - -// ----------------------------------------------------------------------- -void SvColorControl::SetColor( const ColorHSB& rCol, sal_Bool bSetColor ) -{ - if( bSetColor ) - maColor = rCol.GetRGB(); - - if( mpBitmap ) - { - sal_uInt16 nX = (sal_uInt16) mpBitmap->GetSizePixel().Width(); - sal_uInt16 nY = (sal_uInt16) mpBitmap->GetSizePixel().Height(); - sal_Int16 nZ = rCol.GetBri(); - - SetLuminance( nZ ); - nX = rCol.GetHue() * nX / 360; // Farbe - nY = nY - rCol.GetSat() * nY / 100; // Saettigung - ShowPosition( Point( nX, nY ) ); - } -} - -// ----------------------------------------------------------------------- -void SvColorControl::SetColor( const Color& rCol ) -{ - maColor = rCol; - - if( mpBitmap ) - { - ColorHSB aColHsb( rCol ); - SetColor( aColHsb, sal_False ); - } -} - -// ----------------------------------------------------------------------- -void SvColorControl::SetLuminance( short nLum ) -{ - if( nLum != mnLuminance && nLum >= 0 && nLum <= 100 ) - { - mnLuminance = nLum; - - if( mnLuminance < 40 ) - SetLineColor( Color( COL_WHITE ) ); - else - SetLineColor( Color( COL_BLACK ) ); - - CreateBitmap(); - - long nX = maPosition.X() + 2; - long nY = maPosition.Y() + 2; - - if( mpBitmap && ( ( mpReadAccess = mpBitmap->AcquireReadAccess() ) != NULL ) ) - { - // mpBitmap always has a bit count of 24 => use of GetPixel(...) is safe - maColor = mpReadAccess->GetPixel( nY, nX ); - mpBitmap->ReleaseAccess( mpReadAccess ); - mpReadAccess = NULL; - } - - Invalidate(); - } -} - - -// ----------------------- -// - ColorPreviewControl - -// ----------------------- - - -// ----------------------------------------------------------------------- -ColorPreviewControl::ColorPreviewControl( Window* pParent, WinBits nStyle ) : - Control ( pParent, nStyle ) -{ - SetFillColor( maColor ); - SetLineColor( maColor ); -} - -// ----------------------------------------------------------------------- -ColorPreviewControl::ColorPreviewControl( Window* pParent, const ResId& rResId ) : - Control ( pParent, rResId ) -{ - SetFillColor( maColor ); - SetLineColor( maColor ); -} - - -// ----------------------------------------------------------------------- -ColorPreviewControl::~ColorPreviewControl() -{ -} - -// ----------------------------------------------------------------------- -void ColorPreviewControl::Paint( const Rectangle& rRect ) -{ - DrawRect( rRect ); -} - -// ----------------------------------------------------------------------- -void ColorPreviewControl::SetColor( const Color& rCol ) -{ - if( rCol != maColor ) - { - maColor = rCol; - SetFillColor( maColor ); - SetLineColor( maColor ); - Invalidate(); - } -} - - -// ----------------------- -// - ColorMixingControl - -// ----------------------- - - -// ----------------------------------------------------------------------- -ColorMixingControl::ColorMixingControl( Window* pParent, WinBits nStyle, - sal_uInt16 nRows, sal_uInt16 nColumns ) : - ValueSet ( pParent, nStyle ), - mnRows ( nRows ), - mnColumns ( nColumns ) -{ - Initialize(); -} - -// ----------------------------------------------------------------------- -ColorMixingControl::ColorMixingControl( Window* pParent, const ResId& rResId, - sal_uInt16 nRows, sal_uInt16 nColumns ) : - ValueSet ( pParent, rResId ), - mnRows ( nRows ), - mnColumns ( nColumns ) -{ - Initialize(); -} - - -// ----------------------------------------------------------------------- -ColorMixingControl::~ColorMixingControl() -{ -} - -// ----------------------------------------------------------------------- -void ColorMixingControl::Initialize() -{ - SetColCount( mnColumns ); - - Color aColor; - String aStr; - for( sal_uInt16 i = 1; i <= mnRows * mnColumns; i++ ) - { - InsertItem( i, aColor, aStr ); - } - - /*maColor[ 0 ] = Color( COL_LIGHTRED ); - maColor[ 1 ] = Color( COL_LIGHTGREEN ); - maColor[ 2 ] = Color( COL_YELLOW ); - maColor[ 3 ] = Color( COL_LIGHTBLUE );*/ - - SetColor( CMC_TOPLEFT, Color( COL_LIGHTRED ) ); - SetColor( CMC_BOTTOMRIGHT, Color( COL_LIGHTBLUE ) ); - - SetColor( CMC_TOPRIGHT, Color( COL_LIGHTGREEN ) ); - SetColor( CMC_BOTTOMLEFT, Color( COL_YELLOW ) ); - - /*FillColumn( 0 ); - FillColumn( mnColumns - 1 ); - for( i = 0; i < mnRows; i++ ) - FillRow( i );*/ -} - -// ----------------------------------------------------------------------- -Color ColorMixingControl::CalcDifferenceColor( sal_uInt16 nCol1, sal_uInt16 nCol2, - sal_uInt16 nSteps ) -{ - // Die Berechnung ist noch etwas ungenau, daher sollte besser mit floats - // gearbeitet werden... (muss !!!) - Color aColor( GetItemColor( nCol1 ) ); - Color aColor2( GetItemColor( nCol2 ) ); - - aColor.SetRed( (sal_uInt8) ( ( aColor2.GetRed() - aColor.GetRed() ) / nSteps ) ); - aColor.SetGreen( (sal_uInt8) ( ( aColor2.GetGreen() - aColor.GetGreen() ) / nSteps ) ); - aColor.SetBlue( (sal_uInt8) ( ( aColor2.GetBlue() - aColor.GetBlue() ) / nSteps ) ); - - return( aColor ); -} - -// ----------------------------------------------------------------------- -void ColorMixingControl::FillRow( sal_uInt16 nRow ) -{ - sal_uInt16 nCol1 = nRow * mnColumns + 1; - sal_uInt16 nCol2 = ( nRow + 1 ) * mnColumns; - Color aColor( GetItemColor( nCol1 ) ); - Color aDiffColor( CalcDifferenceColor( nCol1, nCol2, mnColumns - 1 ) ); - - for( sal_uInt16 i = nCol1 + 1; i < nCol2; i++ ) - { - aColor.SetRed( aColor.GetRed() + aDiffColor.GetRed() ); - aColor.SetGreen( aColor.GetGreen() + aDiffColor.GetGreen() ); - aColor.SetBlue( aColor.GetBlue() + aDiffColor.GetBlue() ); - - SetItemColor( i, aColor ); - SetItemText( i, GetRGBString( aColor ) ); - } -} - -// ----------------------------------------------------------------------- -void ColorMixingControl::FillColumn( sal_uInt16 nColumn ) -{ - sal_uInt16 nCol1 = nColumn + 1; - sal_uInt16 nCol2 = nColumn + ( mnRows - 1 ) * mnColumns + 1; - Color aColor( GetItemColor( nCol1 ) ); - Color aDiffColor( CalcDifferenceColor( nCol1, nCol2, mnRows - 1 ) ); - - for( sal_uInt16 i = nCol1 + mnColumns; i < nCol2; i = i + mnColumns ) - { - aColor.SetRed( aColor.GetRed() + aDiffColor.GetRed() ); - aColor.SetGreen( aColor.GetGreen() + aDiffColor.GetGreen() ); - aColor.SetBlue( aColor.GetBlue() + aDiffColor.GetBlue() ); - - SetItemColor( i, aColor ); - SetItemText( i, GetRGBString( aColor ) ); - } -} - -// ----------------------------------------------------------------------- -void ColorMixingControl::SetRows( sal_uInt16 nRows ) -{ - mnRows = nRows; -} - -// ----------------------------------------------------------------------- -void ColorMixingControl::SetColumns( sal_uInt16 nColumns ) -{ - mnColumns = nColumns; -} - -// ----------------------------------------------------------------------- -void ColorMixingControl::SetColor( CMCPosition ePos, const Color& rCol ) -{ - if( rCol != maColor[ ePos ] ) - { - maColor[ ePos ] = rCol; - sal_uInt16 nPos = 0; - sal_uInt16 nColumn = 0; - String aStr( GetRGBString( rCol ) ); - - switch( ePos ) - { - case CMC_TOPLEFT: - nPos = 1; - nColumn = 0; - break; - - case CMC_TOPRIGHT: - nPos = mnColumns; - nColumn = mnColumns - 1; - break; - - case CMC_BOTTOMLEFT: - nPos = ( mnRows - 1 ) * mnColumns + 1; - nColumn = 0; - break; - - case CMC_BOTTOMRIGHT: - nPos = mnRows * mnColumns; - nColumn = mnColumns - 1; - break; - case CMC_OTHER: - break; // -Wall not handled. - } - SetItemColor( nPos, rCol ); - SetItemText( nPos, aStr ); - FillColumn( nColumn ); - - for( sal_uInt16 i = 0; i < mnRows; i++ ) - FillRow( i ); - } -} - -// ----------------------------------------------------------------------- -String ColorMixingControl::GetRGBString( const Color& rColor ) -{ - String aStr( String::CreateFromInt32(rColor.GetRed()) ); - aStr += ' '; - aStr += String::CreateFromInt32(rColor.GetGreen()); - aStr += ' '; - aStr += String::CreateFromInt32(rColor.GetBlue()); - - return aStr; -} -// ----------------------------------------------------------------------- -CMCPosition ColorMixingControl::GetCMCPosition() const -{ - CMCPosition ePos = CMC_OTHER; - sal_uInt16 nPos = GetSelectItemId(); - - if( nPos == 1 ) - ePos = CMC_TOPLEFT; - else if( nPos == mnColumns ) - ePos = CMC_TOPRIGHT; - else if( nPos == ( mnRows - 1 ) * mnColumns + 1 ) - ePos = CMC_BOTTOMLEFT; - else if( nPos == mnRows * mnColumns ) - ePos = CMC_BOTTOMRIGHT; - - return( ePos ); -} - - -// ------------ -// - ColorHSB - -// ------------ - -// Erste Ansaetze gingen auf die Berechnung von Sven Hannover zurueck -// Der jetzige Algorithmus stammt im weitesten Sinne aus dem Foley/VanDam - - -/************************************************************************** -|* -|* ColorHSB::ColorHSB() -|* -|* Beschreibung RGB nach HSB -|* Ersterstellung SOH 02.10.97 -|* -**************************************************************************/ - -ColorHSB::ColorHSB( const Color& rColor ) -{ - sal_uInt8 c[3]; - sal_uInt8 cMax, cMin; - - c[0] = rColor.GetRed(); - c[1] = rColor.GetGreen(); - c[2] = rColor.GetBlue(); - - cMax = c[0]; - if( c[1] > cMax ) - cMax = c[1]; - if( c[2] > cMax ) - cMax = c[2]; - - // Brightness = max(R, G, B); - mnBri = cMax * 100 / 255; - - cMin = c[0]; - if( c[1] < cMin ) - cMin = c[1]; - if( c[2] < cMin ) - cMin = c[2]; - - sal_uInt8 cDelta = cMax - cMin; - - // Saturation = max - min / max - if( mnBri > 0 ) - mnSat = cDelta * 100 / cMax; - else - mnSat = 0; - - if( mnSat == 0 ) - mnHue = 0; // Default = undefined - else - { - double dHue = 0; - - if( c[0] == cMax ) - { - dHue = (double)( c[1] - c[2] ) / (double)cDelta; - } - else if( c[1] == cMax ) - { - dHue = 2.0 + (double)( c[2] - c[0] ) / (double)cDelta; - } - else if ( c[2] == cMax ) - { - dHue = 4.0 + (double)( c[0] - c[1] ) / (double)cDelta; - } - // else dHue = ??? -Wall FIXME - dHue *= 60.0; - - if( dHue < 0.0 ) - dHue += 360.0; - - mnHue = (sal_uInt16) dHue; - } -} - -/************************************************************************** -|* -|* ColorHSB::GetRGB() -|* -|* Beschreibung HSB nach RGB -|* Ersterstellung SOH 02.10.97 -|* -**************************************************************************/ - -Color ColorHSB::GetRGB() const -{ - sal_uInt8 cR,cG,cB; - sal_uInt8 nB = (sal_uInt8) ( mnBri * 255 / 100 ); - - if( mnSat == 0 ) - { - cR = nB; - cG = nB; - cB = nB; - } - else - { - double dH = mnHue; - double f; - sal_uInt16 n; - if( dH == 360.0 ) - dH = 0.0; - - dH /= 60.0; - n = (sal_uInt16) dH; - f = dH - n; - - // #107375# Doing the calculation completely in floating - // point, the former optimization gave sometimes negative - // results for c and was pointless anyway - sal_uInt8 a = static_cast( nB * ( 100.0 - mnSat ) / 100.0 ); - sal_uInt8 b = static_cast( nB * ( 100.0 - mnSat * f ) / 100.0 ); - sal_uInt8 c = static_cast( nB * ( 100.0 - mnSat * ( 1.0 - f ) ) / 100.0 ); - - switch( n ) - { - case 0: cR = nB; cG = c; cB = a; break; - case 1: cR = b; cG = nB; cB = a; break; - case 2: cR = a; cG = nB; cB = c; break; - case 3: cR = a; cG = b; cB = nB; break; - case 4: cR = c; cG = a; cB = nB; break; - case 5: cR = nB; cG = a; cB = b; break; - default: cR = 0; cG = 0; cB = 0; break; // -Wall ???? - } - } - - return( Color( cR, cG, cB ) ); -} - -// ------------ -// - ColorCMYK - -// ------------ - - -// ----------------------------------------------------------------------- -ColorCMYK::ColorCMYK( const Color& rColor ) -{ - mnCyan = 255 - rColor.GetRed(); - mnMagenta = 255 - rColor.GetGreen(); - mnYellow = 255 - rColor.GetBlue(); - - mnKey = Min( Min( mnCyan, mnMagenta ), mnYellow ); - - mnCyan = mnCyan - mnKey; - mnMagenta = mnMagenta - mnKey; - mnYellow = mnYellow - mnKey; -} - -// ----------------------------------------------------------------------- -Color ColorCMYK::GetRGB() const -{ - int nTmp = Max( 0, 255 - ( mnCyan + mnKey ) ); - sal_uInt8 cR = (sal_uInt8) nTmp; - nTmp = Max( 0, 255 - ( mnMagenta + mnKey ) ); - sal_uInt8 cG = (sal_uInt8) nTmp; - nTmp = Max( 0, 255 - ( mnYellow + mnKey ) ); - sal_uInt8 cB = (sal_uInt8) nTmp; - - return( Color( cR, cG, cB ) ); -} - - Index: main/svtools/source/dialogs/colrdlg.src =================================================================== --- main/svtools/source/dialogs/colrdlg.src (revision 1232786) +++ main/svtools/source/dialogs/colrdlg.src (working copy) @@ -1,291 +0,0 @@ -/************************************************************** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - *************************************************************/ - - - -#include "colrdlg.hrc" -#define DIFF 3 -ModalDialog DLG_COLOR -{ - HelpID = "svtools:ModalDialog:DLG_COLOR"; - OutputSize = TRUE ; - SVLook = TRUE ; - Size = MAP_APPFONT ( 260 , 165 + DIFF ) ; - Moveable = TRUE ; - Text [ en-US ] = "Color" ; - OKButton BTN_OK - { - Pos = MAP_APPFONT ( 205 , 6 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - DefButton = TRUE ; - }; - CancelButton BTN_CANCEL - { - Pos = MAP_APPFONT ( 205 , 23 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - }; - HelpButton BTN_HELP - { - Pos = MAP_APPFONT ( 205 , 43 ) ; - Size = MAP_APPFONT ( 50 , 14 ) ; - TabStop = TRUE ; - }; - Control VAL_SET_COLOR - { - Border = TRUE ; - Pos = MAP_APPFONT ( 6 , 6 ) ; - Size = MAP_APPFONT ( 91 , 100 ) ; - TabStop = TRUE ; - }; - Control CTL_COLOR - { - Border = TRUE ; - Pos = MAP_APPFONT ( 100 , 6 ) ; - Size = MAP_APPFONT ( 100 , 100 ) ; - TabStop = TRUE ; - }; - FixedText FT_CYAN - { - Pos = MAP_APPFONT ( 6 , 110 + DIFF ) ; - Size = MAP_APPFONT ( 34 , 10 ) ; - Text [ en-US ] = "~Cyan" ; - }; - FixedText FT_MAGENTA - { - Pos = MAP_APPFONT ( 6 , 123 + DIFF ) ; - Size = MAP_APPFONT ( 34 , 10 ) ; - Text [ en-US ] = "~Magenta" ; - }; - FixedText FT_YELLOW - { - Pos = MAP_APPFONT ( 6 , 136 + DIFF ) ; - Size = MAP_APPFONT ( 34 , 10 ) ; - Text [ en-US ] = "~Yellow" ; - }; - FixedText FT_KEY - { - Pos = MAP_APPFONT ( 6 , 149 + DIFF ) ; - Size = MAP_APPFONT ( 34 , 10 ) ; - Text [ en-US ] = "~Key" ; - }; - MetricField NUM_CYAN - { - HelpID = "svtools:MetricField:DLG_COLOR:NUM_CYAN"; - Border = TRUE ; - Pos = MAP_APPFONT ( 42 , 109 + DIFF ) ; - Size = MAP_APPFONT ( 26 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 100 ; - Last = 100 ; - Unit = FUNIT_CUSTOM ; - CustomUnitText = " %" ; - }; - MetricField NUM_MAGENTA - { - HelpID = "svtools:MetricField:DLG_COLOR:NUM_MAGENTA"; - Border = TRUE ; - Pos = MAP_APPFONT ( 42 , 122 + DIFF ) ; - Size = MAP_APPFONT ( 26 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 100 ; - Last = 100 ; - Unit = FUNIT_CUSTOM ; - CustomUnitText = " %" ; - }; - MetricField NUM_YELLOW - { - HelpID = "svtools:MetricField:DLG_COLOR:NUM_YELLOW"; - Border = TRUE ; - Pos = MAP_APPFONT ( 42 , 135 + DIFF ) ; - Size = MAP_APPFONT ( 26 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 100 ; - Last = 100 ; - Unit = FUNIT_CUSTOM ; - CustomUnitText = " %" ; - }; - MetricField NUM_KEY - { - HelpID = "svtools:MetricField:DLG_COLOR:NUM_KEY"; - Border = TRUE ; - Pos = MAP_APPFONT ( 42 , 148 + DIFF ) ; - Size = MAP_APPFONT ( 26 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 100 ; - Last = 100 ; - Unit = FUNIT_CUSTOM ; - CustomUnitText = " %" ; - }; - FixedText FT_RED - { - Pos = MAP_APPFONT ( 72 , 123 + DIFF ) ; - Size = MAP_APPFONT ( 33 , 10 ) ; - Text [ en-US ] = "~Red" ; - }; - FixedText FT_GREEN - { - Pos = MAP_APPFONT ( 72 , 136 + DIFF ) ; - Size = MAP_APPFONT ( 33 , 10 ) ; - Text [ en-US ] = "~Green" ; - }; - FixedText FT_BLUE - { - Pos = MAP_APPFONT ( 72 , 149 + DIFF ) ; - Size = MAP_APPFONT ( 33 , 10 ) ; - Text [ en-US ] = "~Blue" ; - }; - NumericField NUM_RED - { - HelpID = "svtools:NumericField:DLG_COLOR:NUM_RED"; - Border = TRUE ; - Pos = MAP_APPFONT ( 106 , 122 + DIFF ) ; - Size = MAP_APPFONT ( 26 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 255 ; - Last = 255 ; - }; - NumericField NUM_GREEN - { - HelpID = "svtools:NumericField:DLG_COLOR:NUM_GREEN"; - Border = TRUE ; - Pos = MAP_APPFONT ( 106 , 135 + DIFF ) ; - Size = MAP_APPFONT ( 26 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 255 ; - Last = 255 ; - }; - NumericField NUM_BLUE - { - HelpID = "svtools:NumericField:DLG_COLOR:NUM_BLUE"; - Border = TRUE ; - Pos = MAP_APPFONT ( 106 , 148 + DIFF ) ; - Size = MAP_APPFONT ( 26 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 255 ; - Last = 255 ; - }; - FixedText FT_HUE - { - Pos = MAP_APPFONT ( 135 , 123 + DIFF ) ; - Size = MAP_APPFONT ( 34 , 10 ) ; - Text [ en-US ] = "H~ue" ; - }; - NumericField NUM_HUE - { - HelpID = "svtools:NumericField:DLG_COLOR:NUM_HUE"; - Border = TRUE ; - Pos = MAP_APPFONT ( 171 , 122 + DIFF ) ; - Size = MAP_APPFONT ( 26 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 359 ; - Last = 359 ; - }; - FixedText FT_SATURATION - { - Pos = MAP_APPFONT ( 135 , 136 + DIFF ) ; - Size = MAP_APPFONT ( 34 , 10 ) ; - Text [ en-US ] = "~Saturation" ; - }; - NumericField NUM_SATURATION - { - HelpID = "svtools:NumericField:DLG_COLOR:NUM_SATURATION"; - Border = TRUE ; - Pos = MAP_APPFONT ( 171 , 135 + DIFF ) ; - Size = MAP_APPFONT ( 26 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 100 ; - Last = 100 ; - }; - FixedText FT_LUMINANCE - { - Pos = MAP_APPFONT ( 135 , 149 + DIFF ) ; - Size = MAP_APPFONT ( 34 , 10 ) ; - Text [ en-US ] = "Bright~ness" ; - }; - NumericField NUM_LUMINANCE - { - HelpID = "svtools:NumericField:DLG_COLOR:NUM_LUMINANCE"; - Border = TRUE ; - Pos = MAP_APPFONT ( 171 , 148 + DIFF ) ; - Size = MAP_APPFONT ( 26 , 12 ) ; - TabStop = TRUE ; - Repeat = TRUE ; - Spin = TRUE ; - Maximum = 100 ; - Last = 100 ; - }; - PushButton BTN_1 - { - HelpID = "svtools:PushButton:DLG_COLOR:BTN_1"; - Pos = MAP_APPFONT ( 80 , 109 ) ; - Size = MAP_APPFONT ( 17 , 12 ) ; - Text = "~<--" ; - TabStop = TRUE ; - }; - PushButton BTN_2 - { - HelpID = "svtools:PushButton:DLG_COLOR:BTN_2"; - Pos = MAP_APPFONT ( 100 , 109 ) ; - Size = MAP_APPFONT ( 17 , 12 ) ; - Text = "--~>" ; - TabStop = TRUE ; - }; - Control CTL_PREVIEW_OLD - { - Border = TRUE ; - Pos = MAP_APPFONT ( 200 , 109 ) ; - Size = MAP_APPFONT ( 26 , 51 + DIFF ) ; - TabStop = FALSE ; - }; - Control CTL_PREVIEW - { - Border = TRUE ; - Pos = MAP_APPFONT ( 229 , 109 ) ; - Size = MAP_APPFONT ( 26 , 51 + DIFF ) ; - TabStop = FALSE ; - }; -}; - -String STR_COLORDES -{ - Text [ en-US ] = "RGB(%1, %2, %3) Hue:%4 Saturation:%5 Brightness:%6"; -}; - Index: main/svtools/inc/svtools/colctrl.hxx =================================================================== --- main/svtools/inc/svtools/colctrl.hxx (revision 1232786) +++ main/svtools/inc/svtools/colctrl.hxx (working copy) @@ -1,198 +0,0 @@ -/************************************************************** - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - *************************************************************/ - - - -#ifndef _SV_COLCTRL_HXX -#define _SV_COLCTRL_HXX - -#include -#include -#include - -// ---------------- -// - ColorControl - -// ---------------- - -class Bitmap; -class BitmapReadAccess; -class ColorHSB; - -class SvColorControl : public Control -{ -private: - Bitmap* mpBitmap; - BitmapReadAccess* mpReadAccess; - Color maColor; - short mnLuminance; - Point maPosition; - Link maModifyHdl; - - void Initialize(); - void CreateBitmap(); - void ShowPosition( const Point& aPos ); - -public: - SvColorControl( Window* pParent, WinBits nStyle = 0 ); - SvColorControl( Window* pParent, const ResId& rResId ); - ~SvColorControl(); - - virtual void MouseMove( const MouseEvent& rMEvt ); - virtual void MouseButtonDown( const MouseEvent& rMEvt ); - virtual void MouseButtonUp( const MouseEvent& rMEvt ); -// virtual void KeyInput( const KeyEvent& rKEvent ); - virtual void Paint( const Rectangle& rRect ); - virtual void Resize(); -// virtual void GetFocus(); -// virtual void LoseFocus(); - - virtual void Modify(); - - Color GetColor() const { return maColor; }; - void SetColor( const Color& rCol ); - void SetColor( const ColorHSB& rCol, sal_Bool bSetColor = sal_True ); - - short GetLuminance() const { return mnLuminance; }; - void SetLuminance( short nLum ); - - void SetModifyHdl( const Link& rLink ) { maModifyHdl = rLink; } - const Link& GetModifyHdl() const { return maModifyHdl; } - -}; - -// ----------------------- -// - ColorPreviewControl - -// ----------------------- - -class ColorPreviewControl : public Control -{ -private: - Color maColor; - -public: - ColorPreviewControl( Window* pParent, WinBits nStyle = 0 ); - ColorPreviewControl( Window* pParent, const ResId& rResId ); - ~ColorPreviewControl(); - - virtual void Paint( const Rectangle& rRect ); - - Color GetColor() const { return maColor; }; - void SetColor( const Color& rCol ); -}; - -// ----------------------- -// - ColorMixingControl - -// ----------------------- - -enum CMCPosition { CMC_TOPLEFT, CMC_TOPRIGHT, CMC_BOTTOMLEFT, CMC_BOTTOMRIGHT, CMC_OTHER }; - -class ColorMixingControl : public ValueSet -{ -private: - sal_uInt16 mnRows; - sal_uInt16 mnColumns; - Color maColor[4]; - - void Initialize(); - - Color CalcDifferenceColor( sal_uInt16 nCol1, sal_uInt16 nCol2, sal_uInt16 nSteps ); - void FillRow( sal_uInt16 nRow ); - void FillColumn( sal_uInt16 nColumn ); - -public: - ColorMixingControl( Window* pParent, WinBits nStyle = 0, - sal_uInt16 nRows = 4, sal_uInt16 nColumns = 4 ); - ColorMixingControl( Window* pParent, const ResId& rResId, - sal_uInt16 nRows = 4, sal_uInt16 nColumns = 4 ); - ~ColorMixingControl(); - - sal_uInt16 GetRows() const { return mnRows; }; - void SetRows( sal_uInt16 nRows ); - sal_uInt16 GetColumns() const { return mnColumns; }; - void SetColumns( sal_uInt16 nColumns ); - - using ValueSet::GetColor; - Color GetColor( CMCPosition ePos ) const { return maColor[ ePos ]; }; - using ValueSet::SetColor; - void SetColor( CMCPosition ePos, const Color& rCol ); - - String GetRGBString( const Color& rColor ); - CMCPosition GetCMCPosition() const; -}; - -// ------------ -// - ColorHSB - -// ------------ - -class ColorHSB -{ -private: - sal_uInt16 mnHue; // Farbwinkel, 360 Grad - sal_uInt16 mnSat; // Saturation, 100 % - sal_uInt16 mnBri; // Brightness, 100 % - -public: - ColorHSB() - { mnHue=0; mnSat=0; mnBri=0; } - ColorHSB( sal_uInt16 nH, sal_uInt16 nS, sal_uInt16 nB ) - { mnHue=nH; mnSat=nS; mnBri=nB; } - ColorHSB( const Color& rColor ); - - void SetHue( sal_uInt16 nH ) { mnHue=nH; } - void SetSat( sal_uInt16 nS ) { mnSat=nS; } - void SetBri( sal_uInt16 nB ) { mnBri=nB; } - sal_uInt16 GetHue() const { return mnHue; } - sal_uInt16 GetSat() const { return mnSat; } - sal_uInt16 GetBri() const { return mnBri; } - Color GetRGB() const; -}; - -// ------------- -// - ColorCMYK - -// ------------- - -class ColorCMYK -{ -private: - sal_uInt16 mnCyan; - sal_uInt16 mnMagenta; - sal_uInt16 mnYellow; - sal_uInt16 mnKey; - -public: - ColorCMYK() - { mnCyan=0; mnMagenta=0; mnYellow=0; mnKey=100; } - ColorCMYK( sal_uInt16 nC, sal_uInt16 nM, sal_uInt16 nY, sal_uInt16 nK ) - { mnCyan=nC; mnMagenta=nM; mnYellow=nY; mnKey=nK; } - ColorCMYK( const Color& rColor ); - - void SetCyan( sal_uInt16 nC ) { mnCyan=nC; } - void SetMagenta( sal_uInt16 nM ) { mnMagenta=nM; } - void SetYellow( sal_uInt16 nY ) { mnYellow=nY; } - void SetKey( sal_uInt16 nK ) { mnKey=nK; } - sal_uInt16 GetCyan() const { return mnCyan; } - sal_uInt16 GetMagenta() const { return mnMagenta; } - sal_uInt16 GetYellow() const { return mnYellow; } - sal_uInt16 GetKey() const { return mnKey; } - Color GetRGB() const; -}; - -#endif // _SV_COLCTRL_HXX Index: main/svtools/inc/svtools/colrdlg.hxx =================================================================== --- main/svtools/inc/svtools/colrdlg.hxx (revision 1232786) +++ main/svtools/inc/svtools/colrdlg.hxx (working copy) @@ -19,85 +19,39 @@ * *************************************************************/ - - #ifndef _SV_COLRDLG_HXX #define _SV_COLRDLG_HXX #include "svtools/svtdllapi.h" -#include -#ifndef _SV_BUTTON_HXX //autogen -#include -#endif -#include -#include -#include +#include + +class Window; // --------------- // - ColorDialog - // --------------- -class SVT_DLLPUBLIC SvColorDialog : public ModalDialog +namespace svtools { -private: - ColorMixingControl maColMixCtrl; - PushButton maBtn1; - PushButton maBtn2; - //PushButton maBtn3; - //PushButton maBtn4; - //FixedText maFtRGB; - SvColorControl maCtlColor; + // SELECT is the default + enum ColorPickerMode { ColorPickerMode_SELECT = 0, ColorPickerMode_ADD = 1, ColorPickerMode_MODIFY = 2 }; +} - // CMYK controls. - FixedText maFtCyan; - MetricField maNumCyan; - FixedText maFtMagenta; - MetricField maNumMagenta; - FixedText maFtYellow; - MetricField maNumYellow; - FixedText maFtKey; - MetricField maNumKey; - - // RGB controls. - FixedText maFtRed; - NumericField maNumRed; - FixedText maFtGreen; - NumericField maNumGreen; - FixedText maFtBlue; - NumericField maNumBlue; - - // HSL controls. - FixedText maFtHue; - NumericField maNumHue; - FixedText maFtSaturation; - NumericField maNumSaturation; - FixedText maFtLuminance; - NumericField maNumLuminance; - - ColorPreviewControl maCtlPreview; - ColorPreviewControl maCtlPreviewOld; - - OKButton maBtnOK; - CancelButton maBtnCancel; - HelpButton maBtnHelp; - - Color maColor; - - SVT_DLLPRIVATE void Initialize(); - - DECL_DLLPRIVATE_LINK( ColorModifyHdl, void * ); - DECL_DLLPRIVATE_LINK( ClickBtnHdl, void * ); - DECL_DLLPRIVATE_LINK( ClickMixCtrlHdl, void * ); - DECL_DLLPRIVATE_LINK( SelectMixCtrlHdl, void * ); - +class SVT_DLLPUBLIC SvColorDialog +{ public: - SvColorDialog( Window* pParent ); - ~SvColorDialog(); + SvColorDialog( ::Window* pParent ); void SetColor( const Color& rColor ); const Color& GetColor() const; + void SetMode( sal_Int16 eMode ); virtual short Execute(); + +private: + Window* mpParent; + Color maColor; + sal_Int16 meMode; }; #endif // _SV_COLRDLG_HXX