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 FUiCtrlColorPicker.cpp
20 * @brief This is the implementation file for the %ColorPicker class.
23 #include <FBaseSysLog.h>
24 #include <FUiCtrlColorPicker.h>
25 #include "FUiCtrl_ColorPickerImpl.h"
27 using namespace Tizen::Graphics;
29 namespace Tizen { namespace Ui { namespace Controls
32 ColorPicker::ColorPicker(void)
36 ColorPicker::~ColorPicker(void)
41 ColorPicker::Construct(const Point& point)
43 SysAssertf((_ColorPickerImpl::GetInstance(*this) == null),
44 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
46 _ColorPickerImpl* pImpl = _ColorPickerImpl::CreateColorPickerImplN(*this);
47 result r = GetLastResult();
48 SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
50 _pControlImpl = pImpl;
51 r = SetPosition(point);
52 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
64 ColorPicker::Construct(const FloatPoint& point)
66 SysAssertf((_ColorPickerImpl::GetInstance(*this) == null),
67 "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
69 _ColorPickerImpl* pImpl = _ColorPickerImpl::CreateColorPickerImplN(*this);
70 result r = GetLastResult();
71 SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
73 _pControlImpl = pImpl;
74 r = SetPosition(point);
75 SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
87 ColorPicker::GetColor(void) const
89 const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
90 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
92 Color color = pImpl->GetColor();
93 result r = GetLastResult();
94 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), color, r, "[%s] Propagating.", GetErrorMessage(r));
100 ColorPicker::GetHue(void) const
102 const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
103 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
105 int hue = pImpl->GetHue();
106 result r = GetLastResult();
107 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), hue, r, "[%s] Propagating.", GetErrorMessage(r));
113 ColorPicker::GetSaturation(void) const
115 const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
116 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
118 int sat = pImpl->GetSaturation();
119 result r = GetLastResult();
120 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), sat, r, "[%s] Propagating.", GetErrorMessage(r));
126 ColorPicker::GetLuminance(void) const
128 const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
129 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
131 int lum = pImpl->GetLuminance();
132 result r = GetLastResult();
133 SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), lum, r, "[%s] Propagating.", GetErrorMessage(r));
139 ColorPicker::SetColor(const Tizen::Graphics::Color& color)
141 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
142 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
144 result r = pImpl->SetColor(color);
145 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
149 ColorPicker::SetHue(int hue)
151 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
152 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
154 result r = pImpl->SetHue(hue);
155 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
159 ColorPicker::SetSaturation(int saturation)
161 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
162 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
164 result r = pImpl->SetSaturation(saturation);
165 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
169 ColorPicker::SetLuminance(int luminance)
171 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
172 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
174 result r = pImpl->SetLuminance(luminance);
175 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
179 ColorPicker::AddColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener)
181 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
182 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
184 result r = pImpl->AddColorChangeEventListener(listener);
185 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
189 ColorPicker::RemoveColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener)
191 _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
192 SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
194 result r = pImpl->RemoveColorChangeEventListener(listener);
195 SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
198 }}} // Tizen::Ui::Controls