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 DBACCESS_RANGEPROGRESSBAR_HXX
29 #define DBACCESS_RANGEPROGRESSBAR_HXX
30 
31 /** === begin UNO includes === **/
32 /** === end UNO includes === **/
33 
34 #include <svtools/prgsbar.hxx>
35 
36 //........................................................................
37 namespace dbmm
38 {
39 //........................................................................
40 
41 	//====================================================================
42 	//= RangeProgressBar
43 	//====================================================================
44     /** a slight extension of the usual progress bar, which is able to remember a range
45     */
46     class RangeProgressBar : public ProgressBar
47 	{
48     public:
49         RangeProgressBar( Window* _pParent, WinBits nWinBits = WB_STDPROGRESSBAR )
50             :ProgressBar( _pParent, nWinBits )
51         {
52         }
53 
54         RangeProgressBar( Window* _pParent, const ResId& rResId )
55             :ProgressBar( _pParent, rResId )
56         {
57         }
58 
59         inline  void        SetRange( sal_uInt32 _nRange );
60         inline  sal_uInt32  GetRange() const;
61 
62         inline  void        SetValue( sal_uInt32 _nValue );
63         inline  sal_uInt32  GetValue() const;
64 
65     private:
66         sal_uInt32  m_nRange;
67 
68     private:
69         using ProgressBar::SetValue;
70         using ProgressBar::GetValue;
71 	};
72 
73     //--------------------------------------------------------------------
74     inline void RangeProgressBar::SetRange( sal_uInt32 _nRange )
75     {
76         m_nRange = _nRange;
77         if ( !m_nRange )
78             m_nRange = 100;
79     }
80 
81     //--------------------------------------------------------------------
82     inline sal_uInt32 RangeProgressBar::GetRange() const
83     {
84         return m_nRange;
85     }
86 
87     //--------------------------------------------------------------------
88     inline void RangeProgressBar::SetValue( sal_uInt32 _nValue )
89     {
90         ProgressBar::SetValue( (sal_uInt16)( 100.0 * _nValue / m_nRange ) );
91     }
92 
93     //--------------------------------------------------------------------
94     inline sal_uInt32 RangeProgressBar::GetValue() const
95     {
96         return (sal_uInt32)( ProgressBar::GetValue() / 100.0 * m_nRange );
97     }
98 
99 
100 //........................................................................
101 } // namespace dbmm
102 //........................................................................
103 
104 #endif // DBACCESS_RANGEPROGRESSBAR_HXX
105