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 FUiCtrl_Slider.cpp
20 * @brief This is the implementation file for the _Slider class.
24 #include <FBaseSysLog.h>
25 #include <FBaseErrorDefine.h>
26 #include <FGrp_BitmapImpl.h>
27 #include "FUi_ResourceManager.h"
28 #include "FUi_AccessibilityContainer.h"
29 #include "FUi_AccessibilityElement.h"
30 #include "FUiAnim_VisualElement.h"
31 #include "FUiCtrl_Slider.h"
32 #include "FUiCtrl_SliderPresenter.h"
33 #include "FUiCtrl_IAdjustmentEventListener.h"
34 #include "FUiCtrl_ISliderEventListener.h"
35 #include "FUiCtrl_SliderOverlay.h"
37 using namespace Tizen::Ui;
38 using namespace Tizen::Base;
39 using namespace Tizen::Graphics;
40 using namespace Tizen::Ui::Animations;
41 using namespace Tizen::Base::Runtime;
43 namespace Tizen { namespace Ui { namespace Controls
45 IMPLEMENT_PROPERTY(_Slider);
47 _Slider::_Slider(void)
48 : __pSliderPresenter(null)
49 , __pAdjustmentEvent(null)
50 , __pSliderEvent(null)
53 , __pRightBitmap(null)
58 , __sliderStyle(_SLIDER_STYLE_OVERLAY)
61 , __pAccessibilityElement(null)
62 , __isKeyPressed(false)
64 __pBase = GetVisualElement();
68 __pBase->SetSurfaceOpaque(false);
69 __pBase->SetClipChildrenEnabled(false);
72 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
75 pContainer->Activate(true);
79 _Slider::~_Slider(void)
81 if (__pAdjustmentEvent != null)
83 delete __pAdjustmentEvent;
84 __pAdjustmentEvent = null;
87 if (__pSliderEvent != null)
89 delete __pSliderEvent;
90 __pSliderEvent = null;
96 delete __pRightBitmap;
97 __pRightBitmap = null;
99 delete __pSliderPresenter;
100 __pSliderPresenter = null;
102 if (__pAccessibilityElement)
104 __pAccessibilityElement->Activate(false);
105 __pAccessibilityElement = null;
108 if (__pBase != null && __pHandle != null)
110 __pBase->DetachChild(*__pHandle);
111 __pHandle->Destroy();
119 _Slider::CreateSliderN(void)
121 result r = E_SUCCESS;
123 _Slider* pSlider = new (std::nothrow) _Slider;
124 SysTryReturn(NID_UI_CTRL, pSlider, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
126 pSlider->__pSliderPresenter = _SliderPresenter::CreateInstanceN(*pSlider);
128 SysTryCatch(NID_UI_CTRL, pSlider->__pSliderPresenter != null, , r, "[%s] Propagating.", GetErrorMessage(r));
130 r = pSlider->Initialize();
131 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
133 pSlider->AcquireHandle();
145 _Slider::Initialize(void)
147 result r = E_SUCCESS;
149 FloatRectangle handleRect(0.0f, 0.0f, 0.0f, 0.0f);
150 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
152 r = GET_COLOR_CONFIG(SLIDER::BG_DEFAULT_NORMAL, __bgColor);
153 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
155 r = GET_COLOR_CONFIG(SLIDER::BAR_NORMAL, __barColor);
156 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
158 r = GET_COLOR_CONFIG(SLIDER::BAR_BG_NORMAL, __barBgColor);
159 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
161 r = GET_COLOR_CONFIG(SLIDER::TITLE_TEXT_NORMAL, __titleTextColor);
162 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
164 r = GET_SHAPE_CONFIG(SLIDER::HANDLE_WIDTH, orientation, handleRect.width);
165 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
167 r = GET_SHAPE_CONFIG(SLIDER::HANDLE_HEIGHT, orientation, handleRect.height);
168 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
170 __pHandle = new (std::nothrow) Tizen::Ui::Animations::_VisualElement;
171 SysTryReturn(NID_UI_CTRL, __pHandle != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
173 r = __pHandle->Construct();
174 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
176 __pHandle->SetBounds(FloatRectangle(handleRect.x, handleRect.y, handleRect.width, handleRect.height));
178 __pHandle->SetShowState(true);
180 __pBase->SetClipChildrenEnabled(true);
181 __pHandle->SetClipToParent(true);
184 r = __pHandle->SetSurfaceOpaque(false);
185 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
187 __pHandle->SetImplicitAnimationEnabled(false);
189 r = __pBase->AttachChild(*__pHandle);
190 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
192 __pAdjustmentEvent = _AdjustmentEvent::CreateInstanceN(*this);
194 SysTryReturn(NID_UI_CTRL, __pAdjustmentEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
196 __pSliderEvent = _SliderEvent::CreateInstanceN(*this);
198 SysTryReturn(NID_UI_CTRL, __pSliderEvent, r, r, "[%s] Propagating.", GetErrorMessage(r));
200 InitializeAccessibilityElement();
206 _Slider::InitializeAccessibilityElement(void)
208 result r = E_SUCCESS;
210 if (__pAccessibilityElement)
215 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
218 __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
219 SysTryReturn(NID_UI_CTRL, __pAccessibilityElement, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
220 "[E_OUT_OF_MEMORY] Memory allocation failed.");
221 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBounds().width, GetBounds().height));
222 __pAccessibilityElement->SetLabel(__titleText);
223 __pAccessibilityElement->SetName(L"SliderControl");
224 __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_SLIDER_T_TTS");
225 __pAccessibilityElement->SetHintWithStringId("IDS_TPLATFORM_BODY_FLICK_UP_AND_DOWN_TO_ADJUST_THE_POSITION_T_TTS");
226 SetAccessibilityElementValue();
227 r = pContainer->AddElement(*__pAccessibilityElement);
228 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
229 pContainer->AddListener(*this);
236 _Slider::OnDraw(void)
238 __pSliderPresenter->Draw();
243 _Slider::OnAttachedToMainTree(void)
245 return _Control::OnAttachedToMainTree();
249 _Slider::SetStyle(int style)
251 __sliderStyle = style;
256 _Slider::GetStyle(void) const
258 return __sliderStyle;
262 _Slider::GetHandleCanvasN(void) const
264 return __pHandle->GetCanvasN();
268 _Slider::GetHandle(void) const
274 _Slider::SetGroupStyle(GroupStyle groupStyle)
276 __pSliderPresenter->SetGroupStyle(groupStyle);
281 _Slider::UpdateHandle(const FloatRectangle& handleRect)
283 __pHandle->SetBounds(handleRect);
285 return __pHandle->SetFlushNeeded();
289 _Slider::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
291 return __pSliderPresenter->OnTouchPressed(source, touchinfo);
295 _Slider::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
297 return __pSliderPresenter->OnTouchReleased(source, touchinfo);
301 _Slider::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
303 return __pSliderPresenter->OnTouchMoved(source, touchinfo);
307 _Slider::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
309 return __pSliderPresenter->OnTouchCanceled(source, touchinfo);
313 _Slider::OnDrawFocus(void)
315 __pSliderPresenter->SetFocusMode(true);
322 _Slider::OnFocusGained(const _Control& source)
324 __pSliderPresenter->SetFocusMode(true);
331 _Slider::OnFocusLost(const _Control& source)
333 __pSliderPresenter->SetFocusMode(false);
335 if ((GetStyle() & _SLIDER_STYLE_OVERLAY) && (!__pSliderPresenter->IsTouchPressed()) && (__isKeyPressed == true))
337 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
338 pSliderOverlay->SetVisibleState(false);
339 pSliderOverlay->Close();
342 __isKeyPressed = false;
349 _Slider::OnFocusModeStateChanged()
351 __pSliderPresenter->SetFocusMode(false);
356 _Slider::IsKeyPressed() const
358 return __isKeyPressed;
362 _Slider::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
364 if(__pSliderPresenter->GetFocusMode() == false)
369 _KeyCode keyCode = keyInfo.GetKeyCode();
371 if (keyCode == _KEY_RIGHT)
373 SetValue(GetValue() + 1);
374 FireSliderMoveEvent(GetValue());
376 if (GetStyle() & _SLIDER_STYLE_OVERLAY)
378 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
379 pSliderOverlay->SetVisibleState(true);
380 pSliderOverlay->Open();
381 __isKeyPressed = true;
388 if (keyCode == _KEY_LEFT)
390 SetValue(GetValue() - 1);
391 FireSliderMoveEvent(GetValue());
393 if (GetStyle() & _SLIDER_STYLE_OVERLAY)
395 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
396 pSliderOverlay->SetVisibleState(true);
397 pSliderOverlay->Open();
398 __isKeyPressed = true;
409 _Slider::OnKeyReleased(const _Control &source, const _KeyInfo &keyInfo)
411 if(__pSliderPresenter->GetFocusMode() == false)
416 _KeyCode keyCode = keyInfo.GetKeyCode();
418 if (keyCode == _KEY_LEFT || keyCode == _KEY_RIGHT)
420 if ((GetStyle() & _SLIDER_STYLE_OVERLAY) && (__isKeyPressed == true))
422 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
423 pSliderOverlay->SetVisibleState(false);
424 pSliderOverlay->Close();
427 FireAdjustmentValueEvent(GetValue());
428 __isKeyPressed = false;
438 _Slider::OnBoundsChanged(void)
440 __pSliderPresenter->OnBoundsChanged();
442 if (__pAccessibilityElement)
444 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBounds().width, GetBounds().height));
451 _Slider::OnChangeLayout(_ControlOrientation orientation)
453 __pSliderPresenter->OnChangeLayout(orientation);
458 _Slider::SetRange(int minValue, int maxValue)
460 result r = E_SUCCESS;
462 SysTryReturn(NID_UI_CTRL, (minValue >= _SLIDER_MINIMUM_VALUE && maxValue >= _SLIDER_MINIMUM_VALUE),
463 E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The minimum value %d is out of range [-99 to 999].", minValue);
464 SysTryReturn(NID_UI_CTRL, (minValue <= _SLIDER_MAXIMUM_VALUE && maxValue <= _SLIDER_MAXIMUM_VALUE),
465 E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The maximum value %d is out of range [-99 to 999].", maxValue);
466 SysTryReturn(NID_UI_CTRL, (minValue < maxValue), E_INVALID_ARG, E_INVALID_ARG,
467 "[E_INVALID_ARG] The minimum value is greater than maximum value.");
469 Variant oldMinValue = GetProperty("minValue");
470 Variant value = GetProperty("value");
472 r = SetProperty("minValue", Variant(minValue));
473 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set minimum value.", GetErrorMessage(r));
475 r = SetProperty("maxValue", Variant(maxValue));
478 SysLogException(NID_UI_CTRL, r, "[%s] Failed to set maximum value.", GetErrorMessage(r));
480 result nestedResult = SetPropertyMinValue(oldMinValue);
481 if (nestedResult != E_SUCCESS)
483 SysLog(NID_UI_CTRL, "Failed to recover original minimum value");
487 nestedResult = SetPropertyValue(value);
488 if (nestedResult != E_SUCCESS)
490 SysLog(NID_UI_CTRL, "Failed to recover original value");
494 SetAccessibilityElementValue();
500 _Slider::SetPropertyMinValue(const Variant& minValue)
502 result r = E_SUCCESS;
504 int tempMinValue = minValue.ToInt();
506 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
508 __pSliderPresenter->SetMinValue(tempMinValue);
514 _Slider::SetPropertyMaxValue(const Variant& maxValue)
516 result r = E_SUCCESS;
518 int tempMaxValue = maxValue.ToInt();
520 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
522 __pSliderPresenter->SetMaxValue(tempMaxValue);
528 _Slider::GetRange(int& minValue, int& maxValue) const
530 result r = E_SUCCESS;
532 Variant minimum = GetProperty("minValue");
534 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
536 Variant maximum = GetProperty("maxValue");
538 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
540 minValue = minimum.ToInt();
541 maxValue = maximum.ToInt();
547 _Slider::GetPropertyMinValue(void) const
549 return Variant(__pSliderPresenter->GetMinValue());
553 _Slider::GetPropertyMaxValue(void) const
555 return Variant(__pSliderPresenter->GetMaxValue());
559 _Slider::SetValue(int value)
561 return SetProperty("value", Variant(value));
565 _Slider::SetPropertyValue(const Variant& value)
567 result r = E_SUCCESS;
569 int tempValue = value.ToInt();
571 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
573 __pSliderPresenter->SetValue(tempValue);
575 SetAccessibilityElementValue();
581 _Slider::SetAccessibilityElementValue()
583 if (__pAccessibilityElement)
586 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
587 char buffer[10] = {0,};
588 sprintf(buffer, "%d", GetValue());
589 string.Replace(L"%1$d", buffer);
590 memset(buffer, 0, 10);
591 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
592 string.Replace(L"%2$d", buffer);
593 __pAccessibilityElement->SetValue(string);
599 _Slider::GetValue(void) const
601 result r = E_SUCCESS;
603 Variant value = GetProperty("value");
605 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
607 return value.ToInt();
611 _Slider::GetPropertyValue(void) const
613 return Variant(__pSliderPresenter->GetValue());
617 _Slider::SetIcon(IconPosition position, const Bitmap& icon)
619 result r = E_SUCCESS;
621 float iconWidth = 0.0f;
622 float iconHeight = 0.0f;
623 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
624 Bitmap* pNewBitmap = null;
626 r = GET_SHAPE_CONFIG(SLIDER::ICON_WIDTH, orientation, iconWidth);
627 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
629 r = GET_SHAPE_CONFIG(SLIDER::ICON_HEIGHT, orientation, iconHeight);
630 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
632 if (position == ICON_POSITION_LEFT)
634 pNewBitmap = _BitmapImpl::CloneN(icon);
637 SysTryReturn(NID_UI_CTRL, pNewBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
639 r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight));
640 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
642 delete __pLeftBitmap;
643 __pLeftBitmap = pNewBitmap;
646 else //(position == ICON_POSITION_RIGHT)
648 pNewBitmap = _BitmapImpl::CloneN(icon);
651 SysTryReturn(NID_UI_CTRL, pNewBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
653 r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight));
654 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
656 delete __pRightBitmap;
657 __pRightBitmap = pNewBitmap;
661 __pSliderPresenter->SetNeedUpdate();
672 _Slider::GetIcon(IconPosition position) const
674 if (position == ICON_POSITION_LEFT)
676 return __pLeftBitmap;
678 else //(position == ICON_POSITION_RIGHT)
680 return __pRightBitmap;
685 _Slider::SetTitleText(const String& title)
687 return SetProperty("titleText", Variant(title));
691 _Slider::SetPropertyTitleText(const Variant& titleText)
693 result r = E_SUCCESS;
694 String title = titleText.ToString();
696 if (!(GetStyle() & _SLIDER_STYLE_TITLE_TEXT))
698 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The current Slider style does not support title text.");
703 __pSliderPresenter->SetNeedUpdate();
705 r = InitializeAccessibilityElement();
706 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
708 if (__pAccessibilityElement != null)
710 __pAccessibilityElement->SetLabel(__titleText);
717 _Slider::GetTitleText(void) const
719 result r = E_SUCCESS;
721 Variant titleText = GetProperty("titleText");
723 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r));
725 return titleText.ToString();
729 _Slider::GetPropertyTitleText(void) const
731 return Variant(__titleText);
735 _Slider::SetTitleTextColor(const Color& color)
737 return SetProperty("titleTextColor", Variant(color));
741 _Slider::SetPropertyTitleTextColor(const Variant& titleTextColor)
743 result r = E_SUCCESS;
745 Color tempColor = titleTextColor.ToColor();
747 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
749 __titleTextColor = tempColor;
750 __pSliderPresenter->SetNeedUpdate();
756 _Slider::GetTitleTextColor(void) const
758 result r = E_SUCCESS;
760 Variant titleTexColor = GetProperty("titleTextColor");
762 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
764 return titleTexColor.ToColor();
768 _Slider::GetPropertyTitleTextColor(void) const
770 return Variant(__titleTextColor);
774 _Slider::AddAdjustmentEventListener(const _IAdjustmentEventListener& listener)
776 return __pAdjustmentEvent->AddListener(listener);
780 _Slider::RemoveAdjustmentEventListener(const _IAdjustmentEventListener& listener)
782 return __pAdjustmentEvent->RemoveListener(listener);
786 _Slider::AddSliderEventListener(const _ISliderEventListener& listener)
788 return __pSliderEvent->AddListener(listener);
792 _Slider::RemoveSliderEventListener(const _ISliderEventListener& listener)
794 return __pSliderEvent->RemoveListener(listener);
798 _Slider::SetBarColor(const Color& color)
800 return SetProperty("barColor", Variant(color));
804 _Slider::SetPropertyBarColor(const Variant& barColor)
806 result r = E_SUCCESS;
808 Color tempBarColor = barColor.ToColor();
810 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
812 __barColor = tempBarColor;
813 __barColor.SetAlpha(0xFF);
815 __pSliderPresenter->SetNeedUpdate();
821 _Slider::GetBarColor(void) const
823 result r = E_SUCCESS;
825 Variant barColor = GetProperty("barColor");
827 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
829 return barColor.ToColor();
833 _Slider::GetPropertyBarColor(void) const
835 return Variant(__barColor);
839 _Slider::SetBarBackgroundColor(const Color& color)
841 return SetProperty("barBackgroundColor", Variant(color));
845 _Slider::SetPropertyBarBackgroundColor(const Variant& barBackgroundColor)
847 result r = E_SUCCESS;
849 Color tempBarBackgroundColor = barBackgroundColor.ToColor();
851 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
853 __barBgColor = tempBarBackgroundColor;
854 __barBgColor.SetAlpha(0xFF);
856 __pSliderPresenter->SetNeedUpdate();
862 _Slider::GetBarBackgroundColor(void) const
864 result r = E_SUCCESS;
866 Variant barBgColor = GetProperty("barBackgroundColor");
868 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
870 return barBgColor.ToColor();
874 _Slider::GetPropertyBarBackgroundColor(void) const
876 return Variant(__barBgColor);
880 _Slider::SetColor(const Color& color)
882 return SetProperty("color", Variant(color));
886 _Slider::SetPropertyColor(const Variant& color)
888 if (__sliderStyle & _SLIDER_STYLE_NO_BG)
890 SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current Slider style does not support background color.");
891 return E_INVALID_OPERATION;
894 result r = E_SUCCESS;
896 Color tempBgColor = color.ToColor();
897 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
899 __bgColor = tempBgColor;
901 __pSliderPresenter->SetNeedUpdate();
907 _Slider::GetColor(void) const
909 result r = E_SUCCESS;
911 Variant color = GetProperty("color");
913 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
915 return color.ToColor();
919 _Slider::GetPropertyColor(void) const
921 if (__sliderStyle & _SLIDER_STYLE_NO_BG)
923 SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current Slider style does not support background color.");
924 return Variant(Color());
928 return Variant(__bgColor);
932 Tizen::Base::Runtime::_Event*
933 _Slider::GetAdjustmentEvent(void) const
935 return __pAdjustmentEvent;
939 _Slider::GetSliderEvent(void) const
941 return __pSliderEvent;
945 _Slider::SetThumbBitmap(SliderThumbStatus status, const Bitmap& bitmap)
947 return __pSliderPresenter->SetThumbBitmap(status, bitmap);
951 _Slider::SetThumbTextColor(SliderThumbStatus status, const Color& color)
953 __pSliderPresenter->SetThumbTextColor(status, color);
958 _Slider::OnFontChanged(Font* pFont)
960 __pSliderPresenter->OnFontChanged(pFont);
965 _Slider::OnFontInfoRequested(unsigned long& style, float& size)
967 __pSliderPresenter->OnFontInfoRequested(style, size);
972 _Slider::OnAncestorEnableStateChanged(const _Control& control)
974 __pSliderPresenter->OnAncestorEnableStateChanged(control);
980 _Slider::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
982 if (GetEnableState() == false)
986 SetValue(GetValue() + 1);
988 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
989 char buffer[10] = {0,};
990 sprintf(buffer, "%d", GetValue());
991 string.Replace(L"%1$d", buffer);
992 memset(buffer, 0, 10);
993 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
994 string.Replace(L"%2$d", buffer);
995 _AccessibilityManager::GetInstance()->ReadContent(string);
998 FireSliderMoveEvent(GetValue());
999 FireAdjustmentValueEvent(GetValue());
1005 _Slider::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1007 if (GetEnableState() == false)
1011 SetValue(GetValue() - 1);
1013 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
1014 char buffer[10] = {0,};
1015 sprintf(buffer, "%d", GetValue());
1016 string.Replace(L"%1$d", buffer);
1017 memset(buffer, 0, 10);
1018 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
1019 string.Replace(L"%2$d", buffer);
1020 _AccessibilityManager::GetInstance()->ReadContent(string);
1023 FireSliderMoveEvent(GetValue());
1024 FireAdjustmentValueEvent(GetValue());
1030 _Slider::FireSliderMoveEvent(int value)
1032 if (__pSliderEvent != null)
1034 IEventArg* pEventArg = _SliderEvent::CreateSliderEventArgN(value);
1036 if( pEventArg == null)
1041 __pSliderEvent->Fire(*pEventArg);
1046 _Slider::FireAdjustmentValueEvent(int adjustment)
1048 if (__pAdjustmentEvent != null)
1050 IEventArg* pEventArg = _AdjustmentEvent::CreateAdjustmentEventArgN(adjustment);
1051 if( pEventArg == null)
1056 __pAdjustmentEvent->Fire(*pEventArg);
1059 }}} // Tizen::Ui::Controls