Branch data 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 _SV_SPINFLD_HXX
21 : : #define _SV_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 : : sal_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 : : SpinField( WindowType nTyp );
63 : :
64 : : virtual long Notify( NotifyEvent& rNEvt );
65 : : virtual void Command( const CommandEvent& rCEvt );
66 : :
67 : : void EndDropDown();
68 : :
69 : : virtual void FillLayoutData() const;
70 : : Rectangle * ImplFindPartRect( const Point& rPt );
71 : : public:
72 : : SpinField( Window* pParent, WinBits nWinStyle = 0 );
73 : : SpinField( Window* pParent, const ResId& rResId );
74 : : ~SpinField();
75 : :
76 : : virtual sal_Bool ShowDropDown( sal_Bool bShow );
77 : :
78 : : virtual void Up();
79 : : virtual void Down();
80 : : virtual void First();
81 : : virtual void Last();
82 : :
83 : : virtual void MouseButtonDown( const MouseEvent& rMEvt );
84 : : virtual void MouseButtonUp( const MouseEvent& rMEvt );
85 : : virtual void MouseMove( const MouseEvent& rMEvt );
86 : : virtual void Paint( const Rectangle& rRect );
87 : : virtual void Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
88 : : virtual void Resize();
89 : : virtual void StateChanged( StateChangedType nType );
90 : : virtual void DataChanged( const DataChangedEvent& rDCEvt );
91 : : virtual long PreNotify( NotifyEvent& rNEvt );
92 : :
93 : 0 : void SetUpHdl( const Link& rLink ) { maUpHdlLink = rLink; }
94 : 0 : const Link& GetUpHdl() const { return maUpHdlLink; }
95 : 0 : void SetDownHdl( const Link& rLink ) { maDownHdlLink = rLink; }
96 : 0 : const Link& GetDownHdl() const { return maDownHdlLink; }
97 : 0 : void SetFirstHdl( const Link& rLink ) { maFirstHdlLink = rLink; }
98 : : const Link& GetFirstHdl() const { return maFirstHdlLink; }
99 : 0 : void SetLastHdl( const Link& rLink ) { maLastHdlLink = rLink; }
100 : : const Link& GetLastHdl() const { return maLastHdlLink; }
101 : :
102 : : virtual Size CalcMinimumSize() const;
103 : : virtual Size GetOptimalSize(WindowSizeType eType) const;
104 : : virtual Size CalcSize( sal_uInt16 nChars ) const;
105 : : };
106 : :
107 : : #endif // _SV_SPINFLD_HXX
108 : :
109 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|