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