diff options
19 files changed, 796 insertions, 543 deletions
diff --git a/compilerplugins/clang/store/fpcomparison.cxx b/compilerplugins/clang/store/fpcomparison.cxx index b914d7084bc4..0e27ed9819f4 100644 --- a/compilerplugins/clang/store/fpcomparison.cxx +++ b/compilerplugins/clang/store/fpcomparison.cxx @@ -231,8 +231,6 @@ bool FpComparison::ignore(FunctionDecl* function) || dc.Function("ApplySpecialItem").Class("TitleItemConverter").Namespace("wrapper").Namespace("chart").GlobalNamespace() || dc.Function("ApplySpecialItem").Class("TextLabelItemConverter").Namespace("wrapper").Namespace("chart").GlobalNamespace() || dc.Function("operate").Class("OOp_COMPARE").Namespace("file").Namespace("connectivity").GlobalNamespace() - || dc.Function("SetValues").Class("ColorFieldControl").Namespace("cui").GlobalNamespace() - || dc.Function("SetValue").Class("ColorSliderControl").Namespace("cui").GlobalNamespace() || dc.Function("Write").Class("ORTFImportExport").Namespace("dbaui").GlobalNamespace() || dc.Function("appendRow").Class("ORTFImportExport").Namespace("dbaui").GlobalNamespace() || dc.Function("WriteCell").Class("OHTMLImportExport").Namespace("dbaui").GlobalNamespace() diff --git a/cui/inc/bitmaps.hlst b/cui/inc/bitmaps.hlst index dc1ce4a6a9e4..2cefabd14611 100644 --- a/cui/inc/bitmaps.hlst +++ b/cui/inc/bitmaps.hlst @@ -63,7 +63,6 @@ #define RID_SVXBMP_FILEOPEN "res/fileopen.png" #define RID_SVXBMP_TARGET "res/target.png" #define RID_SVXBMP_NEWDOC "res/newdoc.png" -#define RID_SVXBMP_COLORSLIDER "res/colorslider.png" #define RID_SVXBMP_COLLAPSEDNODE "res/sx18002.png" #define RID_SVXBMP_EXPANDEDNODE "res/sx18003.png" diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx index 756c0d5aed6f..70a059a29014 100644 --- a/cui/source/dialogs/colorpicker.cxx +++ b/cui/source/dialogs/colorpicker.cxx @@ -28,6 +28,7 @@ #include <cppuhelper/compbase.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/basemutex.hxx> +#include <vcl/weld.hxx> #include <vcl/dialog.hxx> #include <vcl/button.hxx> #include <vcl/fixed.hxx> @@ -150,61 +151,85 @@ static void RGBtoCMYK( double dR, double dG, double dB, double& fCyan, double& f } } -class ColorPreviewControl : public Control +class ColorPreviewControl { +private: + std::unique_ptr<weld::DrawingArea> m_xDrawingArea; + Color m_aColor; + Size m_aSize; + + DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); + DECL_LINK(DoResize, const Size& rSize, void); public: - ColorPreviewControl( vcl::Window* pParent, WinBits nStyle ); + ColorPreviewControl(weld::DrawingArea* pDrawingArea) + : m_xDrawingArea(pDrawingArea) + { + m_xDrawingArea->connect_size_allocate(LINK(this, ColorPreviewControl, DoResize)); + m_xDrawingArea->connect_draw(LINK(this, ColorPreviewControl, DoPaint)); + m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_char_width() * 10, + m_xDrawingArea->get_text_height() * 2); - virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override; + } - void SetColor(const Color& rColor); + void SetColor(const Color& rCol) + { + if (rCol != m_aColor) + { + m_aColor = rCol; + m_xDrawingArea->queue_draw(); + } + } -private: - Color maColor; + void show() { m_xDrawingArea->show(); } }; -ColorPreviewControl::ColorPreviewControl(vcl::Window* pParent, WinBits nStyle) - : Control(pParent, nStyle) +IMPL_LINK(ColorPreviewControl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) { + vcl::RenderContext& rRenderContext = aPayload.first; + rRenderContext.SetFillColor(m_aColor); + rRenderContext.SetLineColor(m_aColor); + rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), m_aSize)); } -VCL_BUILDER_FACTORY_CONSTRUCTOR(ColorPreviewControl, 0) - -void ColorPreviewControl::SetColor( const Color& rCol ) +IMPL_LINK(ColorPreviewControl, DoResize, const Size&, rSize, void) { - if (rCol != maColor) + if (m_aSize != rSize) { - maColor = rCol; - Invalidate(); + m_aSize = rSize; + m_xDrawingArea->queue_draw(); } } -void ColorPreviewControl::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) -{ - rRenderContext.SetFillColor(maColor); - rRenderContext.SetLineColor(maColor); - rRenderContext.DrawRect(rRect); -} - enum ColorMode { HUE, SATURATION, BRIGHTNESS, RED, GREEN, BLUE }; const ColorMode DefaultMode = HUE; -class ColorFieldControl : public Control +class ColorFieldControl { public: - ColorFieldControl(vcl::Window* pParent, WinBits nStyle); - virtual ~ColorFieldControl() override; - - virtual void dispose() override; + ColorFieldControl(weld::DrawingArea* pDrawingArea) + : m_xDrawingArea(pDrawingArea) + , meMode( DefaultMode ) + , mdX( -1.0 ) + , mdY( -1.0 ) + { + m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_char_width() * 40, + m_xDrawingArea->get_text_height() * 10); + m_xDrawingArea->connect_size_allocate(LINK(this, ColorFieldControl, DoResize)); + m_xDrawingArea->connect_draw(LINK(this, ColorFieldControl, DoPaint)); + m_xDrawingArea->connect_mouse_press(LINK(this, ColorFieldControl, DoButtonDown)); + m_xDrawingArea->connect_mouse_release(LINK(this, ColorFieldControl, DoButtonUp)); + } - virtual void MouseMove( const MouseEvent& rMEvt ) override; - virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; - virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; - virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override; - virtual void Resize() override; + ~ColorFieldControl() + { + mxBitmap.disposeAndClear(); + } - virtual Size GetOptimalSize() const override; + DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); + DECL_LINK(DoResize, const Size& rSize, void); + DECL_LINK(DoButtonDown, const Point& rMEvt, void); + DECL_LINK(DoMouseMove, const Point& rMEvt, void); + DECL_LINK(DoButtonUp, const Point& rMEvt, void); void UpdateBitmap(); void ShowPosition( const Point& rPos, bool bUpdate ); @@ -215,18 +240,18 @@ public: double GetX() { return mdX;} double GetY() { return mdY;} - void KeyMove(int dx, int dy); - void SetModifyHdl(const Link<ColorFieldControl&,void>& rLink) { maModifyHdl = rLink; } private: - Link<ColorFieldControl&,void> maModifyHdl; + std::unique_ptr<weld::DrawingArea> m_xDrawingArea; + Size m_aSize; ColorMode meMode; Color maColor; double mdX; double mdY; Point maPosition; VclPtr<VirtualDevice> mxBitmap; + Link<ColorFieldControl&,void> maModifyHdl; std::vector<sal_uInt8> maRGB_Horiz; std::vector<sal_uInt16> maGrad_Horiz; std::vector<sal_uInt16> maPercent_Horiz; @@ -234,36 +259,9 @@ private: std::vector<sal_uInt16> maPercent_Vert; }; -ColorFieldControl::ColorFieldControl( vcl::Window* pParent, WinBits nStyle ) -: Control( pParent, nStyle ) -, meMode( DefaultMode ) -, mdX( -1.0 ) -, mdY( -1.0 ) -{ - SetControlBackground(); -} - -ColorFieldControl::~ColorFieldControl() -{ - disposeOnce(); -} - -void ColorFieldControl::dispose() -{ - mxBitmap.disposeAndClear(); - Control::dispose(); -} - -VCL_BUILDER_FACTORY_CONSTRUCTOR(ColorFieldControl, 0) - -Size ColorFieldControl::GetOptimalSize() const -{ - return LogicToPixel(Size(158, 158), MapMode(MapUnit::MapAppFont)); -} - void ColorFieldControl::UpdateBitmap() { - const Size aSize(GetOutputSizePixel()); + const Size aSize(m_aSize); if (mxBitmap && mxBitmap->GetOutputSizePixel() != aSize) mxBitmap.disposeAndClear(); @@ -405,7 +403,7 @@ void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate ) if (!mxBitmap) { UpdateBitmap(); - Invalidate(); + m_xDrawingArea->queue_draw(); } if (!mxBitmap) @@ -428,8 +426,8 @@ void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate ) Point aPos = maPosition; maPosition.setX( nX - 5 ); maPosition.setY( nY - 5 ); - Invalidate(::tools::Rectangle(aPos, Size(11, 11))); - Invalidate(::tools::Rectangle(maPosition, Size(11, 11))); + m_xDrawingArea->queue_draw_area(aPos.X(), aPos.Y(), 11, 11); + m_xDrawingArea->queue_draw_area(maPosition.X(), maPosition.Y(), 11, 11); if (bUpdate) { @@ -440,85 +438,32 @@ void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate ) } } -void ColorFieldControl::MouseMove( const MouseEvent& rMEvt ) +IMPL_LINK(ColorFieldControl, DoButtonDown, const Point&, rMEvt, void) { - 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(); + m_xDrawingArea->connect_mouse_move(LINK(this, ColorFieldControl, DoMouseMove)); + ShowPosition(rMEvt, true); + Modify(); } -void ColorFieldControl::KeyMove( int dx, int dy ) +IMPL_LINK(ColorFieldControl, DoMouseMove, const Point&, rMEvt, void) { - Size aSize(GetOutputSizePixel()); - Point aPos(static_cast<long>(mdX * aSize.Width()), static_cast<long>((1.0 - mdY) * aSize.Height())); - aPos.AdjustX(dx ); - aPos.AdjustY(dy ); - if( aPos.X() < 0 ) - aPos.AdjustX(aSize.Width() ); - else if( aPos.X() >= aSize.Width() ) - aPos.AdjustX( -(aSize.Width()) ); - - if( aPos.Y() < 0 ) - aPos.AdjustY(aSize.Height() ); - else if( aPos.Y() >= aSize.Height() ) - aPos.AdjustY( -(aSize.Height()) ); - - ShowPosition( aPos, true ); + ShowPosition(rMEvt, true); Modify(); } -void ColorFieldControl::KeyInput( const KeyEvent& rKEvt ) +IMPL_LINK_NOARG(ColorFieldControl, DoButtonUp, const Point&, void) { - 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); + m_xDrawingArea->connect_mouse_move(Link<const Point&, void>()); } -void ColorFieldControl::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) +IMPL_LINK(ColorFieldControl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) { + vcl::RenderContext& rRenderContext = aPayload.first; if (!mxBitmap) UpdateBitmap(); if (mxBitmap) - rRenderContext.DrawOutDev(rRect.TopLeft(), rRect.GetSize(), rRect.TopLeft(), rRect.GetSize(), *mxBitmap); + rRenderContext.DrawOutDev(Point(0, 0), m_aSize, Point(0, 0), m_aSize, *mxBitmap); // draw circle around current color if (maColor.IsDark()) @@ -531,11 +476,15 @@ void ColorFieldControl::Paint(vcl::RenderContext& rRenderContext, const ::tools: rRenderContext.DrawEllipse(::tools::Rectangle(maPosition, Size(11, 11))); } -void ColorFieldControl::Resize() +IMPL_LINK(ColorFieldControl, DoResize, const Size&, rSize, void) { - UpdateBitmap(); - UpdatePosition(); - Control::Resize(); + if (m_aSize != rSize) + { + m_aSize = rSize; + UpdateBitmap(); + UpdatePosition(); + m_xDrawingArea->queue_draw(); + } } void ColorFieldControl::Modify() @@ -557,29 +506,27 @@ void ColorFieldControl::SetValues( Color aColor, ColorMode eMode, double x, doub UpdateBitmap(); UpdatePosition(); if (bUpdateBitmap) - Invalidate(); + m_xDrawingArea->queue_draw(); } } void ColorFieldControl::UpdatePosition() { - Size aSize(GetOutputSizePixel()); + Size aSize(m_aSize); ShowPosition(Point(static_cast<long>(mdX * aSize.Width()), static_cast<long>((1.0 - mdY) * aSize.Height())), false); } -class ColorSliderControl : public Control +class ColorSliderControl { public: - ColorSliderControl( vcl::Window* pParent, WinBits nStyle ); - virtual ~ColorSliderControl() override; - virtual void dispose() override; + ColorSliderControl(weld::DrawingArea* pDrawingArea); + ~ColorSliderControl(); - virtual void MouseMove( const MouseEvent& rMEvt ) override; - virtual void MouseButtonDown( const MouseEvent& rMEvt ) override; - virtual void MouseButtonUp( const MouseEvent& rMEvt ) override; - virtual void KeyInput( const KeyEvent& rKEvt ) override; - virtual void Paint( vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect ) override; - virtual void Resize() override; + DECL_LINK(DoButtonDown, const Point& rMEvt, void); + DECL_LINK(DoMouseMove, const Point& rMEvt, void); + DECL_LINK(DoButtonUp, const Point& rMEvt, void); + DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); + DECL_LINK(DoResize, const Size& rSize, void); void UpdateBitmap(); void ChangePosition( long nY ); @@ -588,14 +535,17 @@ public: void SetValue( const Color& rColor, ColorMode eMode, double dValue ); double GetValue() const { return mdValue; } - void KeyMove( int dy ); - void SetModifyHdl( const Link<ColorSliderControl&,void>& rLink ) { maModifyHdl = rLink; } sal_Int16 GetLevel() const { return mnLevel; } + void set_margin_top(int nMargin) { m_xDrawingArea->set_margin_top(nMargin); } + void set_margin_bottom(int nMargin) { m_xDrawingArea->set_margin_bottom(nMargin); } + private: Link<ColorSliderControl&,void> maModifyHdl; + std::unique_ptr<weld::DrawingArea> m_xDrawingArea; + Size m_aSize; Color maColor; ColorMode meMode; VclPtr<VirtualDevice> mxBitmap; @@ -603,31 +553,27 @@ private: double mdValue; }; -ColorSliderControl::ColorSliderControl( vcl::Window* pParent, WinBits nStyle ) - : Control( pParent, nStyle ) +ColorSliderControl::ColorSliderControl(weld::DrawingArea* pDrawingArea) + : m_xDrawingArea(pDrawingArea) , meMode( DefaultMode ) , mnLevel( 0 ) , mdValue( -1.0 ) { - SetControlBackground(); + m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_char_width() * 3, -1); + m_xDrawingArea->connect_size_allocate(LINK(this, ColorSliderControl, DoResize)); + m_xDrawingArea->connect_draw(LINK(this, ColorSliderControl, DoPaint)); + m_xDrawingArea->connect_mouse_press(LINK(this, ColorSliderControl, DoButtonDown)); + m_xDrawingArea->connect_mouse_release(LINK(this, ColorSliderControl, DoButtonUp)); } ColorSliderControl::~ColorSliderControl() { - disposeOnce(); -} - -void ColorSliderControl::dispose() -{ mxBitmap.disposeAndClear(); - Control::dispose(); } -VCL_BUILDER_FACTORY_CONSTRUCTOR(ColorSliderControl, 0) - void ColorSliderControl::UpdateBitmap() { - Size aSize(1, GetOutputSizePixel().Height()); + Size aSize(1, m_aSize.Height()); if (mxBitmap && mxBitmap->GetOutputSizePixel() != aSize) mxBitmap.disposeAndClear(); @@ -704,7 +650,7 @@ void ColorSliderControl::UpdateBitmap() void ColorSliderControl::ChangePosition(long nY) { - const long nHeight = GetOutputSizePixel().Height() - 1; + const long nHeight = m_aSize.Height() - 1; if (nY < 0) nY = 0; @@ -715,75 +661,51 @@ void ColorSliderControl::ChangePosition(long nY) mdValue = double(nHeight - nY) / double(nHeight); } -void ColorSliderControl::MouseMove( const MouseEvent& rMEvt ) +IMPL_LINK(ColorSliderControl, DoButtonDown, const Point&, rMEvt, void) { - if (rMEvt.IsLeft()) - { - ChangePosition(rMEvt.GetPosPixel().Y()); - Modify(); - } + m_xDrawingArea->connect_mouse_move(LINK(this, ColorSliderControl, DoMouseMove)); + ChangePosition(rMEvt.Y()); + Modify(); } -void ColorSliderControl::MouseButtonDown(const MouseEvent& rMEvt) +IMPL_LINK(ColorSliderControl, DoMouseMove, const Point&, rMEvt, void) { - if (rMEvt.IsLeft() && !rMEvt.IsShift()) - { - CaptureMouse(); - ChangePosition( rMEvt.GetPosPixel().Y() ); - Modify(); - } + ChangePosition(rMEvt.Y()); + Modify(); } -void ColorSliderControl::MouseButtonUp(const MouseEvent&) +IMPL_LINK_NOARG(ColorSliderControl, DoButtonUp, const Point&, void) { - if (IsMouseCaptured()) - ReleaseMouse(); + m_xDrawingArea->connect_mouse_move(Link<const Point&, void>()); } -void ColorSliderControl::KeyMove(int dy) -{ - ChangePosition( mnLevel + dy ); - Modify(); -} -void ColorSliderControl::KeyInput(const KeyEvent& rKEvt) +IMPL_LINK(ColorSliderControl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) { - 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 ); -} + vcl::RenderContext& rRenderContext = aPayload.first; -void ColorSliderControl::Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& /*rRect*/) -{ if (!mxBitmap) UpdateBitmap(); - const Size aSize(GetOutputSizePixel()); + const Size aSize(m_aSize); Point aPos; int x = aSize.Width(); while (x--) { rRenderContext.DrawOutDev(aPos, aSize, Point(0,0), aSize, *mxBitmap); - aPos.AdjustX(1 ); + aPos.AdjustX(1); } } -void ColorSliderControl::Resize() +IMPL_LINK(ColorSliderControl, DoResize, const Size&, rSize, void) { - UpdateBitmap(); - Control::Resize(); + if (m_aSize != rSize) + { + m_aSize = rSize; + UpdateBitmap(); + m_xDrawingArea->queue_draw(); + } } void ColorSliderControl::Modify() @@ -798,30 +720,56 @@ void ColorSliderControl::SetValue(const Color& rColor, ColorMode eMode, double d { maColor = rColor; mdValue = dValue; - mnLevel = static_cast<sal_Int16>((1.0-dValue) * GetOutputSizePixel().Height()); + mnLevel = static_cast<sal_Int16>((1.0-dValue) * m_aSize.Height()); meMode = eMode; if (bUpdateBitmap) UpdateBitmap(); - Invalidate(); + m_xDrawingArea->queue_draw(); } } -class ColorPickerDialog : public ModalDialog +class ColorPickerDialog : public weld::GenericDialogController { +private: + std::unique_ptr<ColorFieldControl> m_xColorField; + std::unique_ptr<ColorSliderControl> m_xColorSlider; + std::unique_ptr<ColorPreviewControl> m_xColorPreview; + std::unique_ptr<ColorPreviewControl> m_xColorPrevious; + + std::unique_ptr<weld::Widget> m_xFISliderLeft; + std::unique_ptr<weld::Widget> m_xFISliderRight; + std::unique_ptr<weld::RadioButton> m_xRBRed; + std::unique_ptr<weld::RadioButton> m_xRBGreen; + std::unique_ptr<weld::RadioButton> m_xRBBlue; + std::unique_ptr<weld::RadioButton> m_xRBHue; + std::unique_ptr<weld::RadioButton> m_xRBSaturation; + std::unique_ptr<weld::RadioButton> m_xRBBrightness; + + std::unique_ptr<weld::SpinButton> m_xMFRed; + std::unique_ptr<weld::SpinButton> m_xMFGreen; + std::unique_ptr<weld::SpinButton> m_xMFBlue; + std::unique_ptr<weld::HexColorControl> m_xEDHex; + + std::unique_ptr<weld::MetricSpinButton> m_xMFHue; + std::unique_ptr<weld::MetricSpinButton> m_xMFSaturation; + std::unique_ptr<weld::MetricSpinButton> m_xMFBrightness; + + std::unique_ptr<weld::MetricSpinButton> m_xMFCyan; + std::unique_ptr<weld::MetricSpinButton> m_xMFMagenta; + std::unique_ptr<weld::MetricSpinButton> m_xMFYellow; + std::unique_ptr<weld::MetricSpinButton> m_xMFKey; + public: - ColorPickerDialog(vcl::Window* pParent, Color nColor, sal_Int16 nMode); - virtual ~ColorPickerDialog() override - { - disposeOnce(); - } - virtual void dispose() override; + ColorPickerDialog(weld::Window* pParent, Color nColor, sal_Int16 nMode); void update_color(UpdateFlags n = UpdateFlags::All); DECL_LINK(ColorFieldControlModifydl, ColorFieldControl&, void); DECL_LINK(ColorSliderControlModifyHdl, ColorSliderControl&, void); - DECL_LINK(ColorModifyEditHdl, Edit&, void); - DECL_LINK(ModeModifyHdl, RadioButton&, void); + DECL_LINK(ColorModifyMetricHdl, weld::MetricSpinButton&, void); + DECL_LINK(ColorModifySpinHdl, weld::SpinButton&, void); + DECL_LINK(ColorModifyEditHdl, weld::Entry&, void); + DECL_LINK(ModeModifyHdl, weld::ToggleButton&, void); Color GetColor() const; @@ -834,130 +782,84 @@ private: double mdRed, mdGreen, mdBlue; double mdHue, mdSat, mdBri; double mdCyan, mdMagenta, mdYellow, mdKey; - -private: - VclPtr<ColorFieldControl> mpColorField; - VclPtr<ColorSliderControl> mpColorSlider; - VclPtr<ColorPreviewControl> mpColorPreview; - VclPtr<ColorPreviewControl> mpColorPrevious; - - VclPtr<FixedImage> mpFISliderLeft; - VclPtr<FixedImage> mpFISliderRight; - Image maSliderImage; - - VclPtr<RadioButton> mpRBRed; - VclPtr<RadioButton> mpRBGreen; - VclPtr<RadioButton> mpRBBlue; - VclPtr<RadioButton> mpRBHue; - VclPtr<RadioButton> mpRBSaturation; - VclPtr<RadioButton> mpRBBrightness; - - VclPtr<MetricField> mpMFRed; - VclPtr<MetricField> mpMFGreen; - VclPtr<MetricField> mpMFBlue; - VclPtr<HexColorControl> mpEDHex; - - VclPtr<MetricField> mpMFHue; - VclPtr<MetricField> mpMFSaturation; - VclPtr<MetricField> mpMFBrightness; - - VclPtr<MetricField> mpMFCyan; - VclPtr<MetricField> mpMFMagenta; - VclPtr<MetricField> mpMFYellow; - VclPtr<MetricField> mpMFKey; }; -ColorPickerDialog::ColorPickerDialog( vcl::Window* pParent, Color nColor, sal_Int16 nMode ) -: ModalDialog( pParent, "ColorPicker", "cui/ui/colorpickerdialog.ui" ) -, mnDialogMode( nMode ) -, meMode( DefaultMode ) -, maSliderImage( BitmapEx( RID_SVXBMP_COLORSLIDER ) ) +ColorPickerDialog::ColorPickerDialog(weld::Window* pParent, Color nColor, sal_Int16 nMode) + : GenericDialogController(pParent, "cui/ui/colorpickerdialog.ui", "ColorPicker") + , m_xColorField(new ColorFieldControl(m_xBuilder->weld_drawing_area("colorField"))) + , m_xColorSlider(new ColorSliderControl(m_xBuilder->weld_drawing_area("colorSlider"))) + , m_xColorPreview(new ColorPreviewControl(m_xBuilder->weld_drawing_area("preview"))) + , m_xColorPrevious(new ColorPreviewControl(m_xBuilder->weld_drawing_area("previous"))) + , m_xFISliderLeft(m_xBuilder->weld_widget("leftImage")) + , m_xFISliderRight(m_xBuilder->weld_widget("rightImage")) + , m_xRBRed(m_xBuilder->weld_radio_button("redRadiobutton")) + , m_xRBGreen(m_xBuilder->weld_radio_button("greenRadiobutton")) + , m_xRBBlue(m_xBuilder->weld_radio_button("blueRadiobutton")) + , m_xRBHue(m_xBuilder->weld_radio_button("hueRadiobutton")) + , m_xRBSaturation(m_xBuilder->weld_radio_button("satRadiobutton")) + , m_xRBBrightness(m_xBuilder->weld_radio_button("brightRadiobutton")) + , m_xMFRed(m_xBuilder->weld_spin_button("redSpinbutton")) + , m_xMFGreen(m_xBuilder->weld_spin_button("greenSpinbutton")) + , m_xMFBlue(m_xBuilder->weld_spin_button("blueSpinbutton")) + , m_xEDHex(new weld::HexColorControl(m_xBuilder->weld_entry("hexEntry"))) + , m_xMFHue(m_xBuilder->weld_metric_spin_button("hueSpinbutton")) + , m_xMFSaturation(m_xBuilder->weld_metric_spin_button("satSpinbutton")) + , m_xMFBrightness(m_xBuilder->weld_metric_spin_button("brightSpinbutton")) + , m_xMFCyan(m_xBuilder->weld_metric_spin_button("cyanSpinbutton")) + , m_xMFMagenta(m_xBuilder->weld_metric_spin_button("magSpinbutton")) + , m_xMFYellow(m_xBuilder->weld_metric_spin_button("yellowSpinbutton")) + , m_xMFKey(m_xBuilder->weld_metric_spin_button("keySpinbutton")) + , mnDialogMode( nMode ) + , meMode( DefaultMode ) { - get(mpColorField, "colorField"); - get(mpColorSlider, "colorSlider"); - get(mpColorPreview, "preview"); - get(mpColorPrevious, "previous"); - get(mpRBRed, "redRadiobutton"); - get(mpRBGreen, "greenRadiobutton"); - get(mpRBBlue, "blueRadiobutton"); - get(mpRBHue, "hueRadiobutton"); - get(mpRBSaturation, "satRadiobutton"); - get(mpRBBrightness, "brightRadiobutton"); - get(mpMFRed, "redSpinbutton"); - get(mpMFGreen, "greenSpinbutton"); - get(mpMFBlue, "blueSpinbutton"); - get(mpEDHex, "hexEntry"); - get(mpMFHue, "hueSpinbutton"); - get(mpMFSaturation, "satSpinbutton"); - get(mpMFBrightness, "brightSpinbutton"); - get(mpMFCyan, "cyanSpinbutton"); - get(mpMFMagenta, "magSpinbutton"); - get(mpMFYellow, "yellowSpinbutton"); - get(mpMFKey, "keySpinbutton"); - get(mpFISliderLeft, "leftImage"); - get(mpFISliderRight, "rightImage"); - - Size aDialogSize = get_preferred_size(); - set_width_request(aDialogSize.Width() + 50); - set_height_request(aDialogSize.Height() + 30); - - mpColorField->SetModifyHdl( LINK( this, ColorPickerDialog, ColorFieldControlModifydl ) ); - mpColorSlider->SetModifyHdl( LINK( this, ColorPickerDialog, ColorSliderControlModifyHdl ) ); - - Link<Edit&,void> aLink3( LINK( this, ColorPickerDialog, ColorModifyEditHdl ) ); - mpMFRed->SetModifyHdl( aLink3 ); - mpMFGreen->SetModifyHdl( aLink3 ); - mpMFBlue->SetModifyHdl( aLink3 ); - - mpMFCyan->SetModifyHdl( aLink3 ); - mpMFMagenta->SetModifyHdl( aLink3 ); - mpMFYellow->SetModifyHdl( aLink3 ); - mpMFKey->SetModifyHdl( aLink3 ); - - mpMFHue->SetModifyHdl( aLink3 ); - mpMFSaturation->SetModifyHdl( aLink3 ); - mpMFBrightness->SetModifyHdl( aLink3 ); - - mpEDHex->SetModifyHdl( aLink3 ); - - Link<RadioButton&,void> aLink2 = LINK( this, ColorPickerDialog, ModeModifyHdl ); - mpRBRed->SetToggleHdl( aLink2 ); - mpRBGreen->SetToggleHdl( aLink2 ); - mpRBBlue->SetToggleHdl( aLink2 ); - mpRBHue->SetToggleHdl( aLink2 ); - mpRBSaturation->SetToggleHdl( aLink2 ); - mpRBBrightness->SetToggleHdl( aLink2 ); - - Image aSliderImage( maSliderImage ); - - mpFISliderLeft->SetImage( aSliderImage ); - mpFISliderLeft->Show(); - - BitmapEx aTmpBmp( maSliderImage.GetBitmapEx() ); - aTmpBmp.Mirror( BmpMirrorFlags::Horizontal ); - mpFISliderRight->SetImage( Image( aTmpBmp ) ); - - Size aSize( maSliderImage.GetSizePixel() ); - mpFISliderLeft->SetSizePixel( aSize ); - mpFISliderRight->SetSizePixel( aSize ); - - Point aPos( mpColorSlider->GetPosPixel() ); - - aPos.AdjustX( -(aSize.Width()) ); - aPos.AdjustY( -(aSize.Height() / 2) ); - mpFISliderLeft->SetPosPixel( aPos ); - - aPos.AdjustX(aSize.Width() + mpColorSlider->GetSizePixel().Width() ); - mpFISliderRight->SetPosPixel( aPos ); - - Color aColor( nColor ); + m_xMFHue->set_unit(FUNIT_DEGREE); + m_xMFSaturation->set_unit(FUNIT_PERCENT); + m_xMFBrightness->set_unit(FUNIT_PERCENT); + + m_xMFCyan->set_unit(FUNIT_PERCENT); + m_xMFMagenta->set_unit(FUNIT_PERCENT); + m_xMFYellow->set_unit(FUNIT_PERCENT); + m_xMFKey->set_unit(FUNIT_PERCENT); + + m_xColorField->SetModifyHdl( LINK( this, ColorPickerDialog, ColorFieldControlModifydl ) ); + m_xColorSlider->SetModifyHdl( LINK( this, ColorPickerDialog, ColorSliderControlModifyHdl ) ); + + int nMargin = (m_xFISliderLeft->get_preferred_size().Height() + 1) / 2; + m_xColorSlider->set_margin_top(nMargin); + m_xColorSlider->set_margin_bottom(nMargin); + + Link<weld::MetricSpinButton&,void> aLink3( LINK( this, ColorPickerDialog, ColorModifyMetricHdl ) ); + m_xMFCyan->connect_value_changed( aLink3 ); + m_xMFMagenta->connect_value_changed( aLink3 ); + m_xMFYellow->connect_value_changed( aLink3 ); + m_xMFKey->connect_value_changed( aLink3 ); + + m_xMFHue->connect_value_changed( aLink3 ); + m_xMFSaturation->connect_value_changed( aLink3 ); + m_xMFBrightness->connect_value_changed( aLink3 ); + + Link<weld::SpinButton&,void> aLink4(LINK(this, ColorPickerDialog, ColorModifySpinHdl)); + m_xMFRed->connect_value_changed(aLink4); + m_xMFGreen->connect_value_changed(aLink4); + m_xMFBlue->connect_value_changed(aLink4); + + m_xEDHex->connect_changed(LINK(this, ColorPickerDialog, ColorModifyEditHdl)); + + Link<weld::ToggleButton&,void> aLink2 = LINK( this, ColorPickerDialog, ModeModifyHdl ); + m_xRBRed->connect_toggled( aLink2 ); + m_xRBGreen->connect_toggled( aLink2 ); + m_xRBBlue->connect_toggled( aLink2 ); + m_xRBHue->connect_toggled( aLink2 ); + m_xRBSaturation->connect_toggled( aLink2 ); + m_xRBBrightness->connect_toggled( aLink2 ); + + Color aColor(nColor); // modify - if( mnDialogMode == 2 ) + if (mnDialogMode == 2) { - mpColorPreview->SetSizePixel( mpColorPrevious->GetSizePixel() ); - mpColorPrevious->SetColor( aColor ); - mpColorPrevious->Show(); + m_xColorPrevious->SetColor(aColor); + m_xColorPrevious->show(); } mdRed = static_cast<double>(aColor.GetRed()) / 255.0; @@ -970,34 +872,6 @@ ColorPickerDialog::ColorPickerDialog( vcl::Window* pParent, Color nColor, sal_In update_color(); } -void ColorPickerDialog::dispose() -{ - mpColorField.clear(); - mpColorSlider.clear(); - mpColorPreview.clear(); - mpColorPrevious.clear(); - mpFISliderLeft.clear(); - mpFISliderRight.clear(); - mpRBRed.clear(); - mpRBGreen.clear(); - mpRBBlue.clear(); - mpRBHue.clear(); - mpRBSaturation.clear(); - mpRBBrightness.clear(); - mpMFRed.clear(); - mpMFGreen.clear(); - mpMFBlue.clear(); - mpEDHex.clear(); - mpMFHue.clear(); - mpMFSaturation.clear(); - mpMFBrightness.clear(); - mpMFCyan.clear(); - mpMFMagenta.clear(); - mpMFYellow.clear(); - mpMFKey.clear(); - ModalDialog::dispose(); -} - static int toInt( double dValue, double dRange ) { return static_cast< int >( std::floor((dValue * dRange) + 0.5 ) ); @@ -1018,24 +892,24 @@ void ColorPickerDialog::update_color( UpdateFlags n ) if (n & UpdateFlags::RGB) // update RGB { - mpMFRed->SetValue(nRed); - mpMFGreen->SetValue(nGreen); - mpMFBlue->SetValue(nBlue); + m_xMFRed->set_value(nRed); + m_xMFGreen->set_value(nGreen); + m_xMFBlue->set_value(nBlue); } if (n & UpdateFlags::CMYK) // update CMYK { - mpMFCyan->SetValue(toInt(mdCyan, 100.0)); - mpMFMagenta->SetValue(toInt(mdMagenta, 100.0)); - mpMFYellow->SetValue(toInt(mdYellow, 100.0)); - mpMFKey->SetValue(toInt(mdKey, 100.0)); + m_xMFCyan->set_value(toInt(mdCyan, 100.0), FUNIT_PERCENT); + m_xMFMagenta->set_value(toInt(mdMagenta, 100.0), FUNIT_PERCENT); + m_xMFYellow->set_value(toInt(mdYellow, 100.0), FUNIT_PERCENT); + m_xMFKey->set_value(toInt(mdKey, 100.0), FUNIT_PERCENT); } if (n & UpdateFlags::HSB ) // update HSB { - mpMFHue->SetValue(toInt(mdHue, 1.0)); - mpMFSaturation->SetValue(toInt( mdSat, 100.0)); - mpMFBrightness->SetValue(toInt( mdBri, 100.0)); + m_xMFHue->set_value(toInt(mdHue, 1.0), FUNIT_DEGREE); + m_xMFSaturation->set_value(toInt( mdSat, 100.0), FUNIT_PERCENT); + m_xMFBrightness->set_value(toInt( mdBri, 100.0), FUNIT_PERCENT); } if (n & UpdateFlags::ColorChooser ) // update Color Chooser 1 @@ -1043,22 +917,22 @@ void ColorPickerDialog::update_color( UpdateFlags n ) switch( meMode ) { case HUE: - mpColorField->SetValues(aColor, meMode, mdSat, mdBri); + m_xColorField->SetValues(aColor, meMode, mdSat, mdBri); break; case SATURATION: - mpColorField->SetValues(aColor, meMode, mdHue / 360.0, mdBri); + m_xColorField->SetValues(aColor, meMode, mdHue / 360.0, mdBri); break; case BRIGHTNESS: - mpColorField->SetValues(aColor, meMode, mdHue / 360.0, mdSat); + m_xColorField->SetValues(aColor, meMode, mdHue / 360.0, mdSat); break; case RED: - mpColorField->SetValues(aColor, meMode, mdBlue, mdGreen); + m_xColorField->SetValues(aColor, meMode, mdBlue, mdGreen); break; case GREEN: - mpColorField->SetValues(aColor, meMode, mdBlue, mdRed); + m_xColorField->SetValues(aColor, meMode, mdBlue, mdRed); break; case BLUE: - mpColorField->SetValues(aColor, meMode, mdRed, mdGreen); + m_xColorField->SetValues(aColor, meMode, mdRed, mdGreen); break; } } @@ -1068,51 +942,39 @@ void ColorPickerDialog::update_color( UpdateFlags n ) switch (meMode) { case HUE: - mpColorSlider->SetValue(aColor, meMode, mdHue / 360.0); + m_xColorSlider->SetValue(aColor, meMode, mdHue / 360.0); break; case SATURATION: - mpColorSlider->SetValue(aColor, meMode, mdSat); + m_xColorSlider->SetValue(aColor, meMode, mdSat); break; case BRIGHTNESS: - mpColorSlider->SetValue(aColor, meMode, mdBri); + m_xColorSlider->SetValue(aColor, meMode, mdBri); break; case RED: - mpColorSlider->SetValue(aColor, meMode, mdRed); + m_xColorSlider->SetValue(aColor, meMode, mdRed); break; case GREEN: - mpColorSlider->SetValue(aColor, meMode, mdGreen); + m_xColorSlider->SetValue(aColor, meMode, mdGreen); break; case BLUE: - mpColorSlider->SetValue(aColor, meMode, mdBlue); + m_xColorSlider->SetValue(aColor, meMode, mdBlue); break; } } if (n & UpdateFlags::Hex) // update hex { - mpEDHex->SetColor(aColor); - } - - { - Point aPos(0, mpColorSlider->GetLevel() + mpColorSlider->GetPosPixel().Y() - 1); - - aPos.setX( mpFISliderLeft->GetPosPixel().X() ); - if (aPos != mpFISliderLeft->GetPosPixel()) - { - mpFISliderLeft->SetPosPixel(aPos); - - aPos.setX( mpFISliderRight->GetPosPixel().X() ); - mpFISliderRight->SetPosPixel(aPos); - } + m_xFISliderLeft->set_margin_top(m_xColorSlider->GetLevel()); + m_xFISliderRight->set_margin_top(m_xColorSlider->GetLevel()); + m_xEDHex->SetColor(aColor); } - - mpColorPreview->SetColor(aColor); + m_xColorPreview->SetColor(aColor); } IMPL_LINK_NOARG(ColorPickerDialog, ColorFieldControlModifydl, ColorFieldControl&, void) { - double x = mpColorField->GetX(); - double y = mpColorField->GetY(); + double x = m_xColorField->GetX(); + double y = m_xColorField->GetY(); switch( meMode ) { @@ -1147,7 +1009,7 @@ IMPL_LINK_NOARG(ColorPickerDialog, ColorFieldControlModifydl, ColorFieldControl& IMPL_LINK_NOARG(ColorPickerDialog, ColorSliderControlModifyHdl, ColorSliderControl&, void) { - double dValue = mpColorSlider->GetValue(); + double dValue = m_xColorSlider->GetValue(); switch (meMode) { case HUE: @@ -1173,101 +1035,117 @@ IMPL_LINK_NOARG(ColorPickerDialog, ColorSliderControlModifyHdl, ColorSliderContr update_color(UpdateFlags::All & ~UpdateFlags::ColorSlider); } -IMPL_LINK(ColorPickerDialog, ColorModifyEditHdl, Edit&, rEdit, void) +IMPL_LINK(ColorPickerDialog, ColorModifyMetricHdl, weld::MetricSpinButton&, rEdit, void) { UpdateFlags n = UpdateFlags::NONE; - if (&rEdit == mpMFRed) - { - setColorComponent( ColorComponent::Red, static_cast<double>(mpMFRed->GetValue()) / 255.0 ); - n = UpdateFlags::All & ~UpdateFlags::RGB; - } - else if (&rEdit == mpMFGreen) + if (&rEdit == m_xMFHue.get()) { - setColorComponent( ColorComponent::Green, static_cast<double>(mpMFGreen->GetValue()) / 255.0 ); - n = UpdateFlags::All & ~UpdateFlags::RGB; - } - else if (&rEdit == mpMFBlue) - { - setColorComponent( ColorComponent::Blue, static_cast<double>(mpMFBlue->GetValue()) / 255.0 ); - n = UpdateFlags::All & ~UpdateFlags::RGB; - } - else if (&rEdit == mpMFHue) - { - setColorComponent( ColorComponent::Hue, static_cast<double>(mpMFHue->GetValue()) ); + setColorComponent( ColorComponent::Hue, static_cast<double>(m_xMFHue->get_value(FUNIT_DEGREE)) ); n = UpdateFlags::All & ~UpdateFlags::HSB; } - else if (&rEdit == mpMFSaturation) + else if (&rEdit == m_xMFSaturation.get()) { - setColorComponent( ColorComponent::Saturation, static_cast<double>(mpMFSaturation->GetValue()) / 100.0 ); + setColorComponent( ColorComponent::Saturation, static_cast<double>(m_xMFSaturation->get_value(FUNIT_PERCENT)) / 100.0 ); n = UpdateFlags::All & ~UpdateFlags::HSB; } - else if (&rEdit == mpMFBrightness) + else if (&rEdit == m_xMFBrightness.get()) { - setColorComponent( ColorComponent::Brightness, static_cast<double>(mpMFBrightness->GetValue()) / 100.0 ); + setColorComponent( ColorComponent::Brightness, static_cast<double>(m_xMFBrightness->get_value(FUNIT_PERCENT)) / 100.0 ); n = UpdateFlags::All & ~UpdateFlags::HSB; } - else if (&rEdit == mpMFCyan) + else if (&rEdit == m_xMFCyan.get()) { - setColorComponent( ColorComponent::Cyan, static_cast<double>(mpMFCyan->GetValue()) / 100.0 ); + setColorComponent( ColorComponent::Cyan, static_cast<double>(m_xMFCyan->get_value(FUNIT_PERCENT)) / 100.0 ); n = UpdateFlags::All & ~UpdateFlags::CMYK; } - else if (&rEdit == mpMFMagenta) + else if (&rEdit == m_xMFMagenta.get()) { - setColorComponent( ColorComponent::Magenta, static_cast<double>(mpMFMagenta->GetValue()) / 100.0 ); + setColorComponent( ColorComponent::Magenta, static_cast<double>(m_xMFMagenta->get_value(FUNIT_PERCENT)) / 100.0 ); n = UpdateFlags::All & ~UpdateFlags::CMYK; } - else if (&rEdit == mpMFYellow) + else if (&rEdit == m_xMFYellow.get()) { - setColorComponent( ColorComponent::Yellow, static_cast<double>(mpMFYellow->GetValue()) / 100.0 ); + setColorComponent( ColorComponent::Yellow, static_cast<double>(m_xMFYellow->get_value(FUNIT_PERCENT)) / 100.0 ); n = UpdateFlags::All & ~UpdateFlags::CMYK; } - else if (&rEdit == mpMFKey) + else if (&rEdit == m_xMFKey.get()) { - setColorComponent( ColorComponent::Key, static_cast<double>(mpMFKey->GetValue()) / 100.0 ); + setColorComponent( ColorComponent::Key, static_cast<double>(m_xMFKey->get_value(FUNIT_PERCENT)) / 100.0 ); n = UpdateFlags::All & ~UpdateFlags::CMYK; } - else if (&rEdit == mpEDHex) + + if (n != UpdateFlags::NONE) + update_color(n); +} + +IMPL_LINK_NOARG(ColorPickerDialog, ColorModifyEditHdl, weld::Entry&, void) +{ + UpdateFlags n = UpdateFlags::NONE; + + Color aColor = m_xEDHex->GetColor(); + + if (aColor != Color(0xffffffff) && aColor != GetColor()) { - Color aColor = mpEDHex->GetColor(); + mdRed = static_cast<double>(aColor.GetRed()) / 255.0; + mdGreen = static_cast<double>(aColor.GetGreen()) / 255.0; + mdBlue = static_cast<double>(aColor.GetBlue()) / 255.0; - if (aColor != Color(0xffffffff) && aColor != GetColor()) - { - mdRed = static_cast<double>(aColor.GetRed()) / 255.0; - mdGreen = static_cast<double>(aColor.GetGreen()) / 255.0; - mdBlue = static_cast<double>(aColor.GetBlue()) / 255.0; + RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri ); + RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey ); + n = UpdateFlags::All & ~UpdateFlags::Hex; + } - RGBtoHSV( mdRed, mdGreen, mdBlue, mdHue, mdSat, mdBri ); - RGBtoCMYK( mdRed, mdGreen, mdBlue, mdCyan, mdMagenta, mdYellow, mdKey ); - n = UpdateFlags::All & ~UpdateFlags::Hex; - } + if (n != UpdateFlags::NONE) + update_color(n); +} + +IMPL_LINK(ColorPickerDialog, ColorModifySpinHdl, weld::SpinButton&, rEdit, void) +{ + UpdateFlags n = UpdateFlags::NONE; + + if (&rEdit == m_xMFRed.get()) + { + setColorComponent( ColorComponent::Red, static_cast<double>(m_xMFRed->get_value()) / 255.0 ); + n = UpdateFlags::All & ~UpdateFlags::RGB; + } + else if (&rEdit == m_xMFGreen.get()) + { + setColorComponent( ColorComponent::Green, static_cast<double>(m_xMFGreen->get_value()) / 255.0 ); + n = UpdateFlags::All & ~UpdateFlags::RGB; + } + else if (&rEdit == m_xMFBlue.get()) + { + setColorComponent( ColorComponent::Blue, static_cast<double>(m_xMFBlue->get_value()) / 255.0 ); + n = UpdateFlags::All & ~UpdateFlags::RGB; } if (n != UpdateFlags::NONE) update_color(n); } -IMPL_LINK_NOARG(ColorPickerDialog, ModeModifyHdl, RadioButton&, void) + +IMPL_LINK_NOARG(ColorPickerDialog, ModeModifyHdl, weld::ToggleButton&, void) { ColorMode eMode = HUE; - if (mpRBRed->IsChecked()) + if (m_xRBRed->get_active()) { eMode = RED; } - else if (mpRBGreen->IsChecked()) + else if (m_xRBGreen->get_active()) { eMode = GREEN; } - else if (mpRBBlue->IsChecked()) + else if (m_xRBBlue->get_active()) { eMode = BLUE; } - else if (mpRBSaturation->IsChecked()) + else if (m_xRBSaturation->get_active()) { eMode = SATURATION; } - else if (mpRBBrightness->IsChecked()) + else if (m_xRBBrightness->get_active()) { eMode = BRIGHTNESS; } @@ -1445,13 +1323,13 @@ void SAL_CALL ColorPicker::setTitle( const OUString& sTitle ) msTitle = sTitle; } -sal_Int16 SAL_CALL ColorPicker::execute( ) +sal_Int16 SAL_CALL ColorPicker::execute() { - ScopedVclPtrInstance< ColorPickerDialog > aDlg( VCLUnoHelper::GetWindow( mxParent ), mnColor, mnMode ); - sal_Int16 ret = aDlg->Execute(); - if( ret ) - mnColor = aDlg->GetColor(); - + VclPtr<vcl::Window> xWin(VCLUnoHelper::GetWindow(mxParent)); + std::unique_ptr<ColorPickerDialog> xDlg(new ColorPickerDialog(xWin ? xWin->GetFrameWeld() : nullptr, mnColor, mnMode)); + sal_Int16 ret = xDlg->run(); + if (ret) + mnColor = xDlg->GetColor(); return ret; } diff --git a/cui/uiconfig/ui/colorpickerdialog.ui b/cui/uiconfig/ui/colorpickerdialog.ui index 9fd22b3f1c29..660ff5cea3ef 100644 --- a/cui/uiconfig/ui/colorpickerdialog.ui +++ b/cui/uiconfig/ui/colorpickerdialog.ui @@ -1,19 +1,53 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- Generated with glade 3.18.3 --> +<!-- Generated with glade 3.20.2 --> <interface domain="cui"> <requires lib="gtk+" version="3.18"/> - <requires lib="LibreOffice" version="1.0"/> - <object class="GtkAdjustment" id="adjustment1"> + <object class="GtkAdjustment" id="adjustmentblue"> <property name="upper">255</property> <property name="step_increment">1</property> <property name="page_increment">10</property> </object> - <object class="GtkAdjustment" id="adjustment2"> + <object class="GtkAdjustment" id="adjustmentbright"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentcyan"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentgreen"> + <property name="upper">255</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmenthue"> <property name="upper">360</property> <property name="step_increment">1</property> <property name="page_increment">10</property> </object> - <object class="GtkAdjustment" id="adjustment3"> + <object class="GtkAdjustment" id="adjustmentkey"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentmag"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentred"> + <property name="upper">255</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentsat"> + <property name="upper">100</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkAdjustment" id="adjustmentyellow"> <property name="upper">100</property> <property name="step_increment">1</property> <property name="page_increment">10</property> @@ -26,6 +60,8 @@ <property name="title" translatable="yes" context="colorpickerdialog|ColorPicker">Pick a Color</property> <property name="resizable">False</property> <property name="modal">True</property> + <property name="default_width">0</property> + <property name="default_height">0</property> <property name="type_hint">dialog</property> <child internal-child="vbox"> <object class="GtkBox" id="dialog-vbox1"> @@ -115,7 +151,7 @@ <property name="can_focus">False</property> <property name="hexpand">True</property> <child> - <object class="cuilo-ColorPreviewControl" id="preview"> + <object class="GtkDrawingArea" id="preview"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="hexpand">True</property> @@ -127,8 +163,7 @@ </packing> </child> <child> - <object class="cuilo-ColorPreviewControl" id="previous"> - <property name="visible">True</property> + <object class="GtkDrawingArea" id="previous"> <property name="can_focus">False</property> <property name="hexpand">True</property> </object> @@ -145,9 +180,10 @@ </packing> </child> <child> - <object class="cuilo-ColorFieldControl" id="colorField:border"> + <object class="GtkDrawingArea" id="colorField"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property> <property name="hexpand">True</property> <property name="vexpand">True</property> </object> @@ -157,9 +193,10 @@ </packing> </child> <child> - <object class="cuilo-ColorSliderControl" id="colorSlider:border"> + <object class="GtkDrawingArea" id="colorSlider"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK</property> <property name="vexpand">True</property> </object> <packing> @@ -172,7 +209,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="valign">start</property> - <property name="stock">gtk-missing-image</property> + <property name="icon_name">res/colorsliderright.png</property> </object> <packing> <property name="left_attach">3</property> @@ -184,7 +221,7 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="valign">start</property> - <property name="stock">gtk-missing-image</property> + <property name="icon_name">res/colorsliderleft.png</property> </object> <packing> <property name="left_attach">1</property> @@ -248,9 +285,8 @@ <property name="receives_default">False</property> <property name="use_underline">True</property> <property name="xalign">0</property> - <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">greenRadiobutton</property> + <property name="group">hueRadiobutton</property> </object> <packing> <property name="left_attach">0</property> @@ -267,7 +303,7 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">redRadiobutton</property> + <property name="group">hueRadiobutton</property> </object> <packing> <property name="left_attach">0</property> @@ -284,7 +320,7 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">redRadiobutton</property> + <property name="group">hueRadiobutton</property> </object> <packing> <property name="left_attach">0</property> @@ -292,11 +328,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="redSpinbutton:0"> + <object class="GtkSpinButton" id="redSpinbutton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="adjustment">adjustment1</property> + <property name="adjustment">adjustmentred</property> </object> <packing> <property name="left_attach">1</property> @@ -304,11 +340,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="greenSpinbutton:0"> + <object class="GtkSpinButton" id="greenSpinbutton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="adjustment">adjustment1</property> + <property name="adjustment">adjustmentgreen</property> </object> <packing> <property name="left_attach">1</property> @@ -316,11 +352,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="blueSpinbutton:0"> + <object class="GtkSpinButton" id="blueSpinbutton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="adjustment">adjustment1</property> + <property name="adjustment">adjustmentblue</property> </object> <packing> <property name="left_attach">1</property> @@ -331,10 +367,10 @@ <object class="GtkLabel" id="label2"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="colorpickerdialog|label2">Hex _#:</property> <property name="use_underline">True</property> <property name="mnemonic_widget">hexEntry</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -342,7 +378,7 @@ </packing> </child> <child> - <object class="svxcorelo-HexColorControl" id="hexEntry"> + <object class="GtkEntry" id="hexEntry"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> @@ -408,7 +444,6 @@ <property name="xalign">0</property> <property name="active">True</property> <property name="draw_indicator">True</property> - <property name="group">redRadiobutton</property> </object> <packing> <property name="left_attach">0</property> @@ -425,7 +460,7 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">redRadiobutton</property> + <property name="group">hueRadiobutton</property> </object> <packing> <property name="left_attach">0</property> @@ -442,7 +477,7 @@ <property name="use_underline">True</property> <property name="xalign">0</property> <property name="draw_indicator">True</property> - <property name="group">redRadiobutton</property> + <property name="group">hueRadiobutton</property> </object> <packing> <property name="left_attach">0</property> @@ -450,11 +485,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="hueSpinbutton:°"> + <object class="GtkSpinButton" id="hueSpinbutton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="adjustment">adjustment2</property> + <property name="adjustment">adjustmenthue</property> </object> <packing> <property name="left_attach">1</property> @@ -462,11 +497,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="satSpinbutton:%"> + <object class="GtkSpinButton" id="satSpinbutton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="adjustment">adjustment3</property> + <property name="adjustment">adjustmentsat</property> </object> <packing> <property name="left_attach">1</property> @@ -474,11 +509,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="brightSpinbutton:%"> + <object class="GtkSpinButton" id="brightSpinbutton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="adjustment">adjustment3</property> + <property name="adjustment">adjustmentbright</property> </object> <packing> <property name="left_attach">1</property> @@ -533,10 +568,10 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="colorpickerdialog|label5">_Cyan:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">cyanSpinbutton:%</property> + <property name="mnemonic_widget">cyanSpinbutton</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -548,10 +583,10 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="colorpickerdialog|label6">_Magenta:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">magSpinbutton:%</property> + <property name="mnemonic_widget">magSpinbutton</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -563,10 +598,10 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="colorpickerdialog|label7">_Yellow:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">yellowSpinbutton:%</property> + <property name="mnemonic_widget">yellowSpinbutton</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -578,10 +613,10 @@ <property name="visible">True</property> <property name="can_focus">False</property> <property name="halign">start</property> - <property name="xalign">0</property> <property name="label" translatable="yes" context="colorpickerdialog|label8">_Key:</property> <property name="use_underline">True</property> - <property name="mnemonic_widget">keySpinbutton:%</property> + <property name="mnemonic_widget">keySpinbutton</property> + <property name="xalign">0</property> </object> <packing> <property name="left_attach">0</property> @@ -589,11 +624,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="cyanSpinbutton:%"> + <object class="GtkSpinButton" id="cyanSpinbutton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="adjustment">adjustment3</property> + <property name="adjustment">adjustmentcyan</property> </object> <packing> <property name="left_attach">1</property> @@ -601,11 +636,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="magSpinbutton:%"> + <object class="GtkSpinButton" id="magSpinbutton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="adjustment">adjustment3</property> + <property name="adjustment">adjustmentmag</property> </object> <packing> <property name="left_attach">1</property> @@ -613,11 +648,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="yellowSpinbutton:%"> + <object class="GtkSpinButton" id="yellowSpinbutton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="adjustment">adjustment3</property> + <property name="adjustment">adjustmentyellow</property> </object> <packing> <property name="left_attach">1</property> @@ -625,11 +660,11 @@ </packing> </child> <child> - <object class="GtkSpinButton" id="keySpinbutton:%"> + <object class="GtkSpinButton" id="keySpinbutton"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="hexpand">True</property> - <property name="adjustment">adjustment3</property> + <property name="adjustment">adjustmentkey</property> </object> <packing> <property name="left_attach">1</property> @@ -678,6 +713,9 @@ <action-widget response="-6">cancel</action-widget> <action-widget response="-11">help</action-widget> </action-widgets> + <child> + <placeholder/> + </child> </object> <object class="GtkSizeGroup" id="sizegroup1"> <widgets> diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index c0a89747cb8a..71f2c260b26a 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -281,15 +281,6 @@ <glade-widget-class title="Graphic Preview" name="cuilo-GraphicPreviewWindow" generic-name="Graphic Preview Window" parent="GtkDrawingArea" icon-name="widget-gtk-drawingarea"/> - <glade-widget-class title="Color Field Control" name="cuilo-ColorFieldControl" - generic-name="Color Field Control" parent="GtkDrawingArea" - icon-name="widget-gtk-drawingarea"/> - <glade-widget-class title="Color Slider Control" name="cuilo-ColorSliderControl" - generic-name="Color Slider Control" parent="GtkDrawingArea" - icon-name="widget-gtk-drawingarea"/> - <glade-widget-class title="Color Preview Control" name="cuilo-ColorPreviewControl" - generic-name="Color Preview Control" parent="GtkDrawingArea" - icon-name="widget-gtk-drawingarea"/> <glade-widget-class title="Html Attribute Preview" name="sduilo-SdHtmlAttrPreview" generic-name="Html Attribute Preview" parent="GtkDrawingArea" icon-name="widget-gtk-drawingarea"/> diff --git a/icon-themes/galaxy/res/colorslider.png b/icon-themes/galaxy/res/colorsliderleft.png Binary files differindex 0040386b4d93..0040386b4d93 100644 --- a/icon-themes/galaxy/res/colorslider.png +++ b/icon-themes/galaxy/res/colorsliderleft.png diff --git a/icon-themes/galaxy/res/colorsliderright.png b/icon-themes/galaxy/res/colorsliderright.png Binary files differnew file mode 100644 index 000000000000..09259107566b --- /dev/null +++ b/icon-themes/galaxy/res/colorsliderright.png diff --git a/icon-themes/tango/res/colorslider.png b/icon-themes/tango/res/colorsliderleft.png Binary files differindex 50ae9732630f..50ae9732630f 100644 --- a/icon-themes/tango/res/colorslider.png +++ b/icon-themes/tango/res/colorsliderleft.png diff --git a/icon-themes/tango/res/colorsliderright.png b/icon-themes/tango/res/colorsliderright.png Binary files differnew file mode 100644 index 000000000000..25afe492a8c1 --- /dev/null +++ b/icon-themes/tango/res/colorsliderright.png diff --git a/include/svx/hexcolorcontrol.hxx b/include/svx/hexcolorcontrol.hxx index 22d7cf2df540..a39bb5941626 100644 --- a/include/svx/hexcolorcontrol.hxx +++ b/include/svx/hexcolorcontrol.hxx @@ -26,6 +26,7 @@ #include <vcl/edit.hxx> #include <vcl/svapp.hxx> #include <vcl/builderfactory.hxx> +#include <vcl/weld.hxx> #include <sot/exchange.hxx> #include <sax/tools/converter.hxx> #include <svx/svxdllapi.h> @@ -46,6 +47,25 @@ private: static bool ImplProcessKeyInput( const KeyEvent& rKEv ); }; +namespace weld { + +class SVX_DLLPUBLIC HexColorControl +{ +private: + std::unique_ptr<weld::Entry> m_xEntry; + + DECL_LINK(ImplProcessInputHdl, OUString&, bool); +public: + HexColorControl(weld::Entry* pEdit); + + void connect_changed(const Link<Entry&, void>& rLink) { m_xEntry->connect_changed(rLink); } + + void SetColor( ::Color nColor ); + ::Color GetColor(); +}; + +} + #endif // INCLUDED_SVX_HEXCOLOR_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/vcl/layout.hxx b/include/vcl/layout.hxx index f20bc18cac8a..d1488ba77e77 100644 --- a/include/vcl/layout.hxx +++ b/include/vcl/layout.hxx @@ -613,14 +613,39 @@ public: class VCL_DLLPUBLIC VclDrawingArea : public vcl::Window { private: - Link<vcl::RenderContext&, void> m_aPaintHdl; + Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void> m_aPaintHdl; Link<const Size&, void> m_aResizeHdl; + Link<const Point&, void> m_aMousePressHdl; + Link<const Point&, void> m_aMouseMotionHdl; + Link<const Point&, void> m_aMouseReleaseHdl; + + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override + { + m_aPaintHdl.Call(std::pair<vcl::RenderContext&, const tools::Rectangle&>(rRenderContext, rRect)); + } + virtual void Resize() override + { + m_aResizeHdl.Call(GetOutputSizePixel()); + } + virtual void MouseMove(const MouseEvent& rMEvt) override + { + m_aMouseMotionHdl.Call(rMEvt.GetPosPixel()); + } + virtual void MouseButtonDown(const MouseEvent& rMEvt) override + { + m_aMousePressHdl.Call(rMEvt.GetPosPixel()); + } + virtual void MouseButtonUp(const MouseEvent& rMEvt) override + { + m_aMouseReleaseHdl.Call(rMEvt.GetPosPixel()); + } + public: VclDrawingArea(vcl::Window *pParent, WinBits nStyle) : vcl::Window(pParent, nStyle) { } - void SetPaintHdl(const Link<vcl::RenderContext&, void>& rLink) + void SetPaintHdl(const Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void>& rLink) { m_aPaintHdl = rLink; } @@ -628,13 +653,17 @@ public: { m_aResizeHdl = rLink; } - virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/) override + void SetMousePressHdl(const Link<const Point&, void>& rLink) { - m_aPaintHdl.Call(rRenderContext); + m_aMousePressHdl = rLink; } - virtual void Resize() override + void SetMouseMoveHdl(const Link<const Point&, void>& rLink) { - m_aResizeHdl.Call(GetOutputSizePixel()); + m_aMouseMotionHdl = rLink; + } + void SetMouseReleaseHdl(const Link<const Point&, void>& rLink) + { + m_aMouseReleaseHdl = rLink; } }; diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx index 7a82cfb2c6df..86a61b75f194 100644 --- a/include/vcl/weld.hxx +++ b/include/vcl/weld.hxx @@ -54,6 +54,9 @@ public: virtual void set_grid_top_attach(int nAttach) = 0; virtual int get_grid_top_attach() const = 0; + virtual void set_margin_top(int nMargin) = 0; + virtual void set_margin_bottom(int nMargin) = 0; + virtual Container* weld_parent() const = 0; virtual ~Widget() {} @@ -307,6 +310,7 @@ public: virtual void set_text(const OUString& rText) = 0; virtual OUString get_text() const = 0; virtual void set_width_chars(int nChars) = 0; + virtual void set_max_length(int nChars) = 0; virtual void select_region(int nStartPos, int nEndPos) = 0; virtual void set_position(int nCursorPos) = 0; @@ -493,14 +497,27 @@ public: class VCL_DLLPUBLIC DrawingArea : virtual public Widget { +public: + typedef std::pair<vcl::RenderContext&, const tools::Rectangle&> draw_args; + protected: - Link<vcl::RenderContext&, void> m_aDrawHdl; + Link<draw_args, void> m_aDrawHdl; Link<const Size&, void> m_aSizeAllocateHdl; + Link<const Point&, void> m_aMousePressHdl; + Link<const Point&, void> m_aMouseMotionHdl; + Link<const Point&, void> m_aMouseReleaseHdl; public: - void connect_draw(const Link<vcl::RenderContext&, void>& rLink) { m_aDrawHdl = rLink; } + void connect_draw(const Link<draw_args, void>& rLink) { m_aDrawHdl = rLink; } void connect_size_allocate(const Link<const Size&, void>& rLink) { m_aSizeAllocateHdl = rLink; } + void connect_mouse_press(const Link<const Point&, void>& rLink) { m_aMousePressHdl = rLink; } + void connect_mouse_move(const Link<const Point&, void>& rLink) { m_aMouseMotionHdl = rLink; } + void connect_mouse_release(const Link<const Point&, void>& rLink) + { + m_aMouseReleaseHdl = rLink; + } virtual void queue_draw() = 0; + virtual void queue_draw_area(int x, int y, int width, int height) = 0; }; class VCL_DLLPUBLIC Builder diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx index eed042b7d60e..be99751c9a05 100644 --- a/sfx2/source/doc/new.cxx +++ b/sfx2/source/doc/new.cxx @@ -105,9 +105,9 @@ void SfxPreviewWin_Impl::ImpPaint(vcl::RenderContext& rRenderContext, GDIMetaFil } } -IMPL_LINK(SfxPreviewWin_Impl, DoPaint, vcl::RenderContext&, rRenderContext, void) +IMPL_LINK(SfxPreviewWin_Impl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) { - ImpPaint(rRenderContext, xMetaFile.get()); + ImpPaint(aPayload.first, xMetaFile.get()); } IMPL_LINK_NOARG(SfxNewFileDialog, Update, Timer*, void) @@ -193,6 +193,7 @@ IMPL_LINK( SfxNewFileDialog, RegionSelect, weld::TreeView&, rBox, void ) m_xTemplateLb->append(m_aTemplates.GetName(nRegion, i)); m_xTemplateLb->thaw(); m_xTemplateLb->select(0); + TemplateSelect(*m_xTemplateLb); } IMPL_LINK_NOARG(SfxNewFileDialog, Expand, weld::Expander&, void) diff --git a/sfx2/source/inc/preview.hxx b/sfx2/source/inc/preview.hxx index 3a747db969f2..8b39231c31a8 100644 --- a/sfx2/source/inc/preview.hxx +++ b/sfx2/source/inc/preview.hxx @@ -32,7 +32,7 @@ protected: public: SfxPreviewWin_Impl(weld::DrawingArea* pArea); void SetObjectShell( SfxObjectShell const * pObj ); - DECL_LINK(DoPaint, vcl::RenderContext&, void); + DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); DECL_LINK(DoResize, const Size& rSize, void); void queue_draw() { m_xDrawingArea->queue_draw(); } void show() { m_xDrawingArea->show(); } diff --git a/svx/source/dialog/hexcolorcontrol.cxx b/svx/source/dialog/hexcolorcontrol.cxx index 61d38bdeb619..51927caa5202 100644 --- a/svx/source/dialog/hexcolorcontrol.cxx +++ b/svx/source/dialog/hexcolorcontrol.cxx @@ -126,4 +126,67 @@ bool HexColorControl::ImplProcessKeyInput( const KeyEvent& rKEv ) return false; } +namespace weld { + +HexColorControl::HexColorControl(weld::Entry* pEntry) + : m_xEntry(pEntry) +{ + m_xEntry->set_max_length(6); + m_xEntry->set_width_chars(6); + m_xEntry->connect_insert_text(LINK(this, HexColorControl, ImplProcessInputHdl)); +} + +void HexColorControl::SetColor(Color nColor) +{ + OUStringBuffer aBuffer; + sax::Converter::convertColor(aBuffer, nColor); + m_xEntry->set_text(aBuffer.makeStringAndClear().copy(1)); +} + +Color HexColorControl::GetColor() +{ + sal_Int32 nColor = -1; + + OUString aStr("#"); + aStr += m_xEntry->get_text(); + sal_Int32 nLen = aStr.getLength(); + + if (nLen < 7) + { + static const sal_Char* const pNullStr = "000000"; + aStr += OUString::createFromAscii( &pNullStr[nLen-1] ); + } + + sax::Converter::convertColor(nColor, aStr); + +#if 0 + if (nColor == -1) + SetControlBackground(COL_RED); + else + SetControlBackground(); +#endif + + return Color(nColor); +} + +IMPL_LINK(HexColorControl, ImplProcessInputHdl, OUString&, rTest, bool) +{ + const sal_Unicode* pTest = rTest.getStr(); + sal_Int32 nLen = rTest.getLength(); + + OUStringBuffer aFilter(nLen); + for (sal_Int32 i = 0; i < nLen; ++i) + { + if (rtl::isAsciiHexDigit(*pTest)) + aFilter.append(*pTest); + ++pTest; + } + + rTest = aFilter.makeStringAndClear(); + return true; +} + + +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/ui/table/autoformatpreview.cxx b/sw/source/ui/table/autoformatpreview.cxx index 27f5a4c0705c..83aa97e90970 100644 --- a/sw/source/ui/table/autoformatpreview.cxx +++ b/sw/source/ui/table/autoformatpreview.cxx @@ -842,8 +842,10 @@ void AutoFormatPreview::NotifyChange(const SwTableAutoFormat& rNewData) mxDrawingArea->queue_draw(); } -IMPL_LINK(AutoFormatPreview, DoPaint, vcl::RenderContext&, rRenderContext, void) +IMPL_LINK(AutoFormatPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) { + vcl::RenderContext& rRenderContext = aPayload.first; + rRenderContext.Push(PushFlags::ALL); DrawModeFlags nOldDrawMode = rRenderContext.GetDrawMode(); diff --git a/sw/source/uibase/inc/autoformatpreview.hxx b/sw/source/uibase/inc/autoformatpreview.hxx index 3854e8b74090..50bf28074edc 100644 --- a/sw/source/uibase/inc/autoformatpreview.hxx +++ b/sw/source/uibase/inc/autoformatpreview.hxx @@ -67,7 +67,7 @@ private: uno::Reference<i18n::XBreakIterator> m_xBreak; void Init(); - DECL_LINK(DoPaint, vcl::RenderContext&, void); + DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); DECL_LINK(DoResize, const Size& rSize, void); void CalcCellArray(bool bFitWidth); void CalcLineMap(); diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index d1faaadd5cdb..0d5dee9c3fbf 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -289,6 +289,16 @@ public: return m_xWidget->get_grid_top_attach(); } + virtual void set_margin_top(int nMargin) override + { + m_xWidget->set_margin_top(nMargin); + } + + virtual void set_margin_bottom(int nMargin) override + { + m_xWidget->set_margin_bottom(nMargin); + } + virtual weld::Container* weld_parent() const override; virtual ~SalInstanceWidget() override @@ -795,6 +805,11 @@ public: m_xEntry->SetWidthInChars(nChars); } + virtual void set_max_length(int nChars) override + { + m_xEntry->SetMaxTextLen(nChars); + } + virtual void select_region(int nStartPos, int nEndPos) override { m_xEntry->SetSelection(Selection(nStartPos, nEndPos < 0 ? SELECTION_MAX : nEndPos)); @@ -884,7 +899,6 @@ public: m_xTreeView->SetNoSelection(); else m_xTreeView->SelectEntryPos(pos); - m_xTreeView->Select(); } virtual OUString get_selected() override @@ -1122,8 +1136,12 @@ class SalInstanceDrawingArea : public SalInstanceWidget, public virtual weld::Dr private: VclPtr<VclDrawingArea> m_xDrawingArea; - DECL_LINK(PaintHdl, vcl::RenderContext&, void); + typedef std::pair<vcl::RenderContext&, const tools::Rectangle&> target_and_area; + DECL_LINK(PaintHdl, target_and_area, void); DECL_LINK(ResizeHdl, const Size&, void); + DECL_LINK(MousePressHdl, const Point&, void); + DECL_LINK(MouseMoveHdl, const Point&, void); + DECL_LINK(MouseReleaseHdl, const Point&, void); public: SalInstanceDrawingArea(VclDrawingArea* pDrawingArea, bool bTakeOwnership) @@ -1132,6 +1150,9 @@ public: { m_xDrawingArea->SetPaintHdl(LINK(this, SalInstanceDrawingArea, PaintHdl)); m_xDrawingArea->SetResizeHdl(LINK(this, SalInstanceDrawingArea, ResizeHdl)); + m_xDrawingArea->SetMousePressHdl(LINK(this, SalInstanceDrawingArea, MousePressHdl)); + m_xDrawingArea->SetMouseMoveHdl(LINK(this, SalInstanceDrawingArea, MouseMoveHdl)); + m_xDrawingArea->SetMouseReleaseHdl(LINK(this, SalInstanceDrawingArea, MouseReleaseHdl)); } virtual void queue_draw() override @@ -1139,16 +1160,21 @@ public: m_xDrawingArea->Invalidate(); } + virtual void queue_draw_area(int x, int y, int width, int height) override + { + m_xDrawingArea->Invalidate(tools::Rectangle(Point(x, y), Size(width, height))); + } + virtual ~SalInstanceDrawingArea() override { m_xDrawingArea->SetResizeHdl(Link<const Size&, void>()); - m_xDrawingArea->SetPaintHdl(Link<vcl::RenderContext&, void>()); + m_xDrawingArea->SetPaintHdl(Link<std::pair<vcl::RenderContext&, const tools::Rectangle&>, void>()); } }; -IMPL_LINK(SalInstanceDrawingArea, PaintHdl, vcl::RenderContext&, rDevice, void) +IMPL_LINK(SalInstanceDrawingArea, PaintHdl, target_and_area, aPayload, void) { - m_aDrawHdl.Call(rDevice); + m_aDrawHdl.Call(aPayload); } IMPL_LINK(SalInstanceDrawingArea, ResizeHdl, const Size&, rSize, void) @@ -1156,6 +1182,21 @@ IMPL_LINK(SalInstanceDrawingArea, ResizeHdl, const Size&, rSize, void) m_aSizeAllocateHdl.Call(rSize); } +IMPL_LINK(SalInstanceDrawingArea, MousePressHdl, const Point&, rPos, void) +{ + m_aMousePressHdl.Call(rPos); +} + +IMPL_LINK(SalInstanceDrawingArea, MouseMoveHdl, const Point&, rPos, void) +{ + m_aMouseMotionHdl.Call(rPos); +} + +IMPL_LINK(SalInstanceDrawingArea, MouseReleaseHdl, const Point&, rPos, void) +{ + m_aMouseReleaseHdl.Call(rPos); +} + //ComboBox and ListBox have the same apis, ComboBoxes in LibreOffice have an edit box and ListBoxes //don't. This distinction isn't there in Gtk. Use a template to sort this problem out. template <class vcl_type> diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 031f012c8152..4a24e5d03357 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -1300,6 +1300,16 @@ public: return nAttach; } + virtual void set_margin_top(int nMargin) override + { + gtk_widget_set_margin_top(m_pWidget, nMargin); + } + + virtual void set_margin_bottom(int nMargin) override + { + gtk_widget_set_margin_bottom(m_pWidget, nMargin); + } + virtual weld::Container* weld_parent() const override; virtual OString get_buildable_name() const override @@ -1336,6 +1346,14 @@ public: if (m_bTakeOwnership) gtk_widget_destroy(m_pWidget); } + + virtual void disable_notify_events() + { + } + + virtual void enable_notify_events() + { + } }; class GtkInstanceContainer : public GtkInstanceWidget, public virtual weld::Container @@ -1851,7 +1869,9 @@ public: virtual void set_active(bool active) override { + disable_notify_events(); gtk_toggle_button_set_active(m_pToggleButton, active); + enable_notify_events(); } virtual bool get_active() const override @@ -1869,6 +1889,18 @@ public: return gtk_toggle_button_get_inconsistent(m_pToggleButton); } + virtual void disable_notify_events() override + { + g_signal_handler_block(m_pToggleButton, m_nSignalId); + GtkInstanceButton::disable_notify_events(); + } + + virtual void enable_notify_events() override + { + GtkInstanceButton::enable_notify_events(); + g_signal_handler_unblock(m_pToggleButton, m_nSignalId); + } + virtual ~GtkInstanceToggleButton() override { g_signal_handler_disconnect(m_pToggleButton, m_nSignalId); @@ -1939,7 +1971,9 @@ public: virtual void set_text(const OUString& rText) override { + disable_notify_events(); gtk_entry_set_text(m_pEntry, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr()); + enable_notify_events(); } virtual OUString get_text() const override @@ -1951,7 +1985,16 @@ public: virtual void set_width_chars(int nChars) override { + disable_notify_events(); gtk_entry_set_width_chars(m_pEntry, nChars); + enable_notify_events(); + } + + virtual void set_max_length(int nChars) override + { + disable_notify_events(); + gtk_entry_set_max_length(m_pEntry, nChars); + enable_notify_events(); } virtual void select_region(int nStartPos, int nEndPos) override @@ -1964,6 +2007,20 @@ public: gtk_editable_set_position(GTK_EDITABLE(m_pEntry), nCursorPos); } + virtual void disable_notify_events() override + { + g_signal_handler_block(m_pEntry, m_nInsertTextSignalId); + g_signal_handler_block(m_pEntry, m_nChangedSignalId); + GtkInstanceWidget::disable_notify_events(); + } + + virtual void enable_notify_events() override + { + GtkInstanceWidget::disable_notify_events(); + g_signal_handler_unblock(m_pEntry, m_nChangedSignalId); + g_signal_handler_unblock(m_pEntry, m_nInsertTextSignalId); + } + virtual ~GtkInstanceEntry() override { g_signal_handler_disconnect(m_pEntry, m_nInsertTextSignalId); @@ -2034,18 +2091,22 @@ public: virtual void insert(const OUString& rText, int pos) override { + disable_notify_events(); GtkTreeIter iter; gtk_list_store_insert(m_pListStore, &iter, pos); gtk_list_store_set(m_pListStore, &iter, 0, OUStringToOString(rText, RTL_TEXTENCODING_UTF8).getStr(), -1); + enable_notify_events(); } using GtkInstanceContainer::remove; virtual void remove(int pos) override { + disable_notify_events(); GtkTreeIter iter; gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(m_pListStore), &iter, nullptr, pos); gtk_list_store_remove(m_pListStore, &iter); + enable_notify_events(); } virtual int find(const OUString& rText) const override @@ -2060,6 +2121,7 @@ public: if (pos == before) return; + disable_notify_events(); GtkTreeIter iter; gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(m_pListStore), &iter, nullptr, pos); @@ -2067,16 +2129,21 @@ public: gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(m_pListStore), &position, nullptr, before); gtk_list_store_move_before(m_pListStore, &iter, &position); + enable_notify_events(); } virtual void set_top_entry(int pos) override { + disable_notify_events(); move_before(pos, 0); + enable_notify_events(); } virtual void clear() override { + disable_notify_events(); gtk_list_store_clear(m_pListStore); + enable_notify_events(); } virtual int n_children() const override @@ -2087,6 +2154,7 @@ public: virtual void select(int pos) override { assert(gtk_tree_view_get_model(m_pTreeView) && "don't select when frozen"); + disable_notify_events(); if (pos != -1) { GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1); @@ -2097,6 +2165,7 @@ public: { gtk_tree_selection_unselect_all(gtk_tree_view_get_selection(m_pTreeView)); } + enable_notify_events(); } virtual OUString get_selected() override @@ -2141,14 +2210,18 @@ public: virtual void freeze() override { + disable_notify_events(); g_object_ref(m_pListStore); gtk_tree_view_set_model(m_pTreeView, nullptr); + enable_notify_events(); } virtual void thaw() override { + disable_notify_events(); gtk_tree_view_set_model(m_pTreeView, GTK_TREE_MODEL(m_pListStore)); g_object_unref(m_pListStore); + enable_notify_events(); } virtual int get_height_rows(int nRows) const override @@ -2175,6 +2248,20 @@ public: gtk_widget_set_size_request(m_pWidget, nWidth, nHeight); } + virtual void disable_notify_events() override + { + g_signal_handler_block(gtk_tree_view_get_selection(m_pTreeView), m_nChangedSignalId); + g_signal_handler_block(m_pTreeView, m_nRowActivatedSignalId); + GtkInstanceContainer::disable_notify_events(); + } + + virtual void enable_notify_events() override + { + GtkInstanceContainer::disable_notify_events(); + g_signal_handler_unblock(m_pTreeView, m_nRowActivatedSignalId); + g_signal_handler_unblock(gtk_tree_view_get_selection(m_pTreeView), m_nChangedSignalId); + } + virtual ~GtkInstanceTreeView() override { g_signal_handler_disconnect(gtk_tree_view_get_selection(m_pTreeView), m_nChangedSignalId); @@ -2228,12 +2315,16 @@ public: virtual void set_value(int value) override { + disable_notify_events(); gtk_spin_button_set_value(m_pButton, toGtk(value)); + enable_notify_events(); } virtual void set_range(int min, int max) override { + disable_notify_events(); gtk_spin_button_set_range(m_pButton, toGtk(min), toGtk(max)); + enable_notify_events(); } virtual void get_range(int& min, int& max) const override @@ -2246,7 +2337,9 @@ public: virtual void set_increments(int step, int page) override { + disable_notify_events(); gtk_spin_button_set_increments(m_pButton, toGtk(step), toGtk(page)); + enable_notify_events(); } virtual void get_increments(int& step, int& page) const override @@ -2259,7 +2352,9 @@ public: virtual void set_digits(unsigned int digits) override { + disable_notify_events(); gtk_spin_button_set_digits(m_pButton, digits); + enable_notify_events(); } virtual unsigned int get_digits() const override @@ -2267,6 +2362,18 @@ public: return gtk_spin_button_get_digits(m_pButton); } + virtual void disable_notify_events() override + { + g_signal_handler_block(m_pButton, m_nValueChangedSignalId); + GtkInstanceEntry::disable_notify_events(); + } + + virtual void enable_notify_events() override + { + GtkInstanceEntry::disable_notify_events(); + g_signal_handler_unblock(m_pButton, m_nValueChangedSignalId); + } + virtual ~GtkInstanceSpinButton() override { g_signal_handler_disconnect(m_pButton, m_nOutputSignalId); @@ -2356,12 +2463,27 @@ private: cairo_surface_t* m_pSurface; gulong m_nDrawSignalId; gulong m_nSizeAllocateSignalId; + gulong m_nButtonPressSignalId; + gulong m_nMotionSignalId; + gulong m_nButtonReleaseSignalId; static gboolean signalDraw(GtkWidget*, cairo_t* cr, gpointer widget) { GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget); pThis->signal_draw(cr); return false; } + void signal_draw(cairo_t* cr) + { + GdkRectangle rect; + if (!gdk_cairo_get_clip_rectangle(cr, &rect)) + return; + tools::Rectangle aRect(Point(rect.x, rect.y), Size(rect.width, rect.height)); + m_aDrawHdl.Call(std::pair<vcl::RenderContext&, const tools::Rectangle&>(*m_xDevice, aRect)); + cairo_surface_mark_dirty(m_pSurface); + + cairo_set_source_surface(cr, m_pSurface, 0, 0); + cairo_paint(cr); + } static void signalSizeAllocate(GtkWidget*, GdkRectangle* allocation, gpointer widget) { GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget); @@ -2384,22 +2506,52 @@ private: #endif m_aSizeAllocateHdl.Call(Size(nWidth, nHeight)); } - void signal_draw(cairo_t* cr) + static gboolean signalButton(GtkWidget*, GdkEventButton* pEvent, gpointer widget) { - m_aDrawHdl.Call(*m_xDevice); - cairo_surface_mark_dirty(m_pSurface); + GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget); + return pThis->signal_button(pEvent); + } + bool signal_button(GdkEventButton* pEvent) + { + Point aEvent(pEvent->x, pEvent->y); - cairo_set_source_surface(cr, m_pSurface, 0, 0); - cairo_paint(cr); + switch (pEvent->type) + { + case GDK_BUTTON_PRESS: + m_aMousePressHdl.Call(aEvent); + break; + case GDK_BUTTON_RELEASE: + m_aMouseReleaseHdl.Call(aEvent); + break; + default: + return false; + } + + return true; + } + static gboolean signalMotion(GtkWidget*, GdkEventMotion* pEvent, gpointer widget) + { + GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget); + return pThis->signal_motion(pEvent); } + bool signal_motion(GdkEventMotion* pEvent) + { + Point aEvent(pEvent->x, pEvent->y); + m_aMouseMotionHdl.Call(aEvent); + return true; + } + public: GtkInstanceDrawingArea(GtkDrawingArea* pDrawingArea, bool bTakeOwnership) : GtkInstanceWidget(GTK_WIDGET(pDrawingArea), bTakeOwnership) , m_pDrawingArea(pDrawingArea) , m_xDevice(nullptr, Size(1, 1), DeviceFormat::DEFAULT) , m_pSurface(nullptr) - , m_nDrawSignalId(g_signal_connect(pDrawingArea, "draw", G_CALLBACK(signalDraw), this)) - , m_nSizeAllocateSignalId(g_signal_connect(pDrawingArea, "size_allocate", G_CALLBACK(signalSizeAllocate), this)) + , m_nDrawSignalId(g_signal_connect(m_pDrawingArea, "draw", G_CALLBACK(signalDraw), this)) + , m_nSizeAllocateSignalId(g_signal_connect(m_pDrawingArea, "size_allocate", G_CALLBACK(signalSizeAllocate), this)) + , m_nButtonPressSignalId(g_signal_connect(m_pDrawingArea, "button-press-event", G_CALLBACK(signalButton), this)) + , m_nMotionSignalId(g_signal_connect(m_pDrawingArea, "motion-notify-event", G_CALLBACK(signalMotion), this)) + , m_nButtonReleaseSignalId(g_signal_connect(m_pDrawingArea, "button-release-event", G_CALLBACK(signalButton), this)) { } @@ -2408,10 +2560,18 @@ public: gtk_widget_queue_draw(GTK_WIDGET(m_pDrawingArea)); } + virtual void queue_draw_area(int x, int y, int width, int height) override + { + gtk_widget_queue_draw_area(GTK_WIDGET(m_pDrawingArea), x, y, width, height); + } + virtual ~GtkInstanceDrawingArea() override { if (m_pSurface) cairo_surface_destroy(m_pSurface); + g_signal_handler_disconnect(m_pDrawingArea, m_nButtonPressSignalId); + g_signal_handler_disconnect(m_pDrawingArea, m_nMotionSignalId); + g_signal_handler_disconnect(m_pDrawingArea, m_nButtonReleaseSignalId); g_signal_handler_disconnect(m_pDrawingArea, m_nSizeAllocateSignalId); g_signal_handler_disconnect(m_pDrawingArea, m_nDrawSignalId); } @@ -2483,13 +2643,17 @@ public: virtual void set_active_id(const OUString& rStr) override { + disable_notify_events(); OString aId(OUStringToOString(rStr, RTL_TEXTENCODING_UTF8)); gtk_combo_box_set_active_id(GTK_COMBO_BOX(m_pComboBoxText), aId.getStr()); + enable_notify_events(); } virtual void set_active(int pos) override { + disable_notify_events(); gtk_combo_box_set_active(GTK_COMBO_BOX(m_pComboBoxText), pos); + enable_notify_events(); } virtual OUString get_active_text() const override @@ -2581,6 +2745,18 @@ public: gtk_tree_sortable_set_sort_column_id(pSortable, 0, GTK_SORT_ASCENDING); } + virtual void disable_notify_events() override + { + g_signal_handler_block(m_pComboBoxText, m_nSignalId); + GtkInstanceContainer::disable_notify_events(); + } + + virtual void enable_notify_events() override + { + GtkInstanceContainer::disable_notify_events(); + g_signal_handler_unblock(m_pComboBoxText, m_nSignalId); + } + virtual ~GtkInstanceComboBoxText() override { g_signal_handler_disconnect(m_pComboBoxText, m_nSignalId); |