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