Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / controls / FUiCtrl_ButtonImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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_ButtonImpl.cpp
19  * @brief               This is the implementation file for the _ButtonImpl class.
20  */
21
22 #include <FAppApplication.h>
23 #include <FBaseInternalTypes.h>
24 #include <FBaseSysLog.h>
25 #include <FApp_AppInfo.h>
26 #include "FUi_ResourceSizeInfo.h"
27 #include "FUi_ResourceManager.h"
28 #include "FUi_UiBuilder.h"
29 #include "FUiCtrl_ButtonImpl.h"
30 #include "FUiCtrl_Button.h"
31
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Graphics;
35
36 namespace Tizen { namespace Ui { namespace Controls
37 {
38
39 Dimension
40 _ButtonImpl::ButtonSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const
41 {
42         result r = E_SUCCESS;
43         Dimension dimension(0, 0);
44
45         r = GET_DIMENSION_CONFIG(BUTTON::MIN_SIZE, orientation, dimension);
46         SysTryReturn(NID_UI, r == E_SUCCESS, dimension, r, "[%s] A system error occurred.", GetErrorMessage(r));
47
48         SetLastResult(r);
49
50         return dimension;
51 }
52
53 _ButtonImpl*
54 _ButtonImpl::GetInstance(Button& button)
55 {
56         return static_cast<_ButtonImpl*> (button._pControlImpl);
57 }
58
59 const _ButtonImpl*
60 _ButtonImpl::GetInstance(const Button& button)
61 {
62         return static_cast<const _ButtonImpl*> (button._pControlImpl);
63 }
64
65 _ButtonImpl::_ButtonImpl(Button* pPublic, _Button* pCore)
66         : _ControlImpl(pPublic, pCore)
67         , __pPublicActionEvent(null)
68 {
69         ClearLastResult();
70 }
71
72 _ButtonImpl::~_ButtonImpl(void)
73 {
74         _ButtonImpl::GetCore().RemoveActionEventListener(*this);
75
76         if (__pPublicActionEvent)
77         {
78                 delete __pPublicActionEvent;
79                 __pPublicActionEvent = null;
80         }
81
82         ClearLastResult();
83 }
84
85 _ButtonImpl*
86 _ButtonImpl::CreateButtonImplN(Button* pControl, const Rectangle& bounds)
87 {
88         result r = E_SUCCESS;
89         r = GET_SIZE_INFO(Button).CheckInitialSizeValid(Dimension(bounds.width, bounds.height), _CONTROL_ORIENTATION_PORTRAIT);
90         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_INVALID_ARG, "[E_INVALID_ARG] The given size is not valid.");
91
92         _Button* pCore = _Button::CreateButtonN();
93         SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
94
95         _ButtonImpl* pImpl = new (std::nothrow) _ButtonImpl(pControl, pCore);
96         r = _ControlImpl::CheckConstruction(pCore, pImpl);
97         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
98
99         r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Button), bounds, pCore->GetOrientation());
100         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
101
102         r = pCore->AddActionEventListener(*pImpl);
103         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
104
105         ClearLastResult();
106
107         return pImpl;
108
109 CATCH:
110         delete pImpl;
111         return null;
112 }
113
114 const Color
115 _ButtonImpl::GetColorOnError(void)
116 {
117         return Color(0xFFFFFFFF);
118 }
119
120 const char*
121 _ButtonImpl::GetPublicClassName(void) const
122 {
123         return "Tizen::Ui::Controls::Button";
124 }
125
126 const Button&
127 _ButtonImpl::GetPublic(void) const
128 {
129         return static_cast <const Button&>(_ControlImpl::GetPublic());
130 }
131
132 Button&
133 _ButtonImpl::GetPublic(void)
134 {
135         return static_cast <Button&>(_ControlImpl::GetPublic());
136 }
137
138 const _Button&
139 _ButtonImpl::GetCore(void) const
140 {
141         return static_cast <const _Button&>(_ControlImpl::GetCore());
142 }
143
144 _Button&
145 _ButtonImpl::GetCore(void)
146 {
147         return static_cast <_Button&>(_ControlImpl::GetCore());
148 }
149
150 result
151 _ButtonImpl::SetText(const String& text)
152 {
153         int textLength = text.GetLength();
154         int buttonTextMaxLength = 0;
155         GET_FIXED_VALUE_CONFIG(BUTTON::TEXT_MAX_LENGTH, _CONTROL_ORIENTATION_PORTRAIT, buttonTextMaxLength);
156         String tempText = String(text);
157
158         if (textLength >= buttonTextMaxLength)
159         {
160                 tempText.Remove(buttonTextMaxLength - 1, textLength - buttonTextMaxLength + 1);
161         }
162
163         Variant var(tempText);
164         result r = GetCore().SetPropertyText(var);
165         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
166
167         return r;
168 }
169
170 String
171 _ButtonImpl::GetText(void) const
172 {
173         ClearLastResult();
174
175         return GetCore().GetPropertyText().ToString();
176 }
177
178 result
179 _ButtonImpl::SetColor(ButtonStatus status, const Color& color)
180 {
181         _ButtonStatus coreStatus = ConvertStatus(status);
182         result r = GetCore().SetColor(coreStatus, color);
183         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
184
185         return r;
186 }
187
188 Color
189 _ButtonImpl::GetColor(ButtonStatus status) const
190 {
191         ClearLastResult();
192         _ButtonStatus coreStatus = ConvertStatus(status);
193
194         return GetCore().GetColor(coreStatus);
195 }
196
197 result
198 _ButtonImpl::AddActionEventListener(IActionEventListener& listener)
199 {
200         if (__pPublicActionEvent == null)
201         {
202                 __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
203                 SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
204         }
205
206         result r = __pPublicActionEvent->AddListener(listener);
207         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
208
209         return E_SUCCESS;
210 }
211
212 result
213 _ButtonImpl::RemoveActionEventListener(IActionEventListener& listener)
214 {
215         result r = E_OBJ_NOT_FOUND;
216
217         if (__pPublicActionEvent)
218         {
219                 r = __pPublicActionEvent->RemoveListener(listener);
220         }
221
222         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
223
224         return E_SUCCESS;
225 }
226
227 result
228 _ButtonImpl::SetActionId(int actionId)
229 {
230         result r = GetCore().SetActionId(actionId);
231
232         SetLastResultReturn(r);
233 }
234
235 int
236 _ButtonImpl::GetActionId(void) const
237 {
238         ClearLastResult();
239
240         return GetCore().GetActionId();
241 }
242
243 result
244 _ButtonImpl::SetTextHorizontalAlignment(HorizontalAlignment alignment)
245 {
246         result r = GetCore().SetTextHorizontalAlignment(alignment);
247         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
248
249         return r;
250 }
251
252 HorizontalAlignment
253 _ButtonImpl::GetTextHorizontalAlignment(void) const
254 {
255         ClearLastResult();
256
257         return GetCore().GetTextHorizontalAlignment();
258 }
259
260 result
261 _ButtonImpl::SetTextVerticalAlignment(VerticalAlignment alignment)
262 {
263         result r = GetCore().SetTextVerticalAlignment(alignment);
264         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
265
266         return r;
267 }
268
269 VerticalAlignment
270 _ButtonImpl::GetTextVerticalAlignment(void) const
271 {
272         ClearLastResult();
273
274         return GetCore().GetTextVerticalAlignment();
275 }
276
277 result
278 _ButtonImpl::SetTextColor(const Color& color)
279 {
280         result r = GetCore().SetTextColor(_BUTTON_STATUS_NORMAL, color);
281         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
282
283         return r;
284 }
285
286 Color
287 _ButtonImpl::GetTextColor(void) const
288 {
289         ClearLastResult();
290
291         return GetCore().GetTextColor(_BUTTON_STATUS_NORMAL);
292 }
293
294 result
295 _ButtonImpl::SetDisabledTextColor(const Color& color)
296 {
297         result r = GetCore().SetTextColor(_BUTTON_STATUS_DISABLED, color);
298         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
299
300         return r;
301 }
302
303 Color
304 _ButtonImpl::GetDisabledTextColor(void) const
305 {
306         ClearLastResult();
307
308         return GetCore().GetTextColor(_BUTTON_STATUS_DISABLED);
309 }
310
311 result
312 _ButtonImpl::SetPressedTextColor(const Color& color)
313 {
314         result r = GetCore().SetTextColor(_BUTTON_STATUS_PRESSED, color);
315         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
316
317         return r;
318 }
319
320 Color
321 _ButtonImpl::GetPressedTextColor(void) const
322 {
323         ClearLastResult();
324
325         return GetCore().GetTextColor(_BUTTON_STATUS_PRESSED);
326 }
327
328 result
329 _ButtonImpl::SetHighlightedTextColor(const Color& color)
330 {
331         result r = GetCore().SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, color);
332         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
333
334         return r;
335 }
336
337 Color
338 _ButtonImpl::GetHighlightedTextColor(void) const
339 {
340         ClearLastResult();
341
342         return GetCore().GetTextColor(_BUTTON_STATUS_HIGHLIGHTED);
343 }
344
345 result
346 _ButtonImpl::SetNormalBitmap(const Point& position, const Bitmap& bitmap)
347 {
348         result r = GetCore().SetBitmap(_BUTTON_STATUS_NORMAL, position, bitmap);
349         SetLastResultReturn(r);
350 }
351
352 result
353 _ButtonImpl::SetDisabledBitmap(const Point& position, const Bitmap& bitmap)
354 {
355         result r = GetCore().SetBitmap(_BUTTON_STATUS_DISABLED, position, bitmap);
356         SetLastResultReturn(r);
357 }
358
359 result
360 _ButtonImpl::SetPressedBitmap(const Point& position, const Bitmap& bitmap)
361 {
362         result r = GetCore().SetBitmap(_BUTTON_STATUS_PRESSED, position, bitmap);
363         SetLastResultReturn(r);
364 }
365
366 result
367 _ButtonImpl::SetNormalBackgroundBitmap(const Bitmap& bitmap)
368 {
369         result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, bitmap);
370         SetLastResultReturn(r);
371 }
372
373 result
374 _ButtonImpl::SetPressedBackgroundBitmap(const Bitmap& bitmap)
375 {
376         result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, bitmap);
377         SetLastResultReturn(r);
378 }
379
380 result
381 _ButtonImpl::SetHighlightedBackgroundBitmap(const Bitmap& bitmap)
382 {
383         result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, bitmap);
384         SetLastResultReturn(r);
385 }
386
387 result
388 _ButtonImpl::SetTextSize(int size)
389 {
390         result r = GetCore().SetTextSize(size);
391         SetLastResultReturn(r);
392 }
393
394 int
395 _ButtonImpl::GetTextSize(void) const
396 {
397         ClearLastResult();
398
399         return GetCore().GetTextSize();
400 }
401
402 void
403 _ButtonImpl::OnActionPerformed(const _Control& source, int actionId)
404 {
405         if (__pPublicActionEvent != null)
406         {
407                 __pPublicActionEvent->Fire(*_PublicActionEvent::CreateActionEventArgN(actionId));
408         }
409
410         return;
411 }
412
413 result
414 _ButtonImpl::OnAttachedToMainTree(void)
415 {
416         SetFocusable(true);
417
418         _ControlImpl::OnAttachedToMainTree();
419
420         return E_SUCCESS;
421 }
422
423 bool
424 _ButtonImpl::OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo)
425 {
426         if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())  && (!source.IsEnabled() || !source.GetEnableState()))
427         {
428                 return true;
429         }
430
431         return false;
432 }
433
434 bool
435 _ButtonImpl::OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo)
436 {
437         if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())  && (!source.IsEnabled() || !source.GetEnableState()))
438         {
439                 return true;
440         }
441
442         return false;
443 }
444
445 bool
446 _ButtonImpl::OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo)
447 {
448         if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())  && (!source.IsEnabled() || !source.GetEnableState()))
449         {
450                 return true;
451         }
452
453         return false;
454 }
455
456 bool
457 _ButtonImpl::OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo)
458 {
459         if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())  && (!source.IsEnabled() || !source.GetEnableState()))
460         {
461                 return true;
462         }
463
464         return false;
465 }
466
467 Tizen::Graphics::Dimension
468 _ButtonImpl::GetContentSize(void) const
469 {
470         return GetCore().GetContentSizeInternal();
471 }
472
473 _ButtonStatus
474 _ButtonImpl::ConvertStatus(ButtonStatus status) const
475 {
476         _ButtonStatus coreStatus = _BUTTON_STATUS_HIGHLIGHTED;
477         switch (status)
478         {
479         case BUTTON_STATUS_NORMAL:
480                 coreStatus = _BUTTON_STATUS_NORMAL;
481                 break;
482         case BUTTON_STATUS_DISABLED:
483                 coreStatus = _BUTTON_STATUS_DISABLED;
484                 break;
485         case BUTTON_STATUS_PRESSED:
486                 coreStatus = _BUTTON_STATUS_PRESSED;
487                 break;
488         default:
489                 coreStatus = _BUTTON_STATUS_HIGHLIGHTED;
490         }
491
492         return coreStatus;
493 }
494
495 class _ButtonMaker
496         : public _UiBuilderControlMaker
497 {
498 public:
499         _ButtonMaker(_UiBuilder* uibuilder)
500                 : _UiBuilderControlMaker(uibuilder){};
501         _ButtonMaker(){};
502         virtual ~_ButtonMaker(){};
503         static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
504         {
505                 _ButtonMaker* pButtonMaker = new (std::nothrow) _ButtonMaker(uibuilder);
506                 return static_cast<_UiBuilderControlMaker*>(pButtonMaker);
507         };
508 protected:
509         virtual Control* Make(_UiBuilderControl* pControl)
510         {
511                 result r = E_SYSTEM;
512
513                 AppResource* pAppResource = null;
514                 UiApp* pUiApp = UiApp::GetInstance();
515                 if (pUiApp)
516                 {
517                         pAppResource = UiApp::GetInstance()->GetAppResource();
518                 }
519
520                 _UiBuilderControlLayout* pControlProperty = null;
521                 Button* pButton = null;
522                 HorizontalAlignment horizontalAlignment;
523                 VerticalAlignment verticalAlignment;
524                 Color color;
525                 int size = 0;
526                 int opacity = 0;
527                 Rectangle rect;
528                 Rectangle buttonRect(0, 0, 0, 0);
529                 Tizen::Base::String elementString;
530
531                 GetProperty(pControl, &pControlProperty);
532
533                 if (pControlProperty == null)
534                 {
535                         return null;
536                 }
537
538                 pButton = new (std::nothrow) Button();
539                 if (pButton == null)
540                 {
541                         return null;
542                 }
543
544                 buttonRect = pControlProperty->GetRect();
545
546                 if (pControl->GetElement(L"text", elementString))
547                 {
548                         r = pButton->Construct(buttonRect, elementString);
549                 }
550                 else
551                 {
552                         r = pButton->Construct(buttonRect);
553                 }
554
555                 if (r != E_SUCCESS)
556                 {
557                         delete pButton;
558                         return null;
559                 }
560
561                 if (pControl->GetElement(L"horizontalAlign", elementString) || pControl->GetElement(L"hAlign", elementString))
562                 {
563                         if (ConvertHAlignToHorizontalAlignment(elementString, horizontalAlignment))
564                         {
565                                 pButton->SetTextHorizontalAlignment(horizontalAlignment);
566                         }
567                 }
568
569                 if (pControl->GetElement(L"verticalAlign", elementString) || pControl->GetElement(L"vAlign", elementString))
570                 {
571                         if (ConvertVAlignToVerticalAlignment(elementString, verticalAlignment))
572                         {
573                                 pButton->SetTextVerticalAlignment(verticalAlignment);
574                         }
575                 }
576
577                 if (pControl->GetElement(L"normalTextColor", elementString))
578                 {
579                         ConvertStringToColor(elementString, color);
580                         pButton->SetTextColor(color);
581                 }
582
583                 if (pControl->GetElement(L"pressedTextColor", elementString))
584                 {
585                         ConvertStringToColor(elementString, color);
586                         pButton->SetPressedTextColor(color);
587                 }
588
589                 if (pControl->GetElement(L"disableTextColor", elementString))
590                 {
591                         ConvertStringToColor(elementString, color);
592                         pButton->SetDisabledTextColor(color);
593                 }
594
595                 if (pControl->GetElement(L"normalBitmapPath", elementString) || pControl->GetElement(L"NormalBitmapPath", elementString))
596                 {
597                         Bitmap* pNormalBitmap = null;
598                         Point position;
599
600                         pNormalBitmap = pAppResource->GetBitmapN(elementString);
601                         if (pControl->GetElement(L"NormalBitmapX", elementString))
602                         {
603                                 Base::Integer::Parse(elementString, position.x);
604                                 if ((position.x < 0) || (position.x > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x))
605                                 {
606                                         position.x = 0;
607                                 }
608                         }
609
610                         if (pControl->GetElement(L"NormalBitmapY", elementString))
611                         {
612                                 Base::Integer::Parse(elementString, position.y);
613                                 if (position.y < 0 || (position.y > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x))
614                                 {
615                                         position.y = 0;
616                                 }
617                         }
618
619                         if (pNormalBitmap != null)
620                         {
621                                 pButton->SetNormalBitmap(position, *pNormalBitmap);
622                                 delete pNormalBitmap;
623                         }
624                 }
625
626                 if (pControl->GetElement(L"PressedBitmapPath", elementString))
627                 {
628                         Bitmap* pPressedBitmap = null;
629                         Point position;
630
631                         pPressedBitmap = pAppResource->GetBitmapN(elementString);
632                         if (pControl->GetElement(L"PressedBitmapX", elementString))
633                         {
634                                 Base::Integer::Parse(elementString, position.x);
635                                 if ((position.x < 0) || (position.x > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x))
636                                 {
637                                         position.x = 0;
638                                 }
639                         }
640
641                         if (pControl->GetElement(L"PressedBitmapY", elementString))
642                         {
643                                 Base::Integer::Parse(elementString, position.y);
644                                 if (position.y < 0 || (position.y > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x))
645                                 {
646                                         position.y = 0;
647                                 }
648                         }
649
650                         if (pPressedBitmap != null)
651                         {
652                                 pButton->SetPressedBitmap(position, *pPressedBitmap);
653                                 delete pPressedBitmap;
654                         }
655                 }
656
657                 if (pControl->GetElement(L"DisabledBitmapPath", elementString))
658                 {
659                         Bitmap* pDisabledBitmap = null;
660                         Point position;
661                         pDisabledBitmap = pAppResource->GetBitmapN(elementString);
662                         if (pControl->GetElement(L"DisabledBitmapX", elementString))
663                         {
664                                 Base::Integer::Parse(elementString, position.x);
665                                 if ((position.x < 0) || (position.x > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x))
666                                 {
667                                         position.x = 0;
668                                 }
669                         }
670
671                         if (pControl->GetElement(L"DisabledBitmapY", elementString))
672                         {
673                                 Base::Integer::Parse(elementString, position.y);
674                                 if (position.y < 0 || (position.y > ((Control*) (GetContainer()))->GetBounds().width - ((Control*) (GetContainer()))->GetBounds().x))
675                                 {
676                                         position.y = 0;
677                                 }
678                         }
679
680                         if (pDisabledBitmap != null)
681                         {
682                                 pButton->SetDisabledBitmap(position, *pDisabledBitmap);
683                                 delete pDisabledBitmap;
684                         }
685                 }
686
687                 if (pControl->GetElement(L"NormalBGBitmapPath", elementString))
688                 {
689                         Bitmap* pNormalBGBitmap = null;
690                         pNormalBGBitmap = pAppResource->GetBitmapN(elementString);
691                         if (pNormalBGBitmap != null)
692                         {
693                                 pButton->SetNormalBackgroundBitmap(*pNormalBGBitmap);
694                                 delete pNormalBGBitmap;
695                         }
696                 }
697
698                 if (pControl->GetElement(L"PressedBGBitmapPath", elementString))
699                 {
700                         Bitmap* pPressedBGBitmap = null;
701                         pPressedBGBitmap = pAppResource->GetBitmapN(elementString);
702                         if (pPressedBGBitmap != null)
703                         {
704                                 pButton->SetPressedBackgroundBitmap(*pPressedBGBitmap);
705                                 delete pPressedBGBitmap;
706                         }
707                 }
708
709                 if (pControl->GetElement(L"HighlightedBGBitmapPath", elementString))
710                 {
711                         Bitmap* pHighlightedBGBitmap = null;
712                         pHighlightedBGBitmap = pAppResource->GetBitmapN(elementString);
713                         if (pHighlightedBGBitmap != null)
714                         {
715                                 pButton->SetHighlightedBackgroundBitmap(*pHighlightedBGBitmap);
716                                 delete pHighlightedBGBitmap;
717                         }
718                 }
719
720                 if (pControl->GetElement(L"highlightedTextColor", elementString))
721                 {
722                         ConvertStringToColor(elementString, color);
723                         pButton->SetHighlightedTextColor(color);
724                 }
725
726                 if (pControl->GetElement(L"normalColorOpacity", elementString))
727                 {
728                         Base::Integer::Parse(elementString, opacity);
729                 }
730
731                 if (pControl->GetElement(L"normalColor", elementString))
732                 {
733                         ConvertStringToColor32(elementString, opacity, color);
734                         pButton->SetColor(BUTTON_STATUS_NORMAL, color);
735                 }
736
737                 if (pControl->GetElement(L"pressedColorOpacity", elementString))
738                 {
739                         Base::Integer::Parse(elementString, opacity);
740                 }
741
742                 if (pControl->GetElement(L"pressedColor", elementString))
743                 {
744                         ConvertStringToColor32(elementString, opacity, color);
745                         pButton->SetColor(BUTTON_STATUS_PRESSED, color);
746                 }
747
748                 if (pControl->GetElement(L"disabledColorOpacity", elementString))
749                 {
750                         Base::Integer::Parse(elementString, opacity);
751                 }
752
753                 if (pControl->GetElement(L"disabledColor", elementString))
754                 {
755                         ConvertStringToColor32(elementString, opacity, color);
756                         pButton->SetColor(BUTTON_STATUS_DISABLED, color);
757                 }
758
759                 if (pControl->GetElement(L"highlightedColorOpacity", elementString))
760                 {
761                         Base::Integer::Parse(elementString, opacity);
762                 }
763
764                 if (pControl->GetElement(L"highlightedColor", elementString))
765                 {
766                         ConvertStringToColor32(elementString, opacity, color);
767                         pButton->SetColor(BUTTON_STATUS_HIGHLIGHTED, color);
768                 }
769
770                 if (pControl->GetElement(L"textSize", elementString))
771                 {
772                         _ICoordinateSystemTransformer* pTransform = GetTransformer();
773                         Base::Integer::Parse(elementString, size);
774                         if (pTransform)
775                         {
776                                 size = pTransform->Transform(size);
777                         }
778
779                         pButton->SetTextSize(size);
780                 }
781
782                 return pButton;
783         }
784 private:
785 }; // _ButtonMaker
786
787 _ButtonRegister::_ButtonRegister()
788 {
789           _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
790           pUiBuilderControlTableManager->RegisterControl(L"Button", _ButtonMaker::GetInstance);
791 }
792 _ButtonRegister::~_ButtonRegister()
793 {
794           _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
795           pUiBuilderControlTableManager->UnregisterControl(L"Button");
796 }
797 static _ButtonRegister ButtonRegisterToUiBuilder;
798 }}} // Tizen::Ui::Controls