xref: /trunk/main/vcl/inc/vcl/spinfld.hxx (revision e1beba7d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_SPINFLD_HXX
25 #define _SV_SPINFLD_HXX
26 
27 #include <vcl/sv.h>
28 #include <vcl/dllapi.h>
29 #include <vcl/edit.hxx>
30 #include <vcl/timer.hxx>
31 
32 // -------------
33 // - SpinField -
34 // -------------
35 
36 class VCL_DLLPUBLIC SpinField : public Edit
37 {
38 protected:
39 	Edit*			mpEdit;
40 	AutoTimer		maRepeatTimer;
41 	Rectangle		maUpperRect;
42 	Rectangle		maLowerRect;
43 	Rectangle		maDropDownRect; // noch nicht angebunden...
44 	Link			maUpHdlLink;
45 	Link			maDownHdlLink;
46 	Link			maFirstHdlLink;
47 	Link			maLastHdlLink;
48 	sal_Bool			mbRepeat:1,
49 					mbSpin:1,
50 					mbInitialUp:1,
51 					mbInitialDown:1,
52 					mbNoSelect:1,
53 					mbUpperIn:1,
54 					mbLowerIn:1,
55 					mbInDropDown:1;
56 
57     using Window::ImplInit;
58 	SAL_DLLPRIVATE void	  ImplInit( Window* pParent, WinBits nStyle );
59 
60 private:
61 	DECL_DLLPRIVATE_LINK( ImplTimeout, Timer* );
62 	SAL_DLLPRIVATE void	  ImplInitSpinFieldData();
63 	SAL_DLLPRIVATE void	  ImplCalcButtonAreas( OutputDevice* pDev, const Size& rOutSz, Rectangle& rDDArea, Rectangle& rSpinUpArea, Rectangle& rSpinDownArea );
64 
65 protected:
66 	explicit		SpinField( WindowType nTyp );
67 
68 	virtual long	Notify( NotifyEvent& rNEvt );
69 	virtual void	Command( const CommandEvent& rCEvt );
70 
71 	void			EndDropDown();
72 
73     virtual void    FillLayoutData() const;
74     Rectangle *     ImplFindPartRect( const Point& rPt );
75 public:
76 	explicit		SpinField( Window* pParent, WinBits nWinStyle = 0 );
77 	explicit		SpinField( Window* pParent, const ResId& );
78 	virtual			~SpinField();
79 
80 	virtual sal_Bool	ShowDropDown( sal_Bool bShow );
81 
82 	virtual void	Up();
83 	virtual void	Down();
84 	virtual void	First();
85 	virtual void	Last();
86 
87 	virtual void	MouseButtonDown( const MouseEvent& rMEvt );
88 	virtual void	MouseButtonUp( const MouseEvent& rMEvt );
89 	virtual void	MouseMove( const MouseEvent& rMEvt );
90 	virtual void	Paint( const Rectangle& rRect );
91 	virtual void	Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, sal_uLong nFlags );
92 	virtual void	Resize();
93 	virtual void	StateChanged( StateChangedType nType );
94 	virtual void	DataChanged( const DataChangedEvent& rDCEvt );
95     virtual long    PreNotify( NotifyEvent& rNEvt );
96 
SetUpHdl(const Link & rLink)97 	void			SetUpHdl( const Link& rLink ) { maUpHdlLink = rLink; }
GetUpHdl() const98 	const Link& 	GetUpHdl() const { return maUpHdlLink; }
SetDownHdl(const Link & rLink)99 	void			SetDownHdl( const Link& rLink ) { maDownHdlLink = rLink; }
GetDownHdl() const100 	const Link& 	GetDownHdl() const { return maDownHdlLink; }
SetFirstHdl(const Link & rLink)101 	void			SetFirstHdl( const Link& rLink ) { maFirstHdlLink = rLink; }
GetFirstHdl() const102 	const Link& 	GetFirstHdl() const { return maFirstHdlLink; }
SetLastHdl(const Link & rLink)103 	void			SetLastHdl( const Link& rLink ) { maLastHdlLink = rLink; }
GetLastHdl() const104 	const Link& 	GetLastHdl() const { return maLastHdlLink; }
105 
106 	virtual Size	CalcMinimumSize() const;
107     virtual Size    GetOptimalSize(WindowSizeType eType) const;
108 	virtual Size	CalcSize( sal_uInt16 nChars ) const;
109 };
110 
111 #endif // _SV_SPINFLD_HXX
112 
113