29 #include <svx/strings.hrc>
31 #include <bitmaps.hlst>
32 #include <com/sun/star/beans/PropertyValue.hpp>
57 maSnappingPointOffsets(),
58 maSnappingPointZooms(),
63 mbDraggingStarted( false ) {}
74 const tools::Long nControlWidth = getControlRect().GetWidth();
90 nRet =
mxImpl->maSnappingPointZooms[ nCount ];
98 if ( nOffset < nControlWidth / 2 )
103 const tools::Long nZoomPerSliderPixel = (1000 * nFirstHalfRange) / nHalfSliderWidth;
105 nRet =
mxImpl->mnMinZoom + sal_uInt16( nOffsetToSliderLeft * nZoomPerSliderPixel / 1000 );
112 const tools::Long nZoomPerSliderPixel = 1000 * nSecondHalfRange / nHalfSliderWidth;
113 const tools::Long nOffsetToSliderCenter = nOffset - nControlWidth/2;
114 nRet =
mxImpl->mnSliderCenter + sal_uInt16( nOffsetToSliderCenter * nZoomPerSliderPixel / 1000 );
118 if ( nRet < mxImpl->mnMinZoom )
120 else if ( nRet >
mxImpl->mnMaxZoom )
129 const tools::Long nControlWidth = getControlRect().GetWidth();
134 if ( nCurrentZoom <= mxImpl->mnSliderCenter )
136 nCurrentZoom = nCurrentZoom -
mxImpl->mnMinZoom;
138 const tools::Long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nFirstHalfRange;
139 const tools::Long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
144 nCurrentZoom = nCurrentZoom -
mxImpl->mnSliderCenter;
146 const tools::Long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nSecondHalfRange;
147 const tools::Long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
148 nRet += nHalfSliderWidth + nOffset;
158 mxImpl->maSliderButton =
Image(StockImage::Yes, RID_SVXBMP_SLIDERBUTTON);
159 mxImpl->maIncreaseButton =
Image(StockImage::Yes, RID_SVXBMP_SLIDERINCREASE);
160 mxImpl->maDecreaseButton =
Image(StockImage::Yes, RID_SVXBMP_SLIDERDECREASE);
169 if ( (SfxItemState::DEFAULT != eState) || pState->
IsVoidItem() )
172 mxImpl->mbValuesSet =
false;
176 OSL_ENSURE( dynamic_cast<const SvxZoomSliderItem*>( pState) !=
nullptr,
"invalid item type: should be a SvxZoomSliderItem" );
180 mxImpl->mnSliderCenter= 100;
181 mxImpl->mbValuesSet =
true;
184 mxImpl->mnSliderCenter =
mxImpl->mnMinZoom +
static_cast<sal_uInt16
>((
mxImpl->mnMaxZoom -
mxImpl->mnMinZoom) * 0.5);
191 "Looks like the zoom slider item is corrupted" );
193 const css::uno::Sequence < sal_Int32 > rSnappingPoints =
static_cast<const SvxZoomSliderItem*
>( pState )->GetSnappingPoints();
194 mxImpl->maSnappingPointOffsets.clear();
195 mxImpl->maSnappingPointZooms.clear();
198 std::set< sal_uInt16 > aTmpSnappingPoints;
199 for (
const sal_Int32 nSnappingPoint : rSnappingPoints )
201 aTmpSnappingPoints.insert( static_cast<sal_uInt16>(nSnappingPoint) );
207 for (
const sal_uInt16 nCurrent : aTmpSnappingPoints )
213 mxImpl->maSnappingPointOffsets.push_back( nCurrentOffset );
214 mxImpl->maSnappingPointZooms.push_back( nCurrent );
215 nLastOffset = nCurrentOffset;
225 if ( !
mxImpl->mbValuesSet )
256 for (
const auto& rSnappingPoint :
mxImpl->maSnappingPointOffsets )
261 nSnapPosX, aSlider.
Bottom() + nSnappingHeight ) );
267 aImagePoint.AdjustX( -(
mxImpl->maSliderButton.GetSizePixel().Width()/2) );
268 aImagePoint.AdjustY((aControlRect.
GetHeight() -
mxImpl->maSliderButton.GetSizePixel().Height())/2 );
274 aImagePoint.AdjustY((aControlRect.
GetHeight() -
mxImpl->maDecreaseButton.GetSizePixel().Height())/2 );
287 if ( !
mxImpl->mbValuesSet )
292 const sal_Int32 nXDiff = aPoint.X() - aControlRect.
Left();
302 if ( nXDiff >= nButtonLeftOffset && nXDiff <= nButtonRightOffset )
312 mxImpl->mbDraggingStarted =
true;
320 if ( nOldZoom ==
mxImpl->mnCurrentZoom )
330 mxImpl->mbDraggingStarted =
false;
336 if ( !
mxImpl->mbValuesSet )
342 const sal_Int32 nXDiff = aPoint.X() - aControlRect.
Left();
345 if ( 1 == nButtons &&
mxImpl->mbDraggingStarted )
363 if ( nXDiff >= nButtonLeftOffset && nXDiff <= nButtonRightOffset )
391 css::uno::Sequence<css::beans::PropertyValue> aArgs(1);
392 aArgs[0].Name =
"ZoomSlider";
393 aArgs[0].Value = any;
const Color & GetShadowColor() const
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
const tools::Long nSliderHeight
const tools::Rectangle & GetRect() const
tools::Long Zoom2Offset(sal_uInt16 nZoom) const
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
void SetItemText(sal_uInt16 nItemId, const OUString &rText, int nCharsWidth=-1)
void forceRepaint() const
SFX_IMPL_STATUSBAR_CONTROL(SvxZoomSliderControl, SvxZoomSliderItem)
sal_uInt16 mnSliderCenter
virtual bool MouseMove(const MouseEvent &rEvt) override
virtual bool MouseButtonDown(const MouseEvent &) override
sal_uInt16 GetButtons() const
OUString SvxResId(const char *pId)
void SetItemData(sal_uInt16 nItemId, void *pNewData)
std::unique_ptr< SvxZoomSliderControl_Impl > mxImpl
std::vector< tools::Long > maSnappingPointOffsets
void DrawLine(const Point &rStartPt, const Point &rEndPt)
virtual bool IsVoidItem() const
void DrawRect(const tools::Rectangle &rRect)
const Color & GetDarkShadowColor() const
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
SvxZoomSliderControl(sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar &_rStb)
const tools::Long nSliderXOffset
vcl::RenderContext * GetRenderContext() const
#define DBG_ASSERT(sCon, aError)
virtual ~SvxZoomSliderControl() override
sal_uInt16 Offset2Zoom(tools::Long nOffset) const
const Color & GetLineColor() const
const tools::Long nIncDecWidth
virtual bool MouseButtonUp(const MouseEvent &) override
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
const tools::Long nSnappingEpsilon
virtual void Paint(const UserDrawEvent &rEvt) override
float GetDPIScaleFactor() const
void SetQuickHelpText(sal_uInt16 nItemId, const OUString &rText)
std::vector< sal_uInt16 > maSnappingPointZooms
StatusBar & GetStatusBar() const
const Point & GetPosPixel() const
const tools::Long nSnappingPointsMinDist
SvxZoomSliderControl_Impl()
const tools::Long nSnappingHeight
const Color & GetFillColor() const