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 FUiCtrlSlider.cpp
20 * @brief This is the implementation file for Slider class.
23 #include <FBaseSysLog.h>
24 #include <FUiCtrlSlider.h>
25 #include "FUiCtrl_SliderImpl.h"
27 using namespace Tizen::Graphics;
28 using namespace Tizen::Base;
29 using namespace Tizen::Ui;
31 namespace Tizen { namespace Ui { namespace Controls
43 Slider::Construct(const Rectangle& rect, BackgroundStyle backgroundStyle, bool showTitle, int minValue, int maxValue, GroupStyle groupStyle)
47 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
48 SysAssertf((pSliderImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
53 sliderStyle |= SLIDER_STYLE_TITLE;
55 sliderStyle |= SLIDER_STYLE_BUBBLE;
57 pSliderImpl = _SliderImpl::CreateSliderImplN(this, rect, sliderStyle);
59 SysTryReturn(NID_UI_CTRL, pSliderImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
61 r = pSliderImpl->Initialize(minValue, maxValue, backgroundStyle, sliderStyle, groupStyle);
62 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
64 _pControlImpl = pSliderImpl;
76 Slider::Construct(const FloatRectangle& rect, BackgroundStyle backgroundStyle, bool showTitle, int minValue, int maxValue, GroupStyle groupStyle)
80 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
81 SysAssertf((pSliderImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
86 sliderStyle |= SLIDER_STYLE_TITLE;
88 sliderStyle |= SLIDER_STYLE_BUBBLE;
90 pSliderImpl = _SliderImpl::CreateSliderImplFN(this, rect, sliderStyle);
92 SysTryReturn(NID_UI_CTRL, pSliderImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
94 r = pSliderImpl->Initialize(minValue, maxValue, backgroundStyle, sliderStyle, groupStyle);
95 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
97 _pControlImpl = pSliderImpl;
109 Slider::Construct(const Rectangle& rect, unsigned long sliderStyle, int minValue, int maxValue)
111 result r = E_SUCCESS;
113 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
114 SysAssertf((pSliderImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
116 pSliderImpl = _SliderImpl::CreateSliderImplN(this, rect, sliderStyle);
118 SysTryReturn(NID_UI_CTRL, pSliderImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
120 r = pSliderImpl->Initialize(minValue, maxValue, BACKGROUND_STYLE_DEFAULT, sliderStyle, GROUP_STYLE_NONE);
121 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
123 _pControlImpl = pSliderImpl;
135 Slider::Construct(const FloatRectangle& rect, unsigned long sliderStyle, int minValue, int maxValue)
137 result r = E_SUCCESS;
139 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
140 SysAssertf((pSliderImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
142 pSliderImpl = _SliderImpl::CreateSliderImplFN(this, rect, sliderStyle);
144 SysTryReturn(NID_UI_CTRL, pSliderImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
146 r = pSliderImpl->Initialize(minValue, maxValue, BACKGROUND_STYLE_DEFAULT, sliderStyle, GROUP_STYLE_NONE);
147 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
149 _pControlImpl = pSliderImpl;
161 Slider::SetRange(int minValue, int maxValue)
163 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
164 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
166 result r = pSliderImpl->SetRange(minValue, maxValue);
167 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
173 Slider::GetRange(int& minValue, int& maxValue) const
175 const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
176 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
178 result r = pSliderImpl->GetRange(minValue, maxValue);
179 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
185 Slider::SetValue(int value)
187 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
188 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
190 result r = pSliderImpl->SetValue(value);
191 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
197 Slider::GetValue(void) const
199 const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
200 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
202 int value = pSliderImpl->GetValue();
203 result r = GetLastResult();
204 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
210 Slider::SetIcon(IconPosition position, const Bitmap& icon)
212 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
213 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
215 result r = pSliderImpl->SetIcon(position, icon);
216 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
222 Slider::AddAdjustmentEventListener(IAdjustmentEventListener& listener)
224 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
225 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
227 result r = pSliderImpl->AddAdjustmentEventListener(listener);
228 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
234 Slider::RemoveAdjustmentEventListener(IAdjustmentEventListener& listener)
236 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
237 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
239 result r = pSliderImpl->RemoveAdjustmentEventListener(listener);
240 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
246 Slider::SetTitleText(const String& title)
248 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
249 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
251 result r = pSliderImpl->SetTitleText(title);
252 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
258 Slider::GetTitleText(void) const
260 const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
261 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
263 String string = pSliderImpl->GetTitleText();
264 result r = GetLastResult();
265 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r));
271 Slider::SetTitleTextColor(const Color& color)
273 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
274 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
276 result r = pSliderImpl->SetTitleTextColor(color);
277 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
283 Slider::GetTitleTextColor(void) const
285 const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
286 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
288 Color color = pSliderImpl->GetTitleTextColor();
289 result r = GetLastResult();
290 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
296 Slider::AddSliderEventListener(ISliderEventListener& listener)
298 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
299 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
301 result r = pSliderImpl->AddSliderEventListener(listener);
302 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
308 Slider::RemoveSliderEventListener(ISliderEventListener& listener)
310 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
311 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
313 result r = pSliderImpl->RemoveSliderEventListener(listener);
314 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
320 Slider::SetBarColor(const Color& color)
322 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
323 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
325 result r = pSliderImpl->SetBarColor(color);
326 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
332 Slider::GetBarColor(void) const
334 const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
335 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
337 Color color = pSliderImpl->GetBarColor();
338 result r = GetLastResult();
339 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
345 Slider::SetBarBackgroundColor(const Color& color)
347 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
348 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
350 result r = pSliderImpl->SetBarBackgroundColor(color);
351 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
357 Slider::GetBarBackgroundColor(void) const
359 const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
360 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
362 Color color = pSliderImpl->GetBarBackgroundColor();
363 result r = GetLastResult();
364 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
370 Slider::SetColor(const Color& color)
372 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
373 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
375 result r = pSliderImpl->SetColor(color);
376 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
382 Slider::GetColor(void) const
384 const _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
385 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
387 Color color = pSliderImpl->GetColor();
388 result r = GetLastResult();
389 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
395 Slider::SetThumbBitmap(SliderThumbStatus status, const Bitmap& bitmap)
397 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
398 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
400 result r = pSliderImpl->SetThumbBitmap(status, bitmap);
401 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
407 Slider::SetThumbTextColor(SliderThumbStatus status, const Color& color)
409 _SliderImpl* pSliderImpl = _SliderImpl::GetInstance(*this);
410 SysAssertf(pSliderImpl != null, "Not yet constructed. Construct() should be called before use.");
412 pSliderImpl->SetThumbTextColor(status, color);
417 }}} // Tizen::Ui::Controls