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);
340 _Slider::OnFocusModeStateChanged()
342 __pSliderPresenter->SetFocusMode(false);
347 _Slider::IsKeyPressed() const
349 return __isKeyPressed;
353 _Slider::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
355 if(__pSliderPresenter->GetFocusMode() == false)
360 _KeyCode keyCode = keyInfo.GetKeyCode();
362 if (keyCode == _KEY_RIGHT)
364 SetValue(GetValue() + 1);
365 FireSliderMoveEvent(GetValue());
367 if (GetStyle() & _SLIDER_STYLE_OVERLAY)
369 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
370 pSliderOverlay->SetVisibleState(true);
371 pSliderOverlay->Open();
372 __isKeyPressed = true;
379 if (keyCode == _KEY_LEFT)
381 SetValue(GetValue() - 1);
382 FireSliderMoveEvent(GetValue());
384 if (GetStyle() & _SLIDER_STYLE_OVERLAY)
386 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
387 pSliderOverlay->SetVisibleState(true);
388 pSliderOverlay->Open();
389 __isKeyPressed = true;
400 _Slider::OnKeyReleased(const _Control &source, const _KeyInfo &keyInfo)
402 if(__pSliderPresenter->GetFocusMode() == false)
407 _KeyCode keyCode = keyInfo.GetKeyCode();
409 if (keyCode == _KEY_LEFT || keyCode == _KEY_RIGHT)
411 if (GetStyle() & _SLIDER_STYLE_OVERLAY)
413 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
414 pSliderOverlay->SetVisibleState(false);
415 pSliderOverlay->Close();
418 __isKeyPressed = false;
427 _Slider::OnBoundsChanged(void)
429 __pSliderPresenter->OnBoundsChanged();
431 if (__pAccessibilityElement)
433 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBounds().width, GetBounds().height));
440 _Slider::OnChangeLayout(_ControlOrientation orientation)
442 __pSliderPresenter->OnChangeLayout(orientation);
447 _Slider::SetRange(int minValue, int maxValue)
449 result r = E_SUCCESS;
451 SysTryReturn(NID_UI_CTRL, (minValue >= _SLIDER_MINIMUM_VALUE && maxValue >= _SLIDER_MINIMUM_VALUE),
452 E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The minimum value %d is out of range [-99 to 999].", minValue);
453 SysTryReturn(NID_UI_CTRL, (minValue <= _SLIDER_MAXIMUM_VALUE && maxValue <= _SLIDER_MAXIMUM_VALUE),
454 E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The maximum value %d is out of range [-99 to 999].", maxValue);
455 SysTryReturn(NID_UI_CTRL, (minValue < maxValue), E_INVALID_ARG, E_INVALID_ARG,
456 "[E_INVALID_ARG] The minimum value is greater than maximum value.");
458 Variant oldMinValue = GetProperty("minValue");
459 Variant value = GetProperty("value");
461 r = SetProperty("minValue", Variant(minValue));
462 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set minimum value.", GetErrorMessage(r));
464 r = SetProperty("maxValue", Variant(maxValue));
467 SysLogException(NID_UI_CTRL, r, "[%s] Failed to set maximum value.", GetErrorMessage(r));
469 result nestedResult = SetPropertyMinValue(oldMinValue);
470 if (nestedResult != E_SUCCESS)
472 SysLog(NID_UI_CTRL, "Failed to recover original minimum value");
476 nestedResult = SetPropertyValue(value);
477 if (nestedResult != E_SUCCESS)
479 SysLog(NID_UI_CTRL, "Failed to recover original value");
483 SetAccessibilityElementValue();
489 _Slider::SetPropertyMinValue(const Variant& minValue)
491 result r = E_SUCCESS;
493 int tempMinValue = minValue.ToInt();
495 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
497 __pSliderPresenter->SetMinValue(tempMinValue);
503 _Slider::SetPropertyMaxValue(const Variant& maxValue)
505 result r = E_SUCCESS;
507 int tempMaxValue = maxValue.ToInt();
509 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
511 __pSliderPresenter->SetMaxValue(tempMaxValue);
517 _Slider::GetRange(int& minValue, int& maxValue) const
519 result r = E_SUCCESS;
521 Variant minimum = GetProperty("minValue");
523 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
525 Variant maximum = GetProperty("maxValue");
527 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
529 minValue = minimum.ToInt();
530 maxValue = maximum.ToInt();
536 _Slider::GetPropertyMinValue(void) const
538 return Variant(__pSliderPresenter->GetMinValue());
542 _Slider::GetPropertyMaxValue(void) const
544 return Variant(__pSliderPresenter->GetMaxValue());
548 _Slider::SetValue(int value)
550 return SetProperty("value", Variant(value));
554 _Slider::SetPropertyValue(const Variant& value)
556 result r = E_SUCCESS;
558 int tempValue = value.ToInt();
560 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
562 __pSliderPresenter->SetValue(tempValue);
564 SetAccessibilityElementValue();
570 _Slider::SetAccessibilityElementValue()
572 if (__pAccessibilityElement)
575 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
576 char buffer[10] = {0,};
577 sprintf(buffer, "%d", GetValue());
578 string.Replace(L"%1$d", buffer);
579 memset(buffer, 0, 10);
580 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
581 string.Replace(L"%2$d", buffer);
582 __pAccessibilityElement->SetValue(string);
588 _Slider::GetValue(void) const
590 result r = E_SUCCESS;
592 Variant value = GetProperty("value");
594 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
596 return value.ToInt();
600 _Slider::GetPropertyValue(void) const
602 return Variant(__pSliderPresenter->GetValue());
606 _Slider::SetIcon(IconPosition position, const Bitmap& icon)
608 result r = E_SUCCESS;
610 float iconWidth = 0.0f;
611 float iconHeight = 0.0f;
612 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
613 Bitmap* pNewBitmap = null;
615 r = GET_SHAPE_CONFIG(SLIDER::ICON_WIDTH, orientation, iconWidth);
616 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
618 r = GET_SHAPE_CONFIG(SLIDER::ICON_HEIGHT, orientation, iconHeight);
619 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
621 if (position == ICON_POSITION_LEFT)
623 pNewBitmap = _BitmapImpl::CloneN(icon);
626 SysTryReturn(NID_UI_CTRL, pNewBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
628 r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight));
629 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
631 delete __pLeftBitmap;
632 __pLeftBitmap = pNewBitmap;
635 else //(position == ICON_POSITION_RIGHT)
637 pNewBitmap = _BitmapImpl::CloneN(icon);
640 SysTryReturn(NID_UI_CTRL, pNewBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
642 r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight));
643 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
645 delete __pRightBitmap;
646 __pRightBitmap = pNewBitmap;
650 __pSliderPresenter->SetNeedUpdate();
661 _Slider::GetIcon(IconPosition position) const
663 if (position == ICON_POSITION_LEFT)
665 return __pLeftBitmap;
667 else //(position == ICON_POSITION_RIGHT)
669 return __pRightBitmap;
674 _Slider::SetTitleText(const String& title)
676 return SetProperty("titleText", Variant(title));
680 _Slider::SetPropertyTitleText(const Variant& titleText)
682 result r = E_SUCCESS;
683 String title = titleText.ToString();
685 if (!(GetStyle() & _SLIDER_STYLE_TITLE_TEXT))
687 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The current Slider style does not support title text.");
692 __pSliderPresenter->SetNeedUpdate();
694 r = InitializeAccessibilityElement();
695 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
697 if (__pAccessibilityElement != null)
699 __pAccessibilityElement->SetLabel(__titleText);
706 _Slider::GetTitleText(void) const
708 result r = E_SUCCESS;
710 Variant titleText = GetProperty("titleText");
712 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r));
714 return titleText.ToString();
718 _Slider::GetPropertyTitleText(void) const
720 return Variant(__titleText);
724 _Slider::SetTitleTextColor(const Color& color)
726 return SetProperty("titleTextColor", Variant(color));
730 _Slider::SetPropertyTitleTextColor(const Variant& titleTextColor)
732 result r = E_SUCCESS;
734 Color tempColor = titleTextColor.ToColor();
736 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
738 __titleTextColor = tempColor;
739 __pSliderPresenter->SetNeedUpdate();
745 _Slider::GetTitleTextColor(void) const
747 result r = E_SUCCESS;
749 Variant titleTexColor = GetProperty("titleTextColor");
751 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
753 return titleTexColor.ToColor();
757 _Slider::GetPropertyTitleTextColor(void) const
759 return Variant(__titleTextColor);
763 _Slider::AddAdjustmentEventListener(const _IAdjustmentEventListener& listener)
765 return __pAdjustmentEvent->AddListener(listener);
769 _Slider::RemoveAdjustmentEventListener(const _IAdjustmentEventListener& listener)
771 return __pAdjustmentEvent->RemoveListener(listener);
775 _Slider::AddSliderEventListener(const _ISliderEventListener& listener)
777 return __pSliderEvent->AddListener(listener);
781 _Slider::RemoveSliderEventListener(const _ISliderEventListener& listener)
783 return __pSliderEvent->RemoveListener(listener);
787 _Slider::SetBarColor(const Color& color)
789 return SetProperty("barColor", Variant(color));
793 _Slider::SetPropertyBarColor(const Variant& barColor)
795 result r = E_SUCCESS;
797 Color tempBarColor = barColor.ToColor();
799 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
801 __barColor = tempBarColor;
802 __barColor.SetAlpha(0xFF);
804 __pSliderPresenter->SetNeedUpdate();
810 _Slider::GetBarColor(void) const
812 result r = E_SUCCESS;
814 Variant barColor = GetProperty("barColor");
816 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
818 return barColor.ToColor();
822 _Slider::GetPropertyBarColor(void) const
824 return Variant(__barColor);
828 _Slider::SetBarBackgroundColor(const Color& color)
830 return SetProperty("barBackgroundColor", Variant(color));
834 _Slider::SetPropertyBarBackgroundColor(const Variant& barBackgroundColor)
836 result r = E_SUCCESS;
838 Color tempBarBackgroundColor = barBackgroundColor.ToColor();
840 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
842 __barBgColor = tempBarBackgroundColor;
843 __barBgColor.SetAlpha(0xFF);
845 __pSliderPresenter->SetNeedUpdate();
851 _Slider::GetBarBackgroundColor(void) const
853 result r = E_SUCCESS;
855 Variant barBgColor = GetProperty("barBackgroundColor");
857 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
859 return barBgColor.ToColor();
863 _Slider::GetPropertyBarBackgroundColor(void) const
865 return Variant(__barBgColor);
869 _Slider::SetColor(const Color& color)
871 return SetProperty("color", Variant(color));
875 _Slider::SetPropertyColor(const Variant& color)
877 if (__sliderStyle & _SLIDER_STYLE_NO_BG)
879 SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current Slider style does not support background color.");
880 return E_INVALID_OPERATION;
883 result r = E_SUCCESS;
885 Color tempBgColor = color.ToColor();
886 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
888 __bgColor = tempBgColor;
890 __pSliderPresenter->SetNeedUpdate();
896 _Slider::GetColor(void) const
898 result r = E_SUCCESS;
900 Variant color = GetProperty("color");
902 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
904 return color.ToColor();
908 _Slider::GetPropertyColor(void) const
910 if (__sliderStyle & _SLIDER_STYLE_NO_BG)
912 SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current Slider style does not support background color.");
913 return Variant(Color());
917 return Variant(__bgColor);
921 Tizen::Base::Runtime::_Event*
922 _Slider::GetAdjustmentEvent(void) const
924 return __pAdjustmentEvent;
928 _Slider::GetSliderEvent(void) const
930 return __pSliderEvent;
934 _Slider::SetThumbBitmap(SliderThumbStatus status, const Bitmap& bitmap)
936 return __pSliderPresenter->SetThumbBitmap(status, bitmap);
940 _Slider::SetThumbTextColor(SliderThumbStatus status, const Color& color)
942 __pSliderPresenter->SetThumbTextColor(status, color);
947 _Slider::OnFontChanged(Font* pFont)
949 __pSliderPresenter->OnFontChanged(pFont);
954 _Slider::OnFontInfoRequested(unsigned long& style, float& size)
956 __pSliderPresenter->OnFontInfoRequested(style, size);
961 _Slider::OnAncestorEnableStateChanged(const _Control& control)
963 __pSliderPresenter->OnAncestorEnableStateChanged(control);
969 _Slider::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
971 if (GetEnableState() == false)
975 SetValue(GetValue() + 1);
977 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
978 char buffer[10] = {0,};
979 sprintf(buffer, "%d", GetValue());
980 string.Replace(L"%1$d", buffer);
981 memset(buffer, 0, 10);
982 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
983 string.Replace(L"%2$d", buffer);
984 _AccessibilityManager::GetInstance()->ReadContent(string);
987 FireSliderMoveEvent(GetValue());
993 _Slider::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
995 if (GetEnableState() == false)
999 SetValue(GetValue() - 1);
1001 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
1002 char buffer[10] = {0,};
1003 sprintf(buffer, "%d", GetValue());
1004 string.Replace(L"%1$d", buffer);
1005 memset(buffer, 0, 10);
1006 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
1007 string.Replace(L"%2$d", buffer);
1008 _AccessibilityManager::GetInstance()->ReadContent(string);
1011 FireSliderMoveEvent(GetValue());
1017 _Slider::FireSliderMoveEvent(int value)
1019 if (__pSliderEvent != null)
1021 IEventArg* pEventArg = _SliderEvent::CreateSliderEventArgN(value);
1023 if( pEventArg == null)
1028 __pSliderEvent->Fire(*pEventArg);
1032 }}} // Tizen::Ui::Controls