Changed indicator bg color.
[platform/framework/native/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 Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0/
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 /**
19  * @file                FUiCtrlProgress.cpp
20  * @brief       This is the implementation file for Progress class.
21  */
22
23 #include <FUiCtrlProgress.h>
24 #include <FBaseSysLog.h>
25 #include "FUiCtrl_ProgressImpl.h"
26
27 using namespace Tizen::Graphics;
28
29 namespace Tizen { namespace Ui { namespace Controls
30 {
31
32 Progress::Progress(void)
33 {
34 }
35
36 Progress::~Progress(void)
37 {
38 }
39
40 result
41 Progress::Construct(const Rectangle& rect, int minValue, int maxValue)
42 {
43         result r = E_SUCCESS;
44
45         _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
46         SysAssertf((pProgressImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
47
48         pProgressImpl = _ProgressImpl::CreateProgressImplN(this, rect);
49         r = GetLastResult();
50         SysTryReturn(NID_UI_CTRL, pProgressImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
51
52         _pControlImpl = pProgressImpl;
53
54         r = pProgressImpl->SetRange(minValue, maxValue);
55         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
56
57         r = pProgressImpl->SetValue(minValue);
58         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
59
60         return E_SUCCESS;
61
62 CATCH:
63         delete pProgressImpl;
64         pProgressImpl = null;
65
66         _pControlImpl = null;
67
68         return r;
69 }
70
71 result
72 Progress::Construct(const FloatRectangle& rect, int minValue, int maxValue)
73 {
74         result r = E_SUCCESS;
75
76         _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
77         SysAssertf((pProgressImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
78
79         pProgressImpl = _ProgressImpl::CreateProgressImplFN(this, rect);
80         r = GetLastResult();
81         SysTryReturn(NID_UI_CTRL, pProgressImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
82
83         _pControlImpl = pProgressImpl;
84
85         r = pProgressImpl->SetRange(minValue, maxValue);
86         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
87
88         r = pProgressImpl->SetValue(minValue);
89         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
90
91         return E_SUCCESS;
92
93 CATCH:
94         delete pProgressImpl;
95         pProgressImpl = null;
96
97         _pControlImpl = null;
98
99         return r;
100 }
101
102 void
103 Progress::SetValue(int value)
104 {
105         _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
106         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
107
108         result r = pProgressImpl->SetValue(value);
109         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
110
111         return;
112 }
113
114 result
115 Progress::SetRange(int minValue, int maxValue)
116 {
117         _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
118         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
119
120         return pProgressImpl->SetRange(minValue, maxValue);
121 }
122
123 int
124 Progress::GetValue(void) const
125 {
126         const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
127         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
128
129         return pProgressImpl->GetValue();
130 }
131
132 void
133 Progress::GetRange(int& minValue, int& maxValue) const
134 {
135         const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
136         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
137
138         result r = pProgressImpl->GetRange(minValue, maxValue);
139         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
140
141         return;
142 }
143
144 int
145 Progress::GetPercentComplete(void) const
146 {
147         const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
148         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
149
150         return pProgressImpl->GetPercentComplete();
151 }
152
153 result
154 Progress::SetBarColor(const Color& color)
155 {
156         _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
157         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
158
159         return pProgressImpl->SetBarColor(color);
160 }
161
162 Color
163 Progress::GetBarColor(void) const
164 {
165         const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
166         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
167
168         return pProgressImpl->GetBarColor();
169 }
170
171 void
172 Progress::SetBarBackgroundColor(const Color& color)
173 {
174         _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
175         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
176
177         result r = pProgressImpl->SetBarBackgroundColor(color);
178         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
179
180         return;
181 }
182
183 Color
184 Progress::GetBarBackgroundColor(void) const
185 {
186         const _ProgressImpl* pProgressImpl = _ProgressImpl::GetInstance(*this);
187         SysAssertf(pProgressImpl != null, "Not yet constructed. Construct() should be called before use.");
188
189         return pProgressImpl->GetBarBackgroundColor();
190 }
191 }}} // Tizen::Ui::Controls