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 FireAdjustmentValueEvent(GetValue());
419 __isKeyPressed = false;
429 _Slider::OnBoundsChanged(void)
431 __pSliderPresenter->OnBoundsChanged();
433 if (__pAccessibilityElement)
435 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBounds().width, GetBounds().height));
442 _Slider::OnChangeLayout(_ControlOrientation orientation)
444 __pSliderPresenter->OnChangeLayout(orientation);
449 _Slider::SetRange(int minValue, int maxValue)
451 result r = E_SUCCESS;
453 SysTryReturn(NID_UI_CTRL, (minValue >= _SLIDER_MINIMUM_VALUE && maxValue >= _SLIDER_MINIMUM_VALUE),
454 E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The minimum value %d is out of range [-99 to 999].", minValue);
455 SysTryReturn(NID_UI_CTRL, (minValue <= _SLIDER_MAXIMUM_VALUE && maxValue <= _SLIDER_MAXIMUM_VALUE),
456 E_OUT_OF_RANGE, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The maximum value %d is out of range [-99 to 999].", maxValue);
457 SysTryReturn(NID_UI_CTRL, (minValue < maxValue), E_INVALID_ARG, E_INVALID_ARG,
458 "[E_INVALID_ARG] The minimum value is greater than maximum value.");
460 Variant oldMinValue = GetProperty("minValue");
461 Variant value = GetProperty("value");
463 r = SetProperty("minValue", Variant(minValue));
464 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Failed to set minimum value.", GetErrorMessage(r));
466 r = SetProperty("maxValue", Variant(maxValue));
469 SysLogException(NID_UI_CTRL, r, "[%s] Failed to set maximum value.", GetErrorMessage(r));
471 result nestedResult = SetPropertyMinValue(oldMinValue);
472 if (nestedResult != E_SUCCESS)
474 SysLog(NID_UI_CTRL, "Failed to recover original minimum value");
478 nestedResult = SetPropertyValue(value);
479 if (nestedResult != E_SUCCESS)
481 SysLog(NID_UI_CTRL, "Failed to recover original value");
485 SetAccessibilityElementValue();
491 _Slider::SetPropertyMinValue(const Variant& minValue)
493 result r = E_SUCCESS;
495 int tempMinValue = minValue.ToInt();
497 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
499 __pSliderPresenter->SetMinValue(tempMinValue);
505 _Slider::SetPropertyMaxValue(const Variant& maxValue)
507 result r = E_SUCCESS;
509 int tempMaxValue = maxValue.ToInt();
511 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
513 __pSliderPresenter->SetMaxValue(tempMaxValue);
519 _Slider::GetRange(int& minValue, int& maxValue) const
521 result r = E_SUCCESS;
523 Variant minimum = GetProperty("minValue");
525 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
527 Variant maximum = GetProperty("maxValue");
529 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
531 minValue = minimum.ToInt();
532 maxValue = maximum.ToInt();
538 _Slider::GetPropertyMinValue(void) const
540 return Variant(__pSliderPresenter->GetMinValue());
544 _Slider::GetPropertyMaxValue(void) const
546 return Variant(__pSliderPresenter->GetMaxValue());
550 _Slider::SetValue(int value)
552 return SetProperty("value", Variant(value));
556 _Slider::SetPropertyValue(const Variant& value)
558 result r = E_SUCCESS;
560 int tempValue = value.ToInt();
562 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
564 __pSliderPresenter->SetValue(tempValue);
566 SetAccessibilityElementValue();
572 _Slider::SetAccessibilityElementValue()
574 if (__pAccessibilityElement)
577 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
578 char buffer[10] = {0,};
579 sprintf(buffer, "%d", GetValue());
580 string.Replace(L"%1$d", buffer);
581 memset(buffer, 0, 10);
582 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
583 string.Replace(L"%2$d", buffer);
584 __pAccessibilityElement->SetValue(string);
590 _Slider::GetValue(void) const
592 result r = E_SUCCESS;
594 Variant value = GetProperty("value");
596 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
598 return value.ToInt();
602 _Slider::GetPropertyValue(void) const
604 return Variant(__pSliderPresenter->GetValue());
608 _Slider::SetIcon(IconPosition position, const Bitmap& icon)
610 result r = E_SUCCESS;
612 float iconWidth = 0.0f;
613 float iconHeight = 0.0f;
614 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
615 Bitmap* pNewBitmap = null;
617 r = GET_SHAPE_CONFIG(SLIDER::ICON_WIDTH, orientation, iconWidth);
618 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
620 r = GET_SHAPE_CONFIG(SLIDER::ICON_HEIGHT, orientation, iconHeight);
621 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
623 if (position == ICON_POSITION_LEFT)
625 pNewBitmap = _BitmapImpl::CloneN(icon);
628 SysTryReturn(NID_UI_CTRL, pNewBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
630 r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight));
631 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
633 delete __pLeftBitmap;
634 __pLeftBitmap = pNewBitmap;
637 else //(position == ICON_POSITION_RIGHT)
639 pNewBitmap = _BitmapImpl::CloneN(icon);
642 SysTryReturn(NID_UI_CTRL, pNewBitmap != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
644 r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight));
645 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
647 delete __pRightBitmap;
648 __pRightBitmap = pNewBitmap;
652 __pSliderPresenter->SetNeedUpdate();
663 _Slider::GetIcon(IconPosition position) const
665 if (position == ICON_POSITION_LEFT)
667 return __pLeftBitmap;
669 else //(position == ICON_POSITION_RIGHT)
671 return __pRightBitmap;
676 _Slider::SetTitleText(const String& title)
678 return SetProperty("titleText", Variant(title));
682 _Slider::SetPropertyTitleText(const Variant& titleText)
684 result r = E_SUCCESS;
685 String title = titleText.ToString();
687 if (!(GetStyle() & _SLIDER_STYLE_TITLE_TEXT))
689 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The current Slider style does not support title text.");
694 __pSliderPresenter->SetNeedUpdate();
696 r = InitializeAccessibilityElement();
697 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
699 if (__pAccessibilityElement != null)
701 __pAccessibilityElement->SetLabel(__titleText);
708 _Slider::GetTitleText(void) const
710 result r = E_SUCCESS;
712 Variant titleText = GetProperty("titleText");
714 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r));
716 return titleText.ToString();
720 _Slider::GetPropertyTitleText(void) const
722 return Variant(__titleText);
726 _Slider::SetTitleTextColor(const Color& color)
728 return SetProperty("titleTextColor", Variant(color));
732 _Slider::SetPropertyTitleTextColor(const Variant& titleTextColor)
734 result r = E_SUCCESS;
736 Color tempColor = titleTextColor.ToColor();
738 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
740 __titleTextColor = tempColor;
741 __pSliderPresenter->SetNeedUpdate();
747 _Slider::GetTitleTextColor(void) const
749 result r = E_SUCCESS;
751 Variant titleTexColor = GetProperty("titleTextColor");
753 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
755 return titleTexColor.ToColor();
759 _Slider::GetPropertyTitleTextColor(void) const
761 return Variant(__titleTextColor);
765 _Slider::AddAdjustmentEventListener(const _IAdjustmentEventListener& listener)
767 return __pAdjustmentEvent->AddListener(listener);
771 _Slider::RemoveAdjustmentEventListener(const _IAdjustmentEventListener& listener)
773 return __pAdjustmentEvent->RemoveListener(listener);
777 _Slider::AddSliderEventListener(const _ISliderEventListener& listener)
779 return __pSliderEvent->AddListener(listener);
783 _Slider::RemoveSliderEventListener(const _ISliderEventListener& listener)
785 return __pSliderEvent->RemoveListener(listener);
789 _Slider::SetBarColor(const Color& color)
791 return SetProperty("barColor", Variant(color));
795 _Slider::SetPropertyBarColor(const Variant& barColor)
797 result r = E_SUCCESS;
799 Color tempBarColor = barColor.ToColor();
801 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
803 __barColor = tempBarColor;
804 __barColor.SetAlpha(0xFF);
806 __pSliderPresenter->SetNeedUpdate();
812 _Slider::GetBarColor(void) const
814 result r = E_SUCCESS;
816 Variant barColor = GetProperty("barColor");
818 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
820 return barColor.ToColor();
824 _Slider::GetPropertyBarColor(void) const
826 return Variant(__barColor);
830 _Slider::SetBarBackgroundColor(const Color& color)
832 return SetProperty("barBackgroundColor", Variant(color));
836 _Slider::SetPropertyBarBackgroundColor(const Variant& barBackgroundColor)
838 result r = E_SUCCESS;
840 Color tempBarBackgroundColor = barBackgroundColor.ToColor();
842 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
844 __barBgColor = tempBarBackgroundColor;
845 __barBgColor.SetAlpha(0xFF);
847 __pSliderPresenter->SetNeedUpdate();
853 _Slider::GetBarBackgroundColor(void) const
855 result r = E_SUCCESS;
857 Variant barBgColor = GetProperty("barBackgroundColor");
859 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
861 return barBgColor.ToColor();
865 _Slider::GetPropertyBarBackgroundColor(void) const
867 return Variant(__barBgColor);
871 _Slider::SetColor(const Color& color)
873 return SetProperty("color", Variant(color));
877 _Slider::SetPropertyColor(const Variant& color)
879 if (__sliderStyle & _SLIDER_STYLE_NO_BG)
881 SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current Slider style does not support background color.");
882 return E_INVALID_OPERATION;
885 result r = E_SUCCESS;
887 Color tempBgColor = color.ToColor();
888 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
890 __bgColor = tempBgColor;
892 __pSliderPresenter->SetNeedUpdate();
898 _Slider::GetColor(void) const
900 result r = E_SUCCESS;
902 Variant color = GetProperty("color");
904 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
906 return color.ToColor();
910 _Slider::GetPropertyColor(void) const
912 if (__sliderStyle & _SLIDER_STYLE_NO_BG)
914 SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current Slider style does not support background color.");
915 return Variant(Color());
919 return Variant(__bgColor);
923 Tizen::Base::Runtime::_Event*
924 _Slider::GetAdjustmentEvent(void) const
926 return __pAdjustmentEvent;
930 _Slider::GetSliderEvent(void) const
932 return __pSliderEvent;
936 _Slider::SetThumbBitmap(SliderThumbStatus status, const Bitmap& bitmap)
938 return __pSliderPresenter->SetThumbBitmap(status, bitmap);
942 _Slider::SetThumbTextColor(SliderThumbStatus status, const Color& color)
944 __pSliderPresenter->SetThumbTextColor(status, color);
949 _Slider::OnFontChanged(Font* pFont)
951 __pSliderPresenter->OnFontChanged(pFont);
956 _Slider::OnFontInfoRequested(unsigned long& style, float& size)
958 __pSliderPresenter->OnFontInfoRequested(style, size);
963 _Slider::OnAncestorEnableStateChanged(const _Control& control)
965 __pSliderPresenter->OnAncestorEnableStateChanged(control);
971 _Slider::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
973 if (GetEnableState() == false)
977 SetValue(GetValue() + 1);
979 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
980 char buffer[10] = {0,};
981 sprintf(buffer, "%d", GetValue());
982 string.Replace(L"%1$d", buffer);
983 memset(buffer, 0, 10);
984 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
985 string.Replace(L"%2$d", buffer);
986 _AccessibilityManager::GetInstance()->ReadContent(string);
989 FireSliderMoveEvent(GetValue());
990 FireAdjustmentValueEvent(GetValue());
996 _Slider::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
998 if (GetEnableState() == false)
1002 SetValue(GetValue() - 1);
1004 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
1005 char buffer[10] = {0,};
1006 sprintf(buffer, "%d", GetValue());
1007 string.Replace(L"%1$d", buffer);
1008 memset(buffer, 0, 10);
1009 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
1010 string.Replace(L"%2$d", buffer);
1011 _AccessibilityManager::GetInstance()->ReadContent(string);
1014 FireSliderMoveEvent(GetValue());
1015 FireAdjustmentValueEvent(GetValue());
1021 _Slider::FireSliderMoveEvent(int value)
1023 if (__pSliderEvent != null)
1025 IEventArg* pEventArg = _SliderEvent::CreateSliderEventArgN(value);
1027 if( pEventArg == null)
1032 __pSliderEvent->Fire(*pEventArg);
1037 _Slider::FireAdjustmentValueEvent(int adjustment)
1039 if (__pAdjustmentEvent != null)
1041 IEventArg* pEventArg = _AdjustmentEvent::CreateAdjustmentEventArgN(adjustment);
1042 if( pEventArg == null)
1047 __pAdjustmentEvent->Fire(*pEventArg);
1050 }}} // Tizen::Ui::Controls