32 mbInitialDown =
false;
40 maRepeatTimer.SetInvokeHandler(
LINK(
this, SpinButton, ImplTimeout));
44 if (nStyle & WB_HSCROLL)
54 , mbUpperIsFocused(false)
56 ImplInit(pParent, nStyle);
63 pTimer->SetTimeout( GetSettings().GetMouseSettings().GetButtonRepeat() );
77 if (ImplIsUpperEnabled())
88 void SpinButton::Down()
90 if (ImplIsLowerEnabled())
101 void SpinButton::Resize()
105 Size aSize(GetOutputSizePixel());
109 maLowerRect =
tools::Rectangle(0, 0, aSize.Width() / 2, aSize.Height() - 1);
110 maUpperRect =
tools::Rectangle(maLowerRect.TopRight(), aRect.BottomRight());
114 maUpperRect =
tools::Rectangle(0, 0, aSize.Width() - 1, aSize.Height() / 2);
118 ImplCalcFocusRect(ImplIsUpperEnabled() || !ImplIsLowerEnabled());
126 Size aSize = GetSizePixel();
135 if ( IsControlBackground() )
138 aStyleSettings.
SetFaceColor( GetSettings().GetStyleSettings().GetFaceColor() );
161 IsEnabled() && ImplIsUpperEnabled(),
162 IsEnabled() && ImplIsLowerEnabled(), mbHorz,
true);
170 bool bEnable = IsEnabled();
171 ImplDrawSpinButton(rRenderContext,
this, maUpperRect, maLowerRect, mbUpperIn, mbLowerIn,
172 bEnable && ImplIsUpperEnabled(),
173 bEnable && ImplIsLowerEnabled(), mbHorz,
true);
176 ShowFocus(maFocusRect);
179 void SpinButton::MouseButtonDown(
const MouseEvent& rMEvt )
185 Invalidate( maUpperRect );
190 mbInitialDown =
true;
191 Invalidate( maLowerRect );
194 if ( mbUpperIn || mbLowerIn )
198 maRepeatTimer.Start();
202 void SpinButton::MouseButtonUp(
const MouseEvent& )
207 maRepeatTimer.Stop();
214 Invalidate( maUpperRect );
217 else if ( mbLowerIn )
220 Invalidate( maLowerRect );
224 mbInitialUp = mbInitialDown =
false;
227 void SpinButton::MouseMove(
const MouseEvent& rMEvt )
229 if ( !rMEvt.
IsLeft() || (!mbInitialUp && !mbInitialDown) )
233 mbUpperIn && mbInitialUp )
236 maRepeatTimer.Stop();
237 Invalidate( maUpperRect );
240 mbLowerIn && mbInitialDown )
243 maRepeatTimer.Stop();
244 Invalidate( maLowerRect );
247 !mbUpperIn && mbInitialUp )
251 maRepeatTimer.Start();
252 Invalidate( maUpperRect );
255 !mbLowerIn && mbInitialDown )
259 maRepeatTimer.Start();
260 Invalidate( maLowerRect );
264 void SpinButton::KeyInput(
const KeyEvent& rKEvt )
274 if ( mbHorz && !ImplMoveFocus( bUp ) )
289 mbUpperIsFocused ?
Up() :
Down();
312 bool bNewRepeat = 0 != ( GetStyle() &
WB_REPEAT );
313 if ( bNewRepeat != mbRepeat )
315 if ( maRepeatTimer.IsActive() )
317 maRepeatTimer.Stop();
320 mbRepeat = bNewRepeat;
323 bool bNewHorz = 0 != ( GetStyle() &
WB_HSCROLL );
324 if ( bNewHorz != mbHorz )
337 void SpinButton::SetRangeMin(
tools::Long nNewRange )
339 SetRange(
Range( nNewRange, GetRangeMax() ) );
342 void SpinButton::SetRangeMax(
tools::Long nNewRange )
344 SetRange(
Range( GetRangeMin(), nNewRange ) );
347 void SpinButton::SetRange(
const Range& rRange )
350 Range aRange = rRange;
356 if ( (mnMinRange == nNewMinRange) && (mnMaxRange == nNewMaxRange))
359 mnMinRange = nNewMinRange;
360 mnMaxRange = nNewMaxRange;
363 if ( mnValue > mnMaxRange )
365 if ( mnValue < mnMinRange )
374 if ( nValue > mnMaxRange )
376 if ( nValue < mnMinRange )
379 if ( mnValue != nValue )
386 void SpinButton::GetFocus()
388 ShowFocus( maFocusRect );
392 void SpinButton::LoseFocus()
398 bool SpinButton::ImplMoveFocus(
bool _bUpper )
400 if ( _bUpper == mbUpperIsFocused )
404 ImplCalcFocusRect( _bUpper );
406 ShowFocus( maFocusRect );
410 void SpinButton::ImplCalcFocusRect(
bool _bUpper )
412 maFocusRect = _bUpper ? maUpperRect : maLowerRect;
415 maFocusRect.AdjustTop(2 );
416 maFocusRect.AdjustRight( -2 );
417 maFocusRect.AdjustBottom( -2 );
418 mbUpperIsFocused = _bUpper;
425 else if( maLowerRect.
IsInside( rPt ) )
450 Invalidate(*pLastRect);
451 SetClipRegion( aRgn );
#define LINK(Instance, Class, Member)
void SetStyleSettings(const StyleSettings &rSet)
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)
const StyleSettings & GetStyleSettings() const
virtual void StateChanged(StateChangedType nStateChange) override
sal_uInt16 GetCode() const
virtual void SetSettings(const AllSettings &rSettings)
constexpr sal_uInt16 KEY_SPACE
constexpr sal_uInt16 KEY_UP
sal_uInt16 GetButtons() const
bool IsEnterWindow() const
sal_uInt16 GetModifier() const
constexpr sal_uInt16 KEY_DOWN
virtual bool PreNotify(NotifyEvent &rNEvt)
bool IsLeaveWindow() const
tools::Long Width() const
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
MouseNotifyEvent GetType() const
const AllSettings & GetSettings() const
constexpr sal_uInt16 KEY_RIGHT
Point LogicToPixel(const Point &rLogicPt) const
virtual void KeyInput(const KeyEvent &rKEvt)
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
bool IsModifierChanged() const
const vcl::KeyCode & GetKeyCode() const
void SetFaceColor(const Color &rColor)
virtual void Resize() override
const MouseEvent * GetMouseEvent() const
tools::Long Height() const
const Point & GetPosPixel() const
IMPL_LINK(SpinButton, ImplTimeout, Timer *, pTimer, void)
constexpr sal_uInt16 KEY_LEFT
void Push(PushFlags nFlags=PushFlags::ALL)
static sal_uLong GetButtonStartRepeat()