diff options
Diffstat (limited to 'sw/source/core/crsr/FormFieldButton.cxx')
-rw-r--r-- | sw/source/core/crsr/FormFieldButton.cxx | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/sw/source/core/crsr/FormFieldButton.cxx b/sw/source/core/crsr/FormFieldButton.cxx index 8ae84826a3f9..319dcdb9c0dd 100644 --- a/sw/source/core/crsr/FormFieldButton.cxx +++ b/sw/source/core/crsr/FormFieldButton.cxx @@ -10,8 +10,8 @@ #include <DropDownFormFieldButton.hxx> #include <edtwin.hxx> #include <basegfx/color/bcolortools.hxx> -#include <bookmrk.hxx> -#include <vcl/floatwin.hxx> +#include <bookmark.hxx> +#include <vcl/weldutils.hxx> #include <vcl/event.hxx> FormFieldButton::FormFieldButton(SwEditWin* pEditWin, sw::mark::Fieldmark& rFieldmark) @@ -29,9 +29,24 @@ FormFieldButton::FormFieldButton(SwEditWin* pEditWin, sw::mark::Fieldmark& rFiel FormFieldButton::~FormFieldButton() { disposeOnce(); } +void FormFieldButton::LaunchPopup() +{ + m_xFieldPopup->connect_closed(LINK(this, DropDownFormFieldButton, FieldPopupModeEndHdl)); + + tools::Rectangle aRect(Point(0, 0), GetSizePixel()); + weld::Window* pParent = weld::GetPopupParent(*this, aRect); + m_xFieldPopup->popup_at_rect(pParent, aRect); +} + +void FormFieldButton::DestroyPopup() +{ + m_xFieldPopup.reset(); + m_xFieldPopupBuilder.reset(); +} + void FormFieldButton::dispose() { - m_pFieldPopup.disposeAndClear(); + DestroyPopup(); Control::dispose(); } @@ -63,23 +78,13 @@ void FormFieldButton::CalcPosAndSize(const SwRect& rPortionPaintArea) void FormFieldButton::MouseButtonDown(const MouseEvent&) { - assert(GetParent()); - - // sets m_pFieldPopup - InitPopup(); - - m_pFieldPopup->SetPopupModeEndHdl(LINK(this, DropDownFormFieldButton, FieldPopupModeEndHdl)); - - Size aSize = GetSizePixel(); - Point aPos(GetParent()->OutputToScreenPixel(GetPosPixel())); - tools::Rectangle aRect(aPos, aSize); - m_pFieldPopup->StartPopupMode(aRect, FloatWinPopupFlags::Down | FloatWinPopupFlags::GrabFocus); + LaunchPopup(); Invalidate(); } -IMPL_LINK_NOARG(FormFieldButton, FieldPopupModeEndHdl, FloatingWindow*, void) +IMPL_LINK_NOARG(FormFieldButton, FieldPopupModeEndHdl, weld::Popover&, void) { - m_pFieldPopup.disposeAndClear(); + DestroyPopup(); m_rFieldmark.Invalidate(); // Hide the button here and make it visible later, to make transparent background work with SAL_USE_VCLPLUGIN=gen Show(false); @@ -99,7 +104,7 @@ void FormFieldButton::Paint(vcl::RenderContext& rRenderContext, const tools::Rec //const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); Color aLineColor = COL_BLACK; - Color aFillColor(lcl_GetFillColor(aLineColor.getBColor(), (m_pFieldPopup ? 0.5 : 0.75))); + Color aFillColor(lcl_GetFillColor(aLineColor.getBColor(), (m_xFieldPopup ? 0.5 : 0.75))); // Draw the frame around the field // GTK3 backend cuts down the frame's top and left border, to avoid that add a padding around the frame @@ -116,7 +121,7 @@ void FormFieldButton::Paint(vcl::RenderContext& rRenderContext, const tools::Rec Point aButtonPos(aFrameRect.TopLeft()); aButtonPos.AdjustX(aFrameRect.GetSize().getWidth() - 1); Size aButtonSize(aFrameRect.GetSize()); - aButtonSize.setWidth(GetSizePixel().getWidth() - aFrameRect.getWidth() - nPadding); + aButtonSize.setWidth(GetSizePixel().getWidth() - aFrameRect.getOpenWidth() - nPadding); const tools::Rectangle aButtonRect(tools::Rectangle(aButtonPos, aButtonSize)); // Background & border |