Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrlProgress.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file                FUiCtrlProgress.cpp
19  * @brief       This is the implementation file for Progress class.
20  */
21
22 #include <FUiCtrlProgress.h>
23 #include <FBaseSysLog.h>
24 #include "FUiCtrl_ProgressImpl.h"
25
26 using namespace Tizen::Graphics;
27
28 namespace Tizen { namespace Ui { namespace Controls
29 {
30
31 Progress::Progress(void)
32 {
33 }
34
35 Progress::~Progress(void)
36 {
37 }
38
39 result
40 Progress::Construct(const Rectangle& rect, int minValue, int maxValue)
41 {
42         result r = E_SUCCESS;
43
44         _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
45         SysAssertf((pProgressImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
46
47         pProgressImpl = _ProgressImpl::CreateProgressImplN(this, rect);
48         r = GetLastResult();
49         SysTryReturn(NID_UI_CTRL, pProgressImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
50
51         _pControlImpl = pProgressImpl;
52
53         r = pProgressImpl->SetRange(minValue, maxValue);
54         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
55
56         r = pProgressImpl->SetValue(minValue);
57         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
58
59         return E_SUCCESS;
60
61 CATCH:
62         delete pProgressImpl;
63         pProgressImpl = null;
64
65         _pControlImpl = null;
66
67         return r;
68 }
69
70 void
71 Progress::SetValue(int value)
72 {
73         _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
74         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
75
76         result r = pProgressImpl->SetValue(value);
77         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
78
79         return;
80 }
81
82 result
83 Progress::SetRange(int minValue, int maxValue)
84 {
85         _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
86         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
87
88         return pProgressImpl->SetRange(minValue, maxValue);
89 }
90
91 int
92 Progress::GetValue(void) const
93 {
94         const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
95         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
96
97         return pProgressImpl->GetValue();
98 }
99
100 void
101 Progress::GetRange(int& minValue, int& maxValue) const
102 {
103         const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
104         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
105
106         result r = pProgressImpl->GetRange(minValue, maxValue);
107         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
108
109         return;
110 }
111
112 int
113 Progress::GetPercentComplete(void) const
114 {
115         const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
116         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
117
118         return pProgressImpl->GetPercentComplete();
119 }
120
121 result
122 Progress::SetBarColor(const Color& color)
123 {
124         _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
125         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
126
127         return pProgressImpl->SetBarColor(color);
128 }
129
130 Color
131 Progress::GetBarColor(void) const
132 {
133         const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
134         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
135
136         return pProgressImpl->GetBarColor();
137 }
138
139 }}} // Tizen::Ui::Controls