xref: /trunk/main/vcl/inc/vcl/spinfld.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SV_SPINFLD_HXX
29 #define _SV_SPINFLD_HXX
30 
31 #include <vcl/sv.h>
32 #include <vcl/dllapi.h>
33 #include <vcl/edit.hxx>
34 #include <vcl/timer.hxx>
35 
36 // -------------
37 // - SpinField -
38 // -------------
39 
40 class VCL_DLLPUBLIC SpinField : public Edit
41 {
42 protected:
43 	Edit*			mpEdit;
44 	AutoTimer		maRepeatTimer;
45 	Rectangle		maUpperRect;
46 	Rectangle		maLowerRect;
47 	Rectangle		maDropDownRect; // noch nicht angebunden...
48 	Link			maUpHdlLink;
49 	Link			maDownHdlLink;
50 	Link			maFirstHdlLink;
51 	Link			maLastHdlLink;
52 	sal_Bool			mbRepeat:1,
53 					mbSpin:1,
54 					mbInitialUp:1,
55 					mbInitialDown:1,
56 					mbNoSelect:1,
57 					mbUpperIn:1,
58 					mbLowerIn:1,
59 					mbInDropDown:1;
60 
61     using Window::ImplInit;
62 	SAL_DLLPRIVATE void	  ImplInit( Window* pParent, WinBits nStyle );
63 
64 private:
65 	DECL_DLLPRIVATE_LINK( ImplTimeout, Timer* );
66 	SAL_DLLPRIVATE void	  ImplInitSpinFieldData();
67 	SAL_DLLPRIVATE void	  ImplCalcButtonAreas( OutputDevice* pDev, const Size& rOutSz, Rectangle& rDDArea, Rectangle& rSpinUpArea, Rectangle& rSpinDownArea );
68 
69 protected:
70 					SpinField( WindowType nTyp );
71 
72 	virtual long	Notify( NotifyEvent& rNEvt );
73 	virtual void	Command( const CommandEvent& rCEvt );
74 
75 	void			EndDropDown();
76 
77     virtual void    FillLayoutData() const;
78     Rectangle *     ImplFindPartRect( const Point& rPt );
79 public:
80 					SpinField( Window* pParent, WinBits nWinStyle = 0 );
81 					SpinField( Window* pParent, const ResId& rResId );
82 					~SpinField();
83 
84 	virtual sal_Bool	ShowDropDown( sal_Bool bShow );
85 
86 	virtual void	Up();
87 	virtual void	Down();
88 	virtual void	First();
89 	virtual void	Last();
90 
91 	virtual void	MouseButtonDown( const MouseEvent& rMEvt );
92 	virtual void	MouseButtonUp( const MouseEvent& rMEvt );
93 	virtual void	MouseMove( const MouseEvent& rMEvt );
94 	virtual void	Paint( const Rectangle& rRect );
95 	virtual void	Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
96 	virtual void	Resize();
97 	virtual void	StateChanged( StateChangedType nType );
98 	virtual void	DataChanged( const DataChangedEvent& rDCEvt );
99     virtual long    PreNotify( NotifyEvent& rNEvt );
100 
101 	void			SetUpHdl( const Link& rLink ) { maUpHdlLink = rLink; }
102 	const Link& 	GetUpHdl() const { return maUpHdlLink; }
103 	void			SetDownHdl( const Link& rLink ) { maDownHdlLink = rLink; }
104 	const Link& 	GetDownHdl() const { return maDownHdlLink; }
105 	void			SetFirstHdl( const Link& rLink ) { maFirstHdlLink = rLink; }
106 	const Link& 	GetFirstHdl() const { return maFirstHdlLink; }
107 	void			SetLastHdl( const Link& rLink ) { maLastHdlLink = rLink; }
108 	const Link& 	GetLastHdl() const { return maLastHdlLink; }
109 
110 	virtual Size	CalcMinimumSize() const;
111     virtual Size    GetOptimalSize(WindowSizeType eType) const;
112 	virtual Size	CalcSize( sal_uInt16 nChars ) const;
113 };
114 
115 #endif // _SV_SPINFLD_HXX
116