Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_VCL_SPINFLD_HXX
21 : #define INCLUDED_VCL_SPINFLD_HXX
22 :
23 : #include <tools/solar.h>
24 : #include <vcl/dllapi.h>
25 : #include <vcl/edit.hxx>
26 : #include <vcl/timer.hxx>
27 :
28 :
29 : // - SpinField -
30 :
31 :
32 : class VCL_DLLPUBLIC SpinField : public Edit
33 : {
34 : protected:
35 : Edit* mpEdit;
36 : AutoTimer maRepeatTimer;
37 : Rectangle maUpperRect;
38 : Rectangle maLowerRect;
39 : Rectangle maDropDownRect; // noch nicht angebunden...
40 : Link maUpHdlLink;
41 : Link maDownHdlLink;
42 : Link maFirstHdlLink;
43 : Link maLastHdlLink;
44 : bool mbRepeat:1,
45 : mbSpin:1,
46 : mbInitialUp:1,
47 : mbInitialDown:1,
48 : mbNoSelect:1,
49 : mbUpperIn:1,
50 : mbLowerIn:1,
51 : mbInDropDown:1;
52 :
53 : using Window::ImplInit;
54 : SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
55 :
56 : private:
57 : DECL_DLLPRIVATE_LINK( ImplTimeout, Timer* );
58 : SAL_DLLPRIVATE void ImplInitSpinFieldData();
59 : SAL_DLLPRIVATE void ImplCalcButtonAreas( OutputDevice* pDev, const Size& rOutSz, Rectangle& rDDArea, Rectangle& rSpinUpArea, Rectangle& rSpinDownArea );
60 :
61 : protected:
62 : explicit SpinField( WindowType nTyp );
63 :
64 : virtual bool Notify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
65 : virtual void Command( const CommandEvent& rCEvt ) SAL_OVERRIDE;
66 :
67 : void EndDropDown();
68 :
69 : virtual void FillLayoutData() const SAL_OVERRIDE;
70 : Rectangle * ImplFindPartRect( const Point& rPt );
71 :
72 : public:
73 : explicit SpinField( Window* pParent, WinBits nWinStyle = 0 );
74 : explicit SpinField( Window* pParent, const ResId& );
75 : virtual ~SpinField();
76 :
77 : virtual bool ShowDropDown( bool bShow );
78 :
79 : virtual void Up();
80 : virtual void Down();
81 : virtual void First();
82 : virtual void Last();
83 :
84 : virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
85 : virtual void MouseButtonUp( const MouseEvent& rMEvt ) SAL_OVERRIDE;
86 : virtual void MouseMove( const MouseEvent& rMEvt ) SAL_OVERRIDE;
87 : virtual void Paint( const Rectangle& rRect ) SAL_OVERRIDE;
88 : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags ) SAL_OVERRIDE;
89 : virtual void Resize() SAL_OVERRIDE;
90 : virtual void StateChanged( StateChangedType nType ) SAL_OVERRIDE;
91 : virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
92 : virtual bool PreNotify( NotifyEvent& rNEvt ) SAL_OVERRIDE;
93 :
94 0 : void SetUpHdl( const Link& rLink ) { maUpHdlLink = rLink; }
95 0 : const Link& GetUpHdl() const { return maUpHdlLink; }
96 0 : void SetDownHdl( const Link& rLink ) { maDownHdlLink = rLink; }
97 0 : const Link& GetDownHdl() const { return maDownHdlLink; }
98 0 : void SetFirstHdl( const Link& rLink ) { maFirstHdlLink = rLink; }
99 : const Link& GetFirstHdl() const { return maFirstHdlLink; }
100 0 : void SetLastHdl( const Link& rLink ) { maLastHdlLink = rLink; }
101 : const Link& GetLastHdl() const { return maLastHdlLink; }
102 :
103 : virtual Size CalcMinimumSize() const SAL_OVERRIDE;
104 : virtual Size CalcMinimumSizeForText(const OUString &rString) const SAL_OVERRIDE;
105 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
106 : virtual Size CalcSize(sal_Int32 nChars) const SAL_OVERRIDE;
107 : };
108 :
109 : #endif // INCLUDED_VCL_SPINFLD_HXX
110 :
111 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|