diff options
46 files changed, 981 insertions, 855 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 } diff --git a/include/sfx2/charwin.hxx b/include/sfx2/charwin.hxx index 992df5206e11..85c40d84b225 100644 --- a/include/sfx2/charwin.hxx +++ b/include/sfx2/charwin.hxx @@ -22,14 +22,13 @@ #include <sfx2/tbxctrl.hxx> #include <sfx2/dllapi.h> +#include <vcl/customweld.hxx> #include <vcl/weld.hxx> -class SFX2_DLLPUBLIC SvxCharView +class SFX2_DLLPUBLIC SvxCharView : public weld::CustomWidgetController { private: VclPtr<VirtualDevice> mxVirDev; - std::unique_ptr<weld::DrawingArea> mxDrawingArea; - Size m_aSize; long mnY; Point maPosition; vcl::Font maFont; @@ -40,34 +39,29 @@ private: Link<SvxCharView*, void> maClearClickHdl; Link<SvxCharView*, void> maClearAllClickHdl; - - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); - DECL_LINK(DoMouseButtonDown, const MouseEvent&, void); - DECL_LINK(DoKeyDown, const KeyEvent&, bool); - DECL_LINK(DoGetFocus, weld::Widget&, void); - DECL_LINK(DoLoseFocus, weld::Widget&, void); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void Resize() override; + virtual void MouseButtonDown(const MouseEvent&) override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual bool KeyInput(const KeyEvent&) override; + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; public: - SvxCharView(weld::Builder& rBuilder, const OString& rId, const VclPtr<VirtualDevice>& rVirDev); + SvxCharView(const VclPtr<VirtualDevice>& rVirDev); void SetFont( const vcl::Font& rFont ); vcl::Font GetFont() const { return maFont; } void SetText( const OUString& rText ); OUString GetText() const { return m_sText; } - void Show() { mxDrawingArea->show(); } - void Hide() { mxDrawingArea->hide(); } void SetHasInsert( bool bInsert ); void InsertCharToDoc(); void createContextMenu(); - void grab_focus() { mxDrawingArea->grab_focus(); } - void queue_draw() { mxDrawingArea->queue_draw(); } - Size get_preferred_size() const { return mxDrawingArea->get_preferred_size(); } - - void connect_focus_in(const Link<weld::Widget&, void>& rLink) { mxDrawingArea->connect_focus_in(rLink); } - void connect_focus_out(const Link<weld::Widget&, void>& rLink) { mxDrawingArea->connect_focus_out(rLink); } + Size get_preferred_size() const { return GetDrawingArea()->get_preferred_size(); } + void connect_focus_in(const Link<weld::Widget&, void>& rLink); + void connect_focus_out(const Link<weld::Widget&, void>& rLink); void setMouseClickHdl(const Link<SvxCharView*,void> &rLink); void setClearClickHdl(const Link<SvxCharView*,void> &rLink); diff --git a/include/sfx2/new.hxx b/include/sfx2/new.hxx index 4eb1fa8d48c3..f5c30c23060f 100644 --- a/include/sfx2/new.hxx +++ b/include/sfx2/new.hxx @@ -25,6 +25,7 @@ #include <sfx2/objsh.hxx> #include <vcl/idle.hxx> +#include <vcl/customweld.hxx> #include <vcl/weld.hxx> #include <sfx2/doctempl.hxx> #include <o3tl/typed_flags_set.hxx> @@ -57,6 +58,13 @@ namespace o3tl class SFX2_DLLPUBLIC SfxNewFileDialog : public weld::GenericDialogController { private: + Idle m_aPrevIdle; + SfxNewFileDialogMode m_nFlags; + SfxDocumentTemplates m_aTemplates; + SfxObjectShellLock m_xDocShell; + + std::unique_ptr<SfxPreviewWin_Impl> m_xPreviewController; + std::unique_ptr<weld::TreeView> m_xRegionLb; std::unique_ptr<weld::TreeView> m_xTemplateLb; std::unique_ptr<weld::CheckButton> m_xTextStyleCB; @@ -66,13 +74,8 @@ private: std::unique_ptr<weld::CheckButton> m_xMergeStyleCB; std::unique_ptr<weld::Button> m_xLoadFilePB; std::unique_ptr<weld::Expander> m_xMoreBt; - std::unique_ptr<SfxPreviewWin_Impl> m_xPreviewWin; + std::unique_ptr<weld::CustomWeld> m_xPreviewWin; std::unique_ptr<weld::Label> m_xAltTitleFt; - Idle m_aPrevIdle; - - SfxNewFileDialogMode m_nFlags; - SfxDocumentTemplates m_aTemplates; - SfxObjectShellLock m_xDocShell; DECL_LINK( Update, Timer *, void ); diff --git a/include/svx/charmap.hxx b/include/svx/charmap.hxx index 3df37695eb75..2446c0607cbb 100644 --- a/include/svx/charmap.hxx +++ b/include/svx/charmap.hxx @@ -35,6 +35,7 @@ #include <vcl/outdev.hxx> #include <vcl/metric.hxx> #include <vcl/vclptr.hxx> +#include <vcl/customweld.hxx> #include <vcl/weld.hxx> #include <vcl/window.hxx> #include <vcl/textview.hxx> @@ -56,19 +57,15 @@ namespace svx class SvxShowCharSetAcc; } -class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxShowCharSet +class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxShowCharSet : public weld::CustomWidgetController { protected: VclPtr<VirtualDevice> mxVirDev; - std::unique_ptr<weld::DrawingArea> mxDrawingArea; - std::unique_ptr<weld::ScrolledWindow> mxScrollArea; vcl::Font maFont; - Size maSize; + std::unique_ptr<weld::ScrolledWindow> mxScrollArea; public: - SvxShowCharSet(weld::Builder& rBuilder, const OString& rDrawingId, - const OString& rScrollId, const VclPtr<VirtualDevice>& rVirDev); - - virtual ~SvxShowCharSet(); + SvxShowCharSet(weld::ScrolledWindow* pScrollArea, const VclPtr<VirtualDevice>& rVirDev); + virtual ~SvxShowCharSet() override; virtual void RecalculateFont(vcl::RenderContext& rRenderContext); @@ -106,25 +103,22 @@ public: void Show() { mxScrollArea->show(); } void Hide() { mxScrollArea->hide(); } - bool HasFocus() const { return mxDrawingArea->has_focus(); } - void GrabFocus() { mxDrawingArea->grab_focus(); } - bool IsEnabled() const { return mxDrawingArea->get_sensitive(); } - bool IsVisible() const { return mxDrawingArea->get_visible(); } - const Size& GetSize() const { return maSize; } - uno::Reference<css::accessibility::XAccessible> getAccessibleParent() { return mxDrawingArea->get_accessible_parent(); } + uno::Reference<css::accessibility::XAccessible> getAccessibleParent() { return GetDrawingArea()->get_accessible_parent(); } private: - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); - DECL_LINK(DoMouseButtonDown, const MouseEvent& rMEvt, void); - DECL_LINK(DoMouseMove, const MouseEvent& rMEvt, void); - DECL_LINK(DoMouseButtonUp, const MouseEvent& rMEvt, void); - DECL_LINK(DoKeyDown, const KeyEvent& rKEvt, bool); - DECL_LINK(DoGetFocus, weld::Widget&, void); - DECL_LINK(DoLoseFocus, weld::Widget&, void); - - css::uno::Reference<css::accessibility::XAccessible> CreateAccessible(); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + 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; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual bool KeyInput(const KeyEvent&) override; + + virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override; + virtual FactoryFunction GetUITestFactory() const override; protected: typedef std::map<sal_Int32, std::shared_ptr<svx::SvxShowCharSetItem> > ItemsMap; diff --git a/include/svx/dlgctrl.hxx b/include/svx/dlgctrl.hxx index 4752c8033066..c14761bd8017 100644 --- a/include/svx/dlgctrl.hxx +++ b/include/svx/dlgctrl.hxx @@ -24,6 +24,7 @@ #include <svx/svxdllapi.h> #include <svx/rectenum.hxx> #include <vcl/graph.hxx> +#include <vcl/customweld.hxx> #include <vcl/weld.hxx> #include <svx/xtable.hxx> #include <rtl/ref.hxx> @@ -146,10 +147,9 @@ public: bool IsCompletelyDisabled() const { return mbCompleteDisable; } }; -class SAL_WARN_UNUSED SVX_DLLPUBLIC RectCtl +class SAL_WARN_UNUSED SVX_DLLPUBLIC RectCtl : public weld::CustomWidgetController { private: - std::unique_ptr<weld::DrawingArea> m_xControl; VclPtr<SvxTabPage> m_pPage; SVX_DLLPRIVATE void InitSettings(vcl::RenderContext& rRenderContext); @@ -157,11 +157,13 @@ private: SVX_DLLPRIVATE BitmapEx& GetRectBitmap(); SVX_DLLPRIVATE void Resize_Impl(); + RectCtl(const RectCtl&) = delete; + RectCtl& operator=(const RectCtl&) = delete; + protected: rtl::Reference<RectCtlAccessibleContext> pAccContext; sal_uInt16 nBorderWidth; sal_uInt16 nRadius; - Size m_aSize; Point aPtLT, aPtMT, aPtRT; Point aPtLM, aPtMM, aPtRM; Point aPtLB, aPtMB, aPtRB; @@ -178,19 +180,19 @@ protected: Point GetApproxLogPtFromPixPt( const Point& rRoughPixelPoint ) const; public: - RectCtl(weld::Builder& rBuilder, const OString& rDrawingId, SvxTabPage* pPage, - RectPoint eRpt = RectPoint::MM, sal_uInt16 nBorder = 200, sal_uInt16 nCircle = 80); + RectCtl(SvxTabPage* pPage, RectPoint eRpt = RectPoint::MM, sal_uInt16 nBorder = 200, sal_uInt16 nCircle = 80); void SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder, sal_uInt16 nCircl); - ~RectCtl(); + virtual ~RectCtl() override; - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); - DECL_LINK(DoMouseButtonDown, const MouseEvent&, void); - DECL_LINK(DoKeyDown, const KeyEvent&, bool); - DECL_LINK(DoGetFocus, weld::Widget&, void); - DECL_LINK(DoLoseFocus, weld::Widget&, void); - DECL_LINK(MarkToResetSettings, weld::Widget&, void); - DECL_LINK(DoFocusRect, weld::Widget&, tools::Rectangle); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; + virtual void Resize() override; + virtual void MouseButtonDown(const MouseEvent&) override; + virtual bool KeyInput(const KeyEvent&) override; + virtual void GetFocus() override; + virtual void LoseFocus() override; + virtual tools::Rectangle GetFocusRect() override; + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + virtual void StyleUpdated() override; void Reset(); RectPoint GetActualRP() const { return eRP;} @@ -203,19 +205,14 @@ public: tools::Rectangle CalculateFocusRectangle() const; tools::Rectangle CalculateFocusRectangle( RectPoint eRectPoint ) const; - css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() { return m_xControl->get_accessible_parent(); } - css::uno::Reference<css::accessibility::XAccessible> CreateAccessible(); - a11yrelationset get_accessible_relation_set() { return m_xControl->get_accessible_relation_set(); } + css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() { return GetDrawingArea()->get_accessible_parent(); } + virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override; + a11yrelationset get_accessible_relation_set() { return GetDrawingArea()->get_accessible_relation_set(); } RectPoint GetApproxRPFromPixPt( const css::awt::Point& rPixelPoint ) const; bool IsCompletelyDisabled() const { return mbCompleteDisable; } void DoCompletelyDisable(bool bNew); - - bool IsVisible() const { return m_xControl->get_visible(); } - bool HasFocus() const { return m_xControl->has_focus(); } - void GrabFocus() { m_xControl->grab_focus(); } - Size GetSize() const { return m_aSize; } }; /************************************************************************* diff --git a/include/svx/graphctl.hxx b/include/svx/graphctl.hxx index 492e3dd62987..de9b0e7d9060 100644 --- a/include/svx/graphctl.hxx +++ b/include/svx/graphctl.hxx @@ -21,6 +21,7 @@ #include <vcl/ctrl.hxx> #include <vcl/graph.hxx> +#include <vcl/customweld.hxx> #include <vcl/weld.hxx> #include <svx/svxdllapi.h> @@ -124,31 +125,19 @@ public: virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override; }; -class SVX_DLLPUBLIC SvxGraphCtrl +class SVX_DLLPUBLIC SvxGraphCtrl : public weld::CustomWidgetController { MapMode aMap100; Graphic aGraphic; Size aGraphSize; - Size maSize; - std::unique_ptr<weld::DrawingArea> mxDrawingArea; - - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; public: - SvxGraphCtrl(weld::Builder& rBuilder, const OString& rDrawingId); - virtual ~SvxGraphCtrl(); - + SvxGraphCtrl(); + virtual ~SvxGraphCtrl() override; void SetGraphic( const Graphic& rGraphic ); - - const Size& GetSize() const { return maSize; } - - void set_size_request(int nWidth, int nHeight) - { - mxDrawingArea->set_size_request(nWidth, nHeight); - } }; class GraphCtrlView : public SdrView diff --git a/include/svx/searchcharmap.hxx b/include/svx/searchcharmap.hxx index 8f23c4b96d5a..bcc4ac2dc5b9 100644 --- a/include/svx/searchcharmap.hxx +++ b/include/svx/searchcharmap.hxx @@ -53,8 +53,7 @@ class ScrollBar; class SVX_DLLPUBLIC SvxSearchCharSet : public SvxShowCharSet { public: - SvxSearchCharSet(weld::Builder& rBuilder, const OString& rDrawingId, - const OString& rScrollId, const VclPtr<VirtualDevice> &rDevice); + SvxSearchCharSet(weld::ScrolledWindow* pScrolledWindow, const VclPtr<VirtualDevice> &rDevice); virtual ~SvxSearchCharSet() override; virtual void RecalculateFont(vcl::RenderContext& rRenderContext) override; @@ -77,9 +76,9 @@ private: //to uniquely identify each appended element std::unordered_map<sal_Int32, sal_UCS4> m_aItemList; private: - virtual void DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1, int n2) override; - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoKeyDown, const KeyEvent&, bool); + virtual void DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1, int n2) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual bool KeyInput(const KeyEvent& rKEvt) override; }; #endif diff --git a/include/vcl/customweld.hxx b/include/vcl/customweld.hxx new file mode 100644 index 000000000000..4eef04e85323 --- /dev/null +++ b/include/vcl/customweld.hxx @@ -0,0 +1,100 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef INCLUDED_VCL_CUSTOMWELD_HXX +#define INCLUDED_VCL_CUSTOMWELD_HXX + +#include <vcl/weld.hxx> + +namespace weld +{ +class VCL_DLLPUBLIC CustomWidgetController +{ +private: + Size m_aSize; + weld::DrawingArea* m_pDrawingArea; + +public: + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) = 0; + virtual void Resize() {} + virtual void MouseButtonDown(const MouseEvent&) {} + virtual void MouseMove(const MouseEvent&) {} + virtual void MouseButtonUp(const MouseEvent&) {} + virtual void GetFocus() {} + virtual void LoseFocus() {} + virtual void StyleUpdated() { Invalidate(); } + virtual bool KeyInput(const KeyEvent&) { return false; } + virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() + { + return css::uno::Reference<css::accessibility::XAccessible>(); + } + virtual tools::Rectangle GetFocusRect() { return tools::Rectangle(); } + virtual FactoryFunction GetUITestFactory() const { return nullptr; } + Size GetOutputSizePixel() const { return m_aSize; } + void SetOutputSizePixel(const Size& rSize) { m_aSize = rSize; } + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) { m_pDrawingArea = pDrawingArea; } + weld::DrawingArea* GetDrawingArea() const { return m_pDrawingArea; } + void Invalidate() { m_pDrawingArea->queue_draw(); } + void Invalidate(const tools::Rectangle& rRect) + { + m_pDrawingArea->queue_draw_area(rRect.Left(), rRect.Top(), rRect.GetWidth(), + rRect.GetHeight()); + } + void Show() { m_pDrawingArea->show(); } + void Hide() { m_pDrawingArea->hide(); } + void GrabFocus() { m_pDrawingArea->grab_focus(); } + bool HasFocus() const { return m_pDrawingArea->has_focus(); } + bool IsVisible() const { return m_pDrawingArea->get_visible(); } + bool IsEnabled() const { return m_pDrawingArea->get_sensitive(); } + void grab_add() { m_pDrawingArea->grab_add(); } + void grab_remove() { m_pDrawingArea->grab_remove(); } + void set_size_request(int nWidth, int nHeight) + { + m_pDrawingArea->set_size_request(nWidth, nHeight); + } + virtual ~CustomWidgetController(); +}; + +class VCL_DLLPUBLIC CustomWeld +{ +private: + weld::CustomWidgetController& m_rWidgetController; + std::unique_ptr<weld::DrawingArea> m_xDrawingArea; + + DECL_LINK(DoResize, const Size& rSize, void); + DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); + DECL_LINK(DoMouseButtonDown, const MouseEvent&, void); + DECL_LINK(DoMouseMove, const MouseEvent&, void); + DECL_LINK(DoMouseButtonUp, const MouseEvent&, void); + DECL_LINK(DoGetFocus, weld::Widget&, void); + DECL_LINK(DoLoseFocus, weld::Widget&, void); + DECL_LINK(DoKeyPress, const KeyEvent&, bool); + DECL_LINK(DoFocusRect, weld::Widget&, tools::Rectangle); + DECL_LINK(DoStyleUpdated, weld::Widget&, void); + +public: + CustomWeld(weld::Builder& rBuilder, const OString& rDrawingId, + CustomWidgetController& rWidgetController); + void queue_draw() { m_xDrawingArea->queue_draw(); } + void queue_draw_area(int x, int y, int width, int height) + { + m_xDrawingArea->queue_draw_area(x, y, width, height); + } + void set_size_request(int nWidth, int nHeight) + { + m_xDrawingArea->set_size_request(nWidth, nHeight); + } + void show() { m_xDrawingArea->show(); } + void set_margin_top(int nMargin) { m_xDrawingArea->set_margin_top(nMargin); } + void set_margin_bottom(int nMargin) { m_xDrawingArea->set_margin_bottom(nMargin); } +}; +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.cxx b/sd/source/ui/dlg/PhotoAlbumDialog.cxx index 863121b9b201..95b46a89bb69 100644 --- a/sd/source/ui/dlg/PhotoAlbumDialog.cxx +++ b/sd/source/ui/dlg/PhotoAlbumDialog.cxx @@ -49,7 +49,7 @@ SdPhotoAlbumDialog::SdPhotoAlbumDialog(weld::Window* pWindow, SdDrawDocument* pA , m_xDownBtn(m_xBuilder->weld_button("down_btn")) , m_xRemoveBtn(m_xBuilder->weld_button("rem_btn")) , m_xImagesLst(m_xBuilder->weld_tree_view("images_tree")) - , m_xImg(new SvxGraphCtrl(*m_xBuilder, "preview_img")) + , m_xImg(new weld::CustomWeld(*m_xBuilder, "preview_img", m_aImg)) , m_xInsTypeCombo(m_xBuilder->weld_combo_box_text("opt_combo")) , m_xASRCheck(m_xBuilder->weld_check_button("asr_check")) , m_xASRCheckCrop(m_xBuilder->weld_check_button("asr_check_crop")) @@ -583,7 +583,7 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, DownHdl, weld::Button&, void) IMPL_LINK_NOARG(SdPhotoAlbumDialog, RemoveHdl, weld::Button&, void) { m_xImagesLst->remove(m_xImagesLst->get_selected_index()); - m_xImg->SetGraphic(Graphic()); + m_aImg.SetGraphic(Graphic()); EnableDisableButtons(); } @@ -635,11 +635,11 @@ IMPL_LINK_NOARG(SdPhotoAlbumDialog, SelectHdl, weld::TreeView&, void) aBmp.Scale( nYRatio, nYRatio ); aBmp.Convert( BmpConversion::N24Bit ); - m_xImg->SetGraphic(Graphic(aBmp)); + m_aImg.SetGraphic(Graphic(aBmp)); } else { - m_xImg->SetGraphic(Graphic()); + m_aImg.SetGraphic(Graphic()); } EnableDisableButtons(); } diff --git a/sd/source/ui/dlg/PhotoAlbumDialog.hxx b/sd/source/ui/dlg/PhotoAlbumDialog.hxx index 7ec396eb3fb9..2f458555a00f 100644 --- a/sd/source/ui/dlg/PhotoAlbumDialog.hxx +++ b/sd/source/ui/dlg/PhotoAlbumDialog.hxx @@ -48,6 +48,8 @@ private: SdDrawDocument* m_pDoc; GraphicFilter* m_pGraphicFilter; + SvxGraphCtrl m_aImg; + std::unique_ptr<weld::Button> m_xCancelBtn; std::unique_ptr<weld::Button> m_xCreateBtn; std::unique_ptr<weld::Button> m_xAddBtn; @@ -55,7 +57,7 @@ private: std::unique_ptr<weld::Button> m_xDownBtn; std::unique_ptr<weld::Button> m_xRemoveBtn; std::unique_ptr<weld::TreeView> m_xImagesLst; - std::unique_ptr<SvxGraphCtrl> m_xImg; + std::unique_ptr<weld::CustomWeld> m_xImg; std::unique_ptr<weld::ComboBoxText> m_xInsTypeCombo; std::unique_ptr<weld::CheckButton> m_xASRCheck; std::unique_ptr<weld::CheckButton> m_xASRCheckCrop; diff --git a/sd/source/ui/dlg/vectdlg.cxx b/sd/source/ui/dlg/vectdlg.cxx index 145bc94fd3f5..2bbc2810b203 100644 --- a/sd/source/ui/dlg/vectdlg.cxx +++ b/sd/source/ui/dlg/vectdlg.cxx @@ -39,8 +39,8 @@ SdVectorizeDlg::SdVectorizeDlg(weld::Window* pParent, const Bitmap& rBmp, ::sd:: , m_xFtFillHoles(m_xBuilder->weld_label("tilesft")) , m_xMtFillHoles(m_xBuilder->weld_metric_spin_button("tiles", FUNIT_PIXEL)) , m_xCbFillHoles(m_xBuilder->weld_check_button("fillholes")) - , m_xBmpWin(new SvxGraphCtrl(*m_xBuilder, "source")) - , m_xMtfWin(new SvxGraphCtrl(*m_xBuilder, "vectorized")) + , m_xBmpWin(new weld::CustomWeld(*m_xBuilder, "source", m_aBmpWin)) + , m_xMtfWin(new weld::CustomWeld(*m_xBuilder, "vectorized", m_aMtfWin)) , m_xPrgs(m_xBuilder->weld_progress_bar("progressbar")) , m_xBtnOK(m_xBuilder->weld_button("ok")) , m_xBtnPreview(m_xBuilder->weld_button("preview")) @@ -97,11 +97,11 @@ SdVectorizeDlg::~SdVectorizeDlg() void SdVectorizeDlg::InitPreviewBmp() { - const ::tools::Rectangle aRect( GetRect( m_xBmpWin->GetSize(), aBmp.GetSizePixel() ) ); + const ::tools::Rectangle aRect( GetRect( m_aBmpWin.GetOutputSizePixel(), aBmp.GetSizePixel() ) ); aPreviewBmp = aBmp; aPreviewBmp.Scale( aRect.GetSize() ); - m_xBmpWin->SetGraphic( aPreviewBmp ); + m_aBmpWin.SetGraphic( aPreviewBmp ); } Bitmap SdVectorizeDlg::GetPreparedBitmap( Bitmap const & rBmp, Fraction& rScale ) @@ -247,7 +247,7 @@ IMPL_LINK( SdVectorizeDlg, ProgressHdl, long, nData, void ) IMPL_LINK_NOARG(SdVectorizeDlg, ClickPreviewHdl, weld::Button&, void) { Calculate( aBmp, aMtf ); - m_xMtfWin->SetGraphic( aMtf ); + m_aMtfWin.SetGraphic( aMtf ); m_xBtnPreview->set_sensitive(false); } diff --git a/sd/source/ui/inc/vectdlg.hxx b/sd/source/ui/inc/vectdlg.hxx index 370508f90852..85da96e3b93d 100644 --- a/sd/source/ui/inc/vectdlg.hxx +++ b/sd/source/ui/inc/vectdlg.hxx @@ -40,13 +40,16 @@ class SdVectorizeDlg : public weld::GenericDialogController Bitmap aPreviewBmp; GDIMetaFile aMtf; + SvxGraphCtrl m_aBmpWin; + SvxGraphCtrl m_aMtfWin; + std::unique_ptr<weld::SpinButton> m_xNmLayers; std::unique_ptr<weld::MetricSpinButton> m_xMtReduce; std::unique_ptr<weld::Label> m_xFtFillHoles; std::unique_ptr<weld::MetricSpinButton> m_xMtFillHoles; std::unique_ptr<weld::CheckButton> m_xCbFillHoles; - std::unique_ptr<SvxGraphCtrl> m_xBmpWin; - std::unique_ptr<SvxGraphCtrl> m_xMtfWin; + std::unique_ptr<weld::CustomWeld> m_xBmpWin; + std::unique_ptr<weld::CustomWeld> m_xMtfWin; std::unique_ptr<weld::ProgressBar> m_xPrgs; std::unique_ptr<weld::Button> m_xBtnOK; std::unique_ptr<weld::Button> m_xBtnPreview; diff --git a/sfx2/source/control/charwin.cxx b/sfx2/source/control/charwin.cxx index a1c0abc6672d..a585361a3296 100644 --- a/sfx2/source/control/charwin.cxx +++ b/sfx2/source/control/charwin.cxx @@ -28,42 +28,39 @@ using namespace com::sun::star; -SvxCharView::SvxCharView(weld::Builder& rBuilder, const OString& rId, const VclPtr<VirtualDevice>& rVirDev) +SvxCharView::SvxCharView(const VclPtr<VirtualDevice>& rVirDev) : mxVirDev(rVirDev) - , mxDrawingArea(rBuilder.weld_drawing_area(rId)) , mnY(0) , maPosition(0,0) , maHasInsert(true) { - mxDrawingArea->connect_size_allocate(LINK(this, SvxCharView, DoResize)); - mxDrawingArea->connect_draw(LINK(this, SvxCharView, DoPaint)); - mxDrawingArea->connect_mouse_press(LINK(this, SvxCharView, DoMouseButtonDown)); - mxDrawingArea->connect_key_press(LINK(this, SvxCharView, DoKeyDown)); - mxDrawingArea->connect_focus_in(LINK(this, SvxCharView, DoGetFocus)); - mxDrawingArea->connect_focus_out(LINK(this, SvxCharView, DoLoseFocus)); +} +void SvxCharView::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); vcl::Font aFont = rStyleSettings.GetLabelFont(); const Size aFontSize = aFont.GetFontSize(); aFont.SetFontSize(Size(aFontSize.Width() * 2.5, aFontSize.Height() * 2.5)); mxVirDev->Push(PUSH_ALLFONT); mxVirDev->SetFont(aFont); - mxDrawingArea->set_size_request(mxVirDev->approximate_digit_width() * 2, - mxVirDev->GetTextHeight()); + pDrawingArea->set_size_request(mxVirDev->approximate_digit_width() * 2, + mxVirDev->GetTextHeight()); mxVirDev->Pop(); + CustomWidgetController::SetDrawingArea(pDrawingArea); } -IMPL_LINK_NOARG(SvxCharView, DoGetFocus, weld::Widget&, void) +void SvxCharView::GetFocus() { - mxDrawingArea->queue_draw(); + Invalidate(); } -IMPL_LINK_NOARG(SvxCharView, DoLoseFocus, weld::Widget&, void) +void SvxCharView::LoseFocus() { - mxDrawingArea->queue_draw(); + Invalidate(); } -IMPL_LINK(SvxCharView, DoMouseButtonDown, const MouseEvent&, rMEvt, void) +void SvxCharView::MouseButtonDown(const MouseEvent& rMEvt) { if ( rMEvt.IsLeft() ) { @@ -79,13 +76,13 @@ IMPL_LINK(SvxCharView, DoMouseButtonDown, const MouseEvent&, rMEvt, void) { Point aPosition(rMEvt.GetPosPixel()); maPosition = aPosition; - mxDrawingArea->grab_focus(); - mxDrawingArea->queue_draw(); + GrabFocus(); + Invalidate(); createContextMenu(); } } -IMPL_LINK(SvxCharView, DoKeyDown, const KeyEvent&, rKEvt, bool) +bool SvxCharView::KeyInput(const KeyEvent& rKEvt) { bool bRet = false; vcl::KeyCode aCode = rKEvt.GetKeyCode(); @@ -119,10 +116,11 @@ void SvxCharView::InsertCharToDoc() void SvxCharView::createContextMenu() { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(mxDrawingArea.get(), "sfx/ui/charviewmenu.ui")); + weld::DrawingArea* pDrawingArea = GetDrawingArea(); + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pDrawingArea, "sfx/ui/charviewmenu.ui")); std::unique_ptr<weld::Menu> xItemMenu(xBuilder->weld_menu("charviewmenu")); - ContextMenuSelect(xItemMenu->popup_at_rect(mxDrawingArea.get(), tools::Rectangle(maPosition, Size(1,1)))); - queue_draw(); + ContextMenuSelect(xItemMenu->popup_at_rect(pDrawingArea, tools::Rectangle(maPosition, Size(1,1)))); + Invalidate(); } void SvxCharView::ContextMenuSelect(const OString& rMenuId) @@ -133,10 +131,8 @@ void SvxCharView::ContextMenuSelect(const OString& rMenuId) maClearAllClickHdl.Call(this); } -IMPL_LINK(SvxCharView, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void SvxCharView::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; - rRenderContext.SetFont(maFont); const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); @@ -148,8 +144,9 @@ IMPL_LINK(SvxCharView, 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; @@ -180,7 +177,7 @@ IMPL_LINK(SvxCharView, DoPaint, weld::DrawingArea::draw_args, aPayload, void) Point aPoint(2, mnY); if (!bGotBoundary) - aPoint.setX( (m_aSize.Width() - rRenderContext.GetTextWidth(aText)) / 2 ); + aPoint.setX( (aSize.Width() - rRenderContext.GetTextWidth(aText)) / 2 ); else { // adjust position @@ -188,20 +185,20 @@ IMPL_LINK(SvxCharView, DoPaint, weld::DrawingArea::draw_args, aPayload, void) // vertical adjustment 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 ) aPoint.AdjustY(nYHDelta - 1 ); // centrally align glyph - aPoint.setX( -aBoundRect.Left() + (m_aSize.Width() - aBoundRect.GetWidth()) / 2 ); + aPoint.setX( -aBoundRect.Left() + (aSize.Width() - aBoundRect.GetWidth()) / 2 ); } - if (mxDrawingArea->has_focus()) + if (HasFocus()) { rRenderContext.SetFillColor(aHighlightColor); - rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), m_aSize)); + rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), aSize)); rRenderContext.SetTextColor(aHighlightTextColor); rRenderContext.DrawText(aPoint, aText); @@ -209,7 +206,7 @@ IMPL_LINK(SvxCharView, DoPaint, weld::DrawingArea::draw_args, aPayload, void) else { rRenderContext.SetFillColor(aFillColor); - rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), m_aSize)); + rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), aSize)); rRenderContext.SetTextColor(aWindowTextColor); rRenderContext.DrawText(aPoint, aText); @@ -238,7 +235,7 @@ void SvxCharView::setClearAllClickHdl(const Link<SvxCharView*,void> &rLink) void SvxCharView::SetFont( const vcl::Font& rFont ) { - long nWinHeight = m_aSize.Height(); + long nWinHeight = GetOutputSizePixel().Height(); maFont = vcl::Font(rFont); maFont.SetWeight(WEIGHT_NORMAL); maFont.SetAlignment(ALIGN_TOP); @@ -250,19 +247,18 @@ void SvxCharView::SetFont( const vcl::Font& rFont ) mnY = (nWinHeight - mxVirDev->GetTextHeight()) / 2; mxVirDev->Pop(); - queue_draw(); + Invalidate(); } -IMPL_LINK(SvxCharView, DoResize, const Size&, rSize, void) +void SvxCharView::Resize() { - m_aSize = rSize; SetFont(GetFont()); //force recalculation of size } void SvxCharView::SetText( const OUString& rText ) { m_sText = rText; - queue_draw(); + Invalidate(); } void SvxCharView::SetHasInsert( bool bInsert ) diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx index 1d860d18275e..af26dab03b42 100644 --- a/sfx2/source/doc/new.cxx +++ b/sfx2/source/doc/new.cxx @@ -47,19 +47,11 @@ void SfxPreviewWin_Impl::SetObjectShell(SfxObjectShell const * pObj) ? pObj->GetPreviewMetaFile() : std::shared_ptr<GDIMetaFile>(); xMetaFile = xFile; - m_xDrawingArea->queue_draw(); + Invalidate(); } -SfxPreviewWin_Impl::SfxPreviewWin_Impl(weld::DrawingArea* pDrawingArea) - : m_xDrawingArea(pDrawingArea) +SfxPreviewWin_Impl::SfxPreviewWin_Impl() { - m_xDrawingArea->connect_size_allocate(LINK(this, SfxPreviewWin_Impl, DoResize)); - m_xDrawingArea->connect_draw(LINK(this, SfxPreviewWin_Impl, DoPaint)); -} - -IMPL_LINK_NOARG(SfxPreviewWin_Impl, DoResize, const Size&, void) -{ - m_xDrawingArea->queue_draw(); } void SfxPreviewWin_Impl::ImpPaint(vcl::RenderContext& rRenderContext, GDIMetaFile* pFile) @@ -104,9 +96,9 @@ void SfxPreviewWin_Impl::ImpPaint(vcl::RenderContext& rRenderContext, GDIMetaFil } } -IMPL_LINK(SfxPreviewWin_Impl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void SfxPreviewWin_Impl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - ImpPaint(aPayload.first, xMetaFile.get()); + ImpPaint(rRenderContext, xMetaFile.get()); } IMPL_LINK_NOARG(SfxNewFileDialog, Update, Timer*, void) @@ -121,8 +113,8 @@ IMPL_LINK_NOARG(SfxNewFileDialog, Update, Timer*, void) const sal_uInt16 nEntry = GetSelectedTemplatePos(); if (!nEntry) { - m_xPreviewWin->queue_draw(); - m_xPreviewWin->SetObjectShell(nullptr); + m_xPreviewController->Invalidate(); + m_xPreviewController->SetObjectShell(nullptr); return; } @@ -164,12 +156,12 @@ IMPL_LINK_NOARG(SfxNewFileDialog, Update, Timer*, void) ErrorHandler::HandleError(lErr); if (!m_xDocShell.Is()) { - m_xPreviewWin->SetObjectShell(nullptr); + m_xPreviewController->SetObjectShell(nullptr); return; } } - m_xPreviewWin->SetObjectShell(m_xDocShell); + m_xPreviewController->SetObjectShell(m_xDocShell); } } @@ -238,6 +230,8 @@ sal_uInt16 SfxNewFileDialog::GetSelectedTemplatePos() const SfxNewFileDialog::SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode nFlags) : GenericDialogController(pParent, "sfx/ui/loadtemplatedialog.ui", "LoadTemplateDialog") + , m_nFlags(nFlags) + , m_xPreviewController(new SfxPreviewWin_Impl) , m_xRegionLb(m_xBuilder->weld_tree_view("categories")) , m_xTemplateLb(m_xBuilder->weld_tree_view("templates")) , m_xTextStyleCB(m_xBuilder->weld_check_button("text")) @@ -247,9 +241,8 @@ SfxNewFileDialog::SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode n , m_xMergeStyleCB(m_xBuilder->weld_check_button("overwrite")) , m_xLoadFilePB(m_xBuilder->weld_button("fromfile")) , m_xMoreBt(m_xBuilder->weld_expander("expander")) - , m_xPreviewWin(new SfxPreviewWin_Impl(m_xBuilder->weld_drawing_area("image"))) + , m_xPreviewWin(new weld::CustomWeld(*m_xBuilder, "image", *m_xPreviewController)) , m_xAltTitleFt(m_xBuilder->weld_label("alttitle")) - , m_nFlags(nFlags) { const int nWidth = m_xRegionLb->get_approximate_digit_width() * 32; const int nHeight = m_xRegionLb->get_height_rows(8); diff --git a/sfx2/source/inc/preview.hxx b/sfx2/source/inc/preview.hxx index 8b39231c31a8..328fc005330d 100644 --- a/sfx2/source/inc/preview.hxx +++ b/sfx2/source/inc/preview.hxx @@ -20,23 +20,20 @@ #define INCLUDED_SFX2_SOURCE_INC_PREVIEW_HXX #include <tools/link.hxx> +#include <vcl/customweld.hxx> class SfxObjectShell; class GDIMetaFile; -class SfxPreviewWin_Impl +class SfxPreviewWin_Impl : public weld::CustomWidgetController { +private: + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; protected: std::shared_ptr<GDIMetaFile> xMetaFile; - std::unique_ptr<weld::DrawingArea> m_xDrawingArea; public: - SfxPreviewWin_Impl(weld::DrawingArea* pArea); + SfxPreviewWin_Impl(); void SetObjectShell( SfxObjectShell const * pObj ); - 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(); } - void set_size_request(int nWidth, int nHeight) { m_xDrawingArea->set_size_request(nWidth, nHeight); } static void ImpPaint(vcl::RenderContext& rRenderContext, GDIMetaFile* pFile); }; diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx index e2a66edba2c7..81f043c59fde 100644 --- a/starmath/inc/dialog.hxx +++ b/starmath/inc/dialog.hxx @@ -258,9 +258,8 @@ public: /**************************************************************************/ -class SmShowSymbolSet +class SmShowSymbolSet : public weld::CustomWidgetController { - Size m_aSize; Size m_aOldSize; SymbolPtrVec_t aSymbolSet; Link<SmShowSymbolSet&,void> aSelectHdlLink; @@ -269,20 +268,27 @@ class SmShowSymbolSet long nRows, nColumns; long nXOffset, nYOffset; sal_uInt16 nSelectSymbol; - std::unique_ptr<weld::DrawingArea> m_xDrawingArea; std::unique_ptr<weld::ScrolledWindow> m_xScrolledWindow; void SetScrollBarRange(); Point OffsetPoint(const Point &rPoint) const; - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoMouseButtonDown, const MouseEvent& rMEvt, void); - DECL_LINK(DoKeyDown, const KeyEvent& rKEvt, bool); - DECL_LINK(DoResize, const Size& rSize, void); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void MouseButtonDown(const MouseEvent& rMEvt) override; + virtual bool KeyInput(const KeyEvent& rKEvt) override; + DECL_LINK(ScrollHdl, weld::ScrolledWindow&, void); public: - SmShowSymbolSet(weld::DrawingArea* pDrawingArea, weld::ScrolledWindow* pScrolledWindow); + SmShowSymbolSet(weld::ScrolledWindow* pScrolledWindow); + + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override + { + pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 27, + pDrawingArea->get_text_height() * 9); + CustomWidgetController::SetDrawingArea(pDrawingArea); + } + void calccols(vcl::RenderContext& rRenderContext); void SelectSymbol(sal_uInt16 nSymbol); sal_uInt16 GetSelectSymbol() const { return nSelectSymbol; } @@ -291,24 +297,28 @@ public: void SetDblClickHdl(const Link<SmShowSymbolSet&,void>& rLink) { aDblClickHdlLink = rLink; } }; -class SmShowSymbol +class SmShowSymbol : public weld::CustomWidgetController { private: - Size m_aSize; vcl::Font m_aFont; OUString m_aText; - std::unique_ptr<weld::DrawingArea> m_xDrawingArea; Link<SmShowSymbol&,void> aDblClickHdlLink; - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoMouseButtonDown, const MouseEvent& rMEvt, void); - DECL_LINK(DoResize, const Size& rSize, void); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override; + virtual void MouseButtonDown(const MouseEvent& rMEvt) override; void setFontSize(vcl::Font &rFont) const; public: - SmShowSymbol(weld::DrawingArea* pDrawingArea); + SmShowSymbol(); + + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override + { + pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 27, + pDrawingArea->get_text_height() * 9); + CustomWidgetController::SetDrawingArea(pDrawingArea); + } void SetText(const OUString& rText) { m_aText = rText; } const OUString& GetText() const { return m_aText; } @@ -330,10 +340,13 @@ class SmSymbolDialog : public weld::GenericDialogController VclPtr<OutputDevice> pFontListDev; + SmShowSymbol m_aSymbolDisplay; + std::unique_ptr<weld::ComboBoxText> m_xSymbolSets; std::unique_ptr<SmShowSymbolSet> m_xSymbolSetDisplay; + std::unique_ptr<weld::CustomWeld> m_xSymbolSetDisplayArea; std::unique_ptr<weld::Label> m_xSymbolName; - std::unique_ptr<SmShowSymbol> m_xSymbolDisplay; + std::unique_ptr<weld::CustomWeld> m_xSymbolDisplay; std::unique_ptr<weld::Button> m_xGetBtn; std::unique_ptr<weld::Button> m_xEditBtn; @@ -357,25 +370,25 @@ public: void SelectSymbol(sal_uInt16 nSymbolPos); }; -class SmShowChar +class SmShowChar : public weld::CustomWidgetController { private: - std::unique_ptr<weld::DrawingArea> m_xDrawingArea; OUString m_aText; vcl::Font m_aFont; - 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; + virtual void Resize() override; public: - SmShowChar(weld::DrawingArea* pDrawingArea) - : m_xDrawingArea(pDrawingArea) + SmShowChar() { - m_xDrawingArea->connect_size_allocate(LINK(this, SmShowChar, DoResize)); - m_xDrawingArea->connect_draw(LINK(this, SmShowChar, DoPaint)); - m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_width() * 7, - m_xDrawingArea->get_text_height() * 3); + } + + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override + { + pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 7, + pDrawingArea->get_text_height() * 3); + CustomWidgetController::SetDrawingArea(pDrawingArea); } void SetSymbol(const SmSym *pSym); @@ -384,8 +397,6 @@ public: const OUString& GetText() const { return m_aText; } void SetFont(const vcl::Font& rFont) { m_aFont = rFont; } const vcl::Font& GetFont() const { return m_aFont; } - - void queue_draw() { m_xDrawingArea->queue_draw(); } }; class SmSymDefineDialog : public weld::GenericDialogController @@ -393,6 +404,8 @@ class SmSymDefineDialog : public weld::GenericDialogController VclPtr<VirtualDevice> m_xVirDev; SmSymbolManager m_aSymbolMgrCopy; SmSymbolManager& m_rSymbolMgr; + SmShowChar m_aOldSymbolDisplay; + SmShowChar m_aSymbolDisplay; std::unique_ptr<SmSym> m_xOrigSymbol; std::unique_ptr<SubsetMap> m_xSubsetMap; std::unique_ptr<FontList> m_xFontList; @@ -410,9 +423,10 @@ class SmSymDefineDialog : public weld::GenericDialogController std::unique_ptr<weld::Button> m_xAddBtn; std::unique_ptr<weld::Button> m_xChangeBtn; std::unique_ptr<weld::Button> m_xDeleteBtn; - std::unique_ptr<SmShowChar> m_xOldSymbolDisplay; - std::unique_ptr<SmShowChar> m_xSymbolDisplay; + std::unique_ptr<weld::CustomWeld> m_xOldSymbolDisplay; + std::unique_ptr<weld::CustomWeld> m_xSymbolDisplay; std::unique_ptr<SvxShowCharSet> m_xCharsetDisplay; + std::unique_ptr<weld::CustomWeld> m_xCharsetDisplayArea; DECL_LINK(OldSymbolChangeHdl, weld::ComboBoxText&, void); DECL_LINK(OldSymbolSetChangeHdl, weld::ComboBoxText&, void); diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx index 6843cebfaea8..286cb66d6846 100644 --- a/starmath/source/dialog.cxx +++ b/starmath/source/dialog.cxx @@ -958,24 +958,17 @@ void SmAlignDialog::WriteTo(SmFormat &rFormat) const rFormat.RequestApplyChanges(); } -SmShowSymbolSet::SmShowSymbolSet(weld::DrawingArea* pDrawingArea, weld::ScrolledWindow* pScrolledWindow) +SmShowSymbolSet::SmShowSymbolSet(weld::ScrolledWindow* pScrolledWindow) : nLen(0) , nRows(0) , nColumns(0) , nXOffset(0) , nYOffset(0) , nSelectSymbol(SYMBOL_NONE) - , m_xDrawingArea(pDrawingArea) , m_xScrolledWindow(pScrolledWindow) { - m_xDrawingArea->connect_size_allocate(LINK(this, SmShowSymbolSet, DoResize)); - m_xDrawingArea->connect_draw(LINK(this, SmShowSymbolSet, DoPaint)); - m_xDrawingArea->connect_mouse_press(LINK(this, SmShowSymbolSet, DoMouseButtonDown)); - m_xDrawingArea->connect_key_press(LINK(this, SmShowSymbolSet, DoKeyDown)); m_xScrolledWindow->set_user_managed_scrolling(); m_xScrolledWindow->connect_vadjustment_changed(LINK(this, SmShowSymbolSet, ScrollHdl)); - m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_width() * 27, - m_xDrawingArea->get_text_height() * 9); } Point SmShowSymbolSet::OffsetPoint(const Point &rPoint) const @@ -983,14 +976,13 @@ Point SmShowSymbolSet::OffsetPoint(const Point &rPoint) const return Point(rPoint.X() + nXOffset, rPoint.Y() + nYOffset); } -IMPL_LINK(SmShowSymbolSet, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void SmShowSymbolSet::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; - - if (m_aSize != m_aOldSize) + Size aWinSize(GetOutputSizePixel()); + if (aWinSize != m_aOldSize) { calccols(rRenderContext); - m_aOldSize = m_aSize; + m_aOldSize = aWinSize; } Color aBackgroundColor; @@ -1045,9 +1037,9 @@ IMPL_LINK(SmShowSymbolSet, DoPaint, weld::DrawingArea::draw_args, aPayload, void rRenderContext.Pop(); } -IMPL_LINK(SmShowSymbolSet, DoMouseButtonDown, const MouseEvent&, rMEvt, void) +void SmShowSymbolSet::MouseButtonDown(const MouseEvent& rMEvt) { - m_xDrawingArea->grab_focus(); + GrabFocus(); Size aOutputSize(nColumns * nLen, nRows * nLen); aOutputSize.AdjustWidth(nXOffset ); @@ -1069,7 +1061,7 @@ IMPL_LINK(SmShowSymbolSet, DoMouseButtonDown, const MouseEvent&, rMEvt, void) } } -IMPL_LINK(SmShowSymbolSet, DoKeyDown, const KeyEvent&, rKEvt, bool) +bool SmShowSymbolSet::KeyInput(const KeyEvent& rKEvt) { sal_uInt16 n = nSelectSymbol; @@ -1100,7 +1092,7 @@ IMPL_LINK(SmShowSymbolSet, DoKeyDown, const KeyEvent&, rKEvt, bool) (n >= sal::static_int_cast<sal_uInt16>((m_xScrolledWindow->vadjustment_get_value() + nRows) * nColumns))) { m_xScrolledWindow->vadjustment_set_value(n / nColumns); - m_xDrawingArea->queue_draw(); + Invalidate(); } SelectSymbol(n); @@ -1114,7 +1106,7 @@ void SmShowSymbolSet::calccols(vcl::RenderContext& rRenderContext) // Height of 16pt in pixels (matching 'aOutputSize') nLen = rRenderContext.LogicToPixel(Size(0, 16), MapMode(MapUnit::MapPoint)).Height(); - Size aOutputSize = m_aSize; + Size aOutputSize(GetOutputSizePixel()); nColumns = aOutputSize.Width() / nLen; nRows = aOutputSize.Height() / nLen; @@ -1130,14 +1122,14 @@ void SmShowSymbolSet::calccols(vcl::RenderContext& rRenderContext) void SmShowSymbolSet::SetSymbolSet(const SymbolPtrVec_t& rSymbolSet) { aSymbolSet = rSymbolSet; - m_xDrawingArea->queue_draw(); + Invalidate(); } void SmShowSymbolSet::SetScrollBarRange() { const int nLastRow = (aSymbolSet.size() - 1 + nColumns) / nColumns; m_xScrolledWindow->vadjustment_configure(m_xScrolledWindow->vadjustment_get_value(), 0, nLastRow, 1, nRows - 1, nRows); - m_xDrawingArea->queue_draw(); + Invalidate(); } void SmShowSymbolSet::SelectSymbol(sal_uInt16 nSymbol) @@ -1148,7 +1140,7 @@ void SmShowSymbolSet::SelectSymbol(sal_uInt16 nSymbol) { Point aPoint(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen, ((nSelectSymbol - v) / nColumns) * nLen))); - m_xDrawingArea->queue_draw_area(aPoint.X(), aPoint.Y(), nLen, nLen); + Invalidate(tools::Rectangle(aPoint, Size(nLen, nLen))); } if (nSymbol < aSymbolSet.size()) @@ -1161,49 +1153,30 @@ void SmShowSymbolSet::SelectSymbol(sal_uInt16 nSymbol) { Point aPoint(OffsetPoint(Point(((nSelectSymbol - v) % nColumns) * nLen, ((nSelectSymbol - v) / nColumns) * nLen))); - m_xDrawingArea->queue_draw_area(aPoint.X(), aPoint.Y(), nLen, nLen); + Invalidate(tools::Rectangle(aPoint, Size(nLen, nLen))); } if (!nColumns) - m_xDrawingArea->queue_draw(); -} - -IMPL_LINK(SmShowSymbolSet, DoResize, const Size&, rSize, void) -{ - m_aSize = rSize; - m_xDrawingArea->queue_draw(); + Invalidate(); } IMPL_LINK_NOARG(SmShowSymbolSet, ScrollHdl, weld::ScrolledWindow&, void) { - m_xDrawingArea->queue_draw(); -} - -IMPL_LINK(SmShowSymbol, DoResize, const Size&, rSize, void) -{ - m_aSize = rSize; - m_xDrawingArea->queue_draw(); + Invalidate(); } -SmShowSymbol::SmShowSymbol(weld::DrawingArea* pDrawingArea) - : m_xDrawingArea(pDrawingArea) +SmShowSymbol::SmShowSymbol() { - m_xDrawingArea->connect_size_allocate(LINK(this, SmShowSymbol, DoResize)); - m_xDrawingArea->connect_draw(LINK(this, SmShowSymbol, DoPaint)); - m_xDrawingArea->connect_mouse_press(LINK(this, SmShowSymbol, DoMouseButtonDown)); - m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_width() * 27, - m_xDrawingArea->get_text_height() * 9); } void SmShowSymbol::setFontSize(vcl::Font &rFont) const { - rFont.SetFontSize(Size(0, m_aSize.Height() - m_aSize.Height() / 3)); + Size aSize(GetOutputSizePixel()); + rFont.SetFontSize(Size(0, aSize.Height() - aSize.Height() / 3)); } -IMPL_LINK(SmShowSymbol, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void SmShowSymbol::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; - Color aBackgroundColor; Color aTextColor; lclGetSettingColors(aBackgroundColor, aTextColor); @@ -1222,7 +1195,7 @@ IMPL_LINK(SmShowSymbol, DoPaint, weld::DrawingArea::draw_args, aPayload, void) (rRenderContext.GetOutputSize().Height() * 7 / 10)), rText); } -IMPL_LINK(SmShowSymbol, DoMouseButtonDown, const MouseEvent&, rMEvt, void) +void SmShowSymbol::MouseButtonDown(const MouseEvent& rMEvt) { if (rMEvt.GetClicks() > 1) aDblClickHdlLink.Call(*this); @@ -1241,7 +1214,7 @@ void SmShowSymbol::SetSymbol(const SmSym *pSymbol) SetText( aText ); } - m_xDrawingArea->queue_draw(); + Invalidate(); } void SmSymbolDialog::FillSymbolSets() @@ -1343,9 +1316,10 @@ SmSymbolDialog::SmSymbolDialog(weld::Window *pParent, OutputDevice *pFntListDevi , rSymbolMgr(rMgr) , pFontListDev(pFntListDevice) , m_xSymbolSets(m_xBuilder->weld_combo_box_text("symbolset")) - , m_xSymbolSetDisplay(new SmShowSymbolSet(m_xBuilder->weld_drawing_area("symbolsetdisplay"), m_xBuilder->weld_scrolled_window("scrolledwindow"))) + , m_xSymbolSetDisplay(new SmShowSymbolSet(m_xBuilder->weld_scrolled_window("scrolledwindow"))) + , m_xSymbolSetDisplayArea(new weld::CustomWeld(*m_xBuilder, "symbolsetdisplay", *m_xSymbolSetDisplay)) , m_xSymbolName(m_xBuilder->weld_label("symbolname")) - , m_xSymbolDisplay(new SmShowSymbol(m_xBuilder->weld_drawing_area("preview"))) + , m_xSymbolDisplay(new weld::CustomWeld(*m_xBuilder, "preview", m_aSymbolDisplay)) , m_xGetBtn(m_xBuilder->weld_button("ok")) , m_xEditBtn(m_xBuilder->weld_button("edit")) { @@ -1360,7 +1334,7 @@ SmSymbolDialog::SmSymbolDialog(weld::Window *pParent, OutputDevice *pFntListDevi m_xSymbolSets->connect_changed(LINK(this, SmSymbolDialog, SymbolSetChangeHdl)); m_xSymbolSetDisplay->SetSelectHdl(LINK(this, SmSymbolDialog, SymbolChangeHdl)); m_xSymbolSetDisplay->SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl2)); - m_xSymbolDisplay->SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl)); + m_aSymbolDisplay.SetDblClickHdl(LINK(this, SmSymbolDialog, SymbolDblClickHdl)); m_xEditBtn->connect_clicked(LINK(this, SmSymbolDialog, EditClickHdl)); m_xGetBtn->connect_clicked(LINK(this, SmSymbolDialog, GetClickHdl)); } @@ -1409,7 +1383,7 @@ void SmSymbolDialog::SelectSymbol(sal_uInt16 nSymbolNo) pSym = aSymbolSet[ nSymbolNo ]; m_xSymbolSetDisplay->SelectSymbol(nSymbolNo); - m_xSymbolDisplay->SetSymbol(pSym); + m_aSymbolDisplay.SetSymbol(pSym); m_xSymbolName->set_label(pSym ? pSym->GetName() : OUString()); } @@ -1420,10 +1394,8 @@ const SmSym* SmSymbolDialog::GetSymbol() const return bValid ? aSymbolSet[ nSymbolNo ] : nullptr; } -IMPL_LINK(SmShowChar, DoResize, const Size&, rSize, void) +void SmShowChar::Resize() { - m_aSize = rSize; - const OUString &rText = GetText(); if (rText.isEmpty()) return; @@ -1432,10 +1404,8 @@ IMPL_LINK(SmShowChar, DoResize, const Size&, rSize, void) SetSymbol(cChar, GetFont()); //force recalculation of size } -IMPL_LINK(SmShowChar, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void SmShowChar::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; - Color aTextCol = rRenderContext.GetTextColor(); Color aFillCol = rRenderContext.GetFillColor(); @@ -1445,7 +1415,8 @@ IMPL_LINK(SmShowChar, DoPaint, weld::DrawingArea::draw_args, aPayload, void) rRenderContext.SetTextColor(aWindowTextColor); rRenderContext.SetFillColor(aWindowColor); - rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), m_aSize)); + Size aSize(GetOutputSizePixel()); + rRenderContext.DrawRect(tools::Rectangle(Point(0, 0), aSize)); OUString aText(GetText()); if (!aText.isEmpty()) @@ -1456,8 +1427,8 @@ IMPL_LINK(SmShowChar, DoPaint, weld::DrawingArea::draw_args, aPayload, void) Size aTextSize(rRenderContext.GetTextWidth(aText), rRenderContext.GetTextHeight()); - rRenderContext.DrawText(Point((m_aSize.Width() - aTextSize.Width()) / 2, - (m_aSize.Height() - aTextSize.Height()) / 2), aText); + rRenderContext.DrawText(Point((aSize.Width() - aTextSize.Width()) / 2, + (aSize.Height() - aTextSize.Height()) / 2), aText); } rRenderContext.SetTextColor(aTextCol); @@ -1474,14 +1445,15 @@ void SmShowChar::SetSymbol( const SmSym *pSym ) void SmShowChar::SetSymbol( sal_UCS4 cChar, const vcl::Font &rFont ) { vcl::Font aFont( rFont ); - aFont.SetFontSize(Size(0, m_aSize.Height() - m_aSize.Height() / 3)); + Size aSize(GetOutputSizePixel()); + aFont.SetFontSize(Size(0, aSize.Height() - aSize.Height() / 3)); aFont.SetAlignment(ALIGN_BASELINE); SetFont(aFont); OUString aText(&cChar, 1); SetText( aText ); - m_xDrawingArea->queue_draw(); + Invalidate(); } void SmSymDefineDialog::FillSymbols(weld::ComboBoxText& rComboBox, bool bDeleteText) @@ -1635,7 +1607,7 @@ IMPL_LINK_NOARG(SmSymDefineDialog, CharHighlightHdl, SvxShowCharSet*, void) m_xFontsSubsetLB->set_active(-1); } - m_xSymbolDisplay->SetSymbol(cChar, m_xCharsetDisplay->GetFont()); + m_aSymbolDisplay.SetSymbol(cChar, m_xCharsetDisplay->GetFont()); UpdateButtons(); @@ -1661,7 +1633,7 @@ IMPL_LINK( SmSymDefineDialog, AddClickHdl, weld::Button&, rButton, void ) m_aSymbolMgrCopy.AddOrReplaceSymbol( aNewSymbol ); // update display of new symbol - m_xSymbolDisplay->SetSymbol( &aNewSymbol ); + m_aSymbolDisplay.SetSymbol( &aNewSymbol ); m_xSymbolName->set_label(aNewSymbol.GetName()); m_xSymbolSetName->set_label(aNewSymbol.GetSymbolSetName()); @@ -1697,7 +1669,7 @@ IMPL_LINK( SmSymDefineDialog, ChangeClickHdl, weld::Button&, rButton, void ) SetOrigSymbol(nullptr, OUString()); // update display of new symbol - m_xSymbolDisplay->SetSymbol(&aNewSymbol); + m_aSymbolDisplay.SetSymbol(&aNewSymbol); m_xSymbolName->set_label(aNewSymbol.GetName()); m_xSymbolSetName->set_label(aNewSymbol.GetSymbolSetName()); @@ -1788,9 +1760,10 @@ SmSymDefineDialog::SmSymDefineDialog(weld::Window* pParent, OutputDevice *pFntLi , m_xAddBtn(m_xBuilder->weld_button("add")) , m_xChangeBtn(m_xBuilder->weld_button("modify")) , m_xDeleteBtn(m_xBuilder->weld_button("delete")) - , m_xOldSymbolDisplay(new SmShowChar(m_xBuilder->weld_drawing_area("oldSymbolDisplay"))) - , m_xSymbolDisplay(new SmShowChar(m_xBuilder->weld_drawing_area("symbolDisplay"))) - , m_xCharsetDisplay(new SvxShowCharSet(*m_xBuilder, "charsetDisplay", "showscroll", m_xVirDev)) + , m_xOldSymbolDisplay(new weld::CustomWeld(*m_xBuilder, "oldSymbolDisplay", m_aOldSymbolDisplay)) + , m_xSymbolDisplay(new weld::CustomWeld(*m_xBuilder, "symbolDisplay", m_aSymbolDisplay)) + , m_xCharsetDisplay(new SvxShowCharSet(m_xBuilder->weld_scrolled_window("showscroll"), m_xVirDev)) + , m_xCharsetDisplayArea(new weld::CustomWeld(*m_xBuilder, "charsetDisplay", *m_xCharsetDisplay)) { // auto completion is troublesome since that symbols character also gets automatically selected in the // display and if the user previously selected a character to define/redefine that one this is bad @@ -1920,12 +1893,12 @@ void SmSymDefineDialog::SetOrigSymbol(const SmSym *pSymbol, aSymName = pSymbol->GetName(); aSymSetName = rSymbolSetName; - m_xOldSymbolDisplay->SetSymbol( pSymbol ); + m_aOldSymbolDisplay.SetSymbol( pSymbol ); } else { // delete displayed symbols - m_xOldSymbolDisplay->SetText(OUString()); - m_xOldSymbolDisplay->queue_draw(); + m_aOldSymbolDisplay.SetText(OUString()); + m_aOldSymbolDisplay.Invalidate(); } m_xOldSymbolName->set_label(aSymName); m_xOldSymbolSetName->set_label(aSymSetName); @@ -1965,7 +1938,7 @@ bool SmSymDefineDialog::SelectSymbol(weld::ComboBoxText& rComboBox, // work really well (e.g. it can be empty even though the font itself is // bold or italic) we're manually setting the Font with respect to the Symbol m_xCharsetDisplay->SetFont(rFont); - m_xSymbolDisplay->SetFont(rFont); + m_aSymbolDisplay.SetFont(rFont); // select associated character SelectChar(pSymbol->GetCharacter()); @@ -2011,7 +1984,7 @@ void SmSymDefineDialog::SetFont(const OUString &rFontName, const OUString &rStyl SetFontStyle(rStyleName, aFontMetric); m_xCharsetDisplay->SetFont(aFontMetric); - m_xSymbolDisplay->SetFont(aFontMetric); + m_aSymbolDisplay.SetFont(aFontMetric); // update subset listbox for new font's unicode subsets FontCharMapRef xFontCharMap; @@ -2046,7 +2019,7 @@ bool SmSymDefineDialog::SelectFont(const OUString &rFontName, bool bApplyFont) if (bApplyFont) { SetFont(m_xFonts->get_active_text(), m_xStyles->get_active_text()); - m_xSymbolDisplay->SetSymbol(m_xCharsetDisplay->GetSelectCharacter(), m_xCharsetDisplay->GetFont()); + m_aSymbolDisplay.SetSymbol(m_xCharsetDisplay->GetSelectCharacter(), m_xCharsetDisplay->GetFont()); } bRet = true; } @@ -2075,7 +2048,7 @@ bool SmSymDefineDialog::SelectStyle(const OUString &rStyleName, bool bApplyFont) if (bApplyFont) { SetFont(m_xFonts->get_active_text(), m_xStyles->get_active_text()); - m_xSymbolDisplay->SetSymbol(m_xCharsetDisplay->GetSelectCharacter(), m_xCharsetDisplay->GetFont()); + m_aSymbolDisplay.SetSymbol(m_xCharsetDisplay->GetSelectCharacter(), m_xCharsetDisplay->GetFont()); } bRet = true; } @@ -2090,7 +2063,7 @@ bool SmSymDefineDialog::SelectStyle(const OUString &rStyleName, bool bApplyFont) void SmSymDefineDialog::SelectChar(sal_Unicode cChar) { m_xCharsetDisplay->SelectCharacter( cChar ); - m_xSymbolDisplay->SetSymbol(cChar, m_xCharsetDisplay->GetFont()); + m_aSymbolDisplay.SetSymbol(cChar, m_xCharsetDisplay->GetFont()); UpdateButtons(); } diff --git a/svx/source/accessibility/charmapacc.cxx b/svx/source/accessibility/charmapacc.cxx index bb560b9e820d..568e5a1dfe43 100644 --- a/svx/source/accessibility/charmapacc.cxx +++ b/svx/source/accessibility/charmapacc.cxx @@ -121,7 +121,7 @@ css::awt::Rectangle SvxShowCharSetAcc::implGetBounds() if (m_pParent) { const Point aOutPos;//( m_pParent->GetPosPixel() ); - Size aOutSize( m_pParent->GetSize()); + Size aOutSize( m_pParent->GetOutputSizePixel()); aRet.X = aOutPos.X(); aRet.Y = aOutPos.Y(); @@ -549,7 +549,7 @@ awt::Rectangle SvxShowCharSetItemAcc::implGetBounds( ) if( mpParent ) { tools::Rectangle aRect( mpParent->maRect ); - tools::Rectangle aParentRect(Point(), mpParent->mrParent.GetSize()); + tools::Rectangle aParentRect(Point(), mpParent->mrParent.GetOutputSizePixel()); aRect.Intersection( aParentRect ); diff --git a/svx/source/accessibility/svxrectctaccessiblecontext.cxx b/svx/source/accessibility/svxrectctaccessiblecontext.cxx index 62ae619a6c00..06cd902e7c54 100644 --- a/svx/source/accessibility/svxrectctaccessiblecontext.cxx +++ b/svx/source/accessibility/svxrectctaccessiblecontext.cxx @@ -916,8 +916,8 @@ awt::Rectangle RectCtlAccessibleContext::implGetBounds() if (mpRepr) { - const Point aOutPos;//( mpRepr->GetPosPixel() ); - Size aOutSize( mpRepr->GetSize()); + const Point aOutPos; + Size aOutSize(mpRepr->GetOutputSizePixel()); aRet.X = aOutPos.X(); aRet.Y = aOutPos.Y(); diff --git a/svx/source/dialog/charmap.cxx b/svx/source/dialog/charmap.cxx index 1a3521b45ffa..fa9c3cebede3 100644 --- a/svx/source/dialog/charmap.cxx +++ b/svx/source/dialog/charmap.cxx @@ -59,9 +59,14 @@ sal_uInt32& SvxShowCharSet::getSelectedChar() return cSelectedChar; } -SvxShowCharSet::SvxShowCharSet(weld::Builder& rBuilder, const OString& rDrawingId, - const OString& rScrollId, const VclPtr<VirtualDevice>& rVirDev) +FactoryFunction SvxShowCharSet::GetUITestFactory() const +{ + return SvxShowCharSetUIObject::create; +} + +SvxShowCharSet::SvxShowCharSet(weld::ScrolledWindow* pScrolledWindow, const VclPtr<VirtualDevice>& rVirDev) : mxVirDev(rVirDev) + , mxScrollArea(pScrolledWindow) , mxContext(comphelper::getProcessComponentContext()) , maFontSize(0, 0) , maPosition(0,0) @@ -69,24 +74,16 @@ SvxShowCharSet::SvxShowCharSet(weld::Builder& rBuilder, const OString& rDrawingI , mbUpdateForeground(true) , mbUpdateBackground(true) { - mxDrawingArea.reset(rBuilder.weld_drawing_area(rDrawingId, CreateAccessible(), SvxShowCharSetUIObject::create, this)); - mxScrollArea.reset(rBuilder.weld_scrolled_window(rScrollId)); - init(); mxScrollArea->set_user_managed_scrolling(); +} - mxDrawingArea->connect_size_allocate(LINK(this, SvxShowCharSet, DoResize)); - mxDrawingArea->connect_draw(LINK(this, SvxShowCharSet, DoPaint)); - mxDrawingArea->connect_mouse_press(LINK(this, SvxShowCharSet, DoMouseButtonDown)); - mxDrawingArea->connect_mouse_move(LINK(this, SvxShowCharSet, DoMouseMove)); - mxDrawingArea->connect_mouse_release(LINK(this, SvxShowCharSet, DoMouseButtonUp)); - mxDrawingArea->connect_key_press(LINK(this, SvxShowCharSet, DoKeyDown)); - mxDrawingArea->connect_focus_in(LINK(this, SvxShowCharSet, DoGetFocus)); - mxDrawingArea->connect_focus_out(LINK(this, SvxShowCharSet, DoLoseFocus)); - - mxScrollArea->set_size_request(COLUMN_COUNT * mxDrawingArea->get_approximate_digit_width() * 4, - ROW_COUNT * mxDrawingArea->get_text_height() * 2); +void SvxShowCharSet::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + mxScrollArea->set_size_request(COLUMN_COUNT * pDrawingArea->get_approximate_digit_width() * 4, + ROW_COUNT * pDrawingArea->get_text_height() * 2); + CustomWidgetController::SetDrawingArea(pDrawingArea); } void SvxShowCharSet::init() @@ -102,32 +99,30 @@ void SvxShowCharSet::init() bDrag = false; } -IMPL_LINK(SvxShowCharSet, DoResize, const Size&, rSize, void) +void SvxShowCharSet::Resize() { - maSize = rSize; mbRecalculateFont = true; - mxDrawingArea->queue_draw(); } -IMPL_LINK_NOARG(SvxShowCharSet, DoGetFocus, weld::Widget&, void) +void SvxShowCharSet::GetFocus() { SelectIndex(nSelectedIndex, true); } -IMPL_LINK_NOARG(SvxShowCharSet, DoLoseFocus, weld::Widget&, void) +void SvxShowCharSet::LoseFocus() { SelectIndex(nSelectedIndex); } -IMPL_LINK(SvxShowCharSet, DoMouseButtonDown, const MouseEvent&, rMEvt, void) +void SvxShowCharSet::MouseButtonDown(const MouseEvent& rMEvt) { if ( rMEvt.IsLeft() ) { if ( rMEvt.GetClicks() == 1 ) { - mxDrawingArea->grab_focus(); + GrabFocus(); bDrag = true; - mxDrawingArea->grab_add(); + grab_add(); int nIndex = PixelToMapIndex( rMEvt.GetPosPixel() ); // Fire the focus event @@ -138,7 +133,7 @@ IMPL_LINK(SvxShowCharSet, DoMouseButtonDown, const MouseEvent&, rMEvt, void) aDoubleClkHdl.Call( this ); } - if(rMEvt.IsRight()) + if (rMEvt.IsRight()) { Point aPosition (rMEvt.GetPosPixel()); maPosition = aPosition; @@ -149,24 +144,24 @@ IMPL_LINK(SvxShowCharSet, DoMouseButtonDown, const MouseEvent&, rMEvt, void) } } -IMPL_LINK(SvxShowCharSet, DoMouseButtonUp, const MouseEvent&, rMEvt, void) +void SvxShowCharSet::MouseButtonUp(const MouseEvent& rMEvt) { if ( bDrag && rMEvt.IsLeft() ) { // released mouse over character map - if ( tools::Rectangle(Point(), maSize).IsInside(rMEvt.GetPosPixel())) + if ( tools::Rectangle(Point(), GetOutputSizePixel()).IsInside(rMEvt.GetPosPixel())) aSelectHdl.Call( this ); - mxDrawingArea->grab_remove(); + grab_remove(); bDrag = false; } } -IMPL_LINK(SvxShowCharSet, DoMouseMove, const MouseEvent&, rMEvt, void) +void SvxShowCharSet::MouseMove(const MouseEvent& rMEvt) { if ( rMEvt.IsLeft() && bDrag ) { Point aPos = rMEvt.GetPosPixel(); - Size aSize = maSize; + Size aSize = GetOutputSizePixel(); if ( aPos.X() < 0 ) aPos.setX( 0 ); @@ -226,7 +221,7 @@ bool SvxShowCharSet::isFavChar(const OUString& sTitle, const OUString& rFont) void SvxShowCharSet::createContextMenu() { - std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(mxDrawingArea.get(), "svx/ui/charsetmenu.ui")); + std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetDrawingArea(), "svx/ui/charsetmenu.ui")); std::unique_ptr<weld::Menu> xItemMenu(xBuilder->weld_menu("charsetmenu")); sal_UCS4 cChar = GetSelectCharacter(); @@ -236,9 +231,9 @@ void SvxShowCharSet::createContextMenu() else xItemMenu->show("remove", false); - ContextMenuSelect(xItemMenu->popup_at_rect(mxDrawingArea.get(), tools::Rectangle(maPosition, Size(1,1)))); - mxDrawingArea->grab_focus(); - mxDrawingArea->queue_draw(); + ContextMenuSelect(xItemMenu->popup_at_rect(GetDrawingArea(), tools::Rectangle(maPosition, Size(1,1)))); + GrabFocus(); + Invalidate(); } void SvxShowCharSet::ContextMenuSelect(const OString& rIdent) @@ -389,7 +384,7 @@ int SvxShowCharSet::PixelToMapIndex( const Point& point) const return (nBase + ((point.X() - m_nXGap)/nX) + ((point.Y() - m_nYGap)/nY) * COLUMN_COUNT); } -IMPL_LINK(SvxShowCharSet, DoKeyDown, const KeyEvent&, rKEvt, bool) +bool SvxShowCharSet::KeyInput(const KeyEvent& rKEvt) { vcl::KeyCode aCode = rKEvt.GetKeyCode(); @@ -458,9 +453,8 @@ IMPL_LINK(SvxShowCharSet, DoKeyDown, const KeyEvent&, rKEvt, bool) return bRet; } -IMPL_LINK(SvxShowCharSet, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void SvxShowCharSet::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; InitSettings(rRenderContext); RecalculateFont(rRenderContext); DrawChars_Impl(rRenderContext, FirstInView(), LastInView()); @@ -470,12 +464,12 @@ void SvxShowCharSet::SetFont( const vcl::Font& rFont ) { maFont = rFont; mbRecalculateFont = true; - mxDrawingArea->queue_draw(); + Invalidate(); } void SvxShowCharSet::DeSelect() { - mxDrawingArea->queue_draw(); + Invalidate(); } // stretch a grid rectangle if its at the edge to fill unused space @@ -514,7 +508,7 @@ void SvxShowCharSet::DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1, if (n1 > LastInView() || n2 < FirstInView()) return; - Size aOutputSize(maSize); + Size aOutputSize(GetOutputSizePixel()); int i; for (i = 1; i < COLUMN_COUNT; ++i) @@ -663,7 +657,7 @@ void SvxShowCharSet::RecalculateFont(vcl::RenderContext& rRenderContext) if (nSelectedIndex >= 0) getSelectedChar() = mxFontCharMap->GetCharFromIndex(nSelectedIndex); - Size aSize(maSize); + Size aSize(GetOutputSizePixel()); vcl::Font aFont = maFont; aFont.SetWeight(WEIGHT_LIGHT); @@ -707,7 +701,7 @@ void SvxShowCharSet::SelectIndex(int nNewIndex, bool bFocus) int nNewPos = nMapIndex / COLUMN_COUNT; mxScrollArea->vadjustment_set_value(nNewPos); nSelectedIndex = bFocus ? nMapIndex+1 : -1; - mxDrawingArea->queue_draw(); + Invalidate(); } else if( nNewIndex < FirstInView() ) { @@ -716,7 +710,7 @@ void SvxShowCharSet::SelectIndex(int nNewIndex, bool bFocus) int nDelta = (FirstInView() - nNewIndex + COLUMN_COUNT-1) / COLUMN_COUNT; mxScrollArea->vadjustment_set_value(nOldPos - nDelta); nSelectedIndex = nNewIndex; - mxDrawingArea->queue_draw(); + Invalidate(); } else if( nNewIndex > LastInView() ) { @@ -727,17 +721,17 @@ void SvxShowCharSet::SelectIndex(int nNewIndex, bool bFocus) if( nNewIndex < mxFontCharMap->GetCharCount() ) { nSelectedIndex = nNewIndex; - mxDrawingArea->queue_draw(); + Invalidate(); } else if (nOldPos != mxScrollArea->vadjustment_get_value()) { - mxDrawingArea->queue_draw(); + Invalidate(); } } else { nSelectedIndex = nNewIndex; - mxDrawingArea->queue_draw(); + Invalidate(); } if( nSelectedIndex >= 0 ) @@ -785,7 +779,7 @@ void SvxShowCharSet::SelectCharacter( sal_UCS4 cNew ) SelectIndex( nMapIndex ); // move selected item to top row if not in focus mxScrollArea->vadjustment_set_value(nMapIndex / COLUMN_COUNT); - mxDrawingArea->queue_draw(); + Invalidate(); } IMPL_LINK_NOARG(SvxShowCharSet, VscrollHdl, weld::ScrolledWindow&, void) @@ -809,7 +803,7 @@ IMPL_LINK_NOARG(SvxShowCharSet, VscrollHdl, weld::ScrolledWindow&, void) SelectIndex( (LastInView() - COLUMN_COUNT + 1) + (nSelectedIndex % COLUMN_COUNT) ); } - mxDrawingArea->queue_draw(); + Invalidate(); } SvxShowCharSet::~SvxShowCharSet() diff --git a/svx/source/dialog/dlgctrl.cxx b/svx/source/dialog/dlgctrl.cxx index c6612b7e0b61..389e6ec06857 100644 --- a/svx/source/dialog/dlgctrl.cxx +++ b/svx/source/dialog/dlgctrl.cxx @@ -652,7 +652,7 @@ BitmapEx& RectCtl::GetRectBitmap() return *pBitmap; } -RectCtl::RectCtl(weld::Builder& rBuilder, const OString& rDrawingId, SvxTabPage* pPage, RectPoint eRpt, sal_uInt16 nBorder, sal_uInt16 nCircle) +RectCtl::RectCtl(SvxTabPage* pPage, RectPoint eRpt, sal_uInt16 nBorder, sal_uInt16 nCircle) : m_pPage(pPage) , nBorderWidth(Application::GetDefaultDevice()->LogicToPixel(Size(nBorder, 0), MapMode(MapUnit::Map100thMM)).Width()) , nRadius(Application::GetDefaultDevice()->LogicToPixel(Size(nCircle, 0), MapMode(MapUnit::Map100thMM)).Width()) @@ -661,18 +661,13 @@ RectCtl::RectCtl(weld::Builder& rBuilder, const OString& rDrawingId, SvxTabPage* , m_nState(CTL_STATE::NONE) , mbCompleteDisable(false) { - m_xControl.reset(rBuilder.weld_drawing_area(rDrawingId, CreateAccessible())); - m_xControl->connect_style_updated(LINK(this, RectCtl, MarkToResetSettings)); - m_xControl->connect_draw(LINK(this, RectCtl, DoPaint)); - m_xControl->connect_size_allocate(LINK(this, RectCtl, DoResize)); - m_xControl->connect_mouse_press(LINK(this, RectCtl, DoMouseButtonDown)); - m_xControl->connect_key_press(LINK(this, RectCtl, DoKeyDown)); - m_xControl->connect_focus_in(LINK(this, RectCtl, DoGetFocus)); - m_xControl->connect_focus_out(LINK(this, RectCtl, DoLoseFocus)); - m_xControl->connect_focus_rect(LINK(this, RectCtl, DoFocusRect)); - - m_xControl->set_size_request(m_xControl->get_approximate_digit_width() * 25, m_xControl->get_text_height() * 5); - Resize_Impl(); +} + +void RectCtl::SetDrawingArea(weld::DrawingArea* pDrawingArea) +{ + pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 25, + pDrawingArea->get_text_height() * 5); + CustomWidgetController::SetDrawingArea(pDrawingArea); } void RectCtl::SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder, sal_uInt16 nCircle) @@ -690,29 +685,29 @@ RectCtl::~RectCtl() pAccContext.clear(); } -IMPL_LINK(RectCtl, DoResize, const Size&, rSize, void) +void RectCtl::Resize() { - m_aSize = rSize; Resize_Impl(); } void RectCtl::Resize_Impl() { + Size aSize(GetOutputSizePixel()); + aPtLT = Point( 0 + nBorderWidth, 0 + nBorderWidth ); - aPtMT = Point( m_aSize.Width() / 2, 0 + nBorderWidth ); - aPtRT = Point( m_aSize.Width() - nBorderWidth, 0 + nBorderWidth ); + aPtMT = Point( aSize.Width() / 2, 0 + nBorderWidth ); + aPtRT = Point( aSize.Width() - nBorderWidth, 0 + nBorderWidth ); - aPtLM = Point( 0 + nBorderWidth, m_aSize.Height() / 2 ); - aPtMM = Point( m_aSize.Width() / 2, m_aSize.Height() / 2 ); - aPtRM = Point( m_aSize.Width() - nBorderWidth, m_aSize.Height() / 2 ); + aPtLM = Point( 0 + nBorderWidth, aSize.Height() / 2 ); + aPtMM = Point( aSize.Width() / 2, aSize.Height() / 2 ); + aPtRM = Point( aSize.Width() - nBorderWidth, aSize.Height() / 2 ); - aPtLB = Point( 0 + nBorderWidth, m_aSize.Height() - nBorderWidth ); - aPtMB = Point( m_aSize.Width() / 2, m_aSize.Height() - nBorderWidth ); - aPtRB = Point( m_aSize.Width() - nBorderWidth, m_aSize.Height() - nBorderWidth ); + aPtLB = Point( 0 + nBorderWidth, aSize.Height() - nBorderWidth ); + aPtMB = Point( aSize.Width() / 2, aSize.Height() - nBorderWidth ); + aPtRB = Point( aSize.Width() - nBorderWidth, aSize.Height() - nBorderWidth ); Reset(); - MarkToResetSettings(*m_xControl); - m_xControl->queue_draw(); + StyleUpdated(); } void RectCtl::InitRectBitmap() @@ -762,10 +757,11 @@ void RectCtl::InitRectBitmap() pBitmap->Replace( aColorAry1, aColorAry2, 7 ); } -IMPL_LINK_NOARG(RectCtl, MarkToResetSettings, weld::Widget&, void) +void RectCtl::StyleUpdated() { delete pBitmap; pBitmap = nullptr; // forces new creating of bitmap + CustomWidgetController::StyleUpdated(); } void RectCtl::InitSettings(vcl::RenderContext& rRenderContext) @@ -779,7 +775,7 @@ void RectCtl::InitSettings(vcl::RenderContext& rRenderContext) // The clicked rectangle (3 x 3) is determined and the parent (dialog) // is notified that the item was changed -IMPL_LINK(RectCtl, DoMouseButtonDown, const MouseEvent&, rMEvt, void) +void RectCtl::MouseButtonDown(const MouseEvent& rMEvt) { // CompletelyDisabled() added to have a disabled state for RectCtl if(!IsCompletelyDisabled()) @@ -789,11 +785,11 @@ IMPL_LINK(RectCtl, DoMouseButtonDown, const MouseEvent&, rMEvt, void) SetActualRP( eRP ); if (m_pPage) - m_pPage->PointChanged(m_xControl.get(), eRP); + m_pPage->PointChanged(GetDrawingArea(), eRP); } } -IMPL_LINK(RectCtl, DoKeyDown, const KeyEvent&, rKeyEvt, bool) +bool RectCtl::KeyInput(const KeyEvent& rKeyEvt) { // CompletelyDisabled() added to have a disabled state for RectCtl if (IsCompletelyDisabled()) @@ -871,16 +867,14 @@ IMPL_LINK(RectCtl, DoKeyDown, const KeyEvent&, rKeyEvt, bool) SetActualRP( eNewRP ); if (m_pPage) - m_pPage->PointChanged(m_xControl.get(), eRP); + m_pPage->PointChanged(GetDrawingArea(), eRP); } return true; } // the control (rectangle with 9 circles) -IMPL_LINK(RectCtl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void RectCtl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; - InitSettings(rRenderContext); Point aPtDiff(1, 1); @@ -891,14 +885,14 @@ IMPL_LINK(RectCtl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) rRenderContext.SetFillColor(rStyles.GetDialogColor()); rRenderContext.DrawRect(tools::Rectangle(Point(0,0), rRenderContext.GetOutputSize())); - if (m_xControl->get_sensitive()) + if (IsEnabled()) rRenderContext.SetLineColor(rStyles.GetLabelTextColor()); else rRenderContext.SetLineColor(rStyles.GetShadowColor()); rRenderContext.SetFillColor(); - if (!m_xControl->get_sensitive()) + if (!IsEnabled()) { Color aOldCol = rRenderContext.GetLineColor(); rRenderContext.SetLineColor(rStyles.GetLightColor()); @@ -912,7 +906,7 @@ IMPL_LINK(RectCtl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) Size aBtnSize(11, 11); Size aDstBtnSize(aBtnSize); Point aToCenter(aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1); - Point aBtnPnt1(m_xControl->get_sensitive() ? 0 : 22, 0); + Point aBtnPnt1(IsEnabled() ? 0 : 22, 0); Point aBtnPnt2(11, 0); Point aBtnPnt3(22, 0); @@ -954,7 +948,7 @@ IMPL_LINK(RectCtl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) // CompletelyDisabled() added to have a disabled state for SvxRectCtl if (!IsCompletelyDisabled()) { - if (m_xControl->get_sensitive()) + if (IsEnabled()) { Point aCenterPt(aPtNew); aCenterPt -= aToCenter; @@ -964,10 +958,10 @@ IMPL_LINK(RectCtl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) } } -IMPL_LINK(RectCtl, DoFocusRect, weld::Widget&, rControl, tools::Rectangle) +tools::Rectangle RectCtl::GetFocusRect() { tools::Rectangle aRet; - if (rControl.has_focus()) + if (HasFocus()) aRet = CalculateFocusRectangle(); return aRet; } @@ -1012,9 +1006,9 @@ Point RectCtl::SetActualRPWithoutInvalidate( RectPoint eNewRP ) return aPtLast; } -IMPL_LINK_NOARG(RectCtl, DoGetFocus, weld::Widget&, void) +void RectCtl::GetFocus() { - m_xControl->queue_draw(); + Invalidate(); // Send accessibility event. if (pAccContext.is()) @@ -1023,9 +1017,9 @@ IMPL_LINK_NOARG(RectCtl, DoGetFocus, weld::Widget&, void) } } -IMPL_LINK_NOARG(RectCtl, DoLoseFocus, weld::Widget&, void) +void RectCtl::LoseFocus() { - m_xControl->queue_draw(); + Invalidate(); } Point RectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const @@ -1034,11 +1028,13 @@ Point RectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const long x; long y; + Size aSize(GetOutputSizePixel()); + if( !( m_nState & CTL_STATE::NOHORZ ) ) { - if( aPt.X() < m_aSize.Width() / 3 ) + if( aPt.X() < aSize.Width() / 3 ) x = aPtLT.X(); - else if( aPt.X() < m_aSize.Width() * 2 / 3 ) + else if( aPt.X() < aSize.Width() * 2 / 3 ) x = aPtMM.X(); else x = aPtRB.X(); @@ -1048,9 +1044,9 @@ Point RectCtl::GetApproxLogPtFromPixPt( const Point& rPt ) const if( !( m_nState & CTL_STATE::NOVERT ) ) { - if( aPt.Y() < m_aSize.Height() / 3 ) + if( aPt.Y() < aSize.Height() / 3 ) y = aPtLT.Y(); - else if( aPt.Y() < m_aSize.Height() * 2 / 3 ) + else if( aPt.Y() < aSize.Height() * 2 / 3 ) y = aPtMM.Y(); else y = aPtRB.Y(); @@ -1086,7 +1082,7 @@ void RectCtl::Reset() { aPtNew = GetPointFromRP( eDefRP ); eRP = eDefRP; - m_xControl->queue_draw(); + Invalidate(); } // Returns the currently selected RectPoint @@ -1096,7 +1092,7 @@ void RectCtl::SetActualRP( RectPoint eNewRP ) { SetActualRPWithoutInvalidate(eNewRP); - m_xControl->queue_draw(); + Invalidate(); // notify accessibility object about change if (pAccContext.is()) @@ -1117,10 +1113,10 @@ void RectCtl::SetState( CTL_STATE nState ) _aPtNew.setY( aPtMM.Y() ); eRP = GetRPFromPoint( _aPtNew ); - m_xControl->queue_draw(); + Invalidate(); if (m_pPage) - m_pPage->PointChanged(m_xControl.get(), eRP); + m_pPage->PointChanged(GetDrawingArea(), eRP); } tools::Rectangle RectCtl::CalculateFocusRectangle() const @@ -1164,7 +1160,7 @@ RectPoint RectCtl::GetApproxRPFromPixPt( const css::awt::Point& r ) const void RectCtl::DoCompletelyDisable(bool bNew) { mbCompleteDisable = bNew; - m_xControl->queue_draw(); + Invalidate(); } // Control for editing bitmaps diff --git a/svx/source/dialog/graphctl.cxx b/svx/source/dialog/graphctl.cxx index e656d0e18673..45fd6f18d107 100644 --- a/svx/source/dialog/graphctl.cxx +++ b/svx/source/dialog/graphctl.cxx @@ -771,23 +771,13 @@ css::uno::Reference< css::accessibility::XAccessible > GraphCtrl::CreateAccessib return mpAccContext.get(); } -SvxGraphCtrl::SvxGraphCtrl(weld::Builder& rBuilder, const OString& rDrawingId) +SvxGraphCtrl::SvxGraphCtrl() : aMap100(MapUnit::Map100thMM) - , mxDrawingArea(rBuilder.weld_drawing_area(rDrawingId)) { - mxDrawingArea->connect_size_allocate(LINK(this, SvxGraphCtrl, DoResize)); - mxDrawingArea->connect_draw(LINK(this, SvxGraphCtrl, DoPaint)); } -IMPL_LINK(SvxGraphCtrl, DoResize, const Size&, rSize, void) +void SvxGraphCtrl::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - maSize = rSize; - mxDrawingArea->queue_draw(); -} - -IMPL_LINK(SvxGraphCtrl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) -{ - vcl::RenderContext& rRenderContext = aPayload.first; rRenderContext.Erase(); const bool bGraphicValid(GraphicType::NONE != aGraphic.GetType()); // #i73381# in non-SdrMode, paint to local directly @@ -796,7 +786,7 @@ IMPL_LINK(SvxGraphCtrl, DoPaint, weld::DrawingArea::draw_args, aPayload, void) MapMode aDisplayMap( aMap100 ); Point aNewPos; Size aNewSize; - const Size aWinSize = Application::GetDefaultDevice()->PixelToLogic( maSize, aMap100 ); + const Size aWinSize = Application::GetDefaultDevice()->PixelToLogic(GetOutputSizePixel(), aMap100); const long nWidth = aWinSize.Width(); const long nHeight = aWinSize.Height(); double fGrfWH = static_cast<double>(aGraphSize.Width()) / aGraphSize.Height(); @@ -841,7 +831,7 @@ void SvxGraphCtrl::SetGraphic(const Graphic& rGraphic) else aGraphSize = OutputDevice::LogicToLogic( aGraphic.GetPrefSize(), aGraphic.GetPrefMapMode(), aMap100 ); - mxDrawingArea->queue_draw(); + Invalidate(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svx/source/dialog/searchcharmap.cxx b/svx/source/dialog/searchcharmap.cxx index a3c887869ccb..cf9faf363673 100644 --- a/svx/source/dialog/searchcharmap.cxx +++ b/svx/source/dialog/searchcharmap.cxx @@ -46,12 +46,10 @@ using namespace ::com::sun::star::uno; using namespace ::com::sun::star; -SvxSearchCharSet::SvxSearchCharSet(weld::Builder& rBuilder, const OString& rDrawingId, - const OString& rScrollId, const VclPtr<VirtualDevice>& rVirDev) - : SvxShowCharSet(rBuilder, rDrawingId, rScrollId, rVirDev) +SvxSearchCharSet::SvxSearchCharSet(weld::ScrolledWindow* pScrolledWindow, const VclPtr<VirtualDevice>& rVirDev) + : SvxShowCharSet(pScrolledWindow, rVirDev) , nCount(0) { - mxDrawingArea->connect_key_press(LINK(this, SvxSearchCharSet, DoKeyDown)); } int SvxSearchCharSet::LastInView() const @@ -64,7 +62,7 @@ int SvxSearchCharSet::LastInView() const return nIndex; } -IMPL_LINK(SvxSearchCharSet, DoKeyDown, const KeyEvent&, rKEvt, bool) +bool SvxSearchCharSet::KeyInput(const KeyEvent& rKEvt) { vcl::KeyCode aCode = rKEvt.GetKeyCode(); @@ -152,12 +150,11 @@ void SvxSearchCharSet::SelectCharacter( const Subset* sub ) aHighHdl.Call(this); // move selected item to top row if not in focus //TO.DO aVscrollSB->SetThumbPos( nMapIndex / COLUMN_COUNT ); - mxDrawingArea->queue_draw(); + Invalidate(); } -IMPL_LINK(SvxSearchCharSet, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void SvxSearchCharSet::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; InitSettings(rRenderContext); RecalculateFont(rRenderContext); DrawChars_Impl(rRenderContext, FirstInView(), LastInView()); @@ -168,7 +165,7 @@ void SvxSearchCharSet::DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1 if (n1 > LastInView() || n2 < FirstInView()) return; - Size aOutputSize(maSize); + Size aOutputSize(GetOutputSizePixel()); int i; for (i = 1; i < COLUMN_COUNT; ++i) @@ -302,7 +299,7 @@ void SvxSearchCharSet::RecalculateFont(vcl::RenderContext& rRenderContext) if (!mbRecalculateFont) return; - Size aSize(maSize); + Size aSize(GetOutputSizePixel()); vcl::Font aFont = rRenderContext.GetFont(); aFont.SetWeight(WEIGHT_LIGHT); @@ -339,7 +336,7 @@ void SvxSearchCharSet::SelectIndex(int nNewIndex, bool bFocus) { mxScrollArea->vadjustment_set_value(0); nSelectedIndex = bFocus ? 0 : -1; - mxDrawingArea->queue_draw(); + Invalidate(); } else if( nNewIndex < FirstInView() ) { @@ -348,7 +345,7 @@ void SvxSearchCharSet::SelectIndex(int nNewIndex, bool bFocus) int nDelta = (FirstInView() - nNewIndex + COLUMN_COUNT-1) / COLUMN_COUNT; mxScrollArea->vadjustment_set_value(nOldPos - nDelta); nSelectedIndex = nNewIndex; - mxDrawingArea->queue_draw(); + Invalidate(); } else if( nNewIndex > LastInView() ) { @@ -360,17 +357,17 @@ void SvxSearchCharSet::SelectIndex(int nNewIndex, bool bFocus) if( nNewIndex < nCount ) { nSelectedIndex = nNewIndex; - mxDrawingArea->queue_draw(); + Invalidate(); } else if (nOldPos != mxScrollArea->vadjustment_get_value()) { - mxDrawingArea->queue_draw(); + Invalidate(); } } else { nSelectedIndex = nNewIndex; - mxDrawingArea->queue_draw(); + Invalidate(); } if( nSelectedIndex >= 0 ) @@ -434,7 +431,7 @@ void SvxSearchCharSet::ClearPreviousData() { m_aItemList.clear(); nCount = 0; - mxDrawingArea->queue_draw(); + Invalidate(); } void SvxSearchCharSet::AppendCharToList(sal_UCS4 sChar) diff --git a/sw/source/ui/envelp/envfmt.cxx b/sw/source/ui/envelp/envfmt.cxx index 2862d520c57e..b46b795fdaac 100644 --- a/sw/source/ui/envelp/envfmt.cxx +++ b/sw/source/ui/envelp/envfmt.cxx @@ -126,7 +126,7 @@ SwEnvFormatPage::SwEnvFormatPage(TabPageParent pParent, const SfxItemSet& rSet) , m_xSizeFormatBox(m_xBuilder->weld_combo_box_text("format")) , m_xSizeWidthField(m_xBuilder->weld_metric_spin_button("width", FUNIT_CM)) , m_xSizeHeightField(m_xBuilder->weld_metric_spin_button("height", FUNIT_CM)) - , m_xPreview(new SwEnvPreview(m_xBuilder->weld_drawing_area("preview"))) + , m_xPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreview)) { SetExchangeSupport(); @@ -180,7 +180,7 @@ SwEnvFormatPage::SwEnvFormatPage(TabPageParent pParent, const SfxItemSet& rSet) void SwEnvFormatPage::Init(SwEnvDlg* pDialog) { m_pDialog = pDialog; - m_xPreview->SetDialog(m_pDialog); + m_aPreview.SetDialog(m_pDialog); } SwEnvFormatPage::~SwEnvFormatPage() diff --git a/sw/source/ui/envelp/envfmt.hxx b/sw/source/ui/envelp/envfmt.hxx index 20d445f14c61..5fa0bda77de6 100644 --- a/sw/source/ui/envelp/envfmt.hxx +++ b/sw/source/ui/envelp/envfmt.hxx @@ -29,6 +29,7 @@ class SwEnvFormatPage : public SfxTabPage SwEnvDlg* m_pDialog; std::vector<sal_uInt16> m_aIDs; + SwEnvPreview m_aPreview; std::unique_ptr<weld::MetricSpinButton> m_xAddrLeftField; std::unique_ptr<weld::MetricSpinButton> m_xAddrTopField; std::unique_ptr<weld::MenuButton> m_xAddrEditButton; @@ -38,7 +39,7 @@ class SwEnvFormatPage : public SfxTabPage std::unique_ptr<weld::ComboBoxText> m_xSizeFormatBox; std::unique_ptr<weld::MetricSpinButton> m_xSizeWidthField; std::unique_ptr<weld::MetricSpinButton> m_xSizeHeightField; - std::unique_ptr<SwEnvPreview> m_xPreview; + std::unique_ptr<weld::CustomWeld> m_xPreview; DECL_LINK(ModifyHdl, weld::MetricSpinButton&, void); DECL_LINK(AddrEditHdl, const OString&, void); diff --git a/sw/source/ui/envelp/envlop1.cxx b/sw/source/ui/envelp/envlop1.cxx index 9d25bf201544..756a61a6465d 100644 --- a/sw/source/ui/envelp/envlop1.cxx +++ b/sw/source/ui/envelp/envlop1.cxx @@ -44,25 +44,20 @@ using namespace ::com::sun::star::container; using namespace ::com::sun::star::uno; using namespace ::com::sun::star; -SwEnvPreview::SwEnvPreview(weld::DrawingArea* pDrawingArea) - : m_xDrawingArea(pDrawingArea) - , m_pDialog(nullptr) +SwEnvPreview::SwEnvPreview() + : m_pDialog(nullptr) { - m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_width() * 20, - m_xDrawingArea->get_text_height() * 8); - m_xDrawingArea->connect_size_allocate(LINK(this, SwEnvPreview, DoResize)); - m_xDrawingArea->connect_draw(LINK(this, SwEnvPreview, DoPaint)); } -IMPL_LINK(SwEnvPreview, DoResize, const Size&, rSize, void) +void SwEnvPreview::SetDrawingArea(weld::DrawingArea* pDrawingArea) { - m_aSize = rSize; + pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 20, + pDrawingArea->get_text_height() * 8); + CustomWidgetController::SetDrawingArea(pDrawingArea); } -IMPL_LINK(SwEnvPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void SwEnvPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; - const StyleSettings& rSettings = rRenderContext.GetSettings().GetStyleSettings(); rRenderContext.SetBackground(rRenderContext.GetSettings().GetStyleSettings().GetDialogColor()); rRenderContext.Erase(); @@ -72,9 +67,11 @@ IMPL_LINK(SwEnvPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) const long nPageW = std::max(rItem.m_nWidth, rItem.m_nHeight); const long nPageH = std::min(rItem.m_nWidth, rItem.m_nHeight); + Size aSize(GetOutputSizePixel()); + const double f = 0.8 * std::min( - double(m_aSize.Width()) / double(nPageW), - double(m_aSize.Height()) / double(nPageH)); + double(aSize.Width()) / double(nPageW), + double(aSize.Height()) / double(nPageH)); Color aBack = rSettings.GetWindowColor(); Color aFront = SwViewOption::GetFontColor(); @@ -87,8 +84,8 @@ IMPL_LINK(SwEnvPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) // Envelope const long nW = static_cast<long>(f * nPageW); const long nH = static_cast<long>(f * nPageH); - const long nX = (m_aSize.Width () - nW) / 2; - const long nY = (m_aSize.Height() - nH) / 2; + const long nX = (aSize.Width () - nW) / 2; + const long nY = (aSize.Height() - nH) / 2; rRenderContext.SetFillColor(aBack); rRenderContext.DrawRect(tools::Rectangle(Point(nX, nY), Size(nW, nH))); @@ -196,7 +193,7 @@ SwEnvPage::SwEnvPage(TabPageParent pParent, const SfxItemSet& rSet) , m_xInsertBT(m_xBuilder->weld_button("insert")) , m_xSenderBox(m_xBuilder->weld_check_button("sender")) , m_xSenderEdit(m_xBuilder->weld_text_view("senderedit")) - , m_xPreview(new SwEnvPreview(m_xBuilder->weld_drawing_area("preview"))) + , m_xPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreview)) { auto nTextBoxHeight(m_xAddrEdit->get_height_rows(10)); auto nTextBoxWidth(m_xAddrEdit->get_approximate_digit_width() * 25); @@ -216,7 +213,7 @@ void SwEnvPage::Init(SwEnvDlg* pDialog) { m_pDialog = pDialog; m_pSh = m_pDialog->pSh; - m_xPreview->SetDialog(pDialog); + m_aPreview.SetDialog(pDialog); // Install handlers m_xDatabaseLB->connect_changed(LINK(this, SwEnvPage, DatabaseHdl)); diff --git a/sw/source/ui/envelp/labfmt.cxx b/sw/source/ui/envelp/labfmt.cxx index b016700362f0..1f3b81e20c22 100644 --- a/sw/source/ui/envelp/labfmt.cxx +++ b/sw/source/ui/envelp/labfmt.cxx @@ -98,9 +98,8 @@ void DrawArrow(vcl::RenderContext& rRenderContext, const Point &rP1, const Point } -SwLabPreview::SwLabPreview(weld::DrawingArea* pWidget) - : m_xDrawingArea(pWidget) - , m_aGrayColor(COL_LIGHTGRAY) +SwLabPreview::SwLabPreview() + : m_aGrayColor(COL_LIGHTGRAY) , m_aHDistStr(SwResId(STR_HDIST)) , m_aVDistStr(SwResId(STR_VDIST)) , m_aWidthStr(SwResId(STR_WIDTH)) @@ -109,34 +108,39 @@ SwLabPreview::SwLabPreview(weld::DrawingArea* pWidget) , m_aUpperStr(SwResId(STR_UPPER)) , m_aColsStr(SwResId(STR_COLS)) , m_aRowsStr(SwResId(STR_ROWS)) + , m_lHDistWidth(0) + , m_lVDistWidth(0) + , m_lHeightWidth(0) + , m_lLeftWidth(0) + , m_lUpperWidth(0) + , m_lColsWidth(0) + , m_lXWidth(0) + , m_lXHeight(0) +{ +} + +void SwLabPreview::SetDrawingArea(weld::DrawingArea* pWidget) { pWidget->set_size_request(pWidget->get_approximate_digit_width() * 54, pWidget->get_text_height() * 15); - m_xDrawingArea->connect_size_allocate(LINK(this, SwLabPreview, DoResize)); - m_xDrawingArea->connect_draw(LINK(this, SwLabPreview, DoPaint)); - m_lHDistWidth = pWidget->get_pixel_size(m_aHDistStr).Width(); m_lVDistWidth = pWidget->get_pixel_size(m_aVDistStr).Width(); m_lHeightWidth = pWidget->get_pixel_size(m_aHeightStr).Width(); m_lLeftWidth = pWidget->get_pixel_size(m_aLeftStr).Width(); m_lUpperWidth = pWidget->get_pixel_size(m_aUpperStr).Width(); m_lColsWidth = pWidget->get_pixel_size(m_aColsStr).Width(); - m_lXHeight = pWidget->get_text_height(); m_lXWidth = pWidget->get_pixel_size(OUString('X')).Width(); -} + m_lXHeight = pWidget->get_text_height(); -IMPL_LINK(SwLabPreview, DoResize, const Size&, rSize, void) -{ - m_aSize = rSize; + CustomWidgetController::SetDrawingArea(pWidget); } -IMPL_LINK(SwLabPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void SwLabPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; - - const long lOutWPix = m_aSize.Width(); - const long lOutHPix = m_aSize.Height(); + const Size aSize(GetOutputSizePixel()); + const long lOutWPix = aSize.Width(); + const long lOutHPix = aSize.Height(); // Scale factor const double fxpix = double(lOutWPix - (2 * (m_lLeftWidth + 15))) / double(lOutWPix); @@ -276,7 +280,7 @@ IMPL_LINK(SwLabPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) void SwLabPreview::UpdateItem(const SwLabItem& rItem) { m_aItem = rItem; - m_xDrawingArea->queue_draw(); + Invalidate(); } SwLabFormatPage::SwLabFormatPage(TabPageParent pParent, const SfxItemSet& rSet) @@ -286,7 +290,7 @@ SwLabFormatPage::SwLabFormatPage(TabPageParent pParent, const SfxItemSet& rSet) , bModified(false) , m_xMakeFI(m_xBuilder->weld_label("make")) , m_xTypeFI(m_xBuilder->weld_label("type")) - , m_xPreview(new SwLabPreview(m_xBuilder->weld_drawing_area("preview"))) + , m_xPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreview)) , m_xHDistField(m_xBuilder->weld_metric_spin_button("hori", FUNIT_CM)) , m_xVDistField(m_xBuilder->weld_metric_spin_button("vert", FUNIT_CM)) , m_xWidthField(m_xBuilder->weld_metric_spin_button("width", FUNIT_CM)) @@ -355,7 +359,7 @@ IMPL_LINK_NOARG(SwLabFormatPage, PreviewHdl, Timer *, void) aPreviewIdle.Stop(); ChangeMinMax(); FillItem( aItem ); - m_xPreview->UpdateItem( aItem ); + m_aPreview.UpdateItem(aItem); } void SwLabFormatPage::ChangeMinMax() diff --git a/sw/source/ui/envelp/labfmt.hxx b/sw/source/ui/envelp/labfmt.hxx index 1be3737a1e0b..7415792f4642 100644 --- a/sw/source/ui/envelp/labfmt.hxx +++ b/sw/source/ui/envelp/labfmt.hxx @@ -22,15 +22,13 @@ #include "swuilabimp.hxx" #include <labimg.hxx> #include <vcl/idle.hxx> +#include <vcl/customweld.hxx> #include <vcl/weld.hxx> class SwLabFormatPage; -class SwLabPreview +class SwLabPreview : public weld::CustomWidgetController { - std::unique_ptr<weld::DrawingArea> m_xDrawingArea; - - Size m_aSize; Color m_aGrayColor; OUString m_aHDistStr; @@ -54,12 +52,12 @@ class SwLabPreview SwLabItem m_aItem; - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; public: - explicit SwLabPreview(weld::DrawingArea* pDrawingArea); + SwLabPreview(); void UpdateItem(const SwLabItem& rItem); }; @@ -70,9 +68,11 @@ class SwLabFormatPage : public SfxTabPage SwLabItem aItem; bool bModified; + SwLabPreview m_aPreview; + std::unique_ptr<weld::Label> m_xMakeFI; std::unique_ptr<weld::Label> m_xTypeFI; - std::unique_ptr<SwLabPreview> m_xPreview; + std::unique_ptr<weld::CustomWeld> m_xPreview; std::unique_ptr<weld::MetricSpinButton> m_xHDistField; std::unique_ptr<weld::MetricSpinButton> m_xVDistField; std::unique_ptr<weld::MetricSpinButton> m_xWidthField; diff --git a/sw/source/ui/misc/num.cxx b/sw/source/ui/misc/num.cxx index 906d46d580f0..69e0261c494f 100644 --- a/sw/source/ui/misc/num.cxx +++ b/sw/source/ui/misc/num.cxx @@ -87,7 +87,7 @@ SwNumPositionTabPage::SwNumPositionTabPage(TabPageParent pParent, const SfxItemS , m_xIndentAtFT(m_xBuilder->weld_label("indentat")) , m_xIndentAtMF(m_xBuilder->weld_metric_spin_button("indentatmf", FUNIT_CM)) , m_xStandardPB(m_xBuilder->weld_button("standard")) - , m_xPreviewWIN(new SwNumberingPreview(m_xBuilder->weld_drawing_area("preview"))) + , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN)) { SetExchangeSupport(); @@ -131,7 +131,7 @@ SwNumPositionTabPage::SwNumPositionTabPage(TabPageParent pParent, const SfxItemS m_xLevelLB->select_text(sEntry); m_xRelativeCB->set_active(bLastRelative); - m_xPreviewWIN->SetPositionMode(); + m_aPreviewWIN.SetPositionMode(); } SwNumPositionTabPage::~SwNumPositionTabPage() @@ -380,7 +380,7 @@ void SwNumPositionTabPage::ActivatePage(const SfxItemSet& ) InitControls(); } m_xRelativeCB->set_sensitive(1 != nActNumLvl); - m_xPreviewWIN->queue_draw(); + m_aPreviewWIN.Invalidate(); } DeactivateRC SwNumPositionTabPage::DeactivatePage(SfxItemSet *_pSet) @@ -437,7 +437,7 @@ void SwNumPositionTabPage::Reset( const SfxItemSet* rSet ) pActNum = new SwNumRule(*pSaveNum); else if(*pSaveNum != *pActNum) *pActNum = *pSaveNum; - m_xPreviewWIN->SetNumRule(pActNum); + m_aPreviewWIN.SetNumRule(pActNum); InitPosAndSpaceMode(); ShowControlsDependingOnPosAndSpaceMode(); InitControls(); @@ -517,7 +517,7 @@ void SwNumPositionTabPage::SetWrtShell(SwWrtShell* pSh) m_xIndentAtMF->set_max(m_xIndentAtMF->normalize( nWidth ), FUNIT_TWIP ); const SwRect& rPrtRect = pWrtSh->GetAnyCurRect(CurRectType::Page); - m_xPreviewWIN->SetPageWidth(rPrtRect.Width()); + m_aPreviewWIN.SetPageWidth(rPrtRect.Width()); FieldUnit eMetric = ::GetDfltMetric( dynamic_cast<SwWebView*>( &pWrtSh->GetView()) != nullptr ); if(eMetric == FUNIT_MM) { @@ -872,8 +872,8 @@ IMPL_LINK_NOARG(SwNumPositionTabPage, StandardHdl, weld::Button&, void) void SwNumPositionTabPage::SetModified() { bModified = true; - m_xPreviewWIN->SetLevel(nActNumLvl); - m_xPreviewWIN->queue_draw(); + m_aPreviewWIN.SetLevel(nActNumLvl); + m_aPreviewWIN.Invalidate(); } #endif diff --git a/sw/source/ui/misc/outline.cxx b/sw/source/ui/misc/outline.cxx index 8f225ec20ba2..7595495ba044 100644 --- a/sw/source/ui/misc/outline.cxx +++ b/sw/source/ui/misc/outline.cxx @@ -400,7 +400,7 @@ SwOutlineSettingsTabPage::SwOutlineSettingsTabPage(TabPageParent pPage, , m_xPrefixED(m_xBuilder->weld_entry("prefix")) , m_xSuffixED(m_xBuilder->weld_entry("suffix")) , m_xStartEdit(m_xBuilder->weld_spin_button("startat")) - , m_xPreviewWIN(new SwNumberingPreview(m_xBuilder->weld_drawing_area("preview"))) + , m_xPreviewWIN(new weld::CustomWeld(*m_xBuilder, "preview", m_aPreviewWIN)) { SetExchangeSupport(); @@ -723,8 +723,8 @@ void SwOutlineSettingsTabPage::SetWrtShell(SwWrtShell* pShell) pNumRule = static_cast<SwOutlineTabDialog*>(GetDialogController())->GetNumRule(); pCollNames = static_cast<SwOutlineTabDialog*>(GetDialogController())->GetCollNames(); - m_xPreviewWIN->SetNumRule(pNumRule); - m_xPreviewWIN->SetOutlineNames(pCollNames); + m_aPreviewWIN.SetNumRule(pNumRule); + m_aPreviewWIN.SetOutlineNames(pCollNames); // set start value - nActLevel must be 1 here sal_uInt16 nTmpLevel = lcl_BitToLevel(nActLevel); const SwNumFormat& rNumFormat = pNumRule->Get( nTmpLevel ); @@ -1058,16 +1058,9 @@ void NumberingPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Re rRenderContext.DrawOutDev(Point(0,0), aSize, Point(0,0), aSize, *pVDev); } -IMPL_LINK(SwNumberingPreview, DoResize, const Size&, rSize, void) +void SwNumberingPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - m_aSize = rSize; -} - -IMPL_LINK(SwNumberingPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) -{ - vcl::RenderContext& rRenderContext = aPayload.first; - - const Size aSize(rRenderContext.PixelToLogic(m_aSize)); + const Size aSize(rRenderContext.PixelToLogic(GetOutputSizePixel())); ScopedVclPtrInstance<VirtualDevice> pVDev(rRenderContext); pVDev->SetMapMode(rRenderContext.GetMapMode()); diff --git a/sw/source/ui/table/autoformatpreview.cxx b/sw/source/ui/table/autoformatpreview.cxx index 7b302a401703..61af87bdf6e6 100644 --- a/sw/source/ui/table/autoformatpreview.cxx +++ b/sw/source/ui/table/autoformatpreview.cxx @@ -28,9 +28,8 @@ #define FRAME_OFFSET 4 -AutoFormatPreview::AutoFormatPreview(weld::DrawingArea* pDrawingArea) - : mxDrawingArea(pDrawingArea) - , maCurrentData(OUString()) +AutoFormatPreview::AutoFormatPreview() + : maCurrentData(OUString()) , mbFitWidth(false) , mbRTL(false) , maStringJan(SwResId(STR_JAN)) @@ -46,14 +45,12 @@ AutoFormatPreview::AutoFormatPreview(weld::DrawingArea* pDrawingArea) mxNumFormat.reset(new SvNumberFormatter(xContext, LANGUAGE_SYSTEM)); Init(); - - mxDrawingArea->connect_size_allocate(LINK(this, AutoFormatPreview, DoResize)); - mxDrawingArea->connect_draw(LINK(this, AutoFormatPreview, DoPaint)); } -IMPL_LINK(AutoFormatPreview, DoResize, const Size&, rSize, void) +void AutoFormatPreview::Resize() { - maPreviousSize = Size(rSize.Width() - 6, rSize.Height() - 30); + Size aSize = GetOutputSizePixel(); + maPreviousSize = Size(aSize.Width() - 6, aSize.Height() - 30); mnLabelColumnWidth = (maPreviousSize.Width() - 4) / 4 - 12; mnDataColumnWidth1 = (maPreviousSize.Width() - 4 - 2 * mnLabelColumnWidth) / 3; mnDataColumnWidth2 = (maPreviousSize.Width() - 4 - 2 * mnLabelColumnWidth) / 4; @@ -413,13 +410,11 @@ void AutoFormatPreview::NotifyChange(const SwTableAutoFormat& rNewData) mbFitWidth = maCurrentData.IsJustify(); // true; //??? CalcCellArray(mbFitWidth); CalcLineMap(); - mxDrawingArea->queue_draw(); + Invalidate(); } -IMPL_LINK(AutoFormatPreview, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +void AutoFormatPreview::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) { - vcl::RenderContext& rRenderContext = aPayload.first; - rRenderContext.Push(PushFlags::ALL); DrawModeFlags nOldDrawMode = rRenderContext.GetDrawMode(); diff --git a/sw/source/ui/table/instable.cxx b/sw/source/ui/table/instable.cxx index 51a9315b1760..82dff402d7dd 100644 --- a/sw/source/ui/table/instable.cxx +++ b/sw/source/ui/table/instable.cxx @@ -61,6 +61,10 @@ IMPL_LINK(SwInsTableDlg, TextFilterHdl, OUString&, rTest, bool) SwInsTableDlg::SwInsTableDlg(SwView& rView) : weld::GenericDialogController(rView.GetFrameWeld(), "modules/swriter/ui/inserttable.ui", "InsertTableDialog") + , m_aTextFilter(" .<>") + , pShell(&rView.GetWrtShell()) + , pTAutoFormat(nullptr) + , nEnteredValRepeatHeaderNF(-1) , m_xNameEdit(m_xBuilder->weld_entry("nameedit")) , m_xColNF(m_xBuilder->weld_spin_button("colspin")) , m_xRowNF(m_xBuilder->weld_spin_button("rowspin")) @@ -71,11 +75,7 @@ SwInsTableDlg::SwInsTableDlg(SwView& rView) , m_xDontSplitCB(m_xBuilder->weld_check_button("dontsplitcb")) , m_xInsertBtn(m_xBuilder->weld_button("ok")) , m_xLbFormat(m_xBuilder->weld_tree_view("formatlbinstable")) - , m_xWndPreview(new AutoFormatPreview(m_xBuilder->weld_drawing_area("previewinstable"))) - , m_aTextFilter(" .<>") - , pShell(&rView.GetWrtShell()) - , pTAutoFormat(nullptr) - , nEnteredValRepeatHeaderNF(-1) + , m_xWndPreview(new weld::CustomWeld(*m_xBuilder, "previewinstable", m_aWndPreview)) { const int nWidth = m_xLbFormat->get_approximate_digit_width() * 32; const int nHeight = m_xLbFormat->get_height_rows(8); @@ -124,7 +124,7 @@ SwInsTableDlg::SwInsTableDlg(SwView& rView) void SwInsTableDlg::InitAutoTableFormat() { - m_xWndPreview->DetectRTL(pShell); + m_aWndPreview.DetectRTL(pShell); m_xLbFormat->connect_changed(LINK(this, SwInsTableDlg, SelFormatHdl)); @@ -185,13 +185,13 @@ IMPL_LINK_NOARG(SwInsTableDlg, SelFormatHdl, weld::TreeView&, void) // To understand this index maping, look InitAutoTableFormat function to // see how listbox item is implemented. if( tbIndex < 255 ) - m_xWndPreview->NotifyChange( (*pTableTable)[tbIndex] ); + m_aWndPreview.NotifyChange( (*pTableTable)[tbIndex] ); else { SwTableAutoFormat aTmp( SwViewShell::GetShellRes()->aStrNone ); lcl_SetProperties( &aTmp, false ); - m_xWndPreview->NotifyChange( aTmp ); + m_aWndPreview.NotifyChange( aTmp ); } } diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx index c8d8b0fd2395..4c716726aafb 100644 --- a/sw/source/ui/table/tautofmt.cxx +++ b/sw/source/ui/table/tautofmt.cxx @@ -55,18 +55,6 @@ SwAutoFormatDlg::SwAutoFormatDlg(weld::Window* pParent, SwWrtShell* pWrtShell, bool bAutoFormat, const SwTableAutoFormat* pSelFormat) : GenericDialogController(pParent, "modules/swriter/ui/autoformattable.ui", "AutoFormatTableDialog") - , m_xLbFormat(m_xBuilder->weld_tree_view("formatlb")) - , m_xBtnNumFormat(m_xBuilder->weld_check_button("numformatcb")) - , m_xBtnBorder(m_xBuilder->weld_check_button("bordercb")) - , m_xBtnFont(m_xBuilder->weld_check_button("fontcb")) - , m_xBtnPattern(m_xBuilder->weld_check_button("patterncb")) - , m_xBtnAlignment(m_xBuilder->weld_check_button("alignmentcb")) - , m_xBtnCancel(m_xBuilder->weld_button("cancel")) - , m_xBtnAdd(m_xBuilder->weld_button("add")) - , m_xBtnRemove(m_xBuilder->weld_button("remove")) - , m_xBtnRename(m_xBuilder->weld_button("rename")) - , m_xWndPreview(new AutoFormatPreview(m_xBuilder->weld_drawing_area("preview"))) - , m_xTableTable(new SwTableAutoFormatTable) , m_aStrTitle(SwResId(STR_ADD_AUTOFORMAT_TITLE)) , m_aStrLabel(SwResId(STR_ADD_AUTOFORMAT_LABEL)) , m_aStrClose(SwResId(STR_BTN_AUTOFORMAT_CLOSE)) @@ -79,8 +67,20 @@ SwAutoFormatDlg::SwAutoFormatDlg(weld::Window* pParent, SwWrtShell* pWrtShell, , m_nDfltStylePos(0) , m_bCoreDataChanged(false) , m_bSetAutoFormat(bAutoFormat) + , m_xTableTable(new SwTableAutoFormatTable) + , m_xLbFormat(m_xBuilder->weld_tree_view("formatlb")) + , m_xBtnNumFormat(m_xBuilder->weld_check_button("numformatcb")) + , m_xBtnBorder(m_xBuilder->weld_check_button("bordercb")) + , m_xBtnFont(m_xBuilder->weld_check_button("fontcb")) + , m_xBtnPattern(m_xBuilder->weld_check_button("patterncb")) + , m_xBtnAlignment(m_xBuilder->weld_check_button("alignmentcb")) + , m_xBtnCancel(m_xBuilder->weld_button("cancel")) + , m_xBtnAdd(m_xBuilder->weld_button("add")) + , m_xBtnRemove(m_xBuilder->weld_button("remove")) + , m_xBtnRename(m_xBuilder->weld_button("rename")) + , m_xWndPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aWndPreview)) { - m_xWndPreview->DetectRTL(pWrtShell); + m_aWndPreview.DetectRTL(pWrtShell); m_xTableTable->Load(); const int nWidth = m_xLbFormat->get_approximate_digit_width() * 32; @@ -200,7 +200,7 @@ IMPL_LINK(SwAutoFormatDlg, CheckHdl, weld::ToggleButton&, rBtn, void) m_bCoreDataChanged = true; } - m_xWndPreview->NotifyChange(rData); + m_aWndPreview.NotifyChange(rData); } } @@ -369,7 +369,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, SelFormatHdl, weld::TreeView&, void) if (nSelPos >= m_nDfltStylePos) { m_nIndex = nSelPos - m_nDfltStylePos; - m_xWndPreview->NotifyChange((*m_xTableTable)[m_nIndex]); + m_aWndPreview.NotifyChange((*m_xTableTable)[m_nIndex]); bBtnEnable = 0 != m_nIndex; UpdateChecks( (*m_xTableTable)[m_nIndex], true ); } @@ -386,7 +386,7 @@ IMPL_LINK_NOARG(SwAutoFormatDlg, SelFormatHdl, weld::TreeView&, void) aTmp.SetWidthHeight( false ); if (nOldIdx != m_nIndex) - m_xWndPreview->NotifyChange(aTmp); + m_aWndPreview.NotifyChange(aTmp); UpdateChecks( aTmp, false ); } diff --git a/sw/source/uibase/inc/autoformatpreview.hxx b/sw/source/uibase/inc/autoformatpreview.hxx index c1e3b77c9f14..bf840d2f22c6 100644 --- a/sw/source/uibase/inc/autoformatpreview.hxx +++ b/sw/source/uibase/inc/autoformatpreview.hxx @@ -30,27 +30,22 @@ #include <vcl/vclptr.hxx> #include <vcl/virdev.hxx> #include <vcl/weld.hxx> +#include <vcl/customweld.hxx> #include <vcl/font.hxx> #include "wrtsh.hxx" #include <tblafmt.hxx> -class AutoFormatPreview +class AutoFormatPreview : public weld::CustomWidgetController { public: - AutoFormatPreview(weld::DrawingArea* pDrawingArea); + AutoFormatPreview(); void NotifyChange(const SwTableAutoFormat& rNewData); void DetectRTL(SwWrtShell const* pWrtShell); - void set_size_request(int nWidth, int nHeight) - { - mxDrawingArea->set_size_request(nWidth, nHeight); - } - private: - std::unique_ptr<weld::DrawingArea> mxDrawingArea; SwTableAutoFormat maCurrentData; svx::frame::Array maArray; /// Implementation to draw the frame borders. bool mbFitWidth; @@ -72,8 +67,8 @@ private: uno::Reference<i18n::XBreakIterator> m_xBreak; void Init(); - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual void Resize() override; void CalcCellArray(bool bFitWidth); void CalcLineMap(); void PaintCells(vcl::RenderContext& rRenderContext); diff --git a/sw/source/uibase/inc/envlop.hxx b/sw/source/uibase/inc/envlop.hxx index 4d1b640b2bd1..89ba397ed987 100644 --- a/sw/source/uibase/inc/envlop.hxx +++ b/sw/source/uibase/inc/envlop.hxx @@ -27,6 +27,7 @@ #include <vcl/lstbox.hxx> #include <vcl/button.hxx> #include <vcl/weld.hxx> +#include <vcl/customweld.hxx> #include "envimg.hxx" @@ -49,20 +50,17 @@ class SwEnvFormatPage; class SwWrtShell; class Printer; -class SwEnvPreview +class SwEnvPreview : public weld::CustomWidgetController { private: - std::unique_ptr<weld::DrawingArea> m_xDrawingArea; SwEnvDlg* m_pDialog; - 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& rRect) override; + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; public: - SwEnvPreview(weld::DrawingArea* pDrawingArea); + SwEnvPreview(); void SetDialog(SwEnvDlg* pDialog) { m_pDialog = pDialog; } - void queue_draw() { m_xDrawingArea->queue_draw(); } }; class SwEnvDlg : public SfxTabDialogController @@ -94,6 +92,7 @@ class SwEnvPage : public SfxTabPage SwWrtShell* m_pSh; OUString m_sActDBName; + SwEnvPreview m_aPreview; std::unique_ptr<weld::TextView> m_xAddrEdit; std::unique_ptr<weld::ComboBoxText> m_xDatabaseLB; std::unique_ptr<weld::ComboBoxText> m_xTableLB; @@ -101,7 +100,7 @@ class SwEnvPage : public SfxTabPage std::unique_ptr<weld::Button> m_xInsertBT; std::unique_ptr<weld::CheckButton> m_xSenderBox; std::unique_ptr<weld::TextView> m_xSenderEdit; - std::unique_ptr<SwEnvPreview> m_xPreview; + std::unique_ptr<weld::CustomWeld> m_xPreview; DECL_LINK(DatabaseHdl, weld::ComboBoxText&, void); DECL_LINK(FieldHdl, weld::Button&, void); diff --git a/sw/source/uibase/inc/instable.hxx b/sw/source/uibase/inc/instable.hxx index febda4e77613..3f1872fef089 100644 --- a/sw/source/uibase/inc/instable.hxx +++ b/sw/source/uibase/inc/instable.hxx @@ -37,17 +37,6 @@ class SwInsTableDlg : public weld::GenericDialogController { - std::unique_ptr<weld::Entry> m_xNameEdit; - std::unique_ptr<weld::SpinButton> m_xColNF; - std::unique_ptr<weld::SpinButton> m_xRowNF; - std::unique_ptr<weld::CheckButton> m_xHeaderCB; - std::unique_ptr<weld::CheckButton> m_xRepeatHeaderCB; - std::unique_ptr<weld::SpinButton> m_xRepeatHeaderNF; - std::unique_ptr<weld::Widget> m_xRepeatGroup; - std::unique_ptr<weld::CheckButton> m_xDontSplitCB; - std::unique_ptr<weld::Button> m_xInsertBtn; - std::unique_ptr<weld::TreeView> m_xLbFormat; - std::unique_ptr<AutoFormatPreview> m_xWndPreview; TextFilter m_aTextFilter; SwWrtShell* pShell; @@ -60,6 +49,20 @@ class SwInsTableDlg : public weld::GenericDialogController sal_uInt8 maxTableIndexInLb; sal_Int64 nEnteredValRepeatHeaderNF; + AutoFormatPreview m_aWndPreview; + + std::unique_ptr<weld::Entry> m_xNameEdit; + std::unique_ptr<weld::SpinButton> m_xColNF; + std::unique_ptr<weld::SpinButton> m_xRowNF; + std::unique_ptr<weld::CheckButton> m_xHeaderCB; + std::unique_ptr<weld::CheckButton> m_xRepeatHeaderCB; + std::unique_ptr<weld::SpinButton> m_xRepeatHeaderNF; + std::unique_ptr<weld::Widget> m_xRepeatGroup; + std::unique_ptr<weld::CheckButton> m_xDontSplitCB; + std::unique_ptr<weld::Button> m_xInsertBtn; + std::unique_ptr<weld::TreeView> m_xLbFormat; + std::unique_ptr<weld::CustomWeld> m_xWndPreview; + // Returns 255 if mapping is not possible. // This means there cannot be more than 255 autotable style. sal_uInt8 lbIndexToTableIndex( const sal_uInt8 listboxIndex ); diff --git a/sw/source/uibase/inc/num.hxx b/sw/source/uibase/inc/num.hxx index 6bedc870255f..f882c1d8ee3f 100644 --- a/sw/source/uibase/inc/num.hxx +++ b/sw/source/uibase/inc/num.hxx @@ -49,6 +49,8 @@ class SwNumPositionTabPage : public SfxTabPage bool bInInintControl : 1; // work around modify-error; should be resolved from 391 on bool bLabelAlignmentPosAndSpaceModeActive; + SwNumberingPreview m_aPreviewWIN; + std::unique_ptr<weld::TreeView> m_xLevelLB; std::unique_ptr<weld::Widget> m_xPositionFrame; @@ -77,7 +79,7 @@ class SwNumPositionTabPage : public SfxTabPage std::unique_ptr<weld::Label> m_xIndentAtFT; std::unique_ptr<weld::MetricSpinButton> m_xIndentAtMF; std::unique_ptr<weld::Button> m_xStandardPB; - std::unique_ptr<SwNumberingPreview> m_xPreviewWIN; + std::unique_ptr<weld::CustomWeld> m_xPreviewWIN; void InitControls(); @@ -119,10 +121,11 @@ public: void SetModified(); #else void SetModified() - { bModified = true; - m_xPreviewWIN->SetLevel(nActNumLvl); - m_xPreviewWIN->queue_draw(); - } + { + bModified = true; + m_aPreviewWIN.SetLevel(nActNumLvl); + m_aPreviewWIN.Invalidate(); + } #endif }; diff --git a/sw/source/uibase/inc/numprevw.hxx b/sw/source/uibase/inc/numprevw.hxx index b54bcf5ddbb1..44aa3ccc5e34 100644 --- a/sw/source/uibase/inc/numprevw.hxx +++ b/sw/source/uibase/inc/numprevw.hxx @@ -20,6 +20,7 @@ #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_NUMPREVW_HXX #define INCLUDED_SW_SOURCE_UIBASE_INC_NUMPREVW_HXX +#include <vcl/customweld.hxx> #include <vcl/window.hxx> class SwNumRule; @@ -59,10 +60,8 @@ class NumberingPreview : public vcl::Window }; -class SwNumberingPreview +class SwNumberingPreview : public weld::CustomWidgetController { - std::unique_ptr<weld::DrawingArea> m_xDrawingArea; - Size m_aSize; const SwNumRule* pActNum; vcl::Font aStdFont; long nPageWidth; @@ -71,31 +70,22 @@ class SwNumberingPreview sal_uInt16 nActLevel; private: - DECL_LINK(DoPaint, weld::DrawingArea::draw_args, void); - DECL_LINK(DoResize, const Size& rSize, void); + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; public: - SwNumberingPreview(weld::DrawingArea* pDrawingArea) - : m_xDrawingArea(pDrawingArea) - , pActNum(nullptr) + SwNumberingPreview() + : pActNum(nullptr) , nPageWidth(0) , pOutlineNames(nullptr) , bPosition(false) , nActLevel(USHRT_MAX) { - m_xDrawingArea->connect_size_allocate(LINK(this, SwNumberingPreview, DoResize)); - m_xDrawingArea->connect_draw(LINK(this, SwNumberingPreview, DoPaint)); - } - - void queue_draw() - { - m_xDrawingArea->queue_draw(); } void SetNumRule(const SwNumRule* pNum) { pActNum = pNum; - queue_draw(); + Invalidate(); } void SetPageWidth(long nPgWidth) @@ -105,10 +95,8 @@ public: void SetPositionMode() { bPosition = true;} void SetLevel(sal_uInt16 nSet) {nActLevel = nSet;} - }; - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/inc/outline.hxx b/sw/source/uibase/inc/outline.hxx index da5c0e94fddf..a9b8e6d5d529 100644 --- a/sw/source/uibase/inc/outline.hxx +++ b/sw/source/uibase/inc/outline.hxx @@ -84,6 +84,7 @@ class SwOutlineSettingsTabPage : public SfxTabPage SwNumRule* pNumRule; OUString* pCollNames; sal_uInt16 nActLevel; + SwNumberingPreview m_aPreviewWIN; std::unique_ptr<weld::TreeView> m_xLevelLB; std::unique_ptr<weld::ComboBoxText> m_xCollBox; @@ -94,7 +95,7 @@ class SwOutlineSettingsTabPage : public SfxTabPage std::unique_ptr<weld::Entry> m_xPrefixED; std::unique_ptr<weld::Entry> m_xSuffixED; std::unique_ptr<weld::SpinButton> m_xStartEdit; - std::unique_ptr<SwNumberingPreview> m_xPreviewWIN; + std::unique_ptr<weld::CustomWeld> m_xPreviewWIN; DECL_LINK( LevelHdl, weld::TreeView&, void ); DECL_LINK( ToggleComplete, weld::SpinButton&, void ); @@ -107,7 +108,7 @@ class SwOutlineSettingsTabPage : public SfxTabPage void Update(); - void SetModified() { m_xPreviewWIN->queue_draw(); } + void SetModified() { m_aPreviewWIN.Invalidate(); } void CheckForStartValue_Impl(sal_uInt16 nNumberingType); using SfxTabPage::ActivatePage; @@ -129,7 +130,7 @@ public: void SetNumRule(SwNumRule *pRule) { pNumRule = pRule; - m_xPreviewWIN->SetNumRule(pNumRule); + m_aPreviewWIN.SetNumRule(pNumRule); } }; diff --git a/sw/source/uibase/inc/tautofmt.hxx b/sw/source/uibase/inc/tautofmt.hxx index 137d08d0c1dc..59f80d722f69 100644 --- a/sw/source/uibase/inc/tautofmt.hxx +++ b/sw/source/uibase/inc/tautofmt.hxx @@ -37,18 +37,6 @@ enum AutoFormatLine { TOP_LINE, BOTTOM_LINE, LEFT_LINE, RIGHT_LINE }; class SwAutoFormatDlg : public weld::GenericDialogController { - std::unique_ptr<weld::TreeView> m_xLbFormat; - std::unique_ptr<weld::CheckButton> m_xBtnNumFormat; - std::unique_ptr<weld::CheckButton> m_xBtnBorder; - std::unique_ptr<weld::CheckButton> m_xBtnFont; - std::unique_ptr<weld::CheckButton> m_xBtnPattern; - std::unique_ptr<weld::CheckButton> m_xBtnAlignment; - std::unique_ptr<weld::Button> m_xBtnCancel; - std::unique_ptr<weld::Button> m_xBtnAdd; - std::unique_ptr<weld::Button> m_xBtnRemove; - std::unique_ptr<weld::Button> m_xBtnRename; - std::unique_ptr<AutoFormatPreview> m_xWndPreview; - std::unique_ptr<SwTableAutoFormatTable> m_xTableTable; OUString m_aStrTitle; OUString m_aStrLabel; OUString m_aStrClose; @@ -63,6 +51,21 @@ class SwAutoFormatDlg : public weld::GenericDialogController bool m_bCoreDataChanged : 1; bool m_bSetAutoFormat : 1; + AutoFormatPreview m_aWndPreview; + std::unique_ptr<SwTableAutoFormatTable> m_xTableTable; + + std::unique_ptr<weld::TreeView> m_xLbFormat; + std::unique_ptr<weld::CheckButton> m_xBtnNumFormat; + std::unique_ptr<weld::CheckButton> m_xBtnBorder; + std::unique_ptr<weld::CheckButton> m_xBtnFont; + std::unique_ptr<weld::CheckButton> m_xBtnPattern; + std::unique_ptr<weld::CheckButton> m_xBtnAlignment; + std::unique_ptr<weld::Button> m_xBtnCancel; + std::unique_ptr<weld::Button> m_xBtnAdd; + std::unique_ptr<weld::Button> m_xBtnRemove; + std::unique_ptr<weld::Button> m_xBtnRename; + std::unique_ptr<weld::CustomWeld> m_xWndPreview; + void Init( const SwTableAutoFormat* pSelFormat ); void UpdateChecks( const SwTableAutoFormat&, bool bEnableBtn ); diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index 8ea16175dc55..38a2460cf81f 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -352,6 +352,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/source/helper/strhelper \ vcl/source/helper/threadex \ vcl/source/app/brand \ + vcl/source/app/customweld \ vcl/source/app/dbggui \ vcl/source/app/dndhelp \ vcl/source/app/help \ diff --git a/vcl/source/app/customweld.cxx b/vcl/source/app/customweld.cxx new file mode 100644 index 000000000000..706d3992304e --- /dev/null +++ b/vcl/source/app/customweld.cxx @@ -0,0 +1,82 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <vcl/customweld.hxx> + +namespace weld +{ +CustomWidgetController::~CustomWidgetController() {} + +CustomWeld::CustomWeld(weld::Builder& rBuilder, const OString& rDrawingId, + CustomWidgetController& rWidgetController) + : m_rWidgetController(rWidgetController) + , m_xDrawingArea(rBuilder.weld_drawing_area(rDrawingId, rWidgetController.CreateAccessible(), + rWidgetController.GetUITestFactory(), + &rWidgetController)) +{ + m_xDrawingArea->connect_size_allocate(LINK(this, CustomWeld, DoResize)); + m_xDrawingArea->connect_draw(LINK(this, CustomWeld, DoPaint)); + m_xDrawingArea->connect_mouse_press(LINK(this, CustomWeld, DoMouseButtonDown)); + m_xDrawingArea->connect_mouse_move(LINK(this, CustomWeld, DoMouseMove)); + m_xDrawingArea->connect_mouse_release(LINK(this, CustomWeld, DoMouseButtonUp)); + m_xDrawingArea->connect_focus_in(LINK(this, CustomWeld, DoGetFocus)); + m_xDrawingArea->connect_focus_out(LINK(this, CustomWeld, DoLoseFocus)); + m_xDrawingArea->connect_key_press(LINK(this, CustomWeld, DoKeyPress)); + m_xDrawingArea->connect_focus_rect(LINK(this, CustomWeld, DoFocusRect)); + m_xDrawingArea->connect_style_updated(LINK(this, CustomWeld, DoStyleUpdated)); + m_rWidgetController.SetDrawingArea(m_xDrawingArea.get()); +} + +IMPL_LINK(CustomWeld, DoResize, const Size&, rSize, void) +{ + m_rWidgetController.SetOutputSizePixel(rSize); + m_rWidgetController.Resize(); +} + +IMPL_LINK(CustomWeld, DoPaint, weld::DrawingArea::draw_args, aPayload, void) +{ + m_rWidgetController.Paint(aPayload.first, aPayload.second); +} + +IMPL_LINK(CustomWeld, DoMouseButtonDown, const MouseEvent&, rMEvt, void) +{ + m_rWidgetController.MouseButtonDown(rMEvt); +} + +IMPL_LINK(CustomWeld, DoMouseMove, const MouseEvent&, rMEvt, void) +{ + m_rWidgetController.MouseMove(rMEvt); +} + +IMPL_LINK(CustomWeld, DoMouseButtonUp, const MouseEvent&, rMEvt, void) +{ + m_rWidgetController.MouseButtonUp(rMEvt); +} + +IMPL_LINK_NOARG(CustomWeld, DoGetFocus, weld::Widget&, void) { m_rWidgetController.GetFocus(); } + +IMPL_LINK_NOARG(CustomWeld, DoLoseFocus, weld::Widget&, void) { m_rWidgetController.LoseFocus(); } + +IMPL_LINK(CustomWeld, DoKeyPress, const KeyEvent&, rKEvt, bool) +{ + return m_rWidgetController.KeyInput(rKEvt); +} + +IMPL_LINK_NOARG(CustomWeld, DoFocusRect, weld::Widget&, tools::Rectangle) +{ + return m_rWidgetController.GetFocusRect(); +} + +IMPL_LINK_NOARG(CustomWeld, DoStyleUpdated, weld::Widget&, void) +{ + m_rWidgetController.StyleUpdated(); +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |