Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / vcl / toolkit / spinfld.hxx
blob499baa4ff5eba96ccb785fdf601dfcaabc4fb1ef
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #pragma once
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
26 #include <vcl/dllapi.h>
27 #include <vcl/toolkit/edit.hxx>
28 #include <vcl/timer.hxx>
30 class VCL_DLLPUBLIC SpinField : public Edit
32 public:
33 explicit SpinField( vcl::Window* pParent, WinBits nWinStyle, WindowType nType = WindowType::SPINFIELD );
34 virtual ~SpinField() override;
35 virtual void dispose() override;
37 virtual bool ShowDropDown( bool bShow );
39 virtual void Up();
40 virtual void Down();
41 virtual void First();
42 virtual void Last();
44 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
45 virtual void MouseButtonUp( const MouseEvent& rMEvt ) override;
46 virtual void MouseMove( const MouseEvent& rMEvt ) override;
47 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
48 virtual void Draw( OutputDevice* pDev, const Point& rPos,SystemTextColorFlags nFlags ) override;
49 virtual void Resize() override;
50 virtual void StateChanged( StateChangedType nType ) override;
51 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
52 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
54 void SetUpHdl( const Link<SpinField&,void>& rLink ) { maUpHdlLink = rLink; }
55 void SetDownHdl( const Link<SpinField&,void>& rLink ) { maDownHdlLink = rLink; }
57 virtual Size CalcMinimumSize() const override;
58 virtual Size CalcMinimumSizeForText(const OUString &rString) const override;
59 virtual Size GetOptimalSize() const override;
60 virtual Size CalcSize(sal_Int32 nChars) const override;
62 virtual FactoryFunction GetUITestFactory() const override;
64 SAL_DLLPRIVATE void SetUpperEnabled(bool bEnabled);
65 SAL_DLLPRIVATE void SetLowerEnabled(bool bEnabled);
66 SAL_DLLPRIVATE bool IsUpperEnabled() const { return mbUpperEnabled; }
67 SAL_DLLPRIVATE bool IsLowerEnabled() const { return mbLowerEnabled; }
69 protected:
70 using Window::ImplInit;
71 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
73 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
75 void EndDropDown();
77 virtual void FillLayoutData() const override;
78 tools::Rectangle * ImplFindPartRect( const Point& rPt );
80 private:
81 DECL_DLLPRIVATE_LINK( ImplTimeout, Timer*, void );
82 SAL_DLLPRIVATE void ImplInitSpinFieldData();
83 SAL_DLLPRIVATE void ImplCalcButtonAreas( const OutputDevice* pDev, const Size& rOutSz, tools::Rectangle& rDDArea, tools::Rectangle& rSpinUpArea, tools::Rectangle& rSpinDownArea );
85 tools::Rectangle maUpperRect;
86 tools::Rectangle maLowerRect;
87 tools::Rectangle maDropDownRect; // not yet attached ...
89 VclPtr<Edit> mpEdit;
90 AutoTimer maRepeatTimer;
91 Link<SpinField&,void> maUpHdlLink;
92 Link<SpinField&,void> maDownHdlLink;
93 bool mbRepeat:1,
94 mbSpin:1,
95 mbInitialUp:1,
96 mbInitialDown:1,
97 mbUpperIn:1,
98 mbLowerIn:1,
99 mbInDropDown:1,
100 mbUpperEnabled:1,
101 mbLowerEnabled:1;
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */