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();
73 if (pContainer != null)
75 pContainer->Activate(true);
79 _Slider::~_Slider(void)
81 delete __pAdjustmentEvent;
82 __pAdjustmentEvent = null;
84 delete __pSliderEvent;
85 __pSliderEvent = null;
90 delete __pRightBitmap;
91 __pRightBitmap = null;
93 delete __pSliderPresenter;
94 __pSliderPresenter = null;
96 if (__pAccessibilityElement != null)
98 __pAccessibilityElement->Activate(false);
99 __pAccessibilityElement = null;
102 if (__pBase != null && __pHandle != null)
104 __pBase->DetachChild(*__pHandle);
105 __pHandle->Destroy();
113 _Slider::CreateSliderN(void)
115 result r = E_SUCCESS;
117 _Slider* pSlider = new (std::nothrow) _Slider;
118 SysTryReturn(NID_UI_CTRL, pSlider, null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
120 pSlider->__pSliderPresenter = _SliderPresenter::CreateInstanceN(*pSlider);
122 SysTryCatch(NID_UI_CTRL, pSlider->__pSliderPresenter != null, , r, "[%s] Propagating.", GetErrorMessage(r));
124 r = pSlider->Initialize();
125 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
127 pSlider->AcquireHandle();
139 _Slider::Initialize(void)
141 result r = E_SUCCESS;
143 FloatRectangle handleRect(0.0f, 0.0f, 0.0f, 0.0f);
144 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
146 r = GET_COLOR_CONFIG(SLIDER::BG_DEFAULT_NORMAL, __bgColor);
147 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
149 r = GET_COLOR_CONFIG(SLIDER::BAR_NORMAL, __barColor);
150 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
152 r = GET_COLOR_CONFIG(SLIDER::BAR_BG_NORMAL, __barBgColor);
153 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
155 r = GET_COLOR_CONFIG(SLIDER::TITLE_TEXT_NORMAL, __titleTextColor);
156 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
158 r = GET_SHAPE_CONFIG(SLIDER::HANDLE_WIDTH, orientation, handleRect.width);
159 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
161 r = GET_SHAPE_CONFIG(SLIDER::HANDLE_HEIGHT, orientation, handleRect.height);
162 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
164 __pHandle = new (std::nothrow) Tizen::Ui::Animations::_VisualElement;
165 SysTryReturnResult(NID_UI_CTRL, __pHandle != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
167 r = __pHandle->Construct();
168 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
170 __pHandle->SetBounds(FloatRectangle(handleRect.x, handleRect.y, handleRect.width, handleRect.height));
172 __pHandle->SetShowState(true);
174 __pBase->SetClipChildrenEnabled(true);
175 __pHandle->SetClipToParent(true);
178 r = __pHandle->SetSurfaceOpaque(false);
179 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
181 __pHandle->SetImplicitAnimationEnabled(false);
183 r = __pBase->AttachChild(*__pHandle);
184 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
186 __pAdjustmentEvent = _AdjustmentEvent::CreateInstanceN(*this);
188 SysTryReturnResult(NID_UI_CTRL, __pAdjustmentEvent, r, "Propagating.");
190 __pSliderEvent = _SliderEvent::CreateInstanceN(*this);
192 SysTryReturnResult(NID_UI_CTRL, __pSliderEvent, r, "Propagating.");
194 InitializeAccessibilityElement();
200 _Slider::InitializeAccessibilityElement(void)
202 result r = E_SUCCESS;
204 if (__pAccessibilityElement != null)
209 _AccessibilityContainer* pContainer = GetAccessibilityContainer();
210 if (pContainer != null)
212 __pAccessibilityElement = new (std::nothrow) _AccessibilityElement(true);
213 SysTryReturnResult(NID_UI_CTRL, __pAccessibilityElement, E_OUT_OF_MEMORY,
214 "Memory allocation failed.");
215 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBounds().width, GetBounds().height));
216 __pAccessibilityElement->SetLabel(__titleText);
217 __pAccessibilityElement->SetName(L"SliderControl");
218 __pAccessibilityElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_SLIDER_T_TTS");
219 __pAccessibilityElement->SetHintWithStringId("IDS_TPLATFORM_BODY_FLICK_UP_AND_DOWN_TO_ADJUST_THE_POSITION_T_TTS");
220 SetAccessibilityElementValue();
221 r = pContainer->AddElement(*__pAccessibilityElement);
222 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
223 pContainer->AddListener(*this);
230 _Slider::OnDraw(void)
232 __pSliderPresenter->Draw();
237 _Slider::OnAttachedToMainTree(void)
239 return _Control::OnAttachedToMainTree();
243 _Slider::SetStyle(int style)
245 __sliderStyle = style;
250 _Slider::GetStyle(void) const
252 return __sliderStyle;
256 _Slider::GetHandleCanvasN(void) const
258 return __pHandle->GetCanvasN();
262 _Slider::GetHandle(void) const
268 _Slider::SetGroupStyle(GroupStyle groupStyle)
270 __pSliderPresenter->SetGroupStyle(groupStyle);
275 _Slider::UpdateHandle(const FloatRectangle& handleRect)
277 __pHandle->SetBounds(handleRect);
279 return __pHandle->SetFlushNeeded();
283 _Slider::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
285 return __pSliderPresenter->OnTouchPressed(source, touchinfo);
289 _Slider::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
291 return __pSliderPresenter->OnTouchReleased(source, touchinfo);
295 _Slider::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
297 return __pSliderPresenter->OnTouchMoved(source, touchinfo);
301 _Slider::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
303 return __pSliderPresenter->OnTouchCanceled(source, touchinfo);
307 _Slider::OnDrawFocus(void)
309 __pSliderPresenter->SetFocusMode(true);
316 _Slider::OnFocusGained(const _Control& source)
318 if (IsFocusModeStateEnabled())
320 __pSliderPresenter->SetFocusMode(true);
328 _Slider::OnFocusLost(const _Control& source)
330 __pSliderPresenter->SetFocusMode(false);
332 if ((GetStyle() & _SLIDER_STYLE_OVERLAY) && (!__pSliderPresenter->IsTouchPressed()) && (__isKeyPressed))
334 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
335 pSliderOverlay->SetVisibleState(false);
336 pSliderOverlay->Close();
341 FireAdjustmentValueEvent(GetValue());
344 __isKeyPressed = false;
351 _Slider::OnFocusModeStateChanged()
353 __pSliderPresenter->SetFocusMode(false);
355 if ((GetStyle() & _SLIDER_STYLE_OVERLAY) && __isKeyPressed)
357 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
358 pSliderOverlay->SetVisibleState(false);
359 pSliderOverlay->Close();
364 FireAdjustmentValueEvent(GetValue());
367 __isKeyPressed = false;
373 _Slider::IsKeyPressed() const
375 return __isKeyPressed;
379 _Slider::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
381 if(__pSliderPresenter->GetFocusMode() == false)
386 _KeyCode keyCode = keyInfo.GetKeyCode();
388 if (keyCode == _KEY_RIGHT)
390 __pSliderPresenter->SetValue(GetValue() + 1);
391 SetAccessibilityElementValue();
393 FireSliderMoveEvent(GetValue());
395 if (GetStyle() & _SLIDER_STYLE_OVERLAY)
397 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
398 pSliderOverlay->SetVisibleState(true);
399 pSliderOverlay->Open();
400 __isKeyPressed = true;
407 if (keyCode == _KEY_LEFT)
409 __pSliderPresenter->SetValue(GetValue() - 1);
410 SetAccessibilityElementValue();
412 FireSliderMoveEvent(GetValue());
414 if (GetStyle() & _SLIDER_STYLE_OVERLAY)
416 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
417 pSliderOverlay->SetVisibleState(true);
418 pSliderOverlay->Open();
419 __isKeyPressed = true;
430 _Slider::OnKeyReleased(const _Control &source, const _KeyInfo &keyInfo)
432 if(__pSliderPresenter->GetFocusMode() == false)
437 _KeyCode keyCode = keyInfo.GetKeyCode();
439 if (keyCode == _KEY_LEFT || keyCode == _KEY_RIGHT)
441 if ((GetStyle() & _SLIDER_STYLE_OVERLAY) && (__isKeyPressed == true))
443 _SliderOverlay* pSliderOverlay = __pSliderPresenter->GetSliderOverlay();
444 pSliderOverlay->SetVisibleState(false);
445 pSliderOverlay->Close();
448 FireAdjustmentValueEvent(GetValue());
449 __isKeyPressed = false;
459 _Slider::OnBoundsChanged(void)
461 __pSliderPresenter->OnBoundsChanged();
463 if (__pAccessibilityElement != null)
465 __pAccessibilityElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBounds().width, GetBounds().height));
472 _Slider::OnChangeLayout(_ControlOrientation orientation)
474 __pSliderPresenter->OnChangeLayout(orientation);
479 _Slider::SetRange(int minValue, int maxValue)
481 result r = E_SUCCESS;
483 SysTryReturnResult(NID_UI_CTRL, (minValue >= _SLIDER_MINIMUM_VALUE && maxValue >= _SLIDER_MINIMUM_VALUE),
484 E_OUT_OF_RANGE, "[The minimum value %d is out of range [-99 to 999].", minValue);
485 SysTryReturnResult(NID_UI_CTRL, (minValue <= _SLIDER_MAXIMUM_VALUE && maxValue <= _SLIDER_MAXIMUM_VALUE),
486 E_OUT_OF_RANGE, "The maximum value %d is out of range [-99 to 999].", maxValue);
487 SysTryReturnResult(NID_UI_CTRL, (minValue < maxValue), E_INVALID_ARG,
488 "The minimum value is greater than maximum value.");
490 Variant oldMinValue = GetProperty("minValue");
491 Variant value = GetProperty("value");
493 r = SetProperty("minValue", Variant(minValue));
494 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, " Failed to set minimum value.");
496 r = SetProperty("maxValue", Variant(maxValue));
499 SysLogException(NID_UI_CTRL, r, "[%s] Failed to set maximum value.", GetErrorMessage(r));
501 result nestedResult = SetPropertyMinValue(oldMinValue);
502 if (nestedResult != E_SUCCESS)
504 SysLog(NID_UI_CTRL, "Failed to recover original minimum value");
508 nestedResult = SetPropertyValue(value);
509 if (nestedResult != E_SUCCESS)
511 SysLog(NID_UI_CTRL, "Failed to recover original value");
515 SetAccessibilityElementValue();
521 _Slider::SetPropertyMinValue(const Variant& minValue)
523 result r = E_SUCCESS;
525 int tempMinValue = minValue.ToInt();
527 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
529 __pSliderPresenter->SetMinValue(tempMinValue);
535 _Slider::SetPropertyMaxValue(const Variant& maxValue)
537 result r = E_SUCCESS;
539 int tempMaxValue = maxValue.ToInt();
541 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, " Propagating.");
543 __pSliderPresenter->SetMaxValue(tempMaxValue);
549 _Slider::GetRange(int& minValue, int& maxValue) const
551 result r = E_SUCCESS;
553 Variant minimum = GetProperty("minValue");
555 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
557 Variant maximum = GetProperty("maxValue");
559 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
561 minValue = minimum.ToInt();
562 maxValue = maximum.ToInt();
568 _Slider::GetPropertyMinValue(void) const
570 return Variant(__pSliderPresenter->GetMinValue());
574 _Slider::GetPropertyMaxValue(void) const
576 return Variant(__pSliderPresenter->GetMaxValue());
580 _Slider::SetValue(int value)
582 return SetProperty("value", Variant(value));
586 _Slider::SetPropertyValue(const Variant& value)
588 result r = E_SUCCESS;
590 SysTryReturnResult(NID_UI_CTRL, __isKeyPressed == false, E_SYSTEM, "[E_SYSTEM] Failed to set value of slider.");
592 int tempValue = value.ToInt();
594 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
596 if (__pSliderPresenter->GetValue() != tempValue)
598 __pSliderPresenter->SetValue(tempValue);
600 SetAccessibilityElementValue();
607 _Slider::SetAccessibilityElementValue()
609 if (__pAccessibilityElement != null)
612 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
613 char buffer[10] = {0,};
614 sprintf(buffer, "%d", GetValue());
615 string.Replace(L"%1$d", buffer);
616 memset(buffer, 0, 10);
617 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
618 string.Replace(L"%2$d", buffer);
619 __pAccessibilityElement->SetValue(string);
625 _Slider::GetValue(void) const
627 result r = E_SUCCESS;
629 Variant value = GetProperty("value");
631 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r));
633 return value.ToInt();
637 _Slider::GetPropertyValue(void) const
639 return Variant(__pSliderPresenter->GetValue());
643 _Slider::SetIcon(IconPosition position, const Bitmap& icon)
645 result r = E_SUCCESS;
647 float iconWidth = 0.0f;
648 float iconHeight = 0.0f;
649 _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
650 Bitmap* pNewBitmap = null;
652 r = GET_SHAPE_CONFIG(SLIDER::ICON_WIDTH, orientation, iconWidth);
653 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r,"Propagating.");
655 r = GET_SHAPE_CONFIG(SLIDER::ICON_HEIGHT, orientation, iconHeight);
656 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
658 if (position == ICON_POSITION_LEFT)
660 pNewBitmap = _BitmapImpl::CloneN(icon);
663 SysTryReturnResult(NID_UI_CTRL, pNewBitmap != null, r, "Propagating.");
665 r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight));
666 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
668 delete __pLeftBitmap;
669 __pLeftBitmap = pNewBitmap;
672 else //(position == ICON_POSITION_RIGHT)
674 pNewBitmap = _BitmapImpl::CloneN(icon);
677 SysTryReturnResult(NID_UI_CTRL, pNewBitmap != null, r, "Propagating.");
679 r = pNewBitmap->Scale(Dimension(iconWidth, iconHeight));
680 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
682 delete __pRightBitmap;
683 __pRightBitmap = pNewBitmap;
687 __pSliderPresenter->SetNeedUpdate();
698 _Slider::GetIcon(IconPosition position) const
700 if (position == ICON_POSITION_LEFT)
702 return __pLeftBitmap;
704 else //(position == ICON_POSITION_RIGHT)
706 return __pRightBitmap;
711 _Slider::SetTitleText(const String& title)
713 return SetProperty("titleText", Variant(title));
717 _Slider::SetPropertyTitleText(const Variant& titleText)
719 result r = E_SUCCESS;
720 String title = titleText.ToString();
722 if (!(GetStyle() & _SLIDER_STYLE_TITLE_TEXT))
724 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] A system error has occurred. The current Slider style does not support title text.");
729 __pSliderPresenter->SetNeedUpdate();
731 r = InitializeAccessibilityElement();
732 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
734 if (__pAccessibilityElement != null)
736 __pAccessibilityElement->SetLabel(__titleText);
743 _Slider::GetTitleText(void) const
745 result r = E_SUCCESS;
747 Variant titleText = GetProperty("titleText");
749 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, String(), r, "[%s] Propagating.", GetErrorMessage(r));
751 return titleText.ToString();
755 _Slider::GetPropertyTitleText(void) const
757 return Variant(__titleText);
761 _Slider::SetTitleTextColor(const Color& color)
763 return SetProperty("titleTextColor", Variant(color));
767 _Slider::SetPropertyTitleTextColor(const Variant& titleTextColor)
769 result r = E_SUCCESS;
771 Color tempColor = titleTextColor.ToColor();
773 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
775 __titleTextColor = tempColor;
776 __pSliderPresenter->SetNeedUpdate();
782 _Slider::GetTitleTextColor(void) const
784 result r = E_SUCCESS;
786 Variant titleTexColor = GetProperty("titleTextColor");
788 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
790 return titleTexColor.ToColor();
794 _Slider::GetPropertyTitleTextColor(void) const
796 return Variant(__titleTextColor);
800 _Slider::AddAdjustmentEventListener(const _IAdjustmentEventListener& listener)
802 return __pAdjustmentEvent->AddListener(listener);
806 _Slider::RemoveAdjustmentEventListener(const _IAdjustmentEventListener& listener)
808 return __pAdjustmentEvent->RemoveListener(listener);
812 _Slider::AddSliderEventListener(const _ISliderEventListener& listener)
814 return __pSliderEvent->AddListener(listener);
818 _Slider::RemoveSliderEventListener(const _ISliderEventListener& listener)
820 return __pSliderEvent->RemoveListener(listener);
824 _Slider::SetBarColor(const Color& color)
826 return SetProperty("barColor", Variant(color));
830 _Slider::SetPropertyBarColor(const Variant& barColor)
832 result r = E_SUCCESS;
834 Color tempBarColor = barColor.ToColor();
836 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
838 __barColor = tempBarColor;
839 __barColor.SetAlpha(0xFF);
845 _Slider::GetBarColor(void) const
847 result r = E_SUCCESS;
849 Variant barColor = GetProperty("barColor");
851 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
853 return barColor.ToColor();
857 _Slider::GetPropertyBarColor(void) const
859 return Variant(__barColor);
863 _Slider::SetBarBackgroundColor(const Color& color)
865 return SetProperty("barBackgroundColor", Variant(color));
869 _Slider::SetPropertyBarBackgroundColor(const Variant& barBackgroundColor)
871 result r = E_SUCCESS;
873 Color tempBarBackgroundColor = barBackgroundColor.ToColor();
875 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
877 __barBgColor = tempBarBackgroundColor;
878 __barBgColor.SetAlpha(0xFF);
884 _Slider::GetBarBackgroundColor(void) const
886 result r = E_SUCCESS;
888 Variant barBgColor = GetProperty("barBackgroundColor");
890 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
892 return barBgColor.ToColor();
896 _Slider::GetPropertyBarBackgroundColor(void) const
898 return Variant(__barBgColor);
902 _Slider::SetColor(const Color& color)
904 return SetProperty("color", Variant(color));
908 _Slider::SetPropertyColor(const Variant& color)
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 E_INVALID_OPERATION;
916 result r = E_SUCCESS;
918 Color tempBgColor = color.ToColor();
919 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "Propagating.");
921 __bgColor = tempBgColor;
923 __pSliderPresenter->SetNeedUpdate();
929 _Slider::GetColor(void) const
931 result r = E_SUCCESS;
933 Variant color = GetProperty("color");
935 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, Color(), r, "[%s] Propagating.", GetErrorMessage(r));
937 return color.ToColor();
941 _Slider::GetPropertyColor(void) const
943 if (__sliderStyle & _SLIDER_STYLE_NO_BG)
945 SysLogException(NID_UI_CTRL, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The current Slider style does not support background color.");
946 return Variant(Color());
950 return Variant(__bgColor);
954 Tizen::Base::Runtime::_Event*
955 _Slider::GetAdjustmentEvent(void) const
957 return __pAdjustmentEvent;
961 _Slider::GetSliderEvent(void) const
963 return __pSliderEvent;
967 _Slider::SetThumbBitmap(SliderThumbStatus status, const Bitmap& bitmap)
969 return __pSliderPresenter->SetThumbBitmap(status, bitmap);
973 _Slider::SetThumbTextColor(SliderThumbStatus status, const Color& color)
975 __pSliderPresenter->SetThumbTextColor(status, color);
980 _Slider::OnFontChanged(Font* pFont)
982 __pSliderPresenter->OnFontChanged(pFont);
987 _Slider::OnFontInfoRequested(unsigned long& style, float& size)
989 __pSliderPresenter->OnFontInfoRequested(style, size);
994 _Slider::OnAncestorVisibleStateChanged(const _Control& control)
996 __pSliderPresenter->OnAncestorVisibleStateChanged(control);
1002 _Slider::OnAncestorEnableStateChanged(const _Control& control)
1004 __pSliderPresenter->OnAncestorEnableStateChanged(control);
1010 _Slider::OnVisibleStateChanged(void)
1012 __pSliderPresenter->OnVisibleStateChanged();
1018 _Slider::OnAccessibilityValueIncreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1020 if (!GetEnableState())
1024 SetValue(GetValue() + 1);
1026 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
1027 char buffer[10] = {0,};
1028 sprintf(buffer, "%d", GetValue());
1029 string.Replace(L"%1$d", buffer);
1030 memset(buffer, 0, 10);
1031 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
1032 string.Replace(L"%2$d", buffer);
1033 _AccessibilityManager::GetInstance()->ReadContent(string);
1036 FireSliderMoveEvent(GetValue());
1037 FireAdjustmentValueEvent(GetValue());
1043 _Slider::OnAccessibilityValueDecreased(const _AccessibilityContainer& control, const _AccessibilityElement& element)
1045 if (!GetEnableState())
1049 SetValue(GetValue() - 1);
1051 GET_STRING_CONFIG(IDS_TPLATFORM_BODY_POSITION_P1SD_OF_P2SD_T_TTS, string);
1052 char buffer[10] = {0,};
1053 sprintf(buffer, "%d", GetValue());
1054 string.Replace(L"%1$d", buffer);
1055 memset(buffer, 0, 10);
1056 sprintf(buffer, "%d", __pSliderPresenter->GetMaxValue());
1057 string.Replace(L"%2$d", buffer);
1058 _AccessibilityManager::GetInstance()->ReadContent(string);
1061 FireSliderMoveEvent(GetValue());
1062 FireAdjustmentValueEvent(GetValue());
1068 _Slider::FireSliderMoveEvent(int value)
1070 if (__pSliderEvent != null)
1072 IEventArg* pEventArg = _SliderEvent::CreateSliderEventArgN(value);
1074 if(pEventArg == null)
1079 __pSliderEvent->Fire(*pEventArg);
1084 _Slider::FireAdjustmentValueEvent(int adjustment)
1086 if (__pAdjustmentEvent != null)
1088 IEventArg* pEventArg = _AdjustmentEvent::CreateAdjustmentEventArgN(adjustment);
1089 if(pEventArg == null)
1094 __pAdjustmentEvent->Fire(*pEventArg);
1097 }}} // Tizen::Ui::Controls