changing hint text for accessibility.
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_Slider.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                FUiCtrl_Slider.cpp
20  * @brief       This is the implementation file for the _Slider class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FBaseErrorDefine.h>
25 #include <FGrp_BitmapImpl.h>
26 #include "FUi_ResourceManager.h"
27 #include "FUi_AccessibilityContainer.h"
28 #include "FUi_AccessibilityElement.h"
29 #include "FUiAnim_VisualElement.h"
30 #include "FUiCtrl_Slider.h"
31 #include "FUiCtrl_SliderPresenter.h"
32 #include "FUiCtrl_IAdjustmentEventListener.h"
33 #include "FUiCtrl_ISliderEventListener.h"
34
35 using namespace Tizen::Ui;
36 using namespace Tizen::Base;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Ui::Animations;
39
40 namespace Tizen { namespace Ui { namespace Controls
41 {
42 IMPLEMENT_PROPERTY(_Slider);
43
44 _Slider::_Slider(void)
45         : __pSliderPresenter(null)
46         , __pAdjustmentEvent(null)
47         , __pSliderEvent(null)
48         , __titleText()
49         , __pLeftBitmap(null)
50         , __pRightBitmap(null)
51         , __bgColor()
52         , __barColor()
53         , __barBgColor()
54         , __titleTextColor()
55         , __sliderStyle(_SLIDER_STYLE_OVERLAY)
56         , __pBase(null)
57         , __pHandle(null)
58         , __pAccessibilityElement(null)
59 {
60         __pBase = GetVisualElement();
61
62         if (__pBase != null)
63         {
64                 __pBase->SetSurfaceOpaque(false);
65                 __pBase->SetClipChildrenEnabled(false);
66         }
67
68         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
69         if (pContainer)
70         {
71                 pContainer->Activate(true);
72         }
73 }
74
75 _Slider::~_Slider(void)
76 {
77         if (__pAdjustmentEvent != null)
78         {
79                 delete __pAdjustmentEvent;
80                 __pAdjustmentEvent = null;
81         }
82
83         if (__pSliderEvent != null)
84         {
85                 delete __pSliderEvent;
86                 __pSliderEvent = null;
87         }
88
89         delete __pLeftBitmap;
90         __pLeftBitmap = null;
91
92         delete __pRightBitmap;
93         __pRightBitmap = null;
94
95         delete __pSliderPresenter;
96         __pSliderPresenter = null;
97
98         if (__pAccessibilityElement)
99         {
100                 __pAccessibilityElement->Activate(false);
101                 __pAccessibilityElement = null;
102         }
103
104         if (__pBase != null && __pHandle != null)
105         {
106                 __pBase->DetachChild(*__pHandle);
107                 __pHandle->Destroy();
108         }
109
110         __pHandle = null;
111         __pBase = null;
112 }
113
114 _Slider*
115 _Slider::CreateSliderN(void)
116 {
117         result r = E_SUCCESS;
118
119         _Slider* pSlider = new (std::nothrow) _Slider;
120         SysTryReturn(NID_UI_CTRL, pSlider, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
121
122         pSlider->__pSliderPresenter = _SliderPresenter::CreateInstanceN(*pSlider);
123         r = GetLastResult();
124         SysTryCatch(NID_UI_CTRL, pSlider->__pSliderPresenter != null, , r, "[%s] Propagating.", GetErrorMessage(r));
125
126         r = pSlider->Initialize();
127         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
128
129         pSlider->AcquireHandle();
130
131         return pSlider;
132
133 CATCH:
134         delete pSlider;
135         pSlider = null;
136
137         return null;
138 }
139
140 result
141 _Slider::Initialize(void)
142 {
143         result r = E_SUCCESS;
144
145         FloatRectangle handleRect(0.0f, 0.0f, 0.0f, 0.0f);
146         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
147
148         r = GET_COLOR_CONFIG(SLIDER::BG_DEFAULT_NORMAL, __bgColor);
149         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
150
151         r = GET_COLOR_CONFIG(SLIDER::BAR_NORMAL, __barColor);
152         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
153
154         r = GET_COLOR_CONFIG(SLIDER::BAR_BG_NORMAL, __barBgColor);
155         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
156
157         r = GET_COLOR_CONFIG(SLIDER::TITLE_TEXT_NORMAL, __titleTextColor);
158         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
159
160         r = GET_SHAPE_CONFIG(SLIDER::HANDLE_WIDTH, orientation, handleRect.width);
161         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
162
163         r = GET_SHAPE_CONFIG(SLIDER::HANDLE_HEIGHT, orientation, handleRect.height);
164         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
165
166         __pHandle = new (std::nothrow) Tizen::Ui::Animations::_VisualElement;
167         SysTryReturn(NID_UI_CTRL, __pHandle != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
168
169         r = __pHandle->Construct();
170         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
171
172         __pHandle->SetBounds(FloatRectangle(handleRect.x, handleRect.y, handleRect.width, handleRect.height));
173
174         __pHandle->SetShowState(true);
175
176         __pBase->SetClipChildrenEnabled(true);
177         __pHandle->SetClipToParent(true);
178
179
180         r = __pHandle->SetSurfaceOpaque(false);
181         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
182
183         __pHandle->SetImplicitAnimationEnabled(false);
184
185         r = __pBase->AttachChild(*__pHandle);
186         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
187
188         __pAdjustmentEvent = _AdjustmentEvent::CreateInstanceN(*this);
189         r = GetLastResult();
190         SysTryReturn(NID_UI_CTRL, __pAdjustmentEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
191
192         __pSliderEvent = _SliderEvent::CreateInstanceN(*this);
193         r = GetLastResult();
194         SysTryReturn(NID_UI_CTRL, __pSliderEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
195
196         InitializeAccessibilityElement();
197
198         return r;
199 }
200
201 result
202 _Slider::InitializeAccessibilityElement(void)
203 {
204         result r = E_SUCCESS;
205
206         if (__pAccessibilityElement)
207         {
208                 return r;
209         }
210
211         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
212         if (pContainer)
213         {
214                 __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
215                 SysTryReturn(NID_UI_CTRL, __pAccessibilityElement, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
216                                         "[E_OUT_OF_MEMORY] Memory allocation failed.");
217                 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBounds().width, GetBounds().height));
218                 __pAccessibilityElement->SetLabel(__titleText);
219                 __pAccessibilityElement->SetName(L"SliderControl");
220                 __pAccessibilityElement->SetTrait(L"Slider");
221                 __pAccessibilityElement->SetHint(L"flick up and down to adjust");
222                 SetAccessibilityElementValue();
223                 r = pContainer->AddElement(*__pAccessibilityElement);
224                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
225                 pContainer->AddListener(*this);
226         }
227
228         return r;
229 }
230
231 void
232 _Slider::OnDraw(void)
233 {
234         __pSliderPresenter->Draw();
235         return;
236 }
237
238 result
239 _Slider::OnAttachedToMainTree(void)
240 {
241         return _Control::OnAttachedToMainTree();
242 }
243
244 void
245 _Slider::SetStyle(int style)
246 {
247         __sliderStyle = style;
248         return;
249 }
250
251 int
252 _Slider::GetStyle(void) const
253 {
254         return __sliderStyle;
255 }
256
257 Canvas*
258 _Slider::GetHandleCanvasN(void) const
259 {
260         return __pHandle->GetCanvasN();
261 }
262
263 _VisualElement*
264 _Slider::GetHandle(void) const
265 {
266         return __pHandle;
267 }
268
269 void
270 _Slider::SetGroupStyle(GroupStyle groupStyle)
271 {
272         __pSliderPresenter->SetGroupStyle(groupStyle);
273         return;
274 }
275
276 result
277 _Slider::UpdateHandle(const FloatRectangle& handleRect)
278 {
279         __pHandle->SetBounds(handleRect);
280
281         return __pHandle->SetFlushNeeded();
282 }
283
284 bool
285 _Slider::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
286 {
287         return __pSliderPresenter->OnTouchPressed(source, touchinfo);
288 }
289
290 bool
291 _Slider::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
292 {
293         return __pSliderPresenter->OnTouchReleased(source, touchinfo);
294 }
295
296 bool
297 _Slider::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
298 {
299         return __pSliderPresenter->OnTouchMoved(source, touchinfo);
300 }
301
302 bool
303 _Slider::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
304 {
305         return __pSliderPresenter->OnTouchCanceled(source, touchinfo);
306 }
307
308 void
309 _Slider::OnDrawFocus(void)
310 {
311         __pSliderPresenter->SetFocusMode(true);
312         Invalidate();
313
314         return;
315 }
316
317 bool
318 _Slider::OnFocusGained(const _Control& source)
319 {
320         __pSliderPresenter->SetFocusMode(true);
321         Invalidate();
322
323         return true;
324 }
325
326 bool
327 _Slider::OnFocusLost(const _Control& source)
328 {
329         __pSliderPresenter->SetFocusMode(false);
330         Invalidate();
331
332         return true;
333 }
334
335 void
336 _Slider::OnFocusModeStateChanged()
337 {
338         __pSliderPresenter->SetFocusMode(false);
339         Invalidate();
340 }
341
342 bool
343 _Slider::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
344 {
345         if(__pSliderPresenter->GetFocusMode() == false)
346         {
347                 return false;
348         }
349
350         _KeyCode keyCode = keyInfo.GetKeyCode();
351
352         if (keyCode == _KEY_RIGHT)
353         {
354                 SetValue(GetValue() + 1);
355                 Invalidate();
356                 return true;
357         }
358
359         if (keyCode == _KEY_LEFT)
360         {
361                 SetValue(GetValue() - 1);
362                 Invalidate();
363                 return true;
364         }
365
366         return false;
367 }
368
369 void
370 _Slider::OnBoundsChanged(void)
371 {
372         __pSliderPresenter->OnBoundsChanged();
373
374         if (__pAccessibilityElement)
375         {
376                 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBounds().width, GetBounds().height));
377         }
378
379         return;
380 }
381
382 void
383 _Slider::OnChangeLayout(_ControlOrientation orientation)
384 {
385         __pSliderPresenter->OnChangeLayout(orientation);
386         return;
387 }
388
389 result
390 _Slider::SetRange(int minValue, int maxValue)
391 {
392         result r = E_SUCCESS;
393
394         SysTryReturn(NID_UI_CTRL, (minValue >= _SLIDER_MINIMUM_VALUE && maxValue >= _SLIDER_MINIMUM_VALUE),
395                                 E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The minimum value %d is out of range [-99 to 999].", minValue);
396         SysTryReturn(NID_UI_CTRL, (minValue <= _SLIDER_MAXIMUM_VALUE && maxValue <= _SLIDER_MAXIMUM_VALUE),
397                                 E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The maximum value %d is out of range [-99 to 999].", maxValue);
398         SysTryReturn(NID_UI_CTRL, (minValue < maxValue), E_INVALID_ARG, E_INVALID_ARG,
399                                 "[E_INVALID_ARG] The minimum value is greater than maximum value.");
400
401         Variant oldMinValue = GetProperty("minValue");
402         Variant value = GetProperty("value");
403
404         r = SetProperty("minValue", Variant(minValue));
405         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set minimum value.", GetErrorMessage(r));
406
407         r = SetProperty("maxValue", Variant(maxValue));
408         if (r != E_SUCCESS)
409         {
410                 SysLogException(NID_UI_CTRL, r, "[%s] Failed to set maximum value.", GetErrorMessage(r));
411
412                 result nestedResult = SetPropertyMinValue(oldMinValue);
413                 if (nestedResult != E_SUCCESS)
414                 {
415                         SysLog(NID_UI_CTRL, "Failed to recover original minimum value");
416                         return r;
417                 }
418
419                 nestedResult = SetPropertyValue(value);
420                 if (nestedResult != E_SUCCESS)
421                 {
422                         SysLog(NID_UI_CTRL, "Failed to recover original value");
423                 }
424         }
425
426         SetAccessibilityElementValue();
427
428         return r;
429 }
430
431 result
432 _Slider::SetPropertyMinValue(const Variant& minValue)
433 {
434         result r = E_SUCCESS;
435
436         int tempMinValue = minValue.ToInt();
437         r = GetLastResult();
438         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
439
440         __pSliderPresenter->SetMinValue(tempMinValue);
441
442         return r;
443 }
444
445 result
446 _Slider::SetPropertyMaxValue(const Variant& maxValue)
447 {
448         result r = E_SUCCESS;
449
450         int tempMaxValue = maxValue.ToInt();
451         r = GetLastResult();
452         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
453
454         __pSliderPresenter->SetMaxValue(tempMaxValue);
455
456         return r;
457 }
458
459 result
460 _Slider::GetRange(int& minValue, int& maxValue) const
461 {
462         result r = E_SUCCESS;
463
464         Variant minimum = GetProperty("minValue");
465         r = GetLastResult();
466         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
467
468         Variant maximum = GetProperty("maxValue");
469         r = GetLastResult();
470         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
471
472         minValue = minimum.ToInt();
473         maxValue = maximum.ToInt();
474
475         return r;
476 }
477
478 Variant
479 _Slider::GetPropertyMinValue(void) const
480 {
481         return Variant(__pSliderPresenter->GetMinValue());
482 }
483
484 Variant
485 _Slider::GetPropertyMaxValue(void) const
486 {
487         return Variant(__pSliderPresenter->GetMaxValue());
488 }
489
490 result
491 _Slider::SetValue(int value)
492 {
493         return SetProperty("value", Variant(value));
494 }
495
496 result
497 _Slider::SetPropertyValue(const Variant& value)
498 {
499         result r = E_SUCCESS;
500
501         int tempValue = value.ToInt();
502         r = GetLastResult();
503         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
504
505         __pSliderPresenter->SetValue(tempValue);
506
507         SetAccessibilityElementValue();
508
509         return r;
510 }
511
512 void
513 _Slider::SetAccessibilityElementValue()
514 {
515         if (__pAccessibilityElement)
516         {
517                 String string;
518                 string.Append(__pSliderPresenter->GetValue());
519                 string.Append(L" of ");
520                 string.Append(__pSliderPresenter->GetMaxValue());
521                 __pAccessibilityElement->SetValue(string);
522         }
523
524         return;
525 }
526 int
527 _Slider::GetValue(void) const
528 {
529         result r = E_SUCCESS;
530
531         Variant value = GetProperty("value");
532         r = GetLastResult();
533         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
534
535         return value.ToInt();
536 }
537
538 Variant
539 _Slider::GetPropertyValue(void) const
540 {
541         return Variant(__pSliderPresenter->GetValue());
542 }
543
544 result
545 _Slider::SetIcon(IconPosition position, const Bitmap& icon)
546 {
547         result r = E_SUCCESS;
548
549         float iconWidth = 0.0f;
550         float iconHeight = 0.0f;
551         _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
552         Bitmap* pNewBitmap = null;
553
554         r = GET_SHAPE_CONFIG(SLIDER::ICON_WIDTH, orientation, iconWidth);
555         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
556
557         r = GET_SHAPE_CONFIG(SLIDER::ICON_HEIGHT, orientation, iconHeight);
558         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
559
560         if (position == ICON_POSITION_LEFT)
561         {
562                 pNewBitmap = _BitmapImpl::CloneN(icon);
563
564                 r = GetLastResult();
565                 SysTryReturn(NID_UI_CTRL, pNewBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
566
567                 r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight));
568                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
569
570                 delete __pLeftBitmap;
571                 __pLeftBitmap = pNewBitmap;
572
573         }
574         else //(position == ICON_POSITION_RIGHT)
575         {
576                 pNewBitmap = _BitmapImpl::CloneN(icon);
577
578                 r = GetLastResult();
579                 SysTryReturn(NID_UI_CTRL, pNewBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
580
581                 r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight));
582                 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
583
584                 delete __pRightBitmap;
585                 __pRightBitmap = pNewBitmap;
586
587         }
588
589         __pSliderPresenter->SetNeedUpdate();
590
591         return E_SUCCESS;
592 CATCH:
593         delete pNewBitmap;
594         pNewBitmap = null;
595
596         return E_SYSTEM;
597 }
598
599 Bitmap*
600 _Slider::GetIcon(IconPosition position) const
601 {
602         if (position == ICON_POSITION_LEFT)
603         {
604                 return __pLeftBitmap;
605         }
606         else //(position == ICON_POSITION_RIGHT)
607         {
608                 return __pRightBitmap;
609         }
610 }
611
612 result
613 _Slider::SetTitleText(const String& title)
614 {
615         return SetProperty("titleText", Variant(title));
616 }
617
618 result
619 _Slider::SetPropertyTitleText(const Variant& titleText)
620 {
621         result r = E_SUCCESS;
622         String title = titleText.ToString();
623
624         if (!(GetStyle() & _SLIDER_STYLE_TITLE_TEXT))
625         {
626                 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The current Slider style does not support title text.");
627                 return E_SYSTEM;
628         }
629
630         __titleText = title;
631         __pSliderPresenter->SetNeedUpdate();
632
633         r = InitializeAccessibilityElement();
634         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
635
636         if (__pAccessibilityElement != null)
637         {
638                 __pAccessibilityElement->SetLabel(__titleText);
639         }
640
641         return r;
642 }
643
644 String
645 _Slider::GetTitleText(void) const
646 {
647         result r = E_SUCCESS;
648
649         Variant titleText = GetProperty("titleText");
650         r = GetLastResult();
651         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r));
652
653         return titleText.ToString();
654 }
655
656 Variant
657 _Slider::GetPropertyTitleText(void) const
658 {
659         return Variant(__titleText);
660 }
661
662 result
663 _Slider::SetTitleTextColor(const Color& color)
664 {
665         return SetProperty("titleTextColor", Variant(color));
666 }
667
668 result
669 _Slider::SetPropertyTitleTextColor(const Variant& titleTextColor)
670 {
671         result r = E_SUCCESS;
672
673         Color tempColor = titleTextColor.ToColor();
674         r = GetLastResult();
675         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
676
677         __titleTextColor = tempColor;
678         __pSliderPresenter->SetNeedUpdate();
679
680         return r;
681 }
682
683 Color
684 _Slider::GetTitleTextColor(void) const
685 {
686         result r = E_SUCCESS;
687
688         Variant titleTexColor = GetProperty("titleTextColor");
689         r = GetLastResult();
690         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
691
692         return titleTexColor.ToColor();
693 }
694
695 Variant
696 _Slider::GetPropertyTitleTextColor(void) const
697 {
698         return Variant(__titleTextColor);
699 }
700
701 result
702 _Slider::AddAdjustmentEventListener(const _IAdjustmentEventListener& listener)
703 {
704         return  __pAdjustmentEvent->AddListener(listener);
705 }
706
707 result
708 _Slider::RemoveAdjustmentEventListener(const _IAdjustmentEventListener& listener)
709 {
710         return __pAdjustmentEvent->RemoveListener(listener);
711 }
712
713 result
714 _Slider::AddSliderEventListener(const _ISliderEventListener& listener)
715 {
716         return __pSliderEvent->AddListener(listener);
717 }
718
719 result
720 _Slider::RemoveSliderEventListener(const _ISliderEventListener& listener)
721 {
722         return __pSliderEvent->RemoveListener(listener);
723 }
724
725 result
726 _Slider::SetBarColor(const Color& color)
727 {
728         return SetProperty("barColor", Variant(color));
729 }
730
731 result
732 _Slider::SetPropertyBarColor(const Variant& barColor)
733 {
734         result r = E_SUCCESS;
735
736         Color tempBarColor = barColor.ToColor();
737         r = GetLastResult();
738         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
739
740         __barColor = tempBarColor;
741         __barColor.SetAlpha(0xFF);
742
743         __pSliderPresenter->SetNeedUpdate();
744
745         return r;
746 }
747
748 Color
749 _Slider::GetBarColor(void) const
750 {
751         result r = E_SUCCESS;
752
753         Variant barColor = GetProperty("barColor");
754         r = GetLastResult();
755         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
756
757         return barColor.ToColor();
758 }
759
760 Variant
761 _Slider::GetPropertyBarColor(void) const
762 {
763         return Variant(__barColor);
764 }
765
766 result
767 _Slider::SetBarBackgroundColor(const Color& color)
768 {
769         return SetProperty("barBackgroundColor", Variant(color));
770 }
771
772 result
773 _Slider::SetPropertyBarBackgroundColor(const Variant& barBackgroundColor)
774 {
775         result r = E_SUCCESS;
776
777         Color tempBarBackgroundColor = barBackgroundColor.ToColor();
778         r = GetLastResult();
779         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
780
781         __barBgColor = tempBarBackgroundColor;
782         __barBgColor.SetAlpha(0xFF);
783
784         __pSliderPresenter->SetNeedUpdate();
785
786         return r;
787 }
788
789 Color
790 _Slider::GetBarBackgroundColor(void) const
791 {
792         result r = E_SUCCESS;
793
794         Variant barBgColor = GetProperty("barBackgroundColor");
795         r = GetLastResult();
796         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
797
798         return barBgColor.ToColor();
799 }
800
801 Variant
802 _Slider::GetPropertyBarBackgroundColor(void) const
803 {
804         return Variant(__barBgColor);
805 }
806
807 result
808 _Slider::SetColor(const Color& color)
809 {
810         return SetProperty("color", Variant(color));
811 }
812
813 result
814 _Slider::SetPropertyColor(const Variant& color)
815 {
816         if (__sliderStyle & _SLIDER_STYLE_NO_BG)
817         {
818                 SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current Slider style does not support background color.");
819                 return E_INVALID_OPERATION;
820         }
821
822         result r = E_SUCCESS;
823
824         Color tempBgColor = color.ToColor();
825         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
826
827         __bgColor = tempBgColor;
828
829         __pSliderPresenter->SetNeedUpdate();
830
831         return r;
832 }
833
834 Color
835 _Slider::GetColor(void) const
836 {
837         result r = E_SUCCESS;
838
839         Variant color = GetProperty("color");
840         r = GetLastResult();
841         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
842
843         return color.ToColor();
844 }
845
846 Variant
847 _Slider::GetPropertyColor(void) const
848 {
849         if (__sliderStyle & _SLIDER_STYLE_NO_BG)
850         {
851                 SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current Slider style does not support background color.");
852                 return Variant(Color());
853         }
854         else
855         {
856                 return Variant(__bgColor);
857         }
858 }
859
860 Tizen::Base::Runtime::_Event*
861 _Slider::GetAdjustmentEvent(void) const
862 {
863         return __pAdjustmentEvent;
864 }
865
866 _SliderEvent*
867 _Slider::GetSliderEvent(void) const
868 {
869         return __pSliderEvent;
870 }
871
872 result
873 _Slider::SetThumbBitmap(SliderThumbStatus status, const Bitmap& bitmap)
874 {
875         return __pSliderPresenter->SetThumbBitmap(status, bitmap);
876 }
877
878 void
879 _Slider::SetThumbTextColor(SliderThumbStatus status, const Color& color)
880 {
881         __pSliderPresenter->SetThumbTextColor(status, color);
882         return;
883 }
884
885 void
886 _Slider::OnFontChanged(Font* pFont)
887 {
888         __pSliderPresenter->OnFontChanged(pFont);
889         return;
890 }
891
892 void
893 _Slider::OnFontInfoRequested(unsigned long& style, float& size)
894 {
895         __pSliderPresenter->OnFontInfoRequested(style, size);
896         return;
897 }
898
899 void
900 _Slider::OnAncestorEnableStateChanged(const _Control& control)
901 {
902         __pSliderPresenter->OnAncestorEnableStateChanged(control);
903
904         return;
905 }
906
907 bool
908 _Slider::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
909 {
910         SetValue(GetValue() + 1);
911         String string;
912         string.Append(__pSliderPresenter->GetValue());
913         string.Append(L" of ");
914         string.Append(__pSliderPresenter->GetMaxValue());
915         _AccessibilityManager::GetInstance()->ReadContent(string);
916
917         Invalidate();
918         return true;
919 }
920
921 bool
922 _Slider::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
923 {
924         SetValue(GetValue() - 1);
925
926         String string;
927         string.Append(__pSliderPresenter->GetValue());
928         string.Append(L" of ");
929         string.Append(__pSliderPresenter->GetMaxValue());
930         _AccessibilityManager::GetInstance()->ReadContent(string);
931
932         Invalidate();
933         return true;
934 }
935
936 }}} // Tizen::Ui::Controls