Changed indicator bg color.
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_Button.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17 /**
18  * @file                FUiCtrl_Button.cpp
19  * @brief               This is the implementation file for the _Button class.
20  */
21
22 #include <FBaseErrorDefine.h>
23 #include <FBaseSysLog.h>
24 #include <FGrp_BitmapImpl.h>
25 #include "FUi_AccessibilityContainer.h"
26 #include "FUi_AccessibilityElement.h"
27 #include "FUi_AccessibilityManager.h"
28 #include "FUi_CoordinateSystemUtils.h"
29 #include "FUi_ResourceManager.h"
30 #include "FUi_UiTouchEvent.h"
31 #include "FUiCtrl_Button.h"
32 #include "FUiCtrl_ButtonPresenter.h"
33
34
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Runtime;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Graphics::_Text;
39
40 namespace Tizen { namespace Ui { namespace Controls
41 {
42
43 IMPLEMENT_PROPERTY(_Button);
44
45 _Button::_Button()
46         : __pButtonPresenter(null)
47         , __pActionEvent(null)
48         , __actionId(0)
49         , __text(L"")
50         , __horizontalAlignment(ALIGNMENT_CENTER)
51         , __verticalAlignment(ALIGNMENT_MIDDLE)
52         , __buttonStatus(_BUTTON_STATUS_NORMAL)
53         , __buttonStyle(_BUTTON_STYLE_NORMAL)
54         , __textSize(0.0f)
55         , __multilineFontSize(0.0f)
56         , __textMaxLine(2)
57         , __isSettingMultilineFontSize(false)
58         , __previousTouchArea(false)
59         , __userDefinedText(false)
60         , __tabTextSlide(false)
61         , __leftMargin(0.0f)
62         , __topMargin(0.0f)
63         , __rightMargin(0.0f)
64         , __bottomMargin(0.0f)
65         , __leftTouchMargin(0.0f)
66         , __topTouchMargin(0.0f)
67         , __rightTouchMargin(0.0f)
68         , __bottomTouchMargin(0.0f)
69         , __userDefinedTextArea(0.0f, 0.0f, 0.0f, 0.0f)
70         , __pTextElement(null)
71 {
72         result r = E_SUCCESS;
73
74         _AccessibilityContainer* pContainer = null;
75
76         GET_SHAPE_CONFIG(BUTTON::DEFAULT_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __textSize);
77         GET_SHAPE_CONFIG(BUTTON::MULTILINE_FONT_SIZE, _CONTROL_ORIENTATION_PORTRAIT, __multilineFontSize);
78
79         _ButtonPresenter* pPresenter = new (std::nothrow) _ButtonPresenter();
80         SysTryReturnVoidResult(NID_UI_CTRL, pPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
81
82         r = SetPresenter(*pPresenter);
83         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
84
85         r = pPresenter->Construct(*this);
86         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
87
88         r = pPresenter->Install();
89         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
90
91         for (int i = 0; i < NUMBER_OF_BUTTON_STATUS; i++)
92         {
93                 __pBitmap[i] = null;
94                 __pEffectBitmap[i] = null;
95                 __pToolbarItemBackgroundBitmap[i] = null;
96                 __pBackgroundBitmap[i] = null;
97                 __pBackgroundEffectBitmap[i] = null;
98                 __isUserBackgroundBitmap[i] = false;
99                 __isUserBackgroundEffectBitmap[i] = false;
100         }
101
102         __pUnderlineBitmap = null;
103         __pTabTextDimLeftBitmap = null;
104         __pTabTextDimRightBitmap = null;
105         __pSubTitleEffectBitmap = null;
106
107         GET_COLOR_CONFIG(BUTTON::BG_NORMAL, __color[_BUTTON_STATUS_NORMAL]);
108         GET_COLOR_CONFIG(BUTTON::BG_DISABLED, __color[_BUTTON_STATUS_DISABLED]);
109         GET_COLOR_CONFIG(BUTTON::BG_PRESSED, __color[_BUTTON_STATUS_PRESSED]);
110         GET_COLOR_CONFIG(BUTTON::BG_HIGHLIGHTED, __color[_BUTTON_STATUS_HIGHLIGHTED]);
111         GET_COLOR_CONFIG(BUTTON::BG_PRESSED, __color[_BUTTON_STATUS_SELECTED]);
112
113         GET_COLOR_CONFIG(BUTTON::TEXT_NORMAL, __textColor[_BUTTON_STATUS_NORMAL]);
114         GET_COLOR_CONFIG(BUTTON::TEXT_DISABLED, __textColor[_BUTTON_STATUS_DISABLED]);
115         GET_COLOR_CONFIG(BUTTON::TEXT_PRESSED, __textColor[_BUTTON_STATUS_PRESSED]);
116         GET_COLOR_CONFIG(BUTTON::TEXT_HIGHLIGHTED, __textColor[_BUTTON_STATUS_HIGHLIGHTED]);
117         GET_COLOR_CONFIG(BUTTON::TEXT_PRESSED, __textColor[_BUTTON_STATUS_SELECTED]);
118
119         GET_SHAPE_CONFIG(BUTTON::LEFT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __leftMargin);
120         GET_SHAPE_CONFIG(BUTTON::TOP_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __topMargin);
121         GET_SHAPE_CONFIG(BUTTON::RIGHT_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __rightMargin);
122         GET_SHAPE_CONFIG(BUTTON::BOTTOM_MARGIN, _CONTROL_ORIENTATION_PORTRAIT, __bottomMargin);
123
124         AddPropertyChangeEventListener(*this);
125
126         pContainer = GetAccessibilityContainer();
127
128         if(pContainer)
129         {
130                 pContainer->Activate(true);
131                 InitializeAccessibilityElement();
132         }
133
134         ClearLastResult();
135
136         return;
137
138 CATCH:
139         delete pPresenter;
140 }
141
142 _Button*
143 _Button::CreateButtonN(void)
144 {
145         _Button* pButton = new (std::nothrow) _Button();
146         SysTryReturn(NID_UI_CTRL, pButton, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
147         SysTryCatch(NID_UI_CTRL, GetLastResult() == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error occurred.");
148
149         pButton->AcquireHandle();
150
151         pButton->SetTouchPressThreshold(SENSITIVE);
152
153         return pButton;
154
155 CATCH:
156         delete pButton;
157         return null;
158 }
159
160 _Button::~_Button(void)
161 {
162         if (__pButtonPresenter)
163         {
164                 delete __pButtonPresenter;
165                 __pButtonPresenter = null;
166         }
167
168         if (__pActionEvent)
169         {
170                 delete __pActionEvent;
171                 __pActionEvent = null;
172         }
173
174         for (int i = 0; i < NUMBER_OF_BUTTON_STATUS; i++)
175         {
176                 if (__pBitmap[i])
177                 {
178                         delete __pBitmap[i];
179                         __pBitmap[i] = null;
180                 }
181
182                 if (__pEffectBitmap[i])
183                 {
184                         delete __pEffectBitmap[i];
185                         __pEffectBitmap[i] = null;
186                 }
187
188                 if (__pToolbarItemBackgroundBitmap[i])
189                 {
190                         delete __pToolbarItemBackgroundBitmap[i];
191                         __pToolbarItemBackgroundBitmap[i] = null;
192                 }
193
194                 if (__pBackgroundBitmap[i])
195                 {
196                         delete __pBackgroundBitmap[i];
197                         __pBackgroundBitmap[i] = null;
198                 }
199
200                 if (__pBackgroundEffectBitmap[i])
201                 {
202                         delete __pBackgroundEffectBitmap[i];
203                         __pBackgroundEffectBitmap[i] = null;
204                 }
205         }
206
207         if (__pUnderlineBitmap)
208         {
209                 delete __pUnderlineBitmap;
210                 __pUnderlineBitmap = null;
211         }
212
213         if (__pTabTextDimLeftBitmap)
214         {
215                 delete __pTabTextDimLeftBitmap;
216                 __pTabTextDimLeftBitmap = null;
217         }
218
219         if (__pTabTextDimRightBitmap)
220         {
221                 delete __pTabTextDimRightBitmap;
222                 __pTabTextDimRightBitmap = null;
223         }
224
225         if (__pSubTitleEffectBitmap)
226         {
227                 delete __pSubTitleEffectBitmap;
228                 __pSubTitleEffectBitmap = null;
229         }
230
231         if (__pTextElement)
232         {
233                 __pTextElement->Activate(false);
234                 __pTextElement = null;
235         }
236
237         ClearLastResult();
238 }
239
240 result
241 _Button::SetPresenter(const _ButtonPresenter& buttonPresenter)
242 {
243         __pButtonPresenter = const_cast<_ButtonPresenter*>(&buttonPresenter);
244
245         return E_SUCCESS;
246 }
247
248 void
249 _Button::OnDraw(void)
250 {
251         __pButtonPresenter->Draw();
252
253         return;
254 }
255
256 result
257 _Button::OnAttachedToMainTree(void)
258 {
259         if(__pTextElement)
260         {
261                 __pTextElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
262         }
263         return E_SUCCESS;
264 }
265
266 void
267 _Button::InitializeAccessibilityElement(void)
268 {
269         if(__pTextElement)
270         {
271                 return;
272         }
273
274         _AccessibilityContainer* pContainer = GetAccessibilityContainer();
275
276         if(pContainer)
277         {
278                 __pTextElement = new (std::nothrow) _AccessibilityElement(true);
279                 SysTryReturnVoidResult(NID_UI_CTRL, __pTextElement, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
280
281                 __pTextElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
282                 __pTextElement->SetLabel(GetText());
283                 __pTextElement->SetTraitWithStringId("IDS_TPLATFORM_BODY_BUTTON_T_TTS");
284                 __pTextElement->SetName(L"ButtonText");
285
286                 pContainer->AddElement(*__pTextElement);
287         }
288
289         return;
290 }
291
292 void
293 _Button::OnPropertyChanging(_PropertyBase& source, const String& name, const Variant& oldValue, const Variant& newValue)
294 {
295         return;
296 }
297
298 void
299 _Button::OnPropertyChanged(_PropertyBase& source, const String& name, const Variant& oldValue, const Variant& newValue)
300 {
301         return;
302 }
303
304 bool
305 _Button::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
306 {
307         return __pButtonPresenter->OnTouchPressed(source, touchinfo);
308 }
309
310 bool
311 _Button::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
312 {
313         return __pButtonPresenter->OnTouchReleased(source, touchinfo);
314 }
315
316 bool
317 _Button::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
318 {
319         return __pButtonPresenter->OnTouchMoved(source, touchinfo);
320 }
321
322 bool
323 _Button::OnTouchCanceled(const _Control & source, const _TouchInfo & touchinfo)
324 {
325         return __pButtonPresenter->OnTouchCanceled(source, touchinfo);
326 }
327
328 void
329 _Button::OnTouchMoveHandled(const _Control& control)
330 {
331         __pButtonPresenter->OnTouchMoveHandled(control);
332
333         return;
334 }
335
336 bool
337 _Button::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
338 {
339         return __pButtonPresenter->OnKeyPressed(source, keyInfo);
340 }
341
342 bool
343 _Button::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
344 {
345         return __pButtonPresenter->OnKeyReleased(source, keyInfo);
346 }
347
348 void
349 _Button::OnBoundsChanged(void)
350 {
351         if(__pTextElement)
352         {
353                 __pTextElement->SetBounds(FloatRectangle(0.0f, 0.0f, GetBoundsF().width, GetBoundsF().height));
354         }
355
356         return;
357 }
358
359 void
360 _Button::OnFontChanged(Font* pFont)
361 {
362         __pButtonPresenter->OnFontChanged(pFont);
363
364         _Control::OnFontChanged(pFont);
365
366         return;
367 }
368
369 void
370 _Button::OnFontInfoRequested(unsigned long& style, int& size)
371 {
372         __pButtonPresenter->OnFontInfoRequested(style, size);
373
374         return;
375 }
376
377 void
378 _Button::OnFontInfoRequested(unsigned long& style, float& size)
379 {
380         __pButtonPresenter->OnFontInfoRequested(style, size);
381
382         return;
383 }
384
385 void
386 _Button::OnAncestorEnableStateChanged(const _Control& control)
387 {
388         __pButtonPresenter->OnAncestorEnableStateChanged(control);
389
390         return;
391 }
392
393 void
394 _Button::OnDrawFocus(void)
395 {
396         __pButtonPresenter->OnDrawFocus();
397
398         return;
399 }
400
401 void
402 _Button::OnChildControlFocusMoved(const _Control& control)
403 {
404         __pButtonPresenter->OnChildControlFocusMoved(control);
405
406         return;
407 }
408
409 bool
410 _Button::IsChildControlFocusManage(void) const
411 {
412         __pButtonPresenter->IsChildControlFocusManage();
413
414         return true;
415 }
416
417 void
418 _Button::OnFocusableStateChanged(bool focusalbeState)
419 {
420         __pButtonPresenter->OnFocusableStateChanged(focusalbeState);
421
422         return;
423 }
424
425 void
426 _Button::OnFocusModeStateChanged(void)
427 {
428         __pButtonPresenter->OnFocusModeStateChanged();
429
430         return;
431 }
432
433 bool
434 _Button::OnFocusGained(const _Control& source)
435 {
436         __pButtonPresenter->OnFocusGained(source);
437
438         return false;
439 }
440
441 bool
442 _Button::OnFocusLost(const _Control& source)
443 {
444         __pButtonPresenter->OnFocusLost(source);
445
446         return true;
447 }
448
449 Canvas*
450 _Button::OnCanvasRequestedN(const FloatRectangle& bounds)
451 {
452         return __pButtonPresenter->OnCanvasRequestedN(bounds);
453 }
454
455 result
456 _Button::SetText(const String& text)
457 {
458         return SetProperty(L"text", Variant(text));
459 }
460
461 result
462 _Button::SetPropertyText(const Variant& text)
463 {
464         __text = text.ToString();
465
466         if(__pTextElement)
467         {
468                 __pTextElement->SetLabel(__text);
469         }
470
471         result r = __pButtonPresenter->InitTextObject();
472         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
473
474         return E_SUCCESS;
475 }
476
477 String
478 _Button::GetText(void) const
479 {
480         Variant text = GetProperty(L"text");
481
482         return text.ToString();
483 }
484
485 Variant
486 _Button::GetPropertyText(void) const
487 {
488         return Variant(__text);
489 }
490
491 result
492 _Button::SetColor(_ButtonStatus status, const Color& color)
493 {
494         result r = E_SUCCESS;
495
496         switch (status)
497         {
498         case _BUTTON_STATUS_NORMAL:
499                 r = SetProperty(L"normalColor", Variant(color));
500                 break;
501         case _BUTTON_STATUS_DISABLED:
502                 r = SetProperty(L"disabledColor", Variant(color));
503                 break;
504         case _BUTTON_STATUS_PRESSED:
505                 r = SetProperty(L"pressedColor", Variant(color));
506                 break;
507         case _BUTTON_STATUS_HIGHLIGHTED:
508                 r = SetProperty(L"highlightedColor", Variant(color));
509                 break;
510         default:
511                 r = SetProperty(L"selectedColor", Variant(color));
512         }
513
514         return r;
515 }
516
517 result
518 _Button::SetPropertyNormalColor(const Variant& color)
519 {
520         __color[_BUTTON_STATUS_NORMAL] = color.ToColor();
521
522         return E_SUCCESS;
523 }
524
525 result
526 _Button::SetPropertyDisabledColor(const Variant& color)
527 {
528         __color[_BUTTON_STATUS_DISABLED] = color.ToColor();
529
530         return E_SUCCESS;
531 }
532
533 result
534 _Button::SetPropertyPressedColor(const Variant& color)
535 {
536         __color[_BUTTON_STATUS_PRESSED] = color.ToColor();
537
538         return E_SUCCESS;
539 }
540
541 result
542 _Button::SetPropertyHighlightedColor(const Variant& color)
543 {
544         __color[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
545
546         return E_SUCCESS;
547 }
548
549 result
550 _Button::SetPropertySelectedColor(const Variant& color)
551 {
552         __color[_BUTTON_STATUS_SELECTED] = color.ToColor();
553
554         return E_SUCCESS;
555 }
556
557 Color
558 _Button::GetColor(_ButtonStatus status) const
559 {
560         Variant color;
561
562         switch (status)
563         {
564         case _BUTTON_STATUS_NORMAL:
565                  color = GetProperty(L"normalColor");
566                  break;
567         case _BUTTON_STATUS_DISABLED:
568                  color = GetProperty(L"disabledColor");
569                  break;
570         case _BUTTON_STATUS_PRESSED:
571                  color = GetProperty(L"pressedColor");
572                  break;
573         case _BUTTON_STATUS_HIGHLIGHTED:
574                  color = GetProperty(L"highlightedColor");
575                  break;
576         default:
577                  color = GetProperty(L"selectedColor");
578         }
579
580         return color.ToColor();
581 }
582
583 Variant
584 _Button::GetPropertyNormalColor(void) const
585 {
586         return Variant(__color[_BUTTON_STATUS_NORMAL]);
587 }
588
589 Variant
590 _Button::GetPropertyDisabledColor(void) const
591 {
592         return Variant(__color[_BUTTON_STATUS_DISABLED]);
593 }
594
595 Variant
596 _Button::GetPropertyPressedColor(void) const
597 {
598         return Variant(__color[_BUTTON_STATUS_PRESSED]);
599 }
600
601 Variant
602 _Button::GetPropertyHighlightedColor(void) const
603 {
604         return Variant(__color[_BUTTON_STATUS_HIGHLIGHTED]);
605 }
606
607 Variant
608 _Button::GetPropertySelectedColor(void) const
609 {
610         return Variant(__color[_BUTTON_STATUS_SELECTED]);
611 }
612
613 result
614 _Button::AddActionEventListener(const _IActionEventListener& listener)
615 {
616         if (__pActionEvent == null)
617         {
618                 __pActionEvent = _ActionEvent::CreateInstanceN(*this);
619                 SysTryReturn(NID_UI_CTRL, __pActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
620         }
621
622         result r = __pActionEvent->AddListener(listener);
623         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
624
625         return E_SUCCESS;
626 }
627
628 result
629 _Button::RemoveActionEventListener(const _IActionEventListener& listener)
630 {
631         result r = E_OBJ_NOT_FOUND;
632
633         if (__pActionEvent)
634         {
635                 r = __pActionEvent->RemoveListener(listener);
636         }
637
638         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
639
640         return E_SUCCESS;
641 }
642
643 result
644 _Button::SetActionId(int actionId)
645 {
646         return SetProperty(L"actionId", Variant(actionId));
647 }
648
649 result
650 _Button::SetPropertyActionId(const Variant& actionId)
651 {
652         __actionId = actionId.ToInt();
653
654         return E_SUCCESS;
655 }
656
657 int
658 _Button::GetActionId(void) const
659 {
660         Variant actionId = GetProperty(L"actionId");
661
662         return actionId.ToInt();
663 }
664
665 Variant
666 _Button::GetPropertyActionId(void) const
667 {
668         return Variant(__actionId);
669 }
670
671 result
672 _Button::SetTextHorizontalAlignment(HorizontalAlignment alignment)
673 {
674         __horizontalAlignment = alignment;
675
676         return E_SUCCESS;
677 }
678
679 HorizontalAlignment
680 _Button::GetTextHorizontalAlignment(void) const
681 {
682         return __horizontalAlignment;
683 }
684
685 result
686 _Button::SetTextVerticalAlignment(VerticalAlignment alignment)
687 {
688         __verticalAlignment = alignment;
689
690         return E_SUCCESS;
691 }
692
693 VerticalAlignment
694 _Button::GetTextVerticalAlignment(void) const
695 {
696         return __verticalAlignment;
697 }
698
699 result
700 _Button::SetTextColor(_ButtonStatus status, const Color& color)
701 {
702         result r = E_SUCCESS;
703
704         switch (status)
705         {
706         case _BUTTON_STATUS_NORMAL:
707                 r = SetProperty(L"normalTextColor", Variant(color));
708                 break;
709         case _BUTTON_STATUS_DISABLED:
710                 r = SetProperty(L"disabledTextColor", Variant(color));
711                 break;
712         case _BUTTON_STATUS_PRESSED:
713                 r = SetProperty(L"pressedTextColor", Variant(color));
714                 break;
715         case _BUTTON_STATUS_HIGHLIGHTED:
716                 r = SetProperty(L"highlightedTextColor", Variant(color));
717                 break;
718         default:
719                 r = SetProperty(L"selectedTextColor", Variant(color));
720         }
721
722         return r;
723 }
724
725 result
726 _Button::SetPropertyNormalTextColor(const Variant& color)
727 {
728         __textColor[_BUTTON_STATUS_NORMAL] = color.ToColor();
729
730         return E_SUCCESS;
731 }
732
733 result
734 _Button::SetPropertyDisabledTextColor(const Variant& color)
735 {
736         __textColor[_BUTTON_STATUS_DISABLED] = color.ToColor();
737
738         return E_SUCCESS;
739 }
740
741 result
742 _Button::SetPropertyPressedTextColor(const Variant& color)
743 {
744         __textColor[_BUTTON_STATUS_PRESSED] = color.ToColor();
745
746         return E_SUCCESS;
747 }
748
749 result
750 _Button::SetPropertyHighlightedTextColor(const Variant& color)
751 {
752         __textColor[_BUTTON_STATUS_HIGHLIGHTED] = color.ToColor();
753
754         return E_SUCCESS;
755 }
756
757 result
758 _Button::SetPropertySelectedTextColor(const Variant& color)
759 {
760         __textColor[_BUTTON_STATUS_SELECTED] = color.ToColor();
761
762         return E_SUCCESS;
763 }
764
765 Color
766 _Button::GetTextColor(_ButtonStatus status) const
767 {
768         Variant color;
769
770         switch (status)
771         {
772         case _BUTTON_STATUS_NORMAL:
773                  color = GetProperty(L"normalTextColor");
774                  break;
775         case _BUTTON_STATUS_DISABLED:
776                  color = GetProperty(L"disabledTextColor");
777                  break;
778         case _BUTTON_STATUS_PRESSED:
779                  color = GetProperty(L"pressedTextColor");
780                  break;
781         case _BUTTON_STATUS_HIGHLIGHTED:
782                  color = GetProperty(L"highlightedTextColor");
783                  break;
784         default:
785                  color = GetProperty(L"selectedTextColor");
786         }
787
788         return color.ToColor();
789 }
790
791 Variant
792 _Button::GetPropertyNormalTextColor(void) const
793 {
794         return Variant(__textColor[_BUTTON_STATUS_NORMAL]);
795 }
796
797 Variant
798 _Button::GetPropertyDisabledTextColor(void) const
799 {
800         return Variant(__textColor[_BUTTON_STATUS_DISABLED]);
801 }
802
803 Variant
804 _Button::GetPropertyPressedTextColor(void) const
805 {
806         return Variant(__textColor[_BUTTON_STATUS_PRESSED]);
807 }
808
809 Variant
810 _Button::GetPropertyHighlightedTextColor(void) const
811 {
812         return Variant(__textColor[_BUTTON_STATUS_HIGHLIGHTED]);
813 }
814
815 Variant
816 _Button::GetPropertySelectedTextColor(void) const
817 {
818         return Variant(__textColor[_BUTTON_STATUS_SELECTED]);
819 }
820
821 result
822 _Button::SetBitmap(_ButtonStatus status, const Point& position, const Bitmap& bitmap)
823 {
824         FloatPoint floatPosition = _CoordinateSystemUtils::ConvertToFloat(position);
825
826         return SetBitmap(status, floatPosition, bitmap);
827 }
828
829 result
830 _Button::SetBitmap(_ButtonStatus status, const FloatPoint& position, const Bitmap& bitmap)
831 {
832         result r = E_SYSTEM;
833
834         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
835
836         if (pClonedBitmap)
837         {
838                 __bitmapPosition[status] = position;
839
840                 if (__pBitmap[status] != null)
841                 {
842                         delete __pBitmap[status];
843                 }
844
845                 __pBitmap[status] = pClonedBitmap;
846
847                 r = E_SUCCESS;
848         }
849
850         return r;
851 }
852
853 Bitmap*
854 _Button::GetBitmap(_ButtonStatus status) const
855 {
856         return __pBitmap[status];
857 }
858
859 Point
860 _Button::GetBitmapPosition(_ButtonStatus status) const
861 {
862         return _CoordinateSystemUtils::ConvertToInteger(GetBitmapPositionF(status));
863 }
864
865 FloatPoint
866 _Button::GetBitmapPositionF(_ButtonStatus status) const
867 {
868         return FloatPoint(__bitmapPosition[status].x + __leftTouchMargin, __bitmapPosition[status].y + __topTouchMargin);
869 }
870
871 result
872 _Button::SetEffectBitmap(_ButtonStatus status, const Point& position, const Bitmap& bitmap)
873 {
874         FloatPoint floatPosition = _CoordinateSystemUtils::ConvertToFloat(position);
875
876         return SetEffectBitmap(status, floatPosition, bitmap);
877 }
878
879 result
880 _Button::SetEffectBitmap(_ButtonStatus status, const FloatPoint& position, const Bitmap& bitmap)
881 {
882         result r = E_SYSTEM;
883
884         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
885
886         if (pClonedBitmap)
887         {
888                 __effectBitmapPosition[status] = position;
889
890                 if (__pEffectBitmap[status] != null)
891                 {
892                         delete __pEffectBitmap[status];
893                 }
894
895                 __pEffectBitmap[status] = pClonedBitmap;
896
897                 r = E_SUCCESS;
898         }
899
900         return r;
901 }
902
903 Bitmap*
904 _Button::GetEffectBitmap(_ButtonStatus status) const
905 {
906         return __pEffectBitmap[status];
907 }
908
909 Point
910 _Button::GetEffectBitmapPosition(_ButtonStatus status) const
911 {
912         return _CoordinateSystemUtils::ConvertToInteger(GetEffectBitmapPositionF(status));
913 }
914
915 FloatPoint
916 _Button::GetEffectBitmapPositionF(_ButtonStatus status) const
917 {
918         return FloatPoint(__effectBitmapPosition[status].x + __leftTouchMargin, __effectBitmapPosition[status].y + __topTouchMargin);
919 }
920
921 result
922 _Button::SetToolbarItemBackgroundBitmap(_ButtonStatus status, const Bitmap& bitmap)
923 {
924         result r = E_SYSTEM;
925
926         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
927
928         if (pClonedBitmap)
929         {
930                 if (__pToolbarItemBackgroundBitmap[status] != null)
931                 {
932                         delete __pToolbarItemBackgroundBitmap[status];
933                 }
934
935                 __pToolbarItemBackgroundBitmap[status] = pClonedBitmap;
936
937                 r = E_SUCCESS;
938         }
939
940         return r;
941 }
942
943 Bitmap*
944 _Button::GetToolbarItemBackgroundBitmap(_ButtonStatus status) const
945 {
946         return __pToolbarItemBackgroundBitmap[status];
947 }
948
949 result
950 _Button::SetUnderlineBitmap(const Bitmap& bitmap)
951 {
952         result r = E_SYSTEM;
953
954         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
955
956         if (pClonedBitmap)
957         {
958                 if (__pUnderlineBitmap != null)
959                 {
960                         delete __pUnderlineBitmap;
961                 }
962
963                 __pUnderlineBitmap = pClonedBitmap;
964
965                 r = E_SUCCESS;
966         }
967
968         return r;
969 }
970
971 result
972 _Button::ShowUnderlineBitmap(bool show)
973 {
974         return __pButtonPresenter->ShowUnderlineBitmap(show);
975 }
976
977 Bitmap*
978 _Button::GetUnderlineBitmap(void) const
979 {
980         return __pUnderlineBitmap;
981 }
982
983 result
984 _Button::SetTabTextDimLeftBitmap(const Bitmap& bitmap)
985 {
986         result r = E_SYSTEM;
987
988         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
989
990         if (pClonedBitmap)
991         {
992                 if (__pTabTextDimLeftBitmap != null)
993                 {
994                         delete __pTabTextDimLeftBitmap;
995                 }
996
997                 __pTabTextDimLeftBitmap = pClonedBitmap;
998
999                 r = E_SUCCESS;
1000         }
1001
1002         return r;
1003 }
1004
1005 Bitmap*
1006 _Button::GetTabTextDimLeftBitmap(void) const
1007 {
1008         return __pTabTextDimLeftBitmap;
1009 }
1010
1011 result
1012 _Button::SetTabTextDimRightBitmap(const Bitmap& bitmap)
1013 {
1014         result r = E_SYSTEM;
1015
1016         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
1017
1018         if (pClonedBitmap)
1019         {
1020                 if (__pTabTextDimRightBitmap != null)
1021                 {
1022                         delete __pTabTextDimRightBitmap;
1023                 }
1024
1025                 __pTabTextDimRightBitmap = pClonedBitmap;
1026
1027                 r = E_SUCCESS;
1028         }
1029
1030         return r;
1031 }
1032
1033 Bitmap*
1034 _Button::GetTabTextDimRightBitmap(void) const
1035 {
1036         return __pTabTextDimRightBitmap;
1037 }
1038
1039 result
1040 _Button::SetSubTitleEffectBitmap(const Bitmap& bitmap)
1041 {
1042         result r = E_SYSTEM;
1043
1044         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
1045
1046         if (pClonedBitmap)
1047         {
1048                 if (__pSubTitleEffectBitmap != null)
1049                 {
1050                         delete __pSubTitleEffectBitmap;
1051                 }
1052
1053                 __pSubTitleEffectBitmap = pClonedBitmap;
1054
1055                 r = E_SUCCESS;
1056         }
1057
1058         return r;
1059 }
1060
1061 Bitmap*
1062 _Button::GetSubTitleEffectBitmap(void) const
1063 {
1064         return __pSubTitleEffectBitmap;
1065 }
1066
1067 result
1068 _Button::SetBackgroundBitmap(_ButtonStatus status, const Bitmap& bitmap)
1069 {
1070         result r = E_SYSTEM;
1071
1072         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
1073
1074         if (pClonedBitmap)
1075         {
1076                 if (__pBackgroundBitmap[status] != null)
1077                 {
1078                         delete __pBackgroundBitmap[status];
1079                 }
1080
1081                 __pBackgroundBitmap[status] = pClonedBitmap;
1082                 __isUserBackgroundBitmap[status] = true;
1083
1084                 r = E_SUCCESS;
1085         }
1086
1087         return r;
1088 }
1089
1090 Bitmap*
1091 _Button::GetBackgroundBitmap(_ButtonStatus status) const
1092 {
1093         result r = E_SYSTEM;
1094
1095         _Button* pButton = const_cast<_Button*>(this);
1096
1097         if (!pButton->__pBackgroundBitmap[status])
1098         {
1099                 switch(status)
1100                 {
1101                 case _BUTTON_STATUS_NORMAL:
1102                         r = GET_BITMAP_CONFIG_N(BUTTON::BG_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundBitmap[_BUTTON_STATUS_NORMAL]);
1103                         break;
1104                 case _BUTTON_STATUS_DISABLED:
1105                         r = GET_BITMAP_CONFIG_N(BUTTON::BG_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundBitmap[_BUTTON_STATUS_DISABLED]);
1106                         break;
1107                 case _BUTTON_STATUS_PRESSED:
1108                         r = GET_BITMAP_CONFIG_N(BUTTON::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundBitmap[_BUTTON_STATUS_PRESSED]);
1109                         break;
1110                 case _BUTTON_STATUS_HIGHLIGHTED:
1111                         r = GET_BITMAP_CONFIG_N(BUTTON::BG_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundBitmap[_BUTTON_STATUS_HIGHLIGHTED]);
1112                         break;
1113                 default:
1114                         r = GET_BITMAP_CONFIG_N(BUTTON::BG_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundBitmap[_BUTTON_STATUS_SELECTED]);
1115                         break;
1116                 }
1117                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1118         }
1119
1120         return pButton->__pBackgroundBitmap[status];
1121 }
1122
1123 result
1124 _Button::SetBackgroundEffectBitmap(_ButtonStatus status, const Bitmap& bitmap)
1125 {
1126         result r = E_SYSTEM;
1127
1128         Bitmap* pClonedBitmap = _BitmapImpl::CloneN(bitmap);
1129
1130         if (pClonedBitmap)
1131         {
1132                 if (__pBackgroundEffectBitmap[status] != null)
1133                 {
1134                         delete __pBackgroundEffectBitmap[status];
1135                 }
1136
1137                 __pBackgroundEffectBitmap[status] = pClonedBitmap;
1138                 __isUserBackgroundEffectBitmap[status] = true;
1139
1140                 r= E_SUCCESS;
1141         }
1142
1143         return r;
1144 }
1145
1146 Bitmap*
1147 _Button::GetBackgroundEffectBitmap(_ButtonStatus status) const
1148 {
1149         result r = E_SYSTEM;
1150         bool themeBackgroundBitmap = false;
1151
1152         _Button* pButton = const_cast<_Button*>(this);
1153
1154         if (!pButton->__pBackgroundEffectBitmap[status])
1155         {
1156                 switch(status)
1157                 {
1158                 case _BUTTON_STATUS_NORMAL:
1159                         themeBackgroundBitmap = IS_CUSTOM_BITMAP(BUTTON::BG_NORMAL);
1160                         if (!themeBackgroundBitmap)
1161                         {
1162                                 r = GET_BITMAP_CONFIG_N(BUTTON::BG_EFFECT_NORMAL, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundEffectBitmap[_BUTTON_STATUS_NORMAL]);
1163                         }
1164                         break;
1165                 case _BUTTON_STATUS_DISABLED:
1166                         themeBackgroundBitmap = IS_CUSTOM_BITMAP(BUTTON::BG_DISABLED);
1167                         if (!themeBackgroundBitmap)
1168                         {
1169                                 r = GET_BITMAP_CONFIG_N(BUTTON::BG_EFFECT_DISABLED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundEffectBitmap[_BUTTON_STATUS_DISABLED]);
1170                         }
1171                         break;
1172                 case _BUTTON_STATUS_PRESSED:
1173                         themeBackgroundBitmap = IS_CUSTOM_BITMAP(BUTTON::BG_PRESSED);
1174                         if (!themeBackgroundBitmap)
1175                         {
1176                                 r = GET_BITMAP_CONFIG_N(BUTTON::BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundEffectBitmap[_BUTTON_STATUS_PRESSED]);
1177                         }
1178                         break;
1179                 case _BUTTON_STATUS_HIGHLIGHTED:
1180                         themeBackgroundBitmap = IS_CUSTOM_BITMAP(BUTTON::BG_HIGHLIGHTED);
1181                         if (!themeBackgroundBitmap)
1182                         {
1183                                 r = GET_BITMAP_CONFIG_N(BUTTON::BG_EFFECT_HIGHLIGHTED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundEffectBitmap[_BUTTON_STATUS_HIGHLIGHTED]);
1184                         }
1185                         break;
1186                 default:
1187                         themeBackgroundBitmap = IS_CUSTOM_BITMAP(BUTTON::BG_PRESSED);
1188                         if (!themeBackgroundBitmap)
1189                         {
1190                                 r = GET_BITMAP_CONFIG_N(BUTTON::BG_EFFECT_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888, pButton->__pBackgroundEffectBitmap[_BUTTON_STATUS_SELECTED]);
1191                         }
1192                         break;
1193                 }
1194                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1195         }
1196
1197         return pButton->__pBackgroundEffectBitmap[status];
1198 }
1199
1200 result
1201 _Button::SetTextSize(int size, unsigned long fontStyle)
1202 {
1203         float floatSize = _CoordinateSystemUtils::ConvertToFloat(size);
1204
1205         __pButtonPresenter->SetTextSize(floatSize, fontStyle);
1206
1207         return SetProperty(L"textSize", Variant(floatSize));
1208 }
1209
1210 result
1211 _Button::SetTextSize(float size, unsigned long fontStyle)
1212 {
1213         __pButtonPresenter->SetTextSize(size, fontStyle);
1214
1215         return SetProperty(L"textSize", Variant(size));
1216 }
1217
1218 result
1219 _Button::SetPropertyTextSize(const Variant& textSize)
1220 {
1221         result r = E_SUCCESS;
1222
1223         if (textSize.ToFloat() > 0.0f)
1224         {
1225                 __textSize = textSize.ToFloat();
1226                 __multilineFontSize = textSize.ToFloat();
1227         }
1228         else
1229         {
1230                 r = E_INVALID_ARG;
1231                 SysLogException(NID_UI_CTRL, r, "[E_INVALID_ARG] Text size is no greater than 0.");
1232         }
1233
1234         return r;
1235 }
1236
1237 int
1238 _Button::GetTextSize(void) const
1239 {
1240         return _CoordinateSystemUtils::ConvertToInteger(GetTextSizeF());
1241 }
1242
1243 float
1244 _Button::GetTextSizeF(void) const
1245 {
1246         Variant size = GetProperty(L"textSize");
1247
1248         return size.ToFloat();
1249 }
1250
1251 Variant
1252 _Button::GetPropertyTextSize(void) const
1253 {
1254         return Variant(__textSize);
1255 }
1256
1257 result
1258 _Button::SetButtonStyle(_ButtonStyle buttonStyle)
1259 {
1260         __buttonStyle = buttonStyle;
1261
1262         return E_SUCCESS;
1263 }
1264
1265 _ButtonStyle
1266 _Button::GetButtonStyle(void) const
1267 {
1268         return __buttonStyle;
1269 }
1270
1271 result
1272 _Button::SetButtonStatus(_ButtonStatus buttonStatus, bool fire)
1273 {
1274         result r = E_SUCCESS;
1275
1276         __buttonStatus = buttonStatus;
1277
1278         if (_BUTTON_STATUS_DISABLED == __buttonStatus)
1279         {
1280                 SetEnableState(false);
1281         }
1282         else
1283         {
1284                 SetEnableState(true);
1285         }
1286
1287         if ((_BUTTON_STATUS_SELECTED == __buttonStatus || _BUTTON_STATUS_HIGHLIGHTED == __buttonStatus) && fire)
1288         {
1289                 r = FireActionEvent();
1290                 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1291         }
1292
1293         return r;
1294 }
1295
1296 _ButtonStatus
1297 _Button::GetButtonStatus(void) const
1298 {
1299         return __buttonStatus;
1300 }
1301
1302 result
1303 _Button::SetTextMaxLine(int textMaxLine)
1304 {
1305         __textMaxLine = textMaxLine;
1306
1307         return E_SUCCESS;
1308 }
1309
1310 int
1311 _Button::GetTextMaxLine(void) const
1312 {
1313         return __textMaxLine;
1314 }
1315
1316 result
1317 _Button::UnloadBackgroundBitmap(_ButtonStatus status)
1318 {
1319         if (__pBackgroundBitmap[status] != null)
1320         {
1321                 delete __pBackgroundBitmap[status];
1322                 __pBackgroundBitmap[status] = null;
1323         }
1324         return E_SUCCESS;
1325 }
1326
1327 result
1328 _Button::UnloadBackgroundEffectBitmap(_ButtonStatus status)
1329 {
1330         if (__pBackgroundEffectBitmap[status] != null)
1331         {
1332                 delete __pBackgroundEffectBitmap[status];
1333                 __pBackgroundEffectBitmap[status] = null;
1334         }
1335         return E_SUCCESS;
1336 }
1337
1338 bool
1339 _Button::IsUserBackgroundBitmap(_ButtonStatus status) const
1340 {
1341         return __isUserBackgroundBitmap[status];
1342 }
1343
1344 bool
1345 _Button::IsUserBackgroundEffectBitmap(_ButtonStatus status) const
1346 {
1347         return __isUserBackgroundEffectBitmap[status];
1348 }
1349
1350 bool
1351 _Button::IsTouchAreaChanged(bool currentButtonArea)
1352 {
1353         if (__previousTouchArea != currentButtonArea)
1354         {
1355                 __previousTouchArea = currentButtonArea;
1356
1357                 return true;
1358         }
1359         else
1360         {
1361                 return false;
1362         }
1363 }
1364
1365 result
1366 _Button::FireActionEvent(void)
1367 {
1368         result r = E_SUCCESS;
1369
1370         if (__pActionEvent)
1371         {
1372                 IEventArg* pEventArg = _ActionEvent::CreateActionEventArgN(__actionId);
1373                 SysTryReturn(NID_UI_CTRL, pEventArg, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1374
1375                 __pActionEvent->Fire(*pEventArg);
1376         }
1377
1378         return r;
1379 }
1380
1381 result
1382 _Button::SetUserDefinedTextArea(const Rectangle& bounds)
1383 {
1384         FloatRectangle floatBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
1385
1386         return SetUserDefinedTextArea(floatBounds);
1387 }
1388
1389 result
1390 _Button::SetUserDefinedTextArea(const FloatRectangle& bounds)
1391 {
1392         __userDefinedText = true;
1393
1394         __userDefinedTextArea = bounds;
1395
1396         return E_SUCCESS;
1397 }
1398
1399 Rectangle
1400 _Button::GetUserDefinedTextArea(void) const
1401 {
1402         return _CoordinateSystemUtils::ConvertToInteger(GetUserDefinedTextAreaF());
1403 }
1404
1405 FloatRectangle
1406 _Button::GetUserDefinedTextAreaF(void) const
1407 {
1408         return __userDefinedTextArea;
1409 }
1410
1411 bool
1412 _Button::UserDefinedText(void) const
1413 {
1414         return __userDefinedText;
1415 }
1416
1417 result
1418 _Button::SetTabTextSlide(bool tabTextSlide)
1419 {
1420         __tabTextSlide = tabTextSlide;
1421
1422         return E_SUCCESS;
1423 }
1424
1425 bool
1426 _Button::IsTabTextSlide(void) const
1427 {
1428         return __tabTextSlide;
1429 }
1430
1431 result
1432 _Button::SetMargin(int leftMargin, int topMargin, int rightMargin, int bottomMargin)
1433 {
1434         float floatLeftMargin = _CoordinateSystemUtils::ConvertToFloat(leftMargin);
1435         float floatTopMargin = _CoordinateSystemUtils::ConvertToFloat(topMargin);
1436         float floatRightMargin = _CoordinateSystemUtils::ConvertToFloat(rightMargin);
1437         float floatBottomMargin = _CoordinateSystemUtils::ConvertToFloat(bottomMargin);
1438
1439         return SetMargin(floatLeftMargin, floatTopMargin, floatRightMargin, floatBottomMargin);
1440 }
1441
1442 result
1443 _Button::SetMargin(float leftMargin, float topMargin, float rightMargin, float bottomMargin)
1444 {
1445         __leftMargin = leftMargin;
1446         __topMargin = topMargin;
1447         __rightMargin = rightMargin;
1448         __bottomMargin = bottomMargin;
1449
1450         return E_SUCCESS;
1451 }
1452
1453 int
1454 _Button::GetLeftMargin(void) const
1455 {
1456         return _CoordinateSystemUtils::ConvertToInteger(GetLeftMarginF());
1457 }
1458
1459 float
1460 _Button::GetLeftMarginF(void) const
1461 {
1462         return __leftMargin;
1463 }
1464
1465 int
1466 _Button::GetTopMargin(void) const
1467 {
1468         return _CoordinateSystemUtils::ConvertToInteger(GetTopMarginF());
1469 }
1470
1471 float
1472 _Button::GetTopMarginF(void) const
1473 {
1474         return __topMargin;
1475 }
1476 int
1477 _Button::GetRightMargin(void) const
1478 {
1479         return _CoordinateSystemUtils::ConvertToInteger(GetRightMarginF());
1480 }
1481
1482 float
1483 _Button::GetRightMarginF(void) const
1484 {
1485         return __rightMargin;
1486 }
1487
1488 int
1489 _Button::GetBottomMargin(void) const
1490 {
1491         return _CoordinateSystemUtils::ConvertToInteger(GetBottomMarginF());
1492 }
1493
1494 float
1495 _Button::GetBottomMarginF(void) const
1496 {
1497         return __bottomMargin;
1498 }
1499
1500 FloatDimension
1501 _Button::GetContentSizeF(bool horizontalMode, bool verticalMode) const
1502 {
1503         return GetContentSizeInternalF(horizontalMode, verticalMode);
1504 }
1505
1506 FloatDimension
1507 _Button::GetContentSizeInternalF(bool horizontalMode, bool verticalMode) const
1508 {
1509         for (int i = 0; i < NUMBER_OF_BUTTON_STATUS; i++)
1510         {
1511                 if (__text.IsEmpty() && __pBitmap[i] == null && __isUserBackgroundBitmap[i] == false)
1512                 {
1513                         return FloatDimension(GetBoundsF().width, GetBoundsF().height);
1514                 }
1515         }
1516
1517         FloatDimension textSize(0.0f, 0.0f);
1518         FloatDimension dimension(0.0f, 0.0f);
1519         FloatRectangle contentRect(0.0f, 0.0f, 0.0f, 0.0f);
1520
1521         TextObject* pTextObject = __pButtonPresenter->GetTextObject();
1522
1523         FloatRectangle previousRect = pTextObject->GetBoundsF();
1524
1525         dimension.width = GetBoundsF().width - __leftMargin * 2;
1526         dimension.height = GetBoundsF().height - __topMargin * 2;
1527
1528         _ControlOrientation orientation = GetOrientation();
1529         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1530         {
1531                 contentRect.width = _ControlManager::GetInstance()->GetScreenSizeF().width;
1532                 contentRect.height = _ControlManager::GetInstance()->GetScreenSizeF().height;
1533         }
1534         else
1535         {
1536                 contentRect.width = _ControlManager::GetInstance()->GetScreenSizeF().height;
1537                 contentRect.height = _ControlManager::GetInstance()->GetScreenSizeF().width;
1538         }
1539
1540         if (horizontalMode == true)
1541         {
1542                 FloatRectangle bounds(0.0f, 0.0f, contentRect.width - GetBoundsF().x - __leftMargin, dimension.height);
1543                 pTextObject->SetBounds(bounds);
1544                 pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
1545                 pTextObject->Compose();
1546
1547                 textSize = pTextObject->GetTextExtentF();
1548
1549                 dimension.width = (textSize.width < bounds.width) ? textSize.width : bounds.width;
1550         }
1551
1552         if (verticalMode == true)
1553         {
1554                 FloatRectangle bounds(0.0f, 0.0f, dimension.width, dimension.height);
1555                 pTextObject->SetBounds(bounds);
1556                 pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
1557                 pTextObject->Compose();
1558
1559                 textSize = pTextObject->GetTextExtentF();
1560
1561                 dimension.height = textSize.height;
1562         }
1563
1564         pTextObject->SetBounds(previousRect);
1565
1566         dimension.width += __leftMargin * 4 - __leftTouchMargin - __rightTouchMargin;
1567         dimension.height += __topMargin * 4 - __topTouchMargin - __bottomTouchMargin;
1568
1569         for (int i = 0; i < NUMBER_OF_BUTTON_STATUS; i++)
1570         {
1571                 if (__pBitmap[i] != null || __isUserBackgroundBitmap[i] == true)
1572                 {
1573                         dimension.width = GetBoundsF().width;
1574                         dimension.height = GetBoundsF().height;
1575                 }
1576         }
1577
1578         return dimension;
1579 }
1580
1581 int
1582 _Button::GetTextExtentSize(void) const
1583 {
1584         return _CoordinateSystemUtils::ConvertToInteger(GetTextExtentSizeF());
1585 }
1586
1587 float
1588 _Button::GetTextExtentSizeF(void) const
1589 {
1590         float textExtentSize = 0.0f;
1591
1592         TextObject* pTextObject = __pButtonPresenter->GetTextObject();
1593         Font* pFont = __pButtonPresenter->GetFont();
1594
1595         TextObjectActionType previousActionType = pTextObject->GetAction();
1596         TextObjectWrapType previousWrapType = pTextObject->GetWrap();
1597         FloatRectangle previousRect = pTextObject->GetBoundsF();
1598
1599         pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_NONE);
1600         pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD);
1601         pTextObject->SetFont(pFont, 0, pTextObject->GetTextLength());
1602         pTextObject->Compose();
1603
1604         textExtentSize = pTextObject->GetTextExtentF(0, pTextObject->GetTextLength()).width;
1605
1606         pTextObject->SetBounds(previousRect);
1607         pTextObject->SetAction(previousActionType);
1608         pTextObject->SetWrap(previousWrapType);
1609         pTextObject->Compose();
1610
1611         return textExtentSize;
1612 }
1613
1614 result
1615 _Button::SetTouchMargin(int leftTouchMargin, int topTouchMargin, int rightTouchMargin, int bottomTouchMargin)
1616 {
1617         float floatLeftTouchMargin = _CoordinateSystemUtils::ConvertToFloat(leftTouchMargin);
1618         float floatTopTouchMargin = _CoordinateSystemUtils::ConvertToFloat(topTouchMargin);
1619         float floatRightTouchMargin = _CoordinateSystemUtils::ConvertToFloat(rightTouchMargin);
1620         float floatBottomTouchMargin = _CoordinateSystemUtils::ConvertToFloat(bottomTouchMargin);
1621
1622         return SetTouchMargin(floatLeftTouchMargin, floatTopTouchMargin, floatRightTouchMargin, floatBottomTouchMargin);
1623 }
1624
1625 result
1626 _Button::SetTouchMargin(float leftTouchMargin, float topTouchMargin, float rightTouchMargin, float bottomTouchMargin)
1627 {
1628         __leftTouchMargin = leftTouchMargin;
1629         __topTouchMargin = topTouchMargin;
1630         __rightTouchMargin = rightTouchMargin;
1631         __bottomTouchMargin = bottomTouchMargin;
1632
1633         return E_SUCCESS;
1634 }
1635
1636 int
1637 _Button::GetLeftTouchMargin(void) const
1638 {
1639         return _CoordinateSystemUtils::ConvertToInteger(GetLeftTouchMarginF());
1640 }
1641
1642 float
1643 _Button::GetLeftTouchMarginF(void) const
1644 {
1645         return __leftTouchMargin;
1646 }
1647
1648 int
1649 _Button::GetTopTouchMargin(void) const
1650 {
1651         return _CoordinateSystemUtils::ConvertToInteger(GetTopTouchMarginF());
1652 }
1653
1654 float
1655 _Button::GetTopTouchMarginF(void) const
1656 {
1657         return __topTouchMargin;
1658 }
1659
1660 int
1661 _Button::GetRightTouchMargin(void) const
1662 {
1663         return _CoordinateSystemUtils::ConvertToInteger(GetRightTouchMarginF());
1664 }
1665
1666 float
1667 _Button::GetRightTouchMarginF(void) const
1668 {
1669         return __rightTouchMargin;
1670 }
1671
1672 int
1673 _Button::GetBottomTouchMargin(void) const
1674 {
1675         return _CoordinateSystemUtils::ConvertToInteger(GetBottomTouchMarginF());
1676 }
1677
1678 float
1679 _Button::GetBottomTouchMarginF(void) const
1680 {
1681         return __bottomTouchMargin;
1682 }
1683
1684 result
1685 _Button::SetMultilineTextSize(const Variant& textSize)
1686 {
1687         result r = E_SUCCESS;
1688
1689         if (textSize.ToFloat() > 0.0f)
1690         {
1691                 __multilineFontSize = textSize.ToFloat();
1692                 __isSettingMultilineFontSize = true;
1693         }
1694         else
1695         {
1696                 r = E_INVALID_ARG;
1697                 SysLogException(NID_UI_CTRL, r, "[E_INVALID_ARG] Text size is no greater than 0.");
1698         }
1699
1700         return r;
1701 }
1702
1703 float
1704 _Button::GetMultilineTextSizeF(void) const
1705 {
1706         return __multilineFontSize;
1707 }
1708
1709 bool
1710 _Button::IsMultilineFontSizeSet(void) const
1711 {
1712         return __isSettingMultilineFontSize;
1713 }
1714 }}} // Tizen::Ui::Controls