diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-05-22 10:38:34 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-05-24 14:24:06 +0200 |
commit | eeaf6dee2d278eaa037d95a756ad0ffab3314bc2 (patch) | |
tree | a997fee717ad079fb59ff0901d418938ab7585f7 /cui | |
parent | c10928e703366341ab912c42e8959a087a7fa9ff (diff) |
rework custom widget welding to enable inheritence
Change-Id: I0d391b3fe9d2d610ae41e2a03cd2e195a866e103
Reviewed-on: https://gerrit.libreoffice.org/54681
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'cui')
-rw-r--r-- | cui/source/dialogs/colorpicker.cxx | 275 | ||||
-rwxr-xr-x | cui/source/dialogs/cuicharmap.cxx | 241 | ||||
-rw-r--r-- | cui/source/inc/cuicharmap.hxx | 27 | ||||
-rw-r--r-- | cui/source/inc/textattr.hxx | 4 | ||||
-rw-r--r-- | cui/source/tabpages/textattr.cxx | 33 |
5 files changed, 305 insertions, 275 deletions
diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx index 0106a3acdf70..4fba23b2f7ca 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/customweld.hxx> #include <vcl/weld.hxx> #include <vcl/dialog.hxx> #include <vcl/button.hxx> @@ -150,24 +151,22 @@ static void RGBtoCMYK( double dR, double dG, double dB, double& fCyan, double& f } } -class ColorPreviewControl +class ColorPreviewControl : public weld::CustomWidgetController { 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); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; public: - ColorPreviewControl(weld::DrawingArea* pDrawingArea) - : m_xDrawingArea(pDrawingArea) + ColorPreviewControl() { - 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_digit_width() * 10, - m_xDrawingArea->get_text_height() * 2); + } + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override + { + pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 10, + pDrawingArea->get_text_height() * 2); + CustomWidgetController::SetDrawingArea(pDrawingArea); } void SetColor(const Color& rCol) @@ -175,60 +174,49 @@ public: if (rCol != m_aColor) { m_aColor = rCol; - m_xDrawingArea->queue_draw(); + Invalidate(); } } - - void show() { m_xDrawingArea->show(); } }; -IMPL_LINK(ColorPreviewControl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void ColorPreviewControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; rRenderContext.SetFillColor(m_aColor); rRenderContext.SetLineColor(m_aColor); - rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), m_aSize)); -} - -IMPL_LINK(ColorPreviewControl, DoResize, const Size&, rSize, void) -{ - if (m_aSize != rSize) - { - m_aSize = rSize; - m_xDrawingArea->queue_draw(); - } + rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), GetOutputSizePixel())); } enum ColorMode { HUE, SATURATION, BRIGHTNESS, RED, GREEN, BLUE }; const ColorMode DefaultMode = HUE; -class ColorFieldControl +class ColorFieldControl : public weld::CustomWidgetController { public: - ColorFieldControl(weld::DrawingArea* pDrawingArea) - : m_xDrawingArea(pDrawingArea) - , meMode( DefaultMode ) + ColorFieldControl() + : meMode( DefaultMode ) , mdX( -1.0 ) , mdY( -1.0 ) + , mbMouseCaptured(false) + { + } + + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override { - m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_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)); + pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 40, + pDrawingArea->get_text_height() * 10); + CustomWidgetController::SetDrawingArea(pDrawingArea); } - ~ColorFieldControl() + virtual ~ColorFieldControl() override { mxBitmap.disposeAndClear(); } - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); - DECL_LINK(DoButtonDown, const MouseEvent& rMEvt, void); - DECL_LINK(DoMouseMove, const MouseEvent& rMEvt, void); - DECL_LINK(DoButtonUp, const MouseEvent& rMEvt, void); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void Resize() override; + virtual void MouseButtonDown(const MouseEvent& rMEvt) override; + virtual void MouseMove(const MouseEvent& rMEvt) override; + virtual void MouseButtonUp(const MouseEvent& rMEvt) override; void UpdateBitmap(); void ShowPosition( const Point& rPos, bool bUpdate ); @@ -242,12 +230,11 @@ public: void SetModifyHdl(const Link<ColorFieldControl&,void>& rLink) { maModifyHdl = rLink; } private: - std::unique_ptr<weld::DrawingArea> m_xDrawingArea; - Size m_aSize; ColorMode meMode; Color maColor; double mdX; double mdY; + bool mbMouseCaptured; Point maPosition; VclPtr<VirtualDevice> mxBitmap; Link<ColorFieldControl&,void> maModifyHdl; @@ -260,7 +247,7 @@ private: void ColorFieldControl::UpdateBitmap() { - const Size aSize(m_aSize); + const Size aSize(GetOutputSizePixel()); if (mxBitmap && mxBitmap->GetOutputSizePixel() != aSize) mxBitmap.disposeAndClear(); @@ -402,7 +389,7 @@ void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate ) if (!mxBitmap) { UpdateBitmap(); - m_xDrawingArea->queue_draw(); + Invalidate(); } if (!mxBitmap) @@ -425,8 +412,8 @@ void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate ) Point aPos = maPosition; maPosition.setX( nX - 5 ); maPosition.setY( nY - 5 ); - m_xDrawingArea->queue_draw_area(aPos.X(), aPos.Y(), 11, 11); - m_xDrawingArea->queue_draw_area(maPosition.X(), maPosition.Y(), 11, 11); + Invalidate(tools::Rectangle(aPos, Size(11, 11))); + Invalidate(tools::Rectangle(maPosition, Size(11, 11))); if (bUpdate) { @@ -437,34 +424,39 @@ void ColorFieldControl::ShowPosition( const Point& rPos, bool bUpdate ) } } -IMPL_LINK(ColorFieldControl, DoButtonDown, const MouseEvent&, rMEvt, void) +void ColorFieldControl::MouseButtonDown(const MouseEvent& rMEvt) { - m_xDrawingArea->connect_mouse_move(LINK(this, ColorFieldControl, DoMouseMove)); - m_xDrawingArea->grab_add(); + grab_add(); + mbMouseCaptured = true; ShowPosition(rMEvt.GetPosPixel(), true); Modify(); } -IMPL_LINK(ColorFieldControl, DoMouseMove, const MouseEvent&, rMEvt, void) +void ColorFieldControl::MouseMove(const MouseEvent& rMEvt) { - ShowPosition(rMEvt.GetPosPixel(), true); - Modify(); + if (mbMouseCaptured) + { + ShowPosition(rMEvt.GetPosPixel(), true); + Modify(); + } } -IMPL_LINK_NOARG(ColorFieldControl, DoButtonUp, const MouseEvent&, void) +void ColorFieldControl::MouseButtonUp(const MouseEvent&) { - m_xDrawingArea->grab_remove(); - m_xDrawingArea->connect_mouse_move(Link<const MouseEvent&, void>()); + grab_remove(); + mbMouseCaptured = false; } -IMPL_LINK(ColorFieldControl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void ColorFieldControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; if (!mxBitmap) UpdateBitmap(); if (mxBitmap) - rRenderContext.DrawOutDev(Point(0, 0), m_aSize, Point(0, 0), m_aSize, *mxBitmap); + { + Size aSize(GetOutputSizePixel()); + rRenderContext.DrawOutDev(Point(0, 0), aSize, Point(0, 0), aSize, *mxBitmap); + } // draw circle around current color if (maColor.IsDark()) @@ -477,15 +469,11 @@ IMPL_LINK(ColorFieldControl, DoPaint, weld::DrawingArea::draw_args, aPayload, vo rRenderContext.DrawEllipse(::tools::Rectangle(maPosition, Size(11, 11))); } -IMPL_LINK(ColorFieldControl, DoResize, const Size&, rSize, void) +void ColorFieldControl::Resize() { - if (m_aSize != rSize) - { - m_aSize = rSize; - UpdateBitmap(); - UpdatePosition(); - m_xDrawingArea->queue_draw(); - } + CustomWidgetController::Resize(); + UpdateBitmap(); + UpdatePosition(); } void ColorFieldControl::Modify() @@ -507,27 +495,29 @@ void ColorFieldControl::SetValues( Color aColor, ColorMode eMode, double x, doub UpdateBitmap(); UpdatePosition(); if (bUpdateBitmap) - m_xDrawingArea->queue_draw(); + Invalidate(); } } void ColorFieldControl::UpdatePosition() { - Size aSize(m_aSize); + Size aSize(GetOutputSizePixel()); ShowPosition(Point(static_cast<long>(mdX * aSize.Width()), static_cast<long>((1.0 - mdY) * aSize.Height())), false); } -class ColorSliderControl +class ColorSliderControl : public weld::CustomWidgetController { public: - ColorSliderControl(weld::DrawingArea* pDrawingArea); - ~ColorSliderControl(); + ColorSliderControl(); + virtual ~ColorSliderControl() override; - DECL_LINK(DoButtonDown, const MouseEvent& rMEvt, void); - DECL_LINK(DoMouseMove, const MouseEvent& rMEvt, void); - DECL_LINK(DoButtonUp, const MouseEvent& rMEvt, void); - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + + virtual void MouseButtonDown(const MouseEvent& rMEvt) override; + virtual void MouseMove(const MouseEvent& rMEvt) override; + virtual void MouseButtonUp(const MouseEvent& rMEvt) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; + virtual void Resize() override; void UpdateBitmap(); void ChangePosition( long nY ); @@ -540,31 +530,28 @@ public: 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; sal_Int16 mnLevel; double mdValue; + bool mbMouseCaptured; }; -ColorSliderControl::ColorSliderControl(weld::DrawingArea* pDrawingArea) - : m_xDrawingArea(pDrawingArea) - , meMode( DefaultMode ) +ColorSliderControl::ColorSliderControl() + : meMode( DefaultMode ) , mnLevel( 0 ) , mdValue( -1.0 ) + , mbMouseCaptured(false) +{ +} + +void ColorSliderControl::SetDrawingArea(weld::DrawingArea* pDrawingArea) { - m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_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)); + pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 3, -1); + CustomWidgetController::SetDrawingArea(pDrawingArea); } ColorSliderControl::~ColorSliderControl() @@ -574,7 +561,7 @@ ColorSliderControl::~ColorSliderControl() void ColorSliderControl::UpdateBitmap() { - Size aSize(1, m_aSize.Height()); + Size aSize(1, GetOutputSizePixel().Height()); if (mxBitmap && mxBitmap->GetOutputSizePixel() != aSize) mxBitmap.disposeAndClear(); @@ -651,7 +638,7 @@ void ColorSliderControl::UpdateBitmap() void ColorSliderControl::ChangePosition(long nY) { - const long nHeight = m_aSize.Height() - 1; + const long nHeight = GetOutputSizePixel().Height() - 1; if (nY < 0) nY = 0; @@ -662,32 +649,35 @@ void ColorSliderControl::ChangePosition(long nY) mdValue = double(nHeight - nY) / double(nHeight); } -IMPL_LINK(ColorSliderControl, DoButtonDown, const MouseEvent&, rMEvt, void) +void ColorSliderControl::MouseButtonDown(const MouseEvent& rMEvt) { - m_xDrawingArea->connect_mouse_move(LINK(this, ColorSliderControl, DoMouseMove)); + grab_add(); + mbMouseCaptured = true; ChangePosition(rMEvt.GetPosPixel().Y()); Modify(); } -IMPL_LINK(ColorSliderControl, DoMouseMove, const MouseEvent&, rMEvt, void) +void ColorSliderControl::MouseMove(const MouseEvent& rMEvt) { - ChangePosition(rMEvt.GetPosPixel().Y()); - Modify(); + if (mbMouseCaptured) + { + ChangePosition(rMEvt.GetPosPixel().Y()); + Modify(); + } } -IMPL_LINK_NOARG(ColorSliderControl, DoButtonUp, const MouseEvent&, void) +void ColorSliderControl::MouseButtonUp(const MouseEvent&) { - m_xDrawingArea->connect_mouse_move(Link<const MouseEvent&, void>()); + grab_remove(); + mbMouseCaptured = false; } -IMPL_LINK(ColorSliderControl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void ColorSliderControl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; - if (!mxBitmap) UpdateBitmap(); - const Size aSize(m_aSize); + const Size aSize(GetOutputSizePixel()); Point aPos; int x = aSize.Width(); @@ -698,14 +688,10 @@ IMPL_LINK(ColorSliderControl, DoPaint, weld::DrawingArea::draw_args, aPayload, v } } -IMPL_LINK(ColorSliderControl, DoResize, const Size&, rSize, void) +void ColorSliderControl::Resize() { - if (m_aSize != rSize) - { - m_aSize = rSize; - UpdateBitmap(); - m_xDrawingArea->queue_draw(); - } + CustomWidgetController::Resize(); + UpdateBitmap(); } void ColorSliderControl::Modify() @@ -720,21 +706,26 @@ void ColorSliderControl::SetValue(const Color& rColor, ColorMode eMode, double d { maColor = rColor; mdValue = dValue; - mnLevel = static_cast<sal_Int16>((1.0-dValue) * m_aSize.Height()); + mnLevel = static_cast<sal_Int16>((1.0-dValue) * GetOutputSizePixel().Height()); meMode = eMode; if (bUpdateBitmap) UpdateBitmap(); - m_xDrawingArea->queue_draw(); + Invalidate(); } } 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; + ColorFieldControl m_aColorField; + ColorSliderControl m_aColorSlider; + ColorPreviewControl m_aColorPreview; + ColorPreviewControl m_aColorPrevious; + + std::unique_ptr<weld::CustomWeld> m_xColorField; + std::unique_ptr<weld::CustomWeld> m_xColorSlider; + std::unique_ptr<weld::CustomWeld> m_xColorPreview; + std::unique_ptr<weld::CustomWeld> m_xColorPrevious; std::unique_ptr<weld::Widget> m_xFISliderLeft; std::unique_ptr<weld::Widget> m_xFISliderRight; @@ -785,10 +776,10 @@ private: ColorPickerDialog::ColorPickerDialog(weld::Window* pParent, Color nColor, sal_Int16 nDialogMode) : 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_xColorField(new weld::CustomWeld(*m_xBuilder, "colorField", m_aColorField)) + , m_xColorSlider(new weld::CustomWeld(*m_xBuilder, "colorSlider", m_aColorSlider)) + , m_xColorPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aColorPreview)) + , m_xColorPrevious(new weld::CustomWeld(*m_xBuilder, "previous", m_aColorPrevious)) , m_xFISliderLeft(m_xBuilder->weld_widget("leftImage")) , m_xFISliderRight(m_xBuilder->weld_widget("rightImage")) , m_xRBRed(m_xBuilder->weld_radio_button("redRadiobutton")) @@ -810,8 +801,8 @@ ColorPickerDialog::ColorPickerDialog(weld::Window* pParent, Color nColor, sal_In , m_xMFKey(m_xBuilder->weld_metric_spin_button("keySpinbutton", FUNIT_PERCENT)) , meMode( DefaultMode ) { - m_xColorField->SetModifyHdl( LINK( this, ColorPickerDialog, ColorFieldControlModifydl ) ); - m_xColorSlider->SetModifyHdl( LINK( this, ColorPickerDialog, ColorSliderControlModifyHdl ) ); + m_aColorField.SetModifyHdl( LINK( this, ColorPickerDialog, ColorFieldControlModifydl ) ); + m_aColorSlider.SetModifyHdl( LINK( this, ColorPickerDialog, ColorSliderControlModifyHdl ) ); int nMargin = (m_xFISliderLeft->get_preferred_size().Height() + 1) / 2; m_xColorSlider->set_margin_top(nMargin); @@ -847,7 +838,7 @@ ColorPickerDialog::ColorPickerDialog(weld::Window* pParent, Color nColor, sal_In // modify if (nDialogMode == 2) { - m_xColorPrevious->SetColor(aColor); + m_aColorPrevious.SetColor(aColor); m_xColorPrevious->show(); } @@ -906,22 +897,22 @@ void ColorPickerDialog::update_color( UpdateFlags n ) switch( meMode ) { case HUE: - m_xColorField->SetValues(aColor, meMode, mdSat, mdBri); + m_aColorField.SetValues(aColor, meMode, mdSat, mdBri); break; case SATURATION: - m_xColorField->SetValues(aColor, meMode, mdHue / 360.0, mdBri); + m_aColorField.SetValues(aColor, meMode, mdHue / 360.0, mdBri); break; case BRIGHTNESS: - m_xColorField->SetValues(aColor, meMode, mdHue / 360.0, mdSat); + m_aColorField.SetValues(aColor, meMode, mdHue / 360.0, mdSat); break; case RED: - m_xColorField->SetValues(aColor, meMode, mdBlue, mdGreen); + m_aColorField.SetValues(aColor, meMode, mdBlue, mdGreen); break; case GREEN: - m_xColorField->SetValues(aColor, meMode, mdBlue, mdRed); + m_aColorField.SetValues(aColor, meMode, mdBlue, mdRed); break; case BLUE: - m_xColorField->SetValues(aColor, meMode, mdRed, mdGreen); + m_aColorField.SetValues(aColor, meMode, mdRed, mdGreen); break; } } @@ -931,39 +922,39 @@ void ColorPickerDialog::update_color( UpdateFlags n ) switch (meMode) { case HUE: - m_xColorSlider->SetValue(aColor, meMode, mdHue / 360.0); + m_aColorSlider.SetValue(aColor, meMode, mdHue / 360.0); break; case SATURATION: - m_xColorSlider->SetValue(aColor, meMode, mdSat); + m_aColorSlider.SetValue(aColor, meMode, mdSat); break; case BRIGHTNESS: - m_xColorSlider->SetValue(aColor, meMode, mdBri); + m_aColorSlider.SetValue(aColor, meMode, mdBri); break; case RED: - m_xColorSlider->SetValue(aColor, meMode, mdRed); + m_aColorSlider.SetValue(aColor, meMode, mdRed); break; case GREEN: - m_xColorSlider->SetValue(aColor, meMode, mdGreen); + m_aColorSlider.SetValue(aColor, meMode, mdGreen); break; case BLUE: - m_xColorSlider->SetValue(aColor, meMode, mdBlue); + m_aColorSlider.SetValue(aColor, meMode, mdBlue); break; } } if (n & UpdateFlags::Hex) // update hex { - m_xFISliderLeft->set_margin_top(m_xColorSlider->GetLevel()); - m_xFISliderRight->set_margin_top(m_xColorSlider->GetLevel()); + m_xFISliderLeft->set_margin_top(m_aColorSlider.GetLevel()); + m_xFISliderRight->set_margin_top(m_aColorSlider.GetLevel()); m_xEDHex->SetColor(aColor); } - m_xColorPreview->SetColor(aColor); + m_aColorPreview.SetColor(aColor); } IMPL_LINK_NOARG(ColorPickerDialog, ColorFieldControlModifydl, ColorFieldControl&, void) { - double x = m_xColorField->GetX(); - double y = m_xColorField->GetY(); + double x = m_aColorField.GetX(); + double y = m_aColorField.GetY(); switch( meMode ) { @@ -998,7 +989,7 @@ IMPL_LINK_NOARG(ColorPickerDialog, ColorFieldControlModifydl, ColorFieldControl& IMPL_LINK_NOARG(ColorPickerDialog, ColorSliderControlModifyHdl, ColorSliderControl&, void) { - double dValue = m_xColorSlider->GetValue(); + double dValue = m_aColorSlider.GetValue(); switch (meMode) { case HUE: diff --git a/cui/source/dialogs/cuicharmap.cxx b/cui/source/dialogs/cuicharmap.cxx index 4727baca0fc2..5af66b617022 100755 --- a/cui/source/dialogs/cuicharmap.cxx +++ b/cui/source/dialogs/cuicharmap.cxx @@ -59,6 +59,39 @@ SvxCharacterMap::SvxCharacterMap(weld::Window* pParent, const SfxItemSet* pSet, , isSearchMode(true) , m_bHasInsert(bInsert) , mxContext(comphelper::getProcessComponentContext()) + , m_aRecentCharView{SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev)} + , m_aFavCharView{SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev), + SvxCharView(m_xVirDev)} + , m_aShowChar(m_xVirDev) , m_xOKBtn(bInsert ? m_xBuilder->weld_button("insert") : m_xBuilder->weld_button("ok")) , m_xFontText(m_xBuilder->weld_label("fontft")) , m_xFontLB(m_xBuilder->weld_combo_box_text("fontlb")) @@ -71,53 +104,55 @@ SvxCharacterMap::SvxCharacterMap(weld::Window* pParent, const SfxItemSet* pSet, , m_xCharName(m_xBuilder->weld_label("charname")) , m_xRecentGrid(m_xBuilder->weld_widget("viewgrid")) , m_xFavGrid(m_xBuilder->weld_widget("favgrid")) - , m_xShowChar(new SvxShowText(*m_xBuilder, "showchar", m_xVirDev)) - , m_xRecentCharView{o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar1", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar2", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar3", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar4", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar5", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar6", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar7", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar8", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar9", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar10", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar11", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar12", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar13", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar14", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar15", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "viewchar16", m_xVirDev)} - , m_xFavCharView{o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar1", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar2", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar3", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar4", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar5", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar6", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar7", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar8", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar9", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar10", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar11", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar12", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar13", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar14", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar15", m_xVirDev), - o3tl::make_unique<SvxCharView>(*m_xBuilder, "favchar16", m_xVirDev)} - , m_xShowSet(new SvxShowCharSet(*m_xBuilder, "showcharset", "showscroll", m_xVirDev)) - , m_xSearchSet(new SvxSearchCharSet(*m_xBuilder, "searchcharset", "searchscroll", m_xVirDev)) + , m_xShowChar(new weld::CustomWeld(*m_xBuilder, "showchar", m_aShowChar)) + , m_xRecentCharView{o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar1", m_aRecentCharView[0]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar2", m_aRecentCharView[1]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar3", m_aRecentCharView[2]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar4", m_aRecentCharView[3]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar5", m_aRecentCharView[4]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar6", m_aRecentCharView[5]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar7", m_aRecentCharView[6]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar8", m_aRecentCharView[7]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar9", m_aRecentCharView[8]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar10", m_aRecentCharView[9]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar11", m_aRecentCharView[10]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar12", m_aRecentCharView[11]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar13", m_aRecentCharView[12]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar14", m_aRecentCharView[13]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar15", m_aRecentCharView[14]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "viewchar16", m_aRecentCharView[15])} + , m_xFavCharView{o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar1", m_aFavCharView[0]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar2", m_aFavCharView[1]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar3", m_aFavCharView[2]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar4", m_aFavCharView[3]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar5", m_aFavCharView[4]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar6", m_aFavCharView[5]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar7", m_aFavCharView[6]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar8", m_aFavCharView[7]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar9", m_aFavCharView[8]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar10", m_aFavCharView[9]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar11", m_aFavCharView[10]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar12", m_aFavCharView[11]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar13", m_aFavCharView[12]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar14", m_aFavCharView[13]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar15", m_aFavCharView[14]), + o3tl::make_unique<weld::CustomWeld>(*m_xBuilder, "favchar16", m_aFavCharView[15])} + , m_xShowSet(new SvxShowCharSet(m_xBuilder->weld_scrolled_window("showscroll"), m_xVirDev)) + , m_xShowSetArea(new weld::CustomWeld(*m_xBuilder, "showcharset", *m_xShowSet)) + , m_xSearchSet(new SvxSearchCharSet(m_xBuilder->weld_scrolled_window("searchscroll"), m_xVirDev)) + , m_xSearchSetArea(new weld::CustomWeld(*m_xBuilder, "searchcharset", *m_xSearchSet)) { - m_xShowChar->SetCentered(true); + m_aShowChar.SetCentered(true); m_xFontLB->make_sorted(); //lock the size request of this widget to the width of all possible entries fillAllSubsets(*m_xSubsetLB); m_xSubsetLB->set_size_request(m_xSubsetLB->get_preferred_size().Width(), -1); - m_xCharName->set_size_request(m_xShowChar->get_preferred_size().Width(), m_xCharName->get_text_height() * 4); + m_xCharName->set_size_request(m_aShowChar.get_preferred_size().Width(), m_xCharName->get_text_height() * 4); //lock the size request of this widget to the width of the original .ui string m_xHexCodeText->set_size_request(m_xHexCodeText->get_preferred_size().Width(), -1); //so things don't jump around if all the children are hidden - m_xRecentGrid->set_size_request(-1, m_xRecentCharView[0]->get_preferred_size().Height()); - m_xFavGrid->set_size_request(-1, m_xFavCharView[0]->get_preferred_size().Height()); + m_xRecentGrid->set_size_request(-1, m_aRecentCharView[0].get_preferred_size().Height()); + m_xFavGrid->set_size_request(-1, m_aFavCharView[0].get_preferred_size().Height()); init(); @@ -162,9 +197,9 @@ short SvxCharacterMap::execute() sal_UCS4 cChar = m_xShowSet->GetSelectCharacter(); // using the new UCS4 constructor OUString aOUStr( &cChar, 1 ); - m_xShowChar->SetText(aOUStr); + m_aShowChar.SetText(aOUStr); - setFavButtonState(aOUStr, m_xShowChar->GetFont().GetFamilyName()); + setFavButtonState(aOUStr, m_aShowChar.GetFont().GetFamilyName()); m_xOKBtn->set_sensitive(true); } @@ -177,13 +212,11 @@ void SvxCharacterMap::SetChar( sal_UCS4 c ) setFavButtonState(OUString(&c, 1), aFont.GetFamilyName()); } - sal_UCS4 SvxCharacterMap::GetChar() const { - return (m_xShowChar->GetText()).toChar(); + return (m_aShowChar.GetText()).toChar(); } - void SvxCharacterMap::DisableFontSelection() { m_xFontText->set_sensitive(false); @@ -236,17 +269,17 @@ void SvxCharacterMap::updateRecentCharControl() it != maRecentCharList.end() || it2 != maRecentCharFontList.end(); ++it, ++it2, i++) { - m_xRecentCharView[i]->SetText(*it); - vcl::Font rFont = m_xRecentCharView[i]->GetFont(); + m_aRecentCharView[i].SetText(*it); + vcl::Font rFont = m_aRecentCharView[i].GetFont(); rFont.SetFamilyName( *it2 ); - m_xRecentCharView[i]->SetFont(rFont); - m_xRecentCharView[i]->Show(); + m_aRecentCharView[i].SetFont(rFont); + m_aRecentCharView[i].Show(); } for(; i < 16 ; i++) { - m_xRecentCharView[i]->SetText(OUString()); - m_xRecentCharView[i]->Hide(); + m_aRecentCharView[i].SetText(OUString()); + m_aRecentCharView[i].Hide(); } } @@ -343,17 +376,17 @@ void SvxCharacterMap::updateFavCharControl() it != maFavCharList.end() || it2 != maFavCharFontList.end(); ++it, ++it2, i++) { - m_xFavCharView[i]->SetText(*it); - vcl::Font rFont = m_xFavCharView[i]->GetFont(); + m_aFavCharView[i].SetText(*it); + vcl::Font rFont = m_aFavCharView[i].GetFont(); rFont.SetFamilyName( *it2 ); - m_xFavCharView[i]->SetFont(rFont); - m_xFavCharView[i]->Show(); + m_aFavCharView[i].SetFont(rFont); + m_aFavCharView[i].Show(); } for(; i < 16 ; i++) { - m_xFavCharView[i]->SetText(OUString()); - m_xFavCharView[i]->Hide(); + m_aFavCharView[i].SetText(OUString()); + m_aFavCharView[i].Hide(); } m_xShowSet->getFavCharacterList(); m_xSearchSet->getFavCharacterList(); @@ -467,7 +500,7 @@ void SvxCharacterMap::init() sal_UCS4 cChar = m_xShowSet->GetSelectCharacter(); // using the new UCS4 constructor OUString aOUStr( &cChar, 1 ); - m_xShowChar->SetText(aOUStr); + m_aShowChar.SetText(aOUStr); setFavButtonState(aOUStr, aDefStr); m_xOKBtn->set_sensitive(true); @@ -481,14 +514,14 @@ void SvxCharacterMap::init() for(int i = 0; i < 16; i++) { - m_xRecentCharView[i]->SetHasInsert(m_bHasInsert); - m_xRecentCharView[i]->setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl)); - m_xRecentCharView[i]->setClearClickHdl(LINK(this,SvxCharacterMap, RecentClearClickHdl)); - m_xRecentCharView[i]->setClearAllClickHdl(LINK(this,SvxCharacterMap, RecentClearAllClickHdl)); - m_xFavCharView[i]->SetHasInsert(m_bHasInsert); - m_xFavCharView[i]->setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl)); - m_xFavCharView[i]->setClearClickHdl(LINK(this,SvxCharacterMap, FavClearClickHdl)); - m_xFavCharView[i]->setClearAllClickHdl(LINK(this,SvxCharacterMap, FavClearAllClickHdl)); + m_aRecentCharView[i].SetHasInsert(m_bHasInsert); + m_aRecentCharView[i].setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl)); + m_aRecentCharView[i].setClearClickHdl(LINK(this,SvxCharacterMap, RecentClearClickHdl)); + m_aRecentCharView[i].setClearAllClickHdl(LINK(this,SvxCharacterMap, RecentClearAllClickHdl)); + m_aFavCharView[i].SetHasInsert(m_bHasInsert); + m_aFavCharView[i].setMouseClickHdl(LINK(this,SvxCharacterMap, CharClickHdl)); + m_aFavCharView[i].setClearClickHdl(LINK(this,SvxCharacterMap, FavClearClickHdl)); + m_aFavCharView[i].setClearAllClickHdl(LINK(this,SvxCharacterMap, FavClearAllClickHdl)); } setCharName(90); @@ -614,7 +647,7 @@ IMPL_LINK_NOARG(SvxCharacterMap, FontSelectHdl, weld::ComboBoxText&, void) // notify children using this font m_xShowSet->SetFont( aFont ); m_xSearchSet->SetFont( aFont ); - m_xShowChar->SetFont( aFont ); + m_aShowChar.SetFont( aFont ); if (isSearchMode) { SearchUpdateHdl(*m_xSearchText); @@ -841,12 +874,12 @@ IMPL_LINK_NOARG(SvxCharacterMap, SearchUpdateHdl, weld::Entry&, void) IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView*, rView, void) { - m_xShowChar->SetText( rView->GetText() ); - m_xShowChar->SetFont(rView->GetFont()); - m_xShowChar->queue_draw(); + m_aShowChar.SetText( rView->GetText() ); + m_aShowChar.SetFont(rView->GetFont()); + m_aShowChar.Invalidate(); setFavButtonState(rView->GetText(), rView->GetFont().GetFamilyName());//check state - rView->grab_focus(); + rView->GrabFocus(); // Get the hexadecimal code OUString charValue = rView->GetText(); @@ -861,7 +894,7 @@ IMPL_LINK(SvxCharacterMap, CharClickHdl, SvxCharView*, rView, void) m_xDecimalCodeText->set_text(aDecimalText); setCharName(cChar); - rView->queue_draw(); + rView->Invalidate(); m_xOKBtn->set_sensitive(true); } @@ -895,7 +928,7 @@ IMPL_LINK_NOARG(SvxCharacterMap, SearchCharSelectHdl, SvxShowCharSet*, void) IMPL_LINK_NOARG(SvxCharacterMap, InsertClickHdl, weld::Button&, void) { - insertCharToDoc(m_xShowChar->GetText()); + insertCharToDoc(m_aShowChar.GetText()); m_xDialog->response(RET_OK); } @@ -903,12 +936,12 @@ IMPL_LINK_NOARG(SvxCharacterMap, FavSelectHdl, weld::Button&, void) { if (m_xFavouritesBtn->get_label().match(CuiResId(RID_SVXSTR_ADD_FAVORITES))) { - updateFavCharacterList(m_xShowChar->GetText(), m_xShowChar->GetFont().GetFamilyName()); - setFavButtonState(m_xShowChar->GetText(), m_xShowChar->GetFont().GetFamilyName()); + updateFavCharacterList(m_aShowChar.GetText(), m_aShowChar.GetFont().GetFamilyName()); + setFavButtonState(m_aShowChar.GetText(), m_aShowChar.GetFont().GetFamilyName()); } else { - deleteFavCharacterFromList(m_xShowChar->GetText(), m_xShowChar->GetFont().GetFamilyName()); + deleteFavCharacterFromList(m_aShowChar.GetText(), m_aShowChar.GetFont().GetFamilyName()); m_xFavouritesBtn->set_label(CuiResId(RID_SVXSTR_ADD_FAVORITES)); m_xFavouritesBtn->set_sensitive(false); } @@ -958,9 +991,9 @@ IMPL_LINK_NOARG(SvxCharacterMap, CharHighlightHdl, SvxShowCharSet*, void) if(m_xShowSet->HasFocus() || m_xHexCodeText->has_focus() || m_xDecimalCodeText->has_focus() ) { - m_xShowChar->SetText( aText ); - m_xShowChar->SetFont( aFont ); - m_xShowChar->queue_draw(); + m_aShowChar.SetText( aText ); + m_aShowChar.SetFont( aFont ); + m_aShowChar.Invalidate(); setFavButtonState(aText, aFont.GetFamilyName()); } @@ -1001,9 +1034,9 @@ IMPL_LINK_NOARG(SvxCharacterMap, SearchCharHighlightHdl, SvxShowCharSet*, void) if(m_xSearchSet->HasFocus()) { - m_xShowChar->SetText( aText ); - m_xShowChar->SetFont( aFont ); - m_xShowChar->queue_draw(); + m_aShowChar.SetText( aText ); + m_aShowChar.SetFont( aFont ); + m_aShowChar.Invalidate(); setFavButtonState(aText, aFont.GetFamilyName()); } @@ -1031,7 +1064,7 @@ void SvxCharacterMap::selectCharByCode(Radix radix) SetChar(cChar); else { m_xCharName->set_label(CuiResId(RID_SVXSTR_MISSING_GLYPH)); - m_xShowChar->SetText(" "); + m_aShowChar.SetText(" "); switch(radix) { case Radix::decimal: @@ -1087,29 +1120,28 @@ IMPL_LINK_NOARG(SvxCharacterMap, SearchCharPreSelectHdl, SvxShowCharSet*, void) } // class SvxShowText ===================================================== -SvxShowText::SvxShowText(weld::Builder& rBuilder, const OString& rId, const VclPtr<VirtualDevice>& rVirDev) - : m_xDrawingArea(rBuilder.weld_drawing_area(rId)) - , m_xVirDev(rVirDev) +SvxShowText::SvxShowText(const VclPtr<VirtualDevice>& rVirDev) + : m_xVirDev(rVirDev) , mnY(0) , mbCenter(false) { - m_xDrawingArea->connect_size_allocate(LINK(this, SvxShowText, DoResize)); - m_xDrawingArea->connect_draw(LINK(this, SvxShowText, DoPaint)); +} +void SvxShowText::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ vcl::Font aFont = m_xVirDev->GetFont(); Size aFontSize(aFont.GetFontSize().Width() * 5, aFont.GetFontSize().Height() * 5); aFont.SetFontSize(aFontSize); m_xVirDev->Push(PUSH_ALLFONT); m_xVirDev->SetFont(aFont); - m_xDrawingArea->set_size_request(m_xVirDev->approximate_digit_width() + 2 * 12, - m_xVirDev->LogicToPixel(aFontSize).Height() * 2); + pDrawingArea->set_size_request(m_xVirDev->approximate_digit_width() + 2 * 12, + m_xVirDev->LogicToPixel(aFontSize).Height() * 2); + CustomWidgetController::SetDrawingArea(pDrawingArea); m_xVirDev->Pop(); } -IMPL_LINK(SvxShowText, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void SvxShowText::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; - rRenderContext.SetFont(m_aFont); Color aTextCol = rRenderContext.GetTextColor(); @@ -1123,8 +1155,9 @@ IMPL_LINK(SvxShowText, DoPaint, weld::DrawingArea::draw_args, aPayload, void) const OUString aText = GetText(); - long nAvailWidth = m_aSize.Width(); - long nWinHeight = m_aSize.Height(); + Size aSize(GetOutputSizePixel()); + long nAvailWidth = aSize.Width(); + long nWinHeight = aSize.Height(); bool bGotBoundary = true; bool bShrankFont = false; @@ -1156,7 +1189,7 @@ IMPL_LINK(SvxShowText, DoPaint, weld::DrawingArea::draw_args, aPayload, void) Point aPoint(2, mnY); // adjust position using ink boundary if possible if (!bGotBoundary) - aPoint.setX( (m_aSize.Width() - rRenderContext.GetTextWidth(aText)) / 2 ); + aPoint.setX( (aSize.Width() - rRenderContext.GetTextWidth(aText)) / 2 ); else { // adjust position before it gets out of bounds @@ -1164,7 +1197,7 @@ IMPL_LINK(SvxShowText, DoPaint, weld::DrawingArea::draw_args, aPayload, void) // shift back vertically if needed int nYLDelta = aBoundRect.Top(); - int nYHDelta = m_aSize.Height() - aBoundRect.Bottom(); + int nYHDelta = aSize.Height() - aBoundRect.Bottom(); if( nYLDelta <= 0 ) aPoint.AdjustY( -(nYLDelta - 1) ); else if( nYHDelta <= 0 ) @@ -1173,13 +1206,13 @@ IMPL_LINK(SvxShowText, DoPaint, weld::DrawingArea::draw_args, aPayload, void) if (mbCenter) { // move glyph to middle of cell - aPoint.setX( -aBoundRect.Left() + (m_aSize.Width() - aBoundRect.GetWidth()) / 2 ); + aPoint.setX( -aBoundRect.Left() + (aSize.Width() - aBoundRect.GetWidth()) / 2 ); } else { // shift back horizontally if needed int nXLDelta = aBoundRect.Left(); - int nXHDelta = m_aSize.Width() - aBoundRect.Right(); + int nXHDelta = aSize.Width() - aBoundRect.Right(); if( nXLDelta <= 0 ) aPoint.AdjustX( -(nXLDelta - 1) ); else if( nXHDelta <= 0 ) @@ -1187,7 +1220,7 @@ IMPL_LINK(SvxShowText, DoPaint, weld::DrawingArea::draw_args, aPayload, void) } } - rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), m_aSize)); + rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), aSize)); rRenderContext.DrawText(aPoint, aText); rRenderContext.SetTextColor(aTextCol); rRenderContext.SetFillColor(aFillCol); @@ -1195,10 +1228,9 @@ IMPL_LINK(SvxShowText, DoPaint, weld::DrawingArea::draw_args, aPayload, void) rRenderContext.SetFont(aOrigFont); } - void SvxShowText::SetFont( const vcl::Font& rFont ) { - long nWinHeight = m_aSize.Height(); + long nWinHeight = GetOutputSizePixel().Height(); m_aFont = vcl::Font(rFont); m_aFont.SetWeight(WEIGHT_NORMAL); @@ -1211,19 +1243,18 @@ void SvxShowText::SetFont( const vcl::Font& rFont ) mnY = (nWinHeight - m_xVirDev->GetTextHeight()) / 2; m_xVirDev->Pop(); - m_xDrawingArea->queue_draw(); + Invalidate(); } -IMPL_LINK(SvxShowText, DoResize, const Size&, rSize, void) +void SvxShowText::Resize() { - m_aSize = rSize; SetFont(GetFont()); //force recalculation of size } void SvxShowText::SetText(const OUString& rText) { m_sText = rText; - queue_draw(); + Invalidate(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cui/source/inc/cuicharmap.hxx b/cui/source/inc/cuicharmap.hxx index 86bc53052827..e99a0f81573a 100644 --- a/cui/source/inc/cuicharmap.hxx +++ b/cui/source/inc/cuicharmap.hxx @@ -24,6 +24,7 @@ #include <vcl/button.hxx> #include <vcl/fixed.hxx> #include <vcl/lstbox.hxx> +#include <vcl/customweld.hxx> #include <vcl/weld.hxx> #include <sfx2/basedlgs.hxx> #include <svl/itemset.hxx> @@ -41,21 +42,20 @@ namespace svx struct SvxShowCharSetItem; } -class SvxShowText +class SvxShowText : public weld::CustomWidgetController { private: - std::unique_ptr<weld::DrawingArea> m_xDrawingArea; VclPtr<VirtualDevice> m_xVirDev; - Size m_aSize; OUString m_sText; long mnY; bool mbCenter; vcl::Font m_aFont; - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; + virtual void Resize() override; + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; public: - SvxShowText(weld::Builder& rBuilder, const OString& rId, const VclPtr<VirtualDevice>& rVirDev); + SvxShowText(const VclPtr<VirtualDevice>& rVirDev); void SetFont(const vcl::Font& rFont); vcl::Font GetFont() const { return m_aFont; } @@ -63,8 +63,7 @@ public: OUString GetText() const { return m_sText; } void SetCentered(bool bCenter) { mbCenter = bCenter; } - void queue_draw() { m_xDrawingArea->queue_draw(); } - Size get_preferred_size() const { return m_xDrawingArea->get_preferred_size(); } + Size get_preferred_size() const { return GetDrawingArea()->get_preferred_size(); } }; /** The main purpose of this dialog is to enable the use of characters @@ -86,6 +85,10 @@ private: std::deque<OUString> maFavCharFontList; uno::Reference< uno::XComponentContext > mxContext; + SvxCharView m_aRecentCharView[16]; + SvxCharView m_aFavCharView[16]; + SvxShowText m_aShowChar; + std::unique_ptr<weld::Button> m_xOKBtn; std::unique_ptr<weld::Label> m_xFontText; std::unique_ptr<weld::ComboBoxText> m_xFontLB; @@ -98,11 +101,13 @@ private: std::unique_ptr<weld::Label> m_xCharName; std::unique_ptr<weld::Widget> m_xRecentGrid; std::unique_ptr<weld::Widget> m_xFavGrid; - std::unique_ptr<SvxShowText> m_xShowChar; - std::unique_ptr<SvxCharView> m_xRecentCharView[16]; - std::unique_ptr<SvxCharView> m_xFavCharView[16]; + std::unique_ptr<weld::CustomWeld> m_xShowChar; + std::unique_ptr<weld::CustomWeld> m_xRecentCharView[16]; + std::unique_ptr<weld::CustomWeld> m_xFavCharView[16]; std::unique_ptr<SvxShowCharSet> m_xShowSet; + std::unique_ptr<weld::CustomWeld> m_xShowSetArea; std::unique_ptr<SvxSearchCharSet> m_xSearchSet; + std::unique_ptr<weld::CustomWeld> m_xSearchSetArea; std::unique_ptr<SfxAllItemSet> m_xOutputSet; diff --git a/cui/source/inc/textattr.hxx b/cui/source/inc/textattr.hxx index 88a5f7d7113d..f0929e16109b 100644 --- a/cui/source/inc/textattr.hxx +++ b/cui/source/inc/textattr.hxx @@ -50,6 +50,8 @@ private: bool bWordWrapTextEnabled; bool bFitToSizeEnabled; + RectCtl m_aCtlPosition; + std::unique_ptr<weld::Widget> m_xDrawingText; std::unique_ptr<weld::Widget> m_xCustomShapeText; std::unique_ptr<weld::CheckButton> m_xTsbAutoGrowWidth; @@ -64,7 +66,7 @@ private: std::unique_ptr<weld::MetricSpinButton> m_xMtrFldTop; std::unique_ptr<weld::MetricSpinButton> m_xMtrFldBottom; std::unique_ptr<weld::Frame> m_xFlPosition; - std::unique_ptr<RectCtl> m_xCtlPosition; + std::unique_ptr<weld::CustomWeld> m_xCtlPosition; std::unique_ptr<weld::CheckButton> m_xTsbFullWidth; DECL_LINK(ClickFullWidthHdl_Impl, weld::Button&, void); diff --git a/cui/source/tabpages/textattr.cxx b/cui/source/tabpages/textattr.cxx index 092ef3966ffa..3013bd6038d7 100644 --- a/cui/source/tabpages/textattr.cxx +++ b/cui/source/tabpages/textattr.cxx @@ -63,6 +63,7 @@ SvxTextAttrPage::SvxTextAttrPage(TabPageParent pPage, const SfxItemSet& rInAttrs , bAutoGrowHeightEnabled(false) , bWordWrapTextEnabled(false) , bFitToSizeEnabled(false) + , m_aCtlPosition(this) , m_xDrawingText(m_xBuilder->weld_widget("drawingtext")) , m_xCustomShapeText(m_xBuilder->weld_widget("customshapetext")) , m_xTsbAutoGrowWidth(m_xBuilder->weld_check_button("TSB_AUTOGROW_WIDTH")) @@ -77,10 +78,10 @@ SvxTextAttrPage::SvxTextAttrPage(TabPageParent pPage, const SfxItemSet& rInAttrs , m_xMtrFldTop(m_xBuilder->weld_metric_spin_button("MTR_FLD_TOP", FUNIT_CM)) , m_xMtrFldBottom(m_xBuilder->weld_metric_spin_button("MTR_FLD_BOTTOM", FUNIT_CM)) , m_xFlPosition(m_xBuilder->weld_frame("FL_POSITION")) - , m_xCtlPosition(new RectCtl(*m_xBuilder, "CTL_POSITION", this)) + , m_xCtlPosition(new weld::CustomWeld(*m_xBuilder, "CTL_POSITION", m_aCtlPosition)) , m_xTsbFullWidth(m_xBuilder->weld_check_button("TSB_FULL_WIDTH")) { - m_xCtlPosition->SetControlSettings(RectPoint::MM, 240, 100); + m_aCtlPosition.SetControlSettings(RectPoint::MM, 240, 100); FieldUnit eFUnit = GetModuleFieldUnit( rInAttrs ); SetFieldUnit( *m_xMtrFldLeft, eFUnit ); @@ -264,15 +265,15 @@ void SvxTextAttrPage::Reset( const SfxItemSet* rAttrs ) m_xTsbFullWidth->set_state(TRISTATE_TRUE); } - m_xCtlPosition->SetActualRP( eRP ); + m_aCtlPosition.SetActualRP( eRP ); } else { // VertAdjust or HorAdjust is not unequivocal - m_xCtlPosition->Reset(); + m_aCtlPosition.Reset(); - m_xCtlPosition->SetState(CTL_STATE::NOVERT); - m_xCtlPosition->DoCompletelyDisable(true); + m_aCtlPosition.SetState(CTL_STATE::NOVERT); + m_aCtlPosition.DoCompletelyDisable(true); m_xTsbFullWidth->set_state(TRISTATE_INDET); m_xFlPosition->set_sensitive( false ); @@ -389,7 +390,7 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs) } // centered - RectPoint eRP = m_xCtlPosition->GetActualRP(); + RectPoint eRP = m_aCtlPosition.GetActualRP(); SdrTextVertAdjust eTVA, eOldTVA; SdrTextHorzAdjust eTHA, eOldTHA; @@ -417,7 +418,7 @@ bool SvxTextAttrPage::FillItemSet( SfxItemSet* rAttrs) } // #103516# Do not change values if adjust controls were disabled. - bool bIsDisabled(m_xCtlPosition->IsCompletelyDisabled()); + bool bIsDisabled(m_aCtlPosition.IsCompletelyDisabled()); if(!bIsDisabled) { @@ -591,21 +592,21 @@ IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl, weld::Button&, void) if (IsTextDirectionLeftToRight()) { // Move text anchor to horizontal middle axis. - switch( m_xCtlPosition->GetActualRP() ) + switch( m_aCtlPosition.GetActualRP() ) { case RectPoint::LT: case RectPoint::RT: - m_xCtlPosition->SetActualRP( RectPoint::MT ); + m_aCtlPosition.SetActualRP( RectPoint::MT ); break; case RectPoint::LM: case RectPoint::RM: - m_xCtlPosition->SetActualRP( RectPoint::MM ); + m_aCtlPosition.SetActualRP( RectPoint::MM ); break; case RectPoint::LB: case RectPoint::RB: - m_xCtlPosition->SetActualRP( RectPoint::MB ); + m_aCtlPosition.SetActualRP( RectPoint::MB ); break; default: ;//prevent warning } @@ -613,21 +614,21 @@ IMPL_LINK_NOARG(SvxTextAttrPage, ClickFullWidthHdl_Impl, weld::Button&, void) else { // Move text anchor to vertical middle axis. - switch( m_xCtlPosition->GetActualRP() ) + switch( m_aCtlPosition.GetActualRP() ) { case RectPoint::LT: case RectPoint::LB: - m_xCtlPosition->SetActualRP( RectPoint::LM ); + m_aCtlPosition.SetActualRP( RectPoint::LM ); break; case RectPoint::MT: case RectPoint::MB: - m_xCtlPosition->SetActualRP( RectPoint::MM ); + m_aCtlPosition.SetActualRP( RectPoint::MM ); break; case RectPoint::RT: case RectPoint::RB: - m_xCtlPosition->SetActualRP( RectPoint::RM ); + m_aCtlPosition.SetActualRP( RectPoint::RM ); break; default: ;//prevent warning } |