summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-02-12 21:17:48 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-02-13 14:52:16 +0100
commitbcd7eee9e074be5ffe153814664c8f0faf923f6b (patch)
tree8325feda9ee24245bff5e440b1266352af85bcfa /sc
parent420e5a9ced6ad64ad3f81e3441c629b7076a776d (diff)
weld ScZoomSliderWnd ItemWindow
Change-Id: I50ab530f24770dcb4df174e2a379b0d14d76b253 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88573 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r--sc/UIConfig_scalc.mk1
-rw-r--r--sc/source/ui/cctrl/tbzoomsliderctrl.cxx62
-rw-r--r--sc/source/ui/inc/tbzoomsliderctrl.hxx31
-rw-r--r--sc/uiconfig/scalc/ui/zoombox.ui25
4 files changed, 90 insertions, 29 deletions
diff --git a/sc/UIConfig_scalc.mk b/sc/UIConfig_scalc.mk
index 466402c958b7..7268ec8013f7 100644
--- a/sc/UIConfig_scalc.mk
+++ b/sc/UIConfig_scalc.mk
@@ -243,6 +243,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/validationcriteriapage \
sc/uiconfig/scalc/ui/validationhelptabpage \
sc/uiconfig/scalc/ui/xmlsourcedialog \
+ sc/uiconfig/scalc/ui/zoombox \
sc/uiconfig/scalc/ui/ztestdialog \
))
diff --git a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
index 94de56024b03..7ff3c26035c6 100644
--- a/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
+++ b/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
@@ -79,13 +79,13 @@ VclPtr<vcl::Window> ScZoomSliderControl::CreateItemWindow( vcl::Window *pParent
{
// #i98000# Don't try to get a value via SfxViewFrame::Current here.
// The view's value is always notified via StateChanged later.
- VclPtrInstance<ScZoomSliderWnd> pSlider( pParent,
+ VclPtrInstance<ScZoomSliderWnd> xSlider( pParent,
css::uno::Reference< css::frame::XDispatchProvider >( m_xFrame->getController(),
css::uno::UNO_QUERY ), 100 );
- return pSlider.get();
+ return xSlider;
}
-struct ScZoomSliderWnd::ScZoomSliderWnd_Impl
+struct ScZoomSlider::ScZoomSliderWnd_Impl
{
sal_uInt16 mnCurrentZoom;
sal_uInt16 mnMinZoom;
@@ -124,7 +124,7 @@ const long nSliderXOffset = 20;
const long nSnappingEpsilon = 5; // snapping epsilon in pixels
const long nSnappingPointsMinDist = nSnappingEpsilon; // minimum distance of two adjacent snapping points
-sal_uInt16 ScZoomSliderWnd::Offset2Zoom( long nOffset ) const
+sal_uInt16 ScZoomSlider::Offset2Zoom( long nOffset ) const
{
Size aSliderWindowSize = GetOutputSizePixel();
const long nControlWidth = aSliderWindowSize.Width();
@@ -176,7 +176,7 @@ sal_uInt16 ScZoomSliderWnd::Offset2Zoom( long nOffset ) const
return nRet;
}
-long ScZoomSliderWnd::Zoom2Offset( sal_uInt16 nCurrentZoom ) const
+long ScZoomSlider::Zoom2Offset( sal_uInt16 nCurrentZoom ) const
{
Size aSliderWindowSize = GetOutputSizePixel();
const long nControlWidth = aSliderWindowSize.Width();
@@ -205,16 +205,16 @@ long ScZoomSliderWnd::Zoom2Offset( sal_uInt16 nCurrentZoom ) const
ScZoomSliderWnd::ScZoomSliderWnd( vcl::Window* pParent,
const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider,
sal_uInt16 nCurrentZoom ):
- Window( pParent ),
- mpImpl( new ScZoomSliderWnd_Impl( nCurrentZoom ) ),
- aLogicalSize( 115, 40 ),
- m_xDispatchProvider( rDispatchProvider )
+ InterimItemWindow(pParent, "modules/scalc/ui/zoombox.ui", "ZoomBox"),
+ mxWidget(new ScZoomSlider(rDispatchProvider, nCurrentZoom)),
+ mxWeld(new weld::CustomWeld(*m_xBuilder, "zoom", *mxWidget)),
+ aLogicalSize( 115, 40 )
{
- mpImpl->maSliderButton = Image(StockImage::Yes, RID_SVXBMP_SLIDERBUTTON);
- mpImpl->maIncreaseButton = Image(StockImage::Yes, RID_SVXBMP_SLIDERINCREASE);
- mpImpl->maDecreaseButton = Image(StockImage::Yes, RID_SVXBMP_SLIDERDECREASE);
- Size aSliderSize = LogicToPixel( aLogicalSize, MapMode( MapUnit::Map10thMM ) );
- SetSizePixel( Size( aSliderSize.Width() * nSliderWidth-1, aSliderSize.Height() + nSliderHeight ) );
+ Size aSliderSize = LogicToPixel(aLogicalSize, MapMode(MapUnit::Map10thMM));
+ Size aPreferredSize(aSliderSize.Width() * nSliderWidth-1, aSliderSize.Height() + nSliderHeight);
+ mxWidget->GetDrawingArea()->set_size_request(aPreferredSize.Width(), aPreferredSize.Height());
+ mxWidget->SetOutputSizePixel(aPreferredSize);
+ SetSizePixel(aPreferredSize);
}
ScZoomSliderWnd::~ScZoomSliderWnd()
@@ -224,11 +224,22 @@ ScZoomSliderWnd::~ScZoomSliderWnd()
void ScZoomSliderWnd::dispose()
{
- mpImpl.reset();
- vcl::Window::dispose();
+ mxWeld.reset();
+ mxWidget.reset();
+ InterimItemWindow::dispose();
+}
+
+ScZoomSlider::ScZoomSlider(const css::uno::Reference< css::frame::XDispatchProvider>& rDispatchProvider,
+ sal_uInt16 nCurrentZoom)
+ : mpImpl(new ScZoomSliderWnd_Impl(nCurrentZoom))
+ , m_xDispatchProvider(rDispatchProvider)
+{
+ mpImpl->maSliderButton = Image(StockImage::Yes, RID_SVXBMP_SLIDERBUTTON);
+ mpImpl->maIncreaseButton = Image(StockImage::Yes, RID_SVXBMP_SLIDERINCREASE);
+ mpImpl->maDecreaseButton = Image(StockImage::Yes, RID_SVXBMP_SLIDERDECREASE);
}
-void ScZoomSliderWnd::MouseButtonDown( const MouseEvent& rMEvt )
+bool ScZoomSlider::MouseButtonDown( const MouseEvent& rMEvt )
{
Size aSliderWindowSize = GetOutputSizePixel();
@@ -261,7 +272,7 @@ void ScZoomSliderWnd::MouseButtonDown( const MouseEvent& rMEvt )
mpImpl->mnCurrentZoom = mpImpl->mnMaxZoom;
if( nOldZoom == mpImpl->mnCurrentZoom )
- return ;
+ return true;
tools::Rectangle aRect( Point( 0, 0 ), aSliderWindowSize );
@@ -280,9 +291,11 @@ void ScZoomSliderWnd::MouseButtonDown( const MouseEvent& rMEvt )
SfxToolBoxControl::Dispatch( m_xDispatchProvider, ".uno:ScalingFactor", aArgs );
mpImpl->mbOmitPaint = false;
+
+ return true;
}
-void ScZoomSliderWnd::MouseMove( const MouseEvent& rMEvt )
+bool ScZoomSlider::MouseMove( const MouseEvent& rMEvt )
{
Size aSliderWindowSize = GetOutputSizePixel();
const long nControlWidth = aSliderWindowSize.Width();
@@ -317,10 +330,17 @@ void ScZoomSliderWnd::MouseMove( const MouseEvent& rMEvt )
mpImpl->mbOmitPaint = false;
}
}
+
+ return false;
}
void ScZoomSliderWnd::UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem )
{
+ mxWidget->UpdateFromItem(pZoomSliderItem);
+}
+
+void ScZoomSlider::UpdateFromItem(const SvxZoomSliderItem* pZoomSliderItem)
+{
if( pZoomSliderItem )
{
mpImpl->mnCurrentZoom = pZoomSliderItem->GetValue();
@@ -364,12 +384,12 @@ void ScZoomSliderWnd::UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem )
Invalidate(aRect);
}
-void ScZoomSliderWnd::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/)
+void ScZoomSlider::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/)
{
DoPaint(rRenderContext);
}
-void ScZoomSliderWnd::DoPaint(vcl::RenderContext& rRenderContext)
+void ScZoomSlider::DoPaint(vcl::RenderContext& rRenderContext)
{
if (mpImpl->mbOmitPaint)
return;
diff --git a/sc/source/ui/inc/tbzoomsliderctrl.hxx b/sc/source/ui/inc/tbzoomsliderctrl.hxx
index 2b664bf4dd16..d12de0f29294 100644
--- a/sc/source/ui/inc/tbzoomsliderctrl.hxx
+++ b/sc/source/ui/inc/tbzoomsliderctrl.hxx
@@ -19,8 +19,10 @@
#ifndef INCLUDED_SC_SOURCE_UI_INC_TBZOOMSLIDERCTRL_HXX
#define INCLUDED_SC_SOURCE_UI_INC_TBZOOMSLIDERCTRL_HXX
+#include <vcl/customweld.hxx>
#include <vcl/window.hxx>
#include <svl/poolitem.hxx>
+#include <sfx2/InterimItemWindow.hxx>
#include <sfx2/tbxctrl.hxx>
namespace com { namespace sun { namespace star { namespace frame { class XDispatchProvider; } } } }
@@ -38,30 +40,43 @@ public:
virtual VclPtr<vcl::Window> CreateItemWindow( vcl::Window *pParent ) override;
};
-class ScZoomSliderWnd: public vcl::Window
+class ScZoomSlider final : public weld::CustomWidgetController
{
private:
struct ScZoomSliderWnd_Impl;
std::unique_ptr<ScZoomSliderWnd_Impl> mpImpl;
- Size const aLogicalSize;
css::uno::Reference<css::frame::XDispatchProvider> m_xDispatchProvider;
sal_uInt16 Offset2Zoom(long nOffset) const;
long Zoom2Offset(sal_uInt16 nZoom) const;
+
void DoPaint(vcl::RenderContext& rRenderContext);
+public:
+ ScZoomSlider(const css::uno::Reference<css::frame::XDispatchProvider>& rDispatchProvider,
+ sal_uInt16 nCurrentZoom);
+
+ void UpdateFromItem(const SvxZoomSliderItem* pZoomSliderItem);
+
+ virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
+ virtual bool MouseMove( const MouseEvent& rMEvt ) override;
+ virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
+};
+
+class ScZoomSliderWnd final : public InterimItemWindow
+{
+private:
+ std::unique_ptr<ScZoomSlider> mxWidget;
+ std::unique_ptr<weld::CustomWeld> mxWeld;
+ Size const aLogicalSize;
public:
- ScZoomSliderWnd(vcl::Window* pParent, const css::uno::Reference<css::frame::XDispatchProvider >& rDispatchProvider,
+ ScZoomSliderWnd(vcl::Window* pParent, const css::uno::Reference<css::frame::XDispatchProvider>& rDispatchProvider,
sal_uInt16 nCurrentZoom);
virtual ~ScZoomSliderWnd() override;
virtual void dispose() override;
void UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem );
-
-protected:
- virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
- virtual void MouseMove( const MouseEvent& rMEvt ) override;
- virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/uiconfig/scalc/ui/zoombox.ui b/sc/uiconfig/scalc/ui/zoombox.ui
new file mode 100644
index 000000000000..7cbea01705aa
--- /dev/null
+++ b/sc/uiconfig/scalc/ui/zoombox.ui
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="sc">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkBox" id="ZoomBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkDrawingArea" id="zoom">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_FOCUS_CHANGE_MASK | GDK_STRUCTURE_MASK</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>