2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
19 * @file FUiCtrl_ProgressImpl.cpp
20 * @brief This is the implementation file for the _ProgressImpl class.
23 #include <FUiCtrlProgress.h>
24 #include <FBaseSysLog.h>
25 #include <FUiAccessibilityContainer.h>
26 #include <FUiAccessibilityElement.h>
27 #include "FUi_UiBuilder.h"
28 #include "FUi_ResourceManager.h"
29 #include "FUi_ResourceSizeInfo.h"
30 #include "FUiCtrl_ProgressImpl.h"
31 #include "FUiCtrl_Progress.h"
33 using namespace Tizen::Ui;
34 using namespace Tizen::Graphics;
36 const int _DEFAULT_MINIMUM = 0;
37 const int _DEFAULT_MAXIMUM = 100;
39 namespace Tizen { namespace Ui { namespace Controls
43 _ProgressImpl::GetInstance(Progress& progress)
45 return static_cast<_ProgressImpl*> (progress._pControlImpl);
49 _ProgressImpl::GetInstance(const Progress& progress)
51 return static_cast<const _ProgressImpl*> (progress._pControlImpl);
54 _ProgressImpl::_ProgressImpl(Progress* pPublic, _Progress* pCore)
55 : _ControlImpl(pPublic, pCore)
57 SetFocusableChangable(false);
60 _ProgressImpl::~_ProgressImpl(void)
65 _ProgressImpl::CreateProgressImplN(Progress* pControl, const Rectangle& bounds)
71 r = GET_SIZE_INFO(Progress).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
72 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
74 _Progress* pCore = _Progress::CreateProgressN();
76 SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
78 _ProgressImpl* pImpl = new (std::nothrow) _ProgressImpl(pControl, pCore);
79 r = CheckConstruction(pCore, pImpl);
80 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
82 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Progress), bounds, pCore->GetOrientation());
83 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
88 delete pImpl; //This deletes pCore as well
95 _ProgressImpl::CreateProgressImplFN(Progress* pControl, const FloatRectangle& bounds)
101 r = GET_SIZE_INFO(Progress).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
102 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
104 _Progress* pCore = _Progress::CreateProgressN();
106 SysTryReturn(NID_UI_CTRL, pCore != null, null, r, "[%s] Propagating.", GetErrorMessage(r));
108 _ProgressImpl* pImpl = new (std::nothrow) _ProgressImpl(pControl, pCore);
109 r = CheckConstruction(pCore, pImpl);
110 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
112 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Progress), bounds, pCore->GetOrientation());
113 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
118 delete pImpl; //This deletes pCore as well
125 _ProgressImpl::SetValue(int value)
129 Variant newValue(value);
131 return GetCore().SetPropertyValue(newValue);
135 _ProgressImpl::SetRange(int minValue, int maxValue)
139 return GetCore().SetRange(minValue, maxValue);
143 _ProgressImpl::GetValue(void) const
147 return GetCore().GetPropertyValue().ToInt();
151 _ProgressImpl::GetRange(int& minValue, int& maxValue) const
155 return GetCore().GetRange(minValue, maxValue);
159 _ProgressImpl::GetPercentComplete(void) const
163 return GetCore().GetPercentComplete();
167 _ProgressImpl::SetBarColor(const Color& color)
171 Variant barColor(color);
173 return GetCore().SetPropertyBarColor(barColor);
177 _ProgressImpl::GetBarColor() const
181 return GetCore().GetPropertyBarColor().ToColor();
185 _ProgressImpl::SetBarBackgroundColor(const Color& color)
189 Variant barBackgroundColor(color);
191 return GetCore().SetPropertyBarBackgroundColor(barBackgroundColor);
195 _ProgressImpl::GetBarBackgroundColor() const
199 return GetCore().GetPropertyBarBackgroundColor().ToColor();
202 _ProgressImpl::GetPublicClassName(void) const
204 return "Tizen::Ui::Controls::Progress";
208 _ProgressImpl::GetPublic(void) const
210 return static_cast <const Progress&>(_ControlImpl::GetPublic());
214 _ProgressImpl::GetPublic(void)
216 return static_cast <Progress&>(_ControlImpl::GetPublic());
220 _ProgressImpl::GetCore(void) const
222 return static_cast <const _Progress&>(_ControlImpl::GetCore());
226 _ProgressImpl::GetCore(void)
228 return static_cast <_Progress&>(_ControlImpl::GetCore());
233 : public _UiBuilderControlMaker
237 _ProgressMaker(_UiBuilder* pUiBuilder)
238 : _UiBuilderControlMaker(pUiBuilder){}
239 virtual ~_ProgressMaker(void){}
241 static _UiBuilderControlMaker*
242 GetInstance(_UiBuilder* pUiBuilder)
244 _ProgressMaker* pProgressMaker = new (std::nothrow) _ProgressMaker(pUiBuilder);
245 return pProgressMaker;
250 Make(_UiBuilderControl* pControl)
252 result r = E_SUCCESS;
253 _UiBuilderControlLayout* pControlProperty = null;
254 Progress* pProgress = null;
255 Tizen::Base::String elementString;
256 Tizen::Base::String elementString1;
264 GetProperty(pControl, &pControlProperty);
265 if (pControlProperty == null)
270 pProgress = new (std::nothrow) Progress;
271 if (pProgress == null)
275 rect = pControlProperty->GetRectF();
277 if (pControl->GetElement(L"min", elementString) && pControl->GetElement(L"max", elementString1))
279 Base::Integer::Parse(elementString, tempMin);
280 Base::Integer::Parse(elementString1, tempMax);
281 if (tempMin > tempMax)
290 tempMin = _DEFAULT_MINIMUM;
291 tempMax = _DEFAULT_MAXIMUM;
294 r = pProgress->Construct(rect, tempMin, tempMax);
303 if (pControl->GetElement(L"value", elementString))
306 Base::Integer::Parse(elementString, tempValue);
307 pProgress->SetValue(tempValue);
310 if (pControl->GetElement(L"barColor", elementString))
312 ConvertStringToColor(elementString, color);
313 pProgress->SetBarColor(color);
316 if (pControl->GetElement(L"barBackgroundColor", elementString))
318 ConvertStringToColor(elementString, color);
319 pProgress->SetBarBackgroundColor(color);
322 if (pControl->GetElement(L"accessibilityHint", elementString))
324 AccessibilityContainer* pContainer = pProgress->GetAccessibilityContainer();
327 AccessibilityElement* pElement = pContainer->GetElement(L"ProgressingImage");
330 pElement->SetHint(elementString);
340 _ProgressRegister::_ProgressRegister(void)
342 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
343 pUiBuilderControlTableManager->RegisterControl(L"Progress", _ProgressMaker::GetInstance);
346 _ProgressRegister::~_ProgressRegister(void)
348 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
349 pUiBuilderControlTableManager->UnregisterControl(L"Progress");
351 static _ProgressRegister ProgressRegisterToUiBuilder;
352 }}} // Tizen::Ui::Controls