31#include <bitmaps.hlst>
33#include <com/sun/star/frame/XFrame.hpp>
34#include <com/sun/star/frame/XDispatchProvider.hpp>
60 OSL_ENSURE( pBox ,
"Control not found!" );
62 if ( SfxItemState::DEFAULT != eState || pState->
IsVoidItem() )
71 OSL_ENSURE(
dynamic_cast<const SvxZoomSliderItem*
>( pState) !=
nullptr,
"invalid item type" );
74 OSL_ENSURE( pZoomSliderItem,
"Sc::ScZoomSliderControl::StateChanged(), wrong item type!" );
85 css::uno::Reference< css::frame::XDispatchProvider >(
m_xFrame->getController(),
86 css::uno::UNO_QUERY ), 100 );
116 [nOffset](
const tools::Long nCurrent) { return std::abs(nCurrent - nOffset) < nSnappingEpsilon; });
119 nOffset = *aSnappingPointIter;
126 if( nOffset < nControlWidth / 2 )
131 const tools::Long nZoomPerSliderPixel = (1000 * nFirstHalfRange) / nHalfSliderWidth;
133 nRet =
mnMinZoom + sal_uInt16( nOffsetToSliderLeft * nZoomPerSliderPixel / 1000 );
140 const tools::Long nZoomPerSliderPixel = 1000 * nSecondHalfRange / nHalfSliderWidth;
141 const tools::Long nOffsetToSliderCenter = nOffset - nControlWidth/2;
142 nRet =
gnSliderCenter + sal_uInt16( nOffsetToSliderCenter * nZoomPerSliderPixel / 1000 );
166 const tools::Long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nFirstHalfRange;
167 const tools::Long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
174 const tools::Long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nSecondHalfRange;
175 const tools::Long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
176 nRect += nHalfSliderWidth + nOffset;
182 const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider,
183 sal_uInt16 nCurrentZoom ):
185 mxWidget(new
ScZoomSlider(rDispatchProvider, nCurrentZoom)),
186 mxWeld(new
weld::CustomWeld(*m_xBuilder,
"zoom", *mxWidget))
188 Size aLogicalSize( 115, 40 );
191 mxWidget->GetDrawingArea()->set_size_request(aPreferredSize.
Width(), aPreferredSize.
Height());
192 mxWidget->SetOutputSizePixel(aPreferredSize);
209 sal_uInt16 nCurrentZoom)
210 : mnCurrentZoom( nCurrentZoom ),
213 mbOmitPaint( false ),
214 m_xDispatchProvider(
std::move(xDispatchProvider))
234 if ( aPoint.
X() >= nButtonLeftOffset && aPoint.
X() <= nButtonRightOffset )
315 mxWidget->UpdateFromItem(pZoomSliderItem);
320 if( pZoomSliderItem )
330 "Looks like the zoom slider item is corrupted" );
331 const css::uno::Sequence < sal_Int32 >& rSnappingPoints = pZoomSliderItem->
GetSnappingPoints();
336 std::set< sal_uInt16 > aTmpSnappingPoints;
337 std::transform(rSnappingPoints.begin(), rSnappingPoints.end(), std::inserter(aTmpSnappingPoints, aTmpSnappingPoints.end()),
338 [](
const sal_Int32 nSnappingPoint) -> sal_uInt16 { return static_cast<sal_uInt16>(nSnappingPoint); });
343 for (
const sal_uInt16 nCurrent : aTmpSnappingPoints )
351 nLastOffset = nCurrentOffset;
377 pVDev->SetOutputSizePixel(aSliderWindowSize);
403 aStartColor = aEndColor;
407 aGradient.
SetStyle(css::awt::GradientStyle_LINEAR);
411 pVDev->DrawGradient(aRect, aGradient);
415 pVDev->DrawRect(aSecondLine);
416 pVDev->DrawRect(aRight);
419 pVDev->DrawRect(aFirstLine);
420 pVDev->DrawRect(aLeft);
431 pVDev->DrawRect(aSnapping);
435 pVDev->DrawRect(aSnapping);
455 rRenderContext.
DrawOutDev(
Point(0, 0), aSliderWindowSize,
Point(0, 0), aSliderWindowSize, *pVDev);
css::uno::Reference< css::lang::XComponent > m_xFrame
const StyleSettings & GetStyleSettings() const
void SetStyle(css::awt::GradientStyle eStyle)
void SetStartColor(const Color &rColor)
void SetAngle(Degree10 nAngle)
void SetEndColor(const Color &rColor)
virtual void dispose() override
sal_uInt16 GetButtons() const
const Point & GetPosPixel() const
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
const AllSettings & GetSettings() const
void setX(tools::Long nX)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
virtual ~ScZoomSliderControl() override
ScZoomSliderControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox &rTbx)
virtual VclPtr< InterimItemWindow > CreateItemWindow(vcl::Window *pParent) override
void UpdateFromItem(const SvxZoomSliderItem *pZoomSliderItem)
std::unique_ptr< weld::CustomWeld > mxWeld
virtual void dispose() override
std::unique_ptr< ScZoomSlider > mxWidget
ScZoomSliderWnd(vcl::Window *pParent, const css::uno::Reference< css::frame::XDispatchProvider > &rDispatchProvider, sal_uInt16 nCurrentZoom)
virtual ~ScZoomSliderWnd() override
void DoPaint(vcl::RenderContext &rRenderContext)
std::vector< sal_uInt16 > maSnappingPointZooms
virtual bool MouseMove(const MouseEvent &rMEvt) override
sal_uInt16 Offset2Zoom(tools::Long nOffset) const
ScZoomSlider(css::uno::Reference< css::frame::XDispatchProvider > xDispatchProvider, sal_uInt16 nCurrentZoom)
css::uno::Reference< css::frame::XDispatchProvider > m_xDispatchProvider
std::vector< tools::Long > maSnappingPointOffsets
void UpdateFromItem(const SvxZoomSliderItem *pZoomSliderItem)
tools::Long Zoom2Offset(sal_uInt16 nZoom) const
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
virtual bool IsVoidItem() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
const Color & GetFaceColor() const
sal_uInt16 GetMaxZoom() const
const css::uno::Sequence< sal_Int32 > & GetSnappingPoints() const
sal_uInt16 GetMinZoom() const
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
Point LogicToPixel(const Point &rLogicPt) const
virtual void SetSizePixel(const Size &rNewSize)
void Disable(bool bChild=true)
void Enable(bool bEnable=true, bool bChild=true)
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
constexpr ::Color COL_GRAY(0x80, 0x80, 0x80)
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
const tools::Long nSnappingEpsilon
const tools::Long nSnappingPointsMinDist
const tools::Long nSliderXOffset
const tools::Long nSnappingHeight
const tools::Long nSliderHeight
constexpr sal_uInt16 gnSliderCenter(100)
const tools::Long nIncDecHeight
SFX_IMPL_TOOLBOX_CONTROL(ScZoomSliderControl, SvxZoomSliderItem)
const tools::Long nIncDecWidth
const tools::Long nButtonHeight
const tools::Long nButtonWidth
const tools::Long nSliderWidth