Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrlColorPicker.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                FUiCtrlColorPicker.cpp
20  * @brief               This is the implementation file for the %ColorPicker class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FUiCtrlColorPicker.h>
25 #include "FUiCtrl_ColorPickerImpl.h"
26
27 using namespace Tizen::Graphics;
28
29 namespace Tizen { namespace Ui { namespace Controls
30 {
31
32 ColorPicker::ColorPicker(void)
33 {
34 }
35
36 ColorPicker::~ColorPicker(void)
37 {
38 }
39
40 result
41 ColorPicker::Construct(const Point& point)
42 {
43         SysAssertf((_ColorPickerImpl::GetInstance(*this) == null),
44                         "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
45
46         _ColorPickerImpl* pImpl = _ColorPickerImpl::CreateColorPickerImplN(*this);
47         result r = GetLastResult();
48         SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
49
50         _pControlImpl = pImpl;
51         r = SetPosition(point);
52         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
53
54         return r;
55
56 CATCH:
57         delete pImpl;
58         pImpl = null;
59
60         return r;
61 }
62
63 result
64 ColorPicker::Construct(const FloatPoint& point)
65 {
66         SysAssertf((_ColorPickerImpl::GetInstance(*this) == null),
67                         "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class");
68
69         _ColorPickerImpl* pImpl = _ColorPickerImpl::CreateColorPickerImplN(*this);
70         result r = GetLastResult();
71         SysTryReturn(NID_UI_CTRL, (pImpl != null), r, r, "[%s] Propagating.", GetErrorMessage(r));
72
73         _pControlImpl = pImpl;
74         r = SetPosition(point);
75         SysTryCatch(NID_UI_CTRL, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
76
77         return r;
78
79 CATCH:
80         delete pImpl;
81         pImpl = null;
82
83         return r;
84 }
85
86 Color
87 ColorPicker::GetColor(void) const
88 {
89         const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
90         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
91
92         Color color = pImpl->GetColor();
93         result r = GetLastResult();
94         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), color, r, "[%s] Propagating.", GetErrorMessage(r));
95
96         return color;
97 }
98
99 int
100 ColorPicker::GetHue(void) const
101 {
102         const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
103         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
104
105         int hue = pImpl->GetHue();
106         result r = GetLastResult();
107         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), hue, r, "[%s] Propagating.", GetErrorMessage(r));
108
109         return hue;
110 }
111
112 int
113 ColorPicker::GetSaturation(void) const
114 {
115         const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
116         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
117
118         int sat = pImpl->GetSaturation();
119         result r = GetLastResult();
120         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), sat, r, "[%s] Propagating.", GetErrorMessage(r));
121
122         return sat;
123 }
124
125 int
126 ColorPicker::GetLuminance(void) const
127 {
128         const _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
129         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
130
131         int lum = pImpl->GetLuminance();
132         result r = GetLastResult();
133         SysTryReturn(NID_UI_CTRL, (r == E_SUCCESS), lum, r, "[%s] Propagating.", GetErrorMessage(r));
134
135         return lum;
136 }
137
138 void
139 ColorPicker::SetColor(const Tizen::Graphics::Color& color)
140 {
141         _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
142         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
143
144         result r = pImpl->SetColor(color);
145         SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
146 }
147
148 void
149 ColorPicker::SetHue(int hue)
150 {
151         _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
152         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
153
154         result r = pImpl->SetHue(hue);
155         SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
156 }
157
158 void
159 ColorPicker::SetSaturation(int saturation)
160 {
161         _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
162         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
163
164         result r = pImpl->SetSaturation(saturation);
165         SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
166 }
167
168 void
169 ColorPicker::SetLuminance(int luminance)
170 {
171         _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
172         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
173
174         result r = pImpl->SetLuminance(luminance);
175         SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
176 }
177
178 void
179 ColorPicker::AddColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener)
180 {
181         _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
182         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
183
184         result r = pImpl->AddColorChangeEventListener(listener);
185         SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
186 }
187
188 void
189 ColorPicker::RemoveColorChangeEventListener(Tizen::Ui::IColorChangeEventListener& listener)
190 {
191         _ColorPickerImpl* pImpl = _ColorPickerImpl::GetInstance(*this);
192         SysAssertf(pImpl != null, "Not yet constructed. Construct() should be called before use.");
193
194         result r = pImpl->RemoveColorChangeEventListener(listener);
195         SysTryReturnVoidResult(NID_UI_CTRL, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
196 }
197
198 }}} // Tizen::Ui::Controls