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.
18 * @file FUiCtrl_ButtonImpl.cpp
19 * @brief This is the implementation file for the _ButtonImpl class.
22 #include <FAppApplication.h>
23 #include <FBaseInternalTypes.h>
24 #include <FBaseSysLog.h>
25 #include <FBase_LocalizedNumParser.h>
26 #include <FUiAccessibilityContainer.h>
27 #include <FUiAccessibilityElement.h>
28 #include <FApp_AppInfo.h>
29 #include "FUi_ResourceSizeInfo.h"
30 #include "FUi_ResourceManager.h"
31 #include "FUi_UiBuilder.h"
32 #include "FUiCtrl_ButtonImpl.h"
33 #include "FUiCtrl_Button.h"
34 #include "FUi_CoordinateSystemUtils.h"
36 using namespace Tizen::App;
37 using namespace Tizen::Base;
38 using namespace Tizen::Graphics;
40 namespace Tizen { namespace Ui { namespace Controls
44 _ButtonImpl::ButtonSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const
47 Dimension dimension(0, 0);
49 r = GET_DIMENSION_CONFIG(BUTTON::MIN_SIZE, orientation, dimension);
50 SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] A system error occurred.", GetErrorMessage(r));
58 _ButtonImpl::ButtonSizeInfo::GetDefaultMinimumSizeF(_ControlOrientation orientation) const
61 FloatDimension dimension(0.0f, 0.0f);
63 r = GET_DIMENSION_CONFIG(BUTTON::MIN_SIZE, orientation, dimension);
64 SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] A system error occurred.", GetErrorMessage(r));
72 _ButtonImpl::GetInstance(Button& button)
74 return static_cast<_ButtonImpl*> (button._pControlImpl);
78 _ButtonImpl::GetInstance(const Button& button)
80 return static_cast<const _ButtonImpl*> (button._pControlImpl);
83 _ButtonImpl::_ButtonImpl(Button* pPublic, _Button* pCore)
84 : _ControlImpl(pPublic, pCore)
85 , __pPublicActionEvent(null)
90 _ButtonImpl::~_ButtonImpl(void)
92 _ButtonImpl::GetCore().RemoveActionEventListener(*this);
94 if (__pPublicActionEvent)
96 delete __pPublicActionEvent;
97 __pPublicActionEvent = null;
104 _ButtonImpl::CreateButtonImplN(Button* pControl, const Rectangle& bounds)
106 result r = E_SUCCESS;
107 r = GET_SIZE_INFO(Button).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
108 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] The given size is not valid.");
110 _Button* pCore = _Button::CreateButtonN();
111 SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
113 _ButtonImpl* pImpl = new (std::nothrow) _ButtonImpl(pControl, pCore);
114 r = _ControlImpl::CheckConstruction(pCore, pImpl);
115 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
117 r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Button), bounds, pCore->GetOrientation());
118 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
120 r = pCore->AddActionEventListener(*pImpl);
121 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
133 _ButtonImpl::CreateButtonImplN(Button* pControl, const FloatRectangle& bounds)
135 result r = E_SUCCESS;
136 r = GET_SIZE_INFO(Button).CheckInitialSizeValidF(FloatDimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
137 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] The given size is not valid.");
139 _Button* pCore = _Button::CreateButtonN();
140 SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
142 _ButtonImpl* pImpl = new (std::nothrow) _ButtonImpl(pControl, pCore);
143 r = _ControlImpl::CheckConstruction(pCore, pImpl);
144 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
146 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Button), bounds, pCore->GetOrientation());
147 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
149 r = pCore->AddActionEventListener(*pImpl);
150 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
162 _ButtonImpl::GetColorOnError(void)
164 return Color(0xFFFFFFFF);
168 _ButtonImpl::GetPublicClassName(void) const
170 return "Tizen::Ui::Controls::Button";
174 _ButtonImpl::GetPublic(void) const
176 return static_cast <const Button&>(_ControlImpl::GetPublic());
180 _ButtonImpl::GetPublic(void)
182 return static_cast <Button&>(_ControlImpl::GetPublic());
186 _ButtonImpl::GetCore(void) const
188 return static_cast <const _Button&>(_ControlImpl::GetCore());
192 _ButtonImpl::GetCore(void)
194 return static_cast <_Button&>(_ControlImpl::GetCore());
198 _ButtonImpl::SetText(const String& text)
200 int textLength = text.GetLength();
201 int buttonTextMaxLength = 0;
202 GET_FIXED_VALUE_CONFIG(BUTTON::TEXT_MAX_LENGTH, _CONTROL_ORIENTATION_PORTRAIT, buttonTextMaxLength);
203 String tempText = String(text);
205 if (textLength >= buttonTextMaxLength)
207 tempText.Remove(buttonTextMaxLength - 1, textLength - buttonTextMaxLength + 1);
210 Variant var(tempText);
211 result r = GetCore().SetPropertyText(var);
212 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
218 _ButtonImpl::GetText(void) const
222 return GetCore().GetPropertyText().ToString();
226 _ButtonImpl::SetColor(ButtonStatus status, const Color& color)
228 _ButtonStatus coreStatus = ConvertStatus(status);
229 result r = GetCore().SetColor(coreStatus, color);
230 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
236 _ButtonImpl::GetColor(ButtonStatus status) const
239 _ButtonStatus coreStatus = ConvertStatus(status);
241 return GetCore().GetColor(coreStatus);
245 _ButtonImpl::AddActionEventListener(IActionEventListener& listener)
247 if (__pPublicActionEvent == null)
249 __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
250 SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
253 result r = __pPublicActionEvent->AddListener(listener);
254 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
260 _ButtonImpl::RemoveActionEventListener(IActionEventListener& listener)
262 result r = E_OBJ_NOT_FOUND;
264 if (__pPublicActionEvent)
266 r = __pPublicActionEvent->RemoveListener(listener);
269 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
275 _ButtonImpl::SetActionId(int actionId)
277 result r = GetCore().SetActionId(actionId);
279 SetLastResultReturn(r);
283 _ButtonImpl::GetActionId(void) const
287 return GetCore().GetActionId();
291 _ButtonImpl::SetTextHorizontalAlignment(HorizontalAlignment alignment)
293 result r = GetCore().SetTextHorizontalAlignment(alignment);
294 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
300 _ButtonImpl::GetTextHorizontalAlignment(void) const
304 return GetCore().GetTextHorizontalAlignment();
308 _ButtonImpl::SetTextVerticalAlignment(VerticalAlignment alignment)
310 result r = GetCore().SetTextVerticalAlignment(alignment);
311 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
317 _ButtonImpl::GetTextVerticalAlignment(void) const
321 return GetCore().GetTextVerticalAlignment();
325 _ButtonImpl::SetTextColor(const Color& color)
327 result r = GetCore().SetTextColor(_BUTTON_STATUS_NORMAL, color);
328 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
334 _ButtonImpl::GetTextColor(void) const
338 return GetCore().GetTextColor(_BUTTON_STATUS_NORMAL);
342 _ButtonImpl::SetDisabledTextColor(const Color& color)
344 result r = GetCore().SetTextColor(_BUTTON_STATUS_DISABLED, color);
345 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
351 _ButtonImpl::GetDisabledTextColor(void) const
355 return GetCore().GetTextColor(_BUTTON_STATUS_DISABLED);
359 _ButtonImpl::SetPressedTextColor(const Color& color)
361 result r = GetCore().SetTextColor(_BUTTON_STATUS_PRESSED, color);
362 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
368 _ButtonImpl::GetPressedTextColor(void) const
372 return GetCore().GetTextColor(_BUTTON_STATUS_PRESSED);
376 _ButtonImpl::SetHighlightedTextColor(const Color& color)
378 result r = GetCore().SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, color);
379 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
385 _ButtonImpl::GetHighlightedTextColor(void) const
389 return GetCore().GetTextColor(_BUTTON_STATUS_HIGHLIGHTED);
393 _ButtonImpl::SetNormalBitmap(const Point& position, const Bitmap& bitmap)
395 result r = GetCore().SetBitmap(_BUTTON_STATUS_NORMAL, position, bitmap);
396 SetLastResultReturn(r);
400 _ButtonImpl::SetNormalBitmap(const FloatPoint& position, const Bitmap& bitmap)
402 result r = GetCore().SetBitmap(_BUTTON_STATUS_NORMAL, position, bitmap);
403 SetLastResultReturn(r);
407 _ButtonImpl::SetDisabledBitmap(const Point& position, const Bitmap& bitmap)
409 result r = GetCore().SetBitmap(_BUTTON_STATUS_DISABLED, position, bitmap);
410 SetLastResultReturn(r);
414 _ButtonImpl::SetDisabledBitmap(const FloatPoint& position, const Bitmap& bitmap)
416 result r = GetCore().SetBitmap(_BUTTON_STATUS_DISABLED, position, bitmap);
417 SetLastResultReturn(r);
421 _ButtonImpl::SetPressedBitmap(const Point& position, const Bitmap& bitmap)
423 result r = GetCore().SetBitmap(_BUTTON_STATUS_PRESSED, position, bitmap);
424 SetLastResultReturn(r);
428 _ButtonImpl::SetPressedBitmap(const FloatPoint& position, const Bitmap& bitmap)
430 result r = GetCore().SetBitmap(_BUTTON_STATUS_PRESSED, position, bitmap);
431 SetLastResultReturn(r);
435 _ButtonImpl::SetHighlightedBitmap(const Point& position, const Bitmap& bitmap)
437 result r = GetCore().SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, position, bitmap);
438 SetLastResultReturn(r);
442 _ButtonImpl::SetHighlightedBitmap(const FloatPoint& position, const Bitmap& bitmap)
444 result r = GetCore().SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, position, bitmap);
445 SetLastResultReturn(r);
449 _ButtonImpl::SetNormalBackgroundBitmap(const Bitmap& bitmap)
451 result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, bitmap);
452 SetLastResultReturn(r);
456 _ButtonImpl::SetDisabledBackgroundBitmap(const Bitmap& bitmap)
458 result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, bitmap);
459 SetLastResultReturn(r);
463 _ButtonImpl::SetPressedBackgroundBitmap(const Bitmap& bitmap)
465 result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, bitmap);
466 SetLastResultReturn(r);
470 _ButtonImpl::SetHighlightedBackgroundBitmap(const Bitmap& bitmap)
472 result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, bitmap);
473 SetLastResultReturn(r);
477 _ButtonImpl::SetTextSize(int size)
479 result r = GetCore().SetTextSize(size);
480 SetLastResultReturn(r);
484 _ButtonImpl::SetTextSize(float size)
486 result r = GetCore().SetTextSize(size);
487 SetLastResultReturn(r);
491 _ButtonImpl::GetTextSize(void) const
495 return GetCore().GetTextSize();
499 _ButtonImpl::GetTextSizeF(void) const
503 return GetCore().GetTextSizeF();
507 _ButtonImpl::OnActionPerformed(const _Control& source, int actionId)
509 if (__pPublicActionEvent != null)
511 __pPublicActionEvent->Fire(*_PublicActionEvent::CreateActionEventArgN(actionId));
518 _ButtonImpl::OnAttachedToMainTree(void)
520 //SetFocusable(true); // for TDIS-6998
522 _ControlImpl::OnAttachedToMainTree();
528 _ButtonImpl::OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo)
530 if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) && (!source.IsEnabled() || !source.GetEnableState()))
539 _ButtonImpl::OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo)
541 if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) && (!source.IsEnabled() || !source.GetEnableState()))
550 _ButtonImpl::OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo)
552 if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) && (!source.IsEnabled() || !source.GetEnableState()))
561 _ButtonImpl::OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo)
563 if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()) && (!source.IsEnabled() || !source.GetEnableState()))
571 Tizen::Graphics::FloatDimension
572 _ButtonImpl::GetContentSizeF(bool horizontalMode, bool verticalMode) const
574 return GetCore().GetContentSizeF(horizontalMode, verticalMode);
578 _ButtonImpl::ConvertStatus(ButtonStatus status) const
580 _ButtonStatus coreStatus = _BUTTON_STATUS_HIGHLIGHTED;
583 case BUTTON_STATUS_NORMAL:
584 coreStatus = _BUTTON_STATUS_NORMAL;
586 case BUTTON_STATUS_DISABLED:
587 coreStatus = _BUTTON_STATUS_DISABLED;
589 case BUTTON_STATUS_PRESSED:
590 coreStatus = _BUTTON_STATUS_PRESSED;
593 coreStatus = _BUTTON_STATUS_HIGHLIGHTED;
600 : public _UiBuilderControlMaker
603 _ButtonMaker(_UiBuilder* uibuilder)
604 : _UiBuilderControlMaker(uibuilder){};
606 virtual ~_ButtonMaker(){};
607 static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
609 _ButtonMaker* pButtonMaker = new (std::nothrow) _ButtonMaker(uibuilder);
610 return static_cast<_UiBuilderControlMaker*>(pButtonMaker);
613 virtual Control* Make(_UiBuilderControl* pControl)
616 _UiBuilderControlLayout* pControlProperty = null;
617 Button* pButton = null;
618 HorizontalAlignment horizontalAlignment;
619 VerticalAlignment verticalAlignment;
623 FloatRectangle buttonRect(0.0f, 0.0f, 0.0f, 0.0f);
624 Tizen::Base::String elementString;
626 GetProperty(pControl, &pControlProperty);
628 if (pControlProperty == null)
633 pButton = new (std::nothrow) Button();
639 buttonRect = pControlProperty->GetRectF();
641 if (pControl->GetElement(L"text", elementString))
643 r = pButton->Construct(buttonRect, elementString);
647 r = pButton->Construct(buttonRect);
656 if (pControl->GetElement(L"horizontalAlign", elementString) || pControl->GetElement(L"hAlign", elementString))
658 if (ConvertHAlignToHorizontalAlignment(elementString, horizontalAlignment))
660 pButton->SetTextHorizontalAlignment(horizontalAlignment);
664 if (pControl->GetElement(L"verticalAlign", elementString) || pControl->GetElement(L"vAlign", elementString))
666 if (ConvertVAlignToVerticalAlignment(elementString, verticalAlignment))
668 pButton->SetTextVerticalAlignment(verticalAlignment);
672 if (pControl->GetElement(L"normalTextColor", elementString))
674 ConvertStringToColor(elementString, color);
675 pButton->SetTextColor(color);
678 if (pControl->GetElement(L"pressedTextColor", elementString))
680 ConvertStringToColor(elementString, color);
681 pButton->SetPressedTextColor(color);
684 if (pControl->GetElement(L"disableTextColor", elementString))
686 ConvertStringToColor(elementString, color);
687 pButton->SetDisabledTextColor(color);
690 if (pControl->GetElement(L"normalBitmapPath", elementString) || pControl->GetElement(L"NormalBitmapPath", elementString))
692 Bitmap* pNormalBitmap = null;
694 pNormalBitmap = LoadBitmapN(elementString);
696 if (pControl->GetElement(L"NormalBitmapX", elementString))
698 position.x = _LocalizedNumParser::ToDouble(elementString, "C");
699 if ((position.x < 0.0f) || (position.x > ((Control*) (GetContainer()))->GetBoundsF().width - ((Control*) (GetContainer()))->GetBoundsF().x))
705 if (pControl->GetElement(L"NormalBitmapY", elementString))
707 position.y = _LocalizedNumParser::ToDouble(elementString, "C");
708 if (position.y < 0.0f || (position.y > ((Control*) (GetContainer()))->GetBoundsF().height - ((Control*) (GetContainer()))->GetBoundsF().y))
714 if (pNormalBitmap != null)
716 pButton->SetNormalBitmap(position, *pNormalBitmap);
717 delete pNormalBitmap;
721 if (pControl->GetElement(L"PressedBitmapPath", elementString))
723 Bitmap* pPressedBitmap = null;
726 pPressedBitmap = LoadBitmapN(elementString);
727 if (pControl->GetElement(L"PressedBitmapX", elementString))
729 position.x = _LocalizedNumParser::ToDouble(elementString, "C");
730 if ((position.x < 0.0f) || (position.x > ((Control*) (GetContainer()))->GetBoundsF().width - ((Control*) (GetContainer()))->GetBoundsF().x))
736 if (pControl->GetElement(L"PressedBitmapY", elementString))
738 position.y =_LocalizedNumParser::ToDouble(elementString, "C");
739 if (position.y < 0.0f || (position.y > ((Control*) (GetContainer()))->GetBoundsF().height - ((Control*) (GetContainer()))->GetBoundsF().y))
745 if (pPressedBitmap != null)
747 pButton->SetPressedBitmap(position, *pPressedBitmap);
748 delete pPressedBitmap;
752 if (pControl->GetElement(L"DisabledBitmapPath", elementString))
754 Bitmap* pDisabledBitmap = null;
756 pDisabledBitmap = LoadBitmapN(elementString);
757 if (pControl->GetElement(L"DisabledBitmapX", elementString))
759 position.x = _LocalizedNumParser::ToDouble(elementString, "C");
760 if ((position.x < 0.0f) || (position.x > ((Control*) (GetContainer()))->GetBoundsF().width - ((Control*) (GetContainer()))->GetBoundsF().x))
766 if (pControl->GetElement(L"DisabledBitmapY", elementString))
768 position.y = _LocalizedNumParser::ToDouble(elementString, "C");
769 if (position.y < 0.0f || (position.y > ((Control*) (GetContainer()))->GetBoundsF().height - ((Control*) (GetContainer()))->GetBoundsF().y))
775 if (pDisabledBitmap != null)
777 pButton->SetDisabledBitmap(position, *pDisabledBitmap);
778 delete pDisabledBitmap;
782 if (pControl->GetElement(L"HighlightedBitmapPath", elementString))
784 Bitmap* pHighlightedBitmap = null;
786 pHighlightedBitmap = LoadBitmapN(elementString);
787 if (pControl->GetElement(L"HighlightedBitmapX", elementString))
789 position.x = _LocalizedNumParser::ToDouble(elementString, "C");
790 if ((position.x < 0.0f) || (position.x > ((Control*) (GetContainer()))->GetBoundsF().width - ((Control*) (GetContainer()))->GetBoundsF().x))
796 if (pControl->GetElement(L"HighlightedBitmapY", elementString))
798 position.y = _LocalizedNumParser::ToDouble(elementString, "C");
799 if (position.y < 0.0f || (position.y > ((Control*) (GetContainer()))->GetBoundsF().height - ((Control*) (GetContainer()))->GetBoundsF().y))
805 if (pHighlightedBitmap != null)
807 pButton->SetHighlightedBitmap(position, *pHighlightedBitmap);
808 delete pHighlightedBitmap;
812 if (pControl->GetElement(L"NormalBGBitmapPath", elementString))
814 Bitmap* pNormalBGBitmap = null;
815 pNormalBGBitmap = LoadBitmapN(elementString);
816 if (pNormalBGBitmap != null)
818 pButton->SetNormalBackgroundBitmap(*pNormalBGBitmap);
819 delete pNormalBGBitmap;
823 if (pControl->GetElement(L"PressedBGBitmapPath", elementString))
825 Bitmap* pPressedBGBitmap = null;
826 pPressedBGBitmap = LoadBitmapN(elementString);
827 if (pPressedBGBitmap != null)
829 pButton->SetPressedBackgroundBitmap(*pPressedBGBitmap);
830 delete pPressedBGBitmap;
834 if (pControl->GetElement(L"HighlightedBGBitmapPath", elementString))
836 Bitmap* pHighlightedBGBitmap = null;
837 pHighlightedBGBitmap = LoadBitmapN(elementString);
838 if (pHighlightedBGBitmap != null)
840 pButton->SetHighlightedBackgroundBitmap(*pHighlightedBGBitmap);
841 delete pHighlightedBGBitmap;
845 if (pControl->GetElement(L"DisabledBGBitmapPath", elementString))
847 Bitmap* pDisabledBGBitmap = null;
848 pDisabledBGBitmap = LoadBitmapN(elementString);
849 if (pDisabledBGBitmap != null)
851 pButton->SetDisabledBackgroundBitmap(*pDisabledBGBitmap);
852 delete pDisabledBGBitmap;
856 if (pControl->GetElement(L"highlightedTextColor", elementString))
858 ConvertStringToColor(elementString, color);
859 pButton->SetHighlightedTextColor(color);
862 if (pControl->GetElement(L"normalColorOpacity", elementString))
864 Base::Integer::Parse(elementString, opacity);
867 if (pControl->GetElement(L"normalColor", elementString))
869 ConvertStringToColor32(elementString, opacity, color);
870 pButton->SetColor(BUTTON_STATUS_NORMAL, color);
873 if (pControl->GetElement(L"pressedColorOpacity", elementString))
875 Base::Integer::Parse(elementString, opacity);
878 if (pControl->GetElement(L"pressedColor", elementString))
880 ConvertStringToColor32(elementString, opacity, color);
881 pButton->SetColor(BUTTON_STATUS_PRESSED, color);
884 if (pControl->GetElement(L"disabledColorOpacity", elementString))
886 Base::Integer::Parse(elementString, opacity);
889 if (pControl->GetElement(L"disabledColor", elementString))
891 ConvertStringToColor32(elementString, opacity, color);
892 pButton->SetColor(BUTTON_STATUS_DISABLED, color);
895 if (pControl->GetElement(L"highlightedColorOpacity", elementString))
897 Base::Integer::Parse(elementString, opacity);
900 if (pControl->GetElement(L"highlightedColor", elementString))
902 ConvertStringToColor32(elementString, opacity, color);
903 pButton->SetColor(BUTTON_STATUS_HIGHLIGHTED, color);
906 if (pControl->GetElement(L"textSize", elementString))
908 _ICoordinateSystemTransformer* pTransform = GetTransformer();
910 size = _LocalizedNumParser::ToDouble(elementString, "C");
914 size = pTransform->Transform(size);
917 pButton->SetTextSize(size);
920 if (pControl->GetElement(L"accessibilityHint", elementString))
922 AccessibilityContainer* pContainer = pButton->GetAccessibilityContainer();
925 AccessibilityElement* pElement = pContainer->GetElement(L"ButtonText");
928 pElement->SetHint(elementString);
938 _ButtonRegister::_ButtonRegister()
940 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
941 pUiBuilderControlTableManager->RegisterControl(L"Button", _ButtonMaker::GetInstance);
943 _ButtonRegister::~_ButtonRegister()
945 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
946 pUiBuilderControlTableManager->UnregisterControl(L"Button");
948 static _ButtonRegister ButtonRegisterToUiBuilder;
949 }}} // Tizen::Ui::Controls