30#include <svx/strings.hrc>
32#include <bitmaps.hlst>
33#include <com/sun/star/beans/PropertyValue.hpp>
70 const tools::Long nControlWidth = getControlRect().GetWidth();
94 if ( nOffset < nControlWidth / 2 )
99 const tools::Long nZoomPerSliderPixel = (1000 * nFirstHalfRange) / nHalfSliderWidth;
101 nRet =
mxImpl->mnMinZoom + sal_uInt16( nOffsetToSliderLeft * nZoomPerSliderPixel / 1000 );
108 const tools::Long nZoomPerSliderPixel = 1000 * nSecondHalfRange / nHalfSliderWidth;
109 const tools::Long nOffsetToSliderCenter = nOffset - nControlWidth/2;
110 nRet =
mxImpl->mnSliderCenter + sal_uInt16( nOffsetToSliderCenter * nZoomPerSliderPixel / 1000 );
114 if ( nRet < mxImpl->mnMinZoom )
116 else if ( nRet >
mxImpl->mnMaxZoom )
125 const tools::Long nControlWidth = getControlRect().GetWidth();
130 if ( nCurrentZoom <= mxImpl->mnSliderCenter )
132 nCurrentZoom = nCurrentZoom -
mxImpl->mnMinZoom;
134 const tools::Long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nFirstHalfRange;
135 const tools::Long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
140 nCurrentZoom = nCurrentZoom -
mxImpl->mnSliderCenter;
142 const tools::Long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nSecondHalfRange;
143 const tools::Long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000;
144 nRet += nHalfSliderWidth + nOffset;
154 mxImpl->maSliderButton =
Image(StockImage::Yes, RID_SVXBMP_SLIDERBUTTON);
155 mxImpl->maIncreaseButton =
Image(StockImage::Yes, RID_SVXBMP_SLIDERINCREASE);
156 mxImpl->maDecreaseButton =
Image(StockImage::Yes, RID_SVXBMP_SLIDERDECREASE);
165 if ( (SfxItemState::DEFAULT != eState) || pState->
IsVoidItem() )
168 mxImpl->mbValuesSet =
false;
172 assert(
dynamic_cast<const SvxZoomSliderItem*
>( pState) &&
"invalid item type: should be a SvxZoomSliderItem" );
176 mxImpl->mnSliderCenter= 100;
177 mxImpl->mbValuesSet =
true;
180 mxImpl->mnSliderCenter =
mxImpl->mnMinZoom +
static_cast<sal_uInt16
>((
mxImpl->mnMaxZoom -
mxImpl->mnMinZoom) * 0.5);
187 "Looks like the zoom slider item is corrupted" );
189 const css::uno::Sequence < sal_Int32 > rSnappingPoints =
static_cast<const SvxZoomSliderItem*
>( pState )->GetSnappingPoints();
190 mxImpl->maSnappingPointOffsets.clear();
191 mxImpl->maSnappingPointZooms.clear();
194 std::set< sal_uInt16 > aTmpSnappingPoints;
195 for (
const sal_Int32 nSnappingPoint : rSnappingPoints )
197 aTmpSnappingPoints.insert(
static_cast<sal_uInt16
>(nSnappingPoint) );
203 for (
const sal_uInt16 nCurrent : aTmpSnappingPoints )
209 mxImpl->maSnappingPointOffsets.push_back( nCurrentOffset );
210 mxImpl->maSnappingPointZooms.push_back( nCurrent );
211 nLastOffset = nCurrentOffset;
221 if ( !
mxImpl->mbValuesSet )
252 for (
const auto& rSnappingPoint :
mxImpl->maSnappingPointOffsets )
263 aImagePoint.
AdjustX( -(
mxImpl->maSliderButton.GetSizePixel().Width()/2) );
283 if ( !
mxImpl->mbValuesSet )
288 const sal_Int32 nXDiff = aPoint.
X() - aControlRect.
Left();
298 if ( nXDiff >= nButtonLeftOffset && nXDiff <= nButtonRightOffset )
308 mxImpl->mbDraggingStarted =
true;
316 if ( nOldZoom ==
mxImpl->mnCurrentZoom )
326 mxImpl->mbDraggingStarted =
false;
332 if ( !
mxImpl->mbValuesSet )
338 const sal_Int32 nXDiff = aPoint.
X() - aControlRect.
Left();
341 if ( 1 == nButtons &&
mxImpl->mbDraggingStarted )
359 if ( nXDiff >= nButtonLeftOffset && nXDiff <= nButtonRightOffset )
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
sal_uInt16 GetButtons() const
const Point & GetPosPixel() const
float GetDPIScaleFactor() const
void DrawRect(const tools::Rectangle &rRect)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
const Color & GetLineColor() const
const Color & GetFillColor() const
void setX(tools::Long nX)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
virtual bool IsVoidItem() const
StatusBar & GetStatusBar() const
void SetItemText(sal_uInt16 nItemId, const OUString &rText, int nCharsWidth=-1)
void SetQuickHelpText(sal_uInt16 nItemId, const OUString &rText)
void SetItemData(sal_uInt16 nItemId, void *pNewData)
const Color & GetDarkShadowColor() const
const Color & GetShadowColor() const
tools::Long Zoom2Offset(sal_uInt16 nZoom) const
virtual void StateChangedAtStatusBarControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
virtual void Paint(const UserDrawEvent &rEvt) override
virtual bool MouseButtonDown(const MouseEvent &) override
virtual ~SvxZoomSliderControl() override
void forceRepaint() const
SvxZoomSliderControl(sal_uInt16 _nSlotId, sal_uInt16 _nId, StatusBar &_rStb)
virtual bool MouseButtonUp(const MouseEvent &) override
virtual bool MouseMove(const MouseEvent &rEvt) override
std::unique_ptr< SvxZoomSliderControl_Impl > mxImpl
sal_uInt16 Offset2Zoom(tools::Long nOffset) const
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
vcl::RenderContext * GetRenderContext() const
const tools::Rectangle & GetRect() const
#define DBG_ASSERT(sCon, aError)
OUString SvxResId(TranslateId aId)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
SvxZoomSliderControl_Impl()
std::vector< sal_uInt16 > maSnappingPointZooms
std::vector< tools::Long > maSnappingPointOffsets
sal_uInt16 mnSliderCenter
const tools::Long nSnappingHeight
const tools::Long nSliderHeight
const tools::Long nIncDecWidth
const tools::Long nSnappingEpsilon
const tools::Long nSnappingPointsMinDist
const tools::Long nSliderXOffset
SFX_IMPL_STATUSBAR_CONTROL(SvxZoomSliderControl, SvxZoomSliderItem)