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 FUiCtrlColorPicker.cpp
19 * @brief This is the implementation file for the %ColorPicker class.
22 #include <FBaseSysLog.h>
23 #include <FUiCtrlColorPicker.h>
24 #include "FUiCtrl_ColorPickerImpl.h"
26 using namespace Tizen::Graphics;
28 namespace Tizen { namespace Ui { namespace Controls
31 ColorPicker::ColorPicker(void)
35 ColorPicker::~ColorPicker(void)
40 ColorPicker::Construct(const Point& point)
42 SysAssertf((_ColorPickerImpl::GetInstance(*this) == null),
43 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
45 _ColorPickerImpl* pImpl = _ColorPickerImpl::CreateColorPickerImplN(*this);
46 result r = GetLastResult();
47 SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
49 _pControlImpl = pImpl;
50 r = SetPosition(point);
51 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
63 ColorPicker::GetColor(void) const
65 const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
66 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
68 Color color = pImpl->GetColor();
69 result r = GetLastResult();
70 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), color, r, "[%s] Propagating.", GetErrorMessage(r));
76 ColorPicker::GetHue(void) const
78 const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
79 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
81 int hue = pImpl->GetHue();
82 result r = GetLastResult();
83 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), hue, r, "[%s] Propagating.", GetErrorMessage(r));
89 ColorPicker::GetSaturation(void) const
91 const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
92 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
94 int sat = pImpl->GetSaturation();
95 result r = GetLastResult();
96 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), sat, r, "[%s] Propagating.", GetErrorMessage(r));
102 ColorPicker::GetLuminance(void) const
104 const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
105 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
107 int lum = pImpl->GetLuminance();
108 result r = GetLastResult();
109 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), lum, r, "[%s] Propagating.", GetErrorMessage(r));
115 ColorPicker::SetColor(const Tizen::Graphics::Color& color)
117 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
118 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
120 result r = pImpl->SetColor(color);
121 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
125 ColorPicker::SetHue(int hue)
127 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
128 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
130 result r = pImpl->SetHue(hue);
131 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
135 ColorPicker::SetSaturation(int saturation)
137 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
138 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
140 result r = pImpl->SetSaturation(saturation);
141 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
145 ColorPicker::SetLuminance(int luminance)
147 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
148 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
150 result r = pImpl->SetLuminance(luminance);
151 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
155 ColorPicker::AddColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener)
157 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
158 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
160 result r = pImpl->AddColorChangeEventListener(listener);
161 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
165 ColorPicker::RemoveColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener)
167 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
168 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
170 result r = pImpl->RemoveColorChangeEventListener(listener);
171 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
174 }}} // Tizen::Ui::Controls