Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / spinfld.hxx
blobbf4879b52425f686d0a67246ab2fa50edfa97a9e
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 #ifndef INCLUDED_VCL_SPINFLD_HXX
21 #define INCLUDED_VCL_SPINFLD_HXX
23 #include <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/edit.hxx>
26 #include <vcl/timer.hxx>
29 class VCL_DLLPUBLIC SpinField : public Edit
31 protected:
32 VclPtr<Edit> mpEdit;
33 AutoTimer maRepeatTimer;
34 Rectangle maUpperRect;
35 Rectangle maLowerRect;
36 Rectangle maDropDownRect; // noch nicht angebunden...
37 Link<> maUpHdlLink;
38 Link<> maDownHdlLink;
39 Link<> maFirstHdlLink;
40 Link<> maLastHdlLink;
41 bool mbRepeat:1,
42 mbSpin:1,
43 mbInitialUp:1,
44 mbInitialDown:1,
45 mbNoSelect:1,
46 mbUpperIn:1,
47 mbLowerIn:1,
48 mbInDropDown:1;
50 using Window::ImplInit;
51 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
53 private:
54 DECL_DLLPRIVATE_LINK_TYPED( ImplTimeout, Timer*, void );
55 SAL_DLLPRIVATE void ImplInitSpinFieldData();
56 SAL_DLLPRIVATE void ImplCalcButtonAreas( OutputDevice* pDev, const Size& rOutSz, Rectangle& rDDArea, Rectangle& rSpinUpArea, Rectangle& rSpinDownArea );
58 protected:
59 explicit SpinField( WindowType nTyp );
61 virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
62 virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
64 void EndDropDown();
66 virtual void FillLayoutData() const SAL_OVERRIDE;
67 Rectangle * ImplFindPartRect( const Point& rPt );
69 public:
70 explicit SpinField( vcl::Window* pParent, WinBits nWinStyle = 0 );
71 explicit SpinField( vcl::Window* pParent, const ResId& );
72 virtual ~SpinField();
73 virtual void dispose() SAL_OVERRIDE;
75 virtual bool ShowDropDown( bool bShow );
77 virtual void Up();
78 virtual void Down();
79 virtual void First();
80 virtual void Last();
82 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
83 virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
84 virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
85 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
86 virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
87 virtual void Resize() SAL_OVERRIDE;
88 virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
89 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
90 virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
92 void SetUpHdl( const Link<>& rLink ) { maUpHdlLink = rLink; }
93 const Link<>& GetUpHdl() const { return maUpHdlLink; }
94 void SetDownHdl( const Link<>& rLink ) { maDownHdlLink = rLink; }
95 const Link<>& GetDownHdl() const { return maDownHdlLink; }
96 void SetFirstHdl( const Link<>& rLink ) { maFirstHdlLink = rLink; }
97 const Link<>& GetFirstHdl() const { return maFirstHdlLink; }
98 void SetLastHdl( const Link<>& rLink ) { maLastHdlLink = rLink; }
99 const Link<>& GetLastHdl() const { return maLastHdlLink; }
101 virtual Size CalcMinimumSize() const SAL_OVERRIDE;
102 virtual Size CalcMinimumSizeForText(const OUString &rString) const SAL_OVERRIDE;
103 virtual Size GetOptimalSize() const SAL_OVERRIDE;
104 virtual Size CalcSize(sal_Int32 nChars) const SAL_OVERRIDE;
107 #endif // INCLUDED_VCL_SPINFLD_HXX
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */