2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
18 * @file FUiCtrl_ProgressImpl.cpp
19 * @brief This is the implementation file for the _ProgressImpl class.
22 #include <FUiCtrlProgress.h>
23 #include <FBaseSysLog.h>
24 #include "FUi_UiBuilder.h"
25 #include "FUi_ResourceManager.h"
26 #include "FUi_ResourceSizeInfo.h"
27 #include "FUiCtrl_ProgressImpl.h"
28 #include "FUiCtrl_Progress.h"
30 using namespace Tizen::Ui;
31 using namespace Tizen::Graphics;
33 const int _DEFAULT_MINIMUM = 0;
34 const int _DEFAULT_MAXIMUM = 100;
36 namespace Tizen { namespace Ui { namespace Controls
40 _ProgressImpl::GetInstance(Progress& progress)
42 return static_cast<_ProgressImpl*> (progress._pControlImpl);
46 _ProgressImpl::GetInstance(const Progress& progress)
48 return static_cast<const _ProgressImpl*> (progress._pControlImpl);
51 _ProgressImpl::_ProgressImpl(Progress* pPublic, _Progress* pCore)
52 : _ControlImpl(pPublic, pCore)
54 SetFocusableChangable(false);
57 _ProgressImpl::~_ProgressImpl(void)
62 _ProgressImpl::CreateProgressImplN(Progress* pControl, const Rectangle& bounds)
68 r = GET_SIZE_INFO(Progress).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
69 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
71 _Progress* pCore = _Progress::CreateProgressN();
73 SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
75 _ProgressImpl* pImpl = new (std::nothrow) _ProgressImpl(pControl, pCore);
76 r = CheckConstruction(pCore, pImpl);
77 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
79 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Progress), bounds, pCore->GetOrientation());
80 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
85 delete pImpl; //This deletes pCore as well
92 _ProgressImpl::SetValue(int value)
96 Variant newValue(value);
98 return GetCore().SetPropertyValue(newValue);
102 _ProgressImpl::SetRange(int minValue, int maxValue)
106 return GetCore().SetRange(minValue, maxValue);
110 _ProgressImpl::GetValue(void) const
114 return GetCore().GetPropertyValue().ToInt();
118 _ProgressImpl::GetRange(int& minValue, int& maxValue) const
122 return GetCore().GetRange(minValue, maxValue);
126 _ProgressImpl::GetPercentComplete(void) const
130 return GetCore().GetPercentComplete();
134 _ProgressImpl::SetBarColor(const Color& color)
138 Variant barColor(color);
140 return GetCore().SetPropertyBarColor(barColor);
144 _ProgressImpl::GetBarColor() const
148 return GetCore().GetPropertyBarColor().ToColor();
152 _ProgressImpl::GetPublicClassName(void) const
154 return "Tizen::Ui::Controls::Progress";
158 _ProgressImpl::GetPublic(void) const
160 return static_cast <const Progress&>(_ControlImpl::GetPublic());
164 _ProgressImpl::GetPublic(void)
166 return static_cast <Progress&>(_ControlImpl::GetPublic());
170 _ProgressImpl::GetCore(void) const
172 return static_cast <const _Progress&>(_ControlImpl::GetCore());
176 _ProgressImpl::GetCore(void)
178 return static_cast <_Progress&>(_ControlImpl::GetCore());
183 : public _UiBuilderControlMaker
187 _ProgressMaker(_UiBuilder* pUiBuilder)
188 : _UiBuilderControlMaker(pUiBuilder){}
189 virtual ~_ProgressMaker(void){}
191 static _UiBuilderControlMaker*
192 GetInstance(_UiBuilder* pUiBuilder)
194 _ProgressMaker* pProgressMaker = new (std::nothrow) _ProgressMaker(pUiBuilder);
195 return pProgressMaker;
200 Make(_UiBuilderControl* pControl)
202 result r = E_SUCCESS;
203 _UiBuilderControlLayout* pControlProperty = null;
204 Progress* pProgress = null;
205 Tizen::Base::String elementString;
206 Tizen::Base::String elementString1;
214 GetProperty(pControl, &pControlProperty);
215 if (pControlProperty == null)
220 pProgress = new (std::nothrow) Progress;
221 if (pProgress == null)
225 rect = pControlProperty->GetRect();
227 if (pControl->GetElement(L"min", elementString) && pControl->GetElement(L"max", elementString1))
229 Base::Integer::Parse(elementString, tempMin);
230 Base::Integer::Parse(elementString1, tempMax);
231 if (tempMin > tempMax)
240 tempMin = _DEFAULT_MINIMUM;
241 tempMax = _DEFAULT_MAXIMUM;
244 r = pProgress->Construct(rect, tempMin, tempMax);
253 if (pControl->GetElement(L"value", elementString))
256 Base::Integer::Parse(elementString, tempValue);
257 pProgress->SetValue(tempValue);
260 if (pControl->GetElement(L"barColor", elementString))
262 ConvertStringToColor(elementString, color);
263 pProgress->SetBarColor(color);
271 _ProgressRegister::_ProgressRegister(void)
273 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
274 pUiBuilderControlTableManager->RegisterControl(L"Progress", _ProgressMaker::GetInstance);
277 _ProgressRegister::~_ProgressRegister(void)
279 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
280 pUiBuilderControlTableManager->UnregisterControl(L"Progress");
282 static _ProgressRegister ProgressRegisterToUiBuilder;
283 }}} // Tizen::Ui::Controls