32 mbInitialDown =
false;
40 maRepeatTimer.SetInvokeHandler(
LINK(
this, SpinButton, ImplTimeout));
54 , maRepeatTimer(
"SpinButton maRepeatTimer")
55 , mbUpperIsFocused(false)
57 ImplInit(pParent, nStyle);
64 pTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonRepeat() );
78 if (ImplIsUpperEnabled())
89void SpinButton::Down()
91 if (ImplIsLowerEnabled())
102void SpinButton::Resize()
106 Size aSize(GetOutputSizePixel());
110 maLowerRect =
tools::Rectangle(0, 0, aSize.Width() / 2, aSize.Height() - 1);
111 maUpperRect =
tools::Rectangle(maLowerRect.TopRight(), aRect.BottomRight());
115 maUpperRect =
tools::Rectangle(0, 0, aSize.Width() - 1, aSize.Height() / 2);
116 maLowerRect =
tools::Rectangle(maUpperRect.BottomLeft(), aRect.BottomRight());
119 ImplCalcFocusRect(ImplIsUpperEnabled() || !ImplIsLowerEnabled());
127 Size aSize = GetSizePixel();
136 if ( IsControlBackground() )
139 aStyleSettings.
SetFaceColor( GetSettings().GetStyleSettings().GetFaceColor() );
162 IsEnabled() && ImplIsUpperEnabled(),
163 IsEnabled() && ImplIsLowerEnabled(), mbHorz,
true);
171 bool bEnable = IsEnabled();
172 ImplDrawSpinButton(rRenderContext,
this, maUpperRect, maLowerRect, mbUpperIn, mbLowerIn,
173 bEnable && ImplIsUpperEnabled(),
174 bEnable && ImplIsLowerEnabled(), mbHorz,
true);
177 ShowFocus(maFocusRect);
180void SpinButton::MouseButtonDown(
const MouseEvent& rMEvt )
182 if ( maUpperRect.Contains( rMEvt.
GetPosPixel() ) && ( ImplIsUpperEnabled() ) )
186 Invalidate( maUpperRect );
188 else if ( maLowerRect.Contains( rMEvt.
GetPosPixel() ) && ( ImplIsLowerEnabled() ) )
191 mbInitialDown =
true;
192 Invalidate( maLowerRect );
195 if ( mbUpperIn || mbLowerIn )
199 maRepeatTimer.Start();
203void SpinButton::MouseButtonUp(
const MouseEvent& )
208 maRepeatTimer.Stop();
215 Invalidate( maUpperRect );
218 else if ( mbLowerIn )
221 Invalidate( maLowerRect );
225 mbInitialUp = mbInitialDown =
false;
228void SpinButton::MouseMove(
const MouseEvent& rMEvt )
230 if ( !rMEvt.
IsLeft() || (!mbInitialUp && !mbInitialDown) )
233 if ( !maUpperRect.Contains( rMEvt.
GetPosPixel() ) &&
234 mbUpperIn && mbInitialUp )
237 maRepeatTimer.Stop();
238 Invalidate( maUpperRect );
240 else if ( !maLowerRect.Contains( rMEvt.
GetPosPixel() ) &&
241 mbLowerIn && mbInitialDown )
244 maRepeatTimer.Stop();
245 Invalidate( maLowerRect );
247 else if ( maUpperRect.Contains( rMEvt.
GetPosPixel() ) &&
248 !mbUpperIn && mbInitialUp )
252 maRepeatTimer.Start();
253 Invalidate( maUpperRect );
255 else if ( maLowerRect.Contains( rMEvt.
GetPosPixel() ) &&
256 !mbLowerIn && mbInitialDown )
260 maRepeatTimer.Start();
261 Invalidate( maLowerRect );
265void SpinButton::KeyInput(
const KeyEvent& rKEvt )
275 if ( mbHorz && !ImplMoveFocus( bUp ) )
290 mbUpperIsFocused ?
Up() :
Down();
313 bool bNewRepeat = 0 != ( GetStyle() &
WB_REPEAT );
314 if ( bNewRepeat != mbRepeat )
316 if ( maRepeatTimer.IsActive() )
318 maRepeatTimer.Stop();
321 mbRepeat = bNewRepeat;
324 bool bNewHorz = 0 != ( GetStyle() &
WB_HSCROLL );
325 if ( bNewHorz != mbHorz )
338void SpinButton::SetRangeMin(
tools::Long nNewRange )
340 SetRange(
Range( nNewRange, GetRangeMax() ) );
343void SpinButton::SetRangeMax(
tools::Long nNewRange )
345 SetRange(
Range( GetRangeMin(), nNewRange ) );
348void SpinButton::SetRange(
const Range& rRange )
351 Range aRange = rRange;
357 if ( (mnMinRange == nNewMinRange) && (mnMaxRange == nNewMaxRange))
360 mnMinRange = nNewMinRange;
361 mnMaxRange = nNewMaxRange;
364 if ( mnValue > mnMaxRange )
366 if ( mnValue < mnMinRange )
375 if ( nValue > mnMaxRange )
377 if ( nValue < mnMinRange )
380 if ( mnValue != nValue )
387void SpinButton::GetFocus()
389 ShowFocus( maFocusRect );
393void SpinButton::LoseFocus()
399bool SpinButton::ImplMoveFocus(
bool _bUpper )
401 if ( _bUpper == mbUpperIsFocused )
405 ImplCalcFocusRect( _bUpper );
407 ShowFocus( maFocusRect );
411void SpinButton::ImplCalcFocusRect(
bool _bUpper )
413 maFocusRect = _bUpper ? maUpperRect : maLowerRect;
415 maFocusRect.AdjustLeft(2 );
416 maFocusRect.AdjustTop(2 );
417 maFocusRect.AdjustRight( -2 );
418 maFocusRect.AdjustBottom( -2 );
419 mbUpperIsFocused = _bUpper;
424 if( maUpperRect.Contains( rPt ) )
426 else if( maLowerRect.Contains( rPt ) )
447 vcl::Region aRgn(GetOutDev()->GetActiveClipRegion());
450 GetOutDev()->SetClipRegion(
vcl::Region(*pLastRect));
451 Invalidate(*pLastRect);
452 GetOutDev()->SetClipRegion( aRgn );
458 GetOutDev()->SetClipRegion(aRgn);
const StyleSettings & GetStyleSettings() const
void SetStyleSettings(const StyleSettings &rSet)
virtual void StateChanged(StateChangedType nStateChange) override
virtual void Resize() override
const vcl::KeyCode & GetKeyCode() const
bool IsEnterWindow() const
bool IsLeaveWindow() const
sal_uInt16 GetButtons() const
const Point & GetPosPixel() const
bool IsModifierChanged() const
static sal_Int32 GetButtonStartRepeat()
const MouseEvent * GetMouseEvent() const
NotifyEventType GetType() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
virtual void SetSettings(const AllSettings &rSettings)
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
const AllSettings & GetSettings() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetFaceColor(const Color &rColor)
sal_uInt16 GetCode() const
sal_uInt16 GetModifier() const
virtual void KeyInput(const KeyEvent &rKEvt)
virtual bool PreNotify(NotifyEvent &rNEvt)
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
constexpr sal_uInt16 KEY_LEFT
constexpr sal_uInt16 KEY_UP
constexpr sal_uInt16 KEY_RIGHT
constexpr sal_uInt16 KEY_DOWN
constexpr sal_uInt16 KEY_SPACE
#define LINK(Instance, Class, Member)
IMPL_LINK(SpinButton, ImplTimeout, Timer *, pTimer, void)
void ImplDrawSpinButton(vcl::RenderContext &rRenderContext, vcl::Window *pWindow, const tools::Rectangle &rUpperRect, const tools::Rectangle &rLowerRect, bool bUpperIn, bool bLowerIn, bool bUpperEnabled, bool bLowerEnabled, bool bHorz, bool bMirrorHorz)