add patch
[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 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_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 <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"
35
36 using namespace Tizen::App;
37 using namespace Tizen::Base;
38 using namespace Tizen::Graphics;
39
40 namespace Tizen { namespace Ui { namespace Controls
41 {
42
43 Dimension
44 _ButtonImpl::ButtonSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const
45 {
46         result r = E_SUCCESS;
47         Dimension dimension(0, 0);
48
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));
51
52         SetLastResult(r);
53
54         return dimension;
55 }
56
57 FloatDimension
58 _ButtonImpl::ButtonSizeInfo::GetDefaultMinimumSizeF(_ControlOrientation orientation) const
59 {
60         result r = E_SUCCESS;
61         FloatDimension dimension(0.0f, 0.0f);
62
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));
65
66         SetLastResult(r);
67
68         return dimension;
69 }
70
71 _ButtonImpl*
72 _ButtonImpl::GetInstance(Button& button)
73 {
74         return static_cast<_ButtonImpl*> (button._pControlImpl);
75 }
76
77 const _ButtonImpl*
78 _ButtonImpl::GetInstance(const Button& button)
79 {
80         return static_cast<const _ButtonImpl*> (button._pControlImpl);
81 }
82
83 _ButtonImpl::_ButtonImpl(Button* pPublic, _Button* pCore)
84         : _ControlImpl(pPublic, pCore)
85         , __pPublicActionEvent(null)
86 {
87         ClearLastResult();
88 }
89
90 _ButtonImpl::~_ButtonImpl(void)
91 {
92         _ButtonImpl::GetCore().RemoveActionEventListener(*this);
93
94         if (__pPublicActionEvent)
95         {
96                 delete __pPublicActionEvent;
97                 __pPublicActionEvent = null;
98         }
99
100         ClearLastResult();
101 }
102
103 _ButtonImpl*
104 _ButtonImpl::CreateButtonImplN(Button* pControl, const Rectangle& bounds)
105 {
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.");
109
110         _Button* pCore = _Button::CreateButtonN();
111         SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
112
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));
116
117         r = pImpl->InitializeBoundsProperties(GET_SIZE_INFO(Button), bounds, pCore->GetOrientation());
118         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
119
120         r = pCore->AddActionEventListener(*pImpl);
121         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
122
123         ClearLastResult();
124
125         return pImpl;
126
127 CATCH:
128         delete pImpl;
129         return null;
130 }
131
132 _ButtonImpl*
133 _ButtonImpl::CreateButtonImplN(Button* pControl, const FloatRectangle& bounds)
134 {
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.");
138
139         _Button* pCore = _Button::CreateButtonN();
140         SysTryReturn(NID_UI_CTRL, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(GetLastResult()));
141
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));
145
146         r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Button), bounds, pCore->GetOrientation());
147         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
148
149         r = pCore->AddActionEventListener(*pImpl);
150         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
151
152         ClearLastResult();
153
154         return pImpl;
155
156 CATCH:
157         delete pImpl;
158         return null;
159 }
160
161 const Color
162 _ButtonImpl::GetColorOnError(void)
163 {
164         return Color(0xFFFFFFFF);
165 }
166
167 const char*
168 _ButtonImpl::GetPublicClassName(void) const
169 {
170         return "Tizen::Ui::Controls::Button";
171 }
172
173 const Button&
174 _ButtonImpl::GetPublic(void) const
175 {
176         return static_cast <const Button&>(_ControlImpl::GetPublic());
177 }
178
179 Button&
180 _ButtonImpl::GetPublic(void)
181 {
182         return static_cast <Button&>(_ControlImpl::GetPublic());
183 }
184
185 const _Button&
186 _ButtonImpl::GetCore(void) const
187 {
188         return static_cast <const _Button&>(_ControlImpl::GetCore());
189 }
190
191 _Button&
192 _ButtonImpl::GetCore(void)
193 {
194         return static_cast <_Button&>(_ControlImpl::GetCore());
195 }
196
197 result
198 _ButtonImpl::SetText(const String& text)
199 {
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);
204
205         if (textLength >= buttonTextMaxLength)
206         {
207                 tempText.Remove(buttonTextMaxLength - 1, textLength - buttonTextMaxLength + 1);
208         }
209
210         Variant var(tempText);
211         result r = GetCore().SetPropertyText(var);
212         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
213
214         return r;
215 }
216
217 String
218 _ButtonImpl::GetText(void) const
219 {
220         ClearLastResult();
221
222         return GetCore().GetPropertyText().ToString();
223 }
224
225 result
226 _ButtonImpl::SetColor(ButtonStatus status, const Color& color)
227 {
228         _ButtonStatus coreStatus = ConvertStatus(status);
229         result r = GetCore().SetColor(coreStatus, color);
230         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
231
232         return r;
233 }
234
235 Color
236 _ButtonImpl::GetColor(ButtonStatus status) const
237 {
238         ClearLastResult();
239         _ButtonStatus coreStatus = ConvertStatus(status);
240
241         return GetCore().GetColor(coreStatus);
242 }
243
244 result
245 _ButtonImpl::AddActionEventListener(IActionEventListener& listener)
246 {
247         if (__pPublicActionEvent == null)
248         {
249                 __pPublicActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
250                 SysTryReturn(NID_UI_CTRL, __pPublicActionEvent, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
251         }
252
253         result r = __pPublicActionEvent->AddListener(listener);
254         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
255
256         return E_SUCCESS;
257 }
258
259 result
260 _ButtonImpl::RemoveActionEventListener(IActionEventListener& listener)
261 {
262         result r = E_OBJ_NOT_FOUND;
263
264         if (__pPublicActionEvent)
265         {
266                 r = __pPublicActionEvent->RemoveListener(listener);
267         }
268
269         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
270
271         return E_SUCCESS;
272 }
273
274 result
275 _ButtonImpl::SetActionId(int actionId)
276 {
277         result r = GetCore().SetActionId(actionId);
278
279         SetLastResultReturn(r);
280 }
281
282 int
283 _ButtonImpl::GetActionId(void) const
284 {
285         ClearLastResult();
286
287         return GetCore().GetActionId();
288 }
289
290 result
291 _ButtonImpl::SetTextHorizontalAlignment(HorizontalAlignment alignment)
292 {
293         result r = GetCore().SetTextHorizontalAlignment(alignment);
294         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
295
296         return r;
297 }
298
299 HorizontalAlignment
300 _ButtonImpl::GetTextHorizontalAlignment(void) const
301 {
302         ClearLastResult();
303
304         return GetCore().GetTextHorizontalAlignment();
305 }
306
307 result
308 _ButtonImpl::SetTextVerticalAlignment(VerticalAlignment alignment)
309 {
310         result r = GetCore().SetTextVerticalAlignment(alignment);
311         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
312
313         return r;
314 }
315
316 VerticalAlignment
317 _ButtonImpl::GetTextVerticalAlignment(void) const
318 {
319         ClearLastResult();
320
321         return GetCore().GetTextVerticalAlignment();
322 }
323
324 result
325 _ButtonImpl::SetTextColor(const Color& color)
326 {
327         result r = GetCore().SetTextColor(_BUTTON_STATUS_NORMAL, color);
328         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
329
330         return r;
331 }
332
333 Color
334 _ButtonImpl::GetTextColor(void) const
335 {
336         ClearLastResult();
337
338         return GetCore().GetTextColor(_BUTTON_STATUS_NORMAL);
339 }
340
341 result
342 _ButtonImpl::SetDisabledTextColor(const Color& color)
343 {
344         result r = GetCore().SetTextColor(_BUTTON_STATUS_DISABLED, color);
345         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
346
347         return r;
348 }
349
350 Color
351 _ButtonImpl::GetDisabledTextColor(void) const
352 {
353         ClearLastResult();
354
355         return GetCore().GetTextColor(_BUTTON_STATUS_DISABLED);
356 }
357
358 result
359 _ButtonImpl::SetPressedTextColor(const Color& color)
360 {
361         result r = GetCore().SetTextColor(_BUTTON_STATUS_PRESSED, color);
362         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
363
364         return r;
365 }
366
367 Color
368 _ButtonImpl::GetPressedTextColor(void) const
369 {
370         ClearLastResult();
371
372         return GetCore().GetTextColor(_BUTTON_STATUS_PRESSED);
373 }
374
375 result
376 _ButtonImpl::SetHighlightedTextColor(const Color& color)
377 {
378         result r = GetCore().SetTextColor(_BUTTON_STATUS_HIGHLIGHTED, color);
379         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
380
381         return r;
382 }
383
384 Color
385 _ButtonImpl::GetHighlightedTextColor(void) const
386 {
387         ClearLastResult();
388
389         return GetCore().GetTextColor(_BUTTON_STATUS_HIGHLIGHTED);
390 }
391
392 result
393 _ButtonImpl::SetNormalBitmap(const Point& position, const Bitmap& bitmap)
394 {
395         result r = GetCore().SetBitmap(_BUTTON_STATUS_NORMAL, position, bitmap);
396         SetLastResultReturn(r);
397 }
398
399 result
400 _ButtonImpl::SetNormalBitmap(const FloatPoint& position, const Bitmap& bitmap)
401 {
402         result r = GetCore().SetBitmap(_BUTTON_STATUS_NORMAL, position, bitmap);
403         SetLastResultReturn(r);
404 }
405
406 result
407 _ButtonImpl::SetDisabledBitmap(const Point& position, const Bitmap& bitmap)
408 {
409         result r = GetCore().SetBitmap(_BUTTON_STATUS_DISABLED, position, bitmap);
410         SetLastResultReturn(r);
411 }
412
413 result
414 _ButtonImpl::SetDisabledBitmap(const FloatPoint& position, const Bitmap& bitmap)
415 {
416         result r = GetCore().SetBitmap(_BUTTON_STATUS_DISABLED, position, bitmap);
417         SetLastResultReturn(r);
418 }
419
420 result
421 _ButtonImpl::SetPressedBitmap(const Point& position, const Bitmap& bitmap)
422 {
423         result r = GetCore().SetBitmap(_BUTTON_STATUS_PRESSED, position, bitmap);
424         SetLastResultReturn(r);
425 }
426
427 result
428 _ButtonImpl::SetPressedBitmap(const FloatPoint& position, const Bitmap& bitmap)
429 {
430         result r = GetCore().SetBitmap(_BUTTON_STATUS_PRESSED, position, bitmap);
431         SetLastResultReturn(r);
432 }
433
434 result
435 _ButtonImpl::SetHighlightedBitmap(const Point& position, const Bitmap& bitmap)
436 {
437         result r = GetCore().SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, position, bitmap);
438         SetLastResultReturn(r);
439 }
440
441 result
442 _ButtonImpl::SetHighlightedBitmap(const FloatPoint& position, const Bitmap& bitmap)
443 {
444         result r = GetCore().SetBitmap(_BUTTON_STATUS_HIGHLIGHTED, position, bitmap);
445         SetLastResultReturn(r);
446 }
447
448 result
449 _ButtonImpl::SetNormalBackgroundBitmap(const Bitmap& bitmap)
450 {
451         result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_NORMAL, bitmap);
452         SetLastResultReturn(r);
453 }
454
455 result
456 _ButtonImpl::SetDisabledBackgroundBitmap(const Bitmap& bitmap)
457 {
458         result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_DISABLED, bitmap);
459         SetLastResultReturn(r);
460 }
461
462 result
463 _ButtonImpl::SetPressedBackgroundBitmap(const Bitmap& bitmap)
464 {
465         result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_PRESSED, bitmap);
466         SetLastResultReturn(r);
467 }
468
469 result
470 _ButtonImpl::SetHighlightedBackgroundBitmap(const Bitmap& bitmap)
471 {
472         result r = GetCore().SetBackgroundBitmap(_BUTTON_STATUS_HIGHLIGHTED, bitmap);
473         SetLastResultReturn(r);
474 }
475
476 result
477 _ButtonImpl::SetTextSize(int size)
478 {
479         result r = GetCore().SetTextSize(size);
480         SetLastResultReturn(r);
481 }
482
483 result
484 _ButtonImpl::SetTextSize(float size)
485 {
486         result r = GetCore().SetTextSize(size);
487         SetLastResultReturn(r);
488 }
489
490 int
491 _ButtonImpl::GetTextSize(void) const
492 {
493         ClearLastResult();
494
495         return GetCore().GetTextSize();
496 }
497
498 float
499 _ButtonImpl::GetTextSizeF(void) const
500 {
501         ClearLastResult();
502
503         return GetCore().GetTextSizeF();
504 }
505
506 void
507 _ButtonImpl::OnActionPerformed(const _Control& source, int actionId)
508 {
509         if (__pPublicActionEvent != null)
510         {
511                 __pPublicActionEvent->Fire(*_PublicActionEvent::CreateActionEventArgN(actionId));
512         }
513
514         return;
515 }
516
517 result
518 _ButtonImpl::OnAttachedToMainTree(void)
519 {
520         //SetFocusable(true); // for TDIS-6998
521
522         _ControlImpl::OnAttachedToMainTree();
523
524         return E_SUCCESS;
525 }
526
527 bool
528 _ButtonImpl::OnTouchPressed(const _ControlImpl& source, const _TouchInfo& touchinfo)
529 {
530         if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())  && (!source.IsEnabled() || !source.GetEnableState()))
531         {
532                 return true;
533         }
534
535         return false;
536 }
537
538 bool
539 _ButtonImpl::OnTouchReleased(const _ControlImpl& source, const _TouchInfo& touchinfo)
540 {
541         if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())  && (!source.IsEnabled() || !source.GetEnableState()))
542         {
543                 return true;
544         }
545
546         return false;
547 }
548
549 bool
550 _ButtonImpl::OnTouchMoved(const _ControlImpl& source, const _TouchInfo& touchinfo)
551 {
552         if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())  && (!source.IsEnabled() || !source.GetEnableState()))
553         {
554                 return true;
555         }
556
557         return false;
558 }
559
560 bool
561 _ButtonImpl::OnTouchCanceled(const _ControlImpl& source, const _TouchInfo& touchinfo)
562 {
563         if ((_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())  && (!source.IsEnabled() || !source.GetEnableState()))
564         {
565                 return true;
566         }
567
568         return false;
569 }
570
571 Tizen::Graphics::FloatDimension
572 _ButtonImpl::GetContentSizeF(bool horizontalMode, bool verticalMode) const
573 {
574         return GetCore().GetContentSizeF(horizontalMode, verticalMode);
575 }
576
577 _ButtonStatus
578 _ButtonImpl::ConvertStatus(ButtonStatus status) const
579 {
580         _ButtonStatus coreStatus = _BUTTON_STATUS_HIGHLIGHTED;
581         switch (status)
582         {
583         case BUTTON_STATUS_NORMAL:
584                 coreStatus = _BUTTON_STATUS_NORMAL;
585                 break;
586         case BUTTON_STATUS_DISABLED:
587                 coreStatus = _BUTTON_STATUS_DISABLED;
588                 break;
589         case BUTTON_STATUS_PRESSED:
590                 coreStatus = _BUTTON_STATUS_PRESSED;
591                 break;
592         default:
593                 coreStatus = _BUTTON_STATUS_HIGHLIGHTED;
594         }
595
596         return coreStatus;
597 }
598
599 class _ButtonMaker
600         : public _UiBuilderControlMaker
601 {
602 public:
603         _ButtonMaker(_UiBuilder* uibuilder)
604                 : _UiBuilderControlMaker(uibuilder){};
605         _ButtonMaker(){};
606         virtual ~_ButtonMaker(){};
607         static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
608         {
609                 _ButtonMaker* pButtonMaker = new (std::nothrow) _ButtonMaker(uibuilder);
610                 return static_cast<_UiBuilderControlMaker*>(pButtonMaker);
611         };
612 protected:
613         virtual Control* Make(_UiBuilderControl* pControl)
614         {
615                 result r = E_SYSTEM;
616                 _UiBuilderControlLayout* pControlProperty = null;
617                 Button* pButton = null;
618                 HorizontalAlignment horizontalAlignment;
619                 VerticalAlignment verticalAlignment;
620                 Color color;
621                 float size = 0;
622                 int opacity = 0;
623                 FloatRectangle buttonRect(0.0f, 0.0f, 0.0f, 0.0f);
624                 Tizen::Base::String elementString;
625
626                 GetProperty(pControl, &pControlProperty);
627
628                 if (pControlProperty == null)
629                 {
630                         return null;
631                 }
632
633                 pButton = new (std::nothrow) Button();
634                 if (pButton == null)
635                 {
636                         return null;
637                 }
638
639                 buttonRect = pControlProperty->GetRectF();
640
641                 if (pControl->GetElement(L"text", elementString))
642                 {
643                         r = pButton->Construct(buttonRect, elementString);
644                 }
645                 else
646                 {
647                         r = pButton->Construct(buttonRect);
648                 }
649
650                 if (r != E_SUCCESS)
651                 {
652                         delete pButton;
653                         return null;
654                 }
655
656                 if (pControl->GetElement(L"horizontalAlign", elementString) || pControl->GetElement(L"hAlign", elementString))
657                 {
658                         if (ConvertHAlignToHorizontalAlignment(elementString, horizontalAlignment))
659                         {
660                                 pButton->SetTextHorizontalAlignment(horizontalAlignment);
661                         }
662                 }
663
664                 if (pControl->GetElement(L"verticalAlign", elementString) || pControl->GetElement(L"vAlign", elementString))
665                 {
666                         if (ConvertVAlignToVerticalAlignment(elementString, verticalAlignment))
667                         {
668                                 pButton->SetTextVerticalAlignment(verticalAlignment);
669                         }
670                 }
671
672                 if (pControl->GetElement(L"normalTextColor", elementString))
673                 {
674                         ConvertStringToColor(elementString, color);
675                         pButton->SetTextColor(color);
676                 }
677
678                 if (pControl->GetElement(L"pressedTextColor", elementString))
679                 {
680                         ConvertStringToColor(elementString, color);
681                         pButton->SetPressedTextColor(color);
682                 }
683
684                 if (pControl->GetElement(L"disableTextColor", elementString))
685                 {
686                         ConvertStringToColor(elementString, color);
687                         pButton->SetDisabledTextColor(color);
688                 }
689
690                 if (pControl->GetElement(L"normalBitmapPath", elementString) || pControl->GetElement(L"NormalBitmapPath", elementString))
691                 {
692                         Bitmap* pNormalBitmap = null;
693                         FloatPoint position;
694                         pNormalBitmap = LoadBitmapN(elementString);
695
696                         if (pControl->GetElement(L"NormalBitmapX", elementString))
697                         {
698                                 position.x = _LocalizedNumParser::ToDouble(elementString, "C");
699                                 if ((position.x < 0.0f) || (position.x > ((Control*) (GetContainer()))->GetBoundsF().width - ((Control*) (GetContainer()))->GetBoundsF().x))
700                                 {
701                                         position.x = 0.0f;
702                                 }
703                         }
704
705                         if (pControl->GetElement(L"NormalBitmapY", elementString))
706                         {
707                                 position.y = _LocalizedNumParser::ToDouble(elementString, "C");
708                                 if (position.y < 0.0f || (position.y > ((Control*) (GetContainer()))->GetBoundsF().height - ((Control*) (GetContainer()))->GetBoundsF().y))
709                                 {
710                                         position.y = 0.0f;
711                                 }
712                         }
713
714                         if (pNormalBitmap != null)
715                         {
716                                 pButton->SetNormalBitmap(position, *pNormalBitmap);
717                                 delete pNormalBitmap;
718                         }
719                 }
720
721                 if (pControl->GetElement(L"PressedBitmapPath", elementString))
722                 {
723                         Bitmap* pPressedBitmap = null;
724                         FloatPoint position;
725
726                         pPressedBitmap = LoadBitmapN(elementString);
727                         if (pControl->GetElement(L"PressedBitmapX", elementString))
728                         {
729                                 position.x = _LocalizedNumParser::ToDouble(elementString, "C");
730                                 if ((position.x < 0.0f) || (position.x > ((Control*) (GetContainer()))->GetBoundsF().width - ((Control*) (GetContainer()))->GetBoundsF().x))
731                                 {
732                                         position.x = 0.0f;
733                                 }
734                         }
735
736                         if (pControl->GetElement(L"PressedBitmapY", elementString))
737                         {
738                                 position.y =_LocalizedNumParser::ToDouble(elementString, "C");
739                                 if (position.y < 0.0f || (position.y > ((Control*) (GetContainer()))->GetBoundsF().height - ((Control*) (GetContainer()))->GetBoundsF().y))
740                                 {
741                                         position.y = 0.0f;
742                                 }
743                         }
744
745                         if (pPressedBitmap != null)
746                         {
747                                 pButton->SetPressedBitmap(position, *pPressedBitmap);
748                                 delete pPressedBitmap;
749                         }
750                 }
751
752                 if (pControl->GetElement(L"DisabledBitmapPath", elementString))
753                 {
754                         Bitmap* pDisabledBitmap = null;
755                         FloatPoint position;
756                         pDisabledBitmap = LoadBitmapN(elementString);
757                         if (pControl->GetElement(L"DisabledBitmapX", elementString))
758                         {
759                                 position.x = _LocalizedNumParser::ToDouble(elementString, "C");
760                                 if ((position.x < 0.0f) || (position.x > ((Control*) (GetContainer()))->GetBoundsF().width - ((Control*) (GetContainer()))->GetBoundsF().x))
761                                 {
762                                         position.x = 0.0f;
763                                 }
764                         }
765
766                         if (pControl->GetElement(L"DisabledBitmapY", elementString))
767                         {
768                                 position.y = _LocalizedNumParser::ToDouble(elementString, "C");
769                                 if (position.y < 0.0f || (position.y > ((Control*) (GetContainer()))->GetBoundsF().height - ((Control*) (GetContainer()))->GetBoundsF().y))
770                                 {
771                                         position.y = 0.0f;
772                                 }
773                         }
774
775                         if (pDisabledBitmap != null)
776                         {
777                                 pButton->SetDisabledBitmap(position, *pDisabledBitmap);
778                                 delete pDisabledBitmap;
779                         }
780                 }
781
782                 if (pControl->GetElement(L"HighlightedBitmapPath", elementString))
783                 {
784                         Bitmap* pHighlightedBitmap = null;
785                         FloatPoint position;
786                         pHighlightedBitmap = LoadBitmapN(elementString);
787                         if (pControl->GetElement(L"HighlightedBitmapX", elementString))
788                         {
789                                 position.x = _LocalizedNumParser::ToDouble(elementString, "C");
790                                 if ((position.x < 0.0f) || (position.x > ((Control*) (GetContainer()))->GetBoundsF().width - ((Control*) (GetContainer()))->GetBoundsF().x))
791                                 {
792                                         position.x = 0.0f;
793                                 }
794                         }
795
796                         if (pControl->GetElement(L"HighlightedBitmapY", elementString))
797                         {
798                                 position.y = _LocalizedNumParser::ToDouble(elementString, "C");
799                                 if (position.y < 0.0f || (position.y > ((Control*) (GetContainer()))->GetBoundsF().height - ((Control*) (GetContainer()))->GetBoundsF().y))
800                                 {
801                                         position.y = 0.0f;
802                                 }
803                         }
804
805                         if (pHighlightedBitmap != null)
806                         {
807                                 pButton->SetHighlightedBitmap(position, *pHighlightedBitmap);
808                                 delete pHighlightedBitmap;
809                         }
810                 }
811
812                 if (pControl->GetElement(L"NormalBGBitmapPath", elementString))
813                 {
814                         Bitmap* pNormalBGBitmap = null;
815                         pNormalBGBitmap = LoadBitmapN(elementString);
816                         if (pNormalBGBitmap != null)
817                         {
818                                 pButton->SetNormalBackgroundBitmap(*pNormalBGBitmap);
819                                 delete pNormalBGBitmap;
820                         }
821                 }
822
823                 if (pControl->GetElement(L"PressedBGBitmapPath", elementString))
824                 {
825                         Bitmap* pPressedBGBitmap = null;
826                         pPressedBGBitmap = LoadBitmapN(elementString);
827                         if (pPressedBGBitmap != null)
828                         {
829                                 pButton->SetPressedBackgroundBitmap(*pPressedBGBitmap);
830                                 delete pPressedBGBitmap;
831                         }
832                 }
833
834                 if (pControl->GetElement(L"HighlightedBGBitmapPath", elementString))
835                 {
836                         Bitmap* pHighlightedBGBitmap = null;
837                         pHighlightedBGBitmap = LoadBitmapN(elementString);
838                         if (pHighlightedBGBitmap != null)
839                         {
840                                 pButton->SetHighlightedBackgroundBitmap(*pHighlightedBGBitmap);
841                                 delete pHighlightedBGBitmap;
842                         }
843                 }
844
845                 if (pControl->GetElement(L"DisabledBGBitmapPath", elementString))
846                 {
847                         Bitmap* pDisabledBGBitmap = null;
848                         pDisabledBGBitmap = LoadBitmapN(elementString);
849                         if (pDisabledBGBitmap != null)
850                         {
851                                 pButton->SetDisabledBackgroundBitmap(*pDisabledBGBitmap);
852                                 delete pDisabledBGBitmap;
853                         }
854                 }
855
856                 if (pControl->GetElement(L"highlightedTextColor", elementString))
857                 {
858                         ConvertStringToColor(elementString, color);
859                         pButton->SetHighlightedTextColor(color);
860                 }
861
862                 if (pControl->GetElement(L"normalColorOpacity", elementString))
863                 {
864                         Base::Integer::Parse(elementString, opacity);
865                 }
866
867                 if (pControl->GetElement(L"normalColor", elementString))
868                 {
869                         ConvertStringToColor32(elementString, opacity, color);
870                         pButton->SetColor(BUTTON_STATUS_NORMAL, color);
871                 }
872
873                 if (pControl->GetElement(L"pressedColorOpacity", elementString))
874                 {
875                         Base::Integer::Parse(elementString, opacity);
876                 }
877
878                 if (pControl->GetElement(L"pressedColor", elementString))
879                 {
880                         ConvertStringToColor32(elementString, opacity, color);
881                         pButton->SetColor(BUTTON_STATUS_PRESSED, color);
882                 }
883
884                 if (pControl->GetElement(L"disabledColorOpacity", elementString))
885                 {
886                         Base::Integer::Parse(elementString, opacity);
887                 }
888
889                 if (pControl->GetElement(L"disabledColor", elementString))
890                 {
891                         ConvertStringToColor32(elementString, opacity, color);
892                         pButton->SetColor(BUTTON_STATUS_DISABLED, color);
893                 }
894
895                 if (pControl->GetElement(L"highlightedColorOpacity", elementString))
896                 {
897                         Base::Integer::Parse(elementString, opacity);
898                 }
899
900                 if (pControl->GetElement(L"highlightedColor", elementString))
901                 {
902                         ConvertStringToColor32(elementString, opacity, color);
903                         pButton->SetColor(BUTTON_STATUS_HIGHLIGHTED, color);
904                 }
905
906                 if (pControl->GetElement(L"textSize", elementString))
907                 {
908                         _ICoordinateSystemTransformer* pTransform = GetTransformer();
909
910                         size = _LocalizedNumParser::ToDouble(elementString, "C");
911
912                         if (pTransform)
913                         {
914                                 size = pTransform->Transform(size);
915                         }
916
917                         pButton->SetTextSize(size);
918                 }
919
920                 if (pControl->GetElement(L"accessibilityHint", elementString))
921                 {
922                         AccessibilityContainer* pContainer = pButton->GetAccessibilityContainer();
923                         if (pContainer)
924                         {
925                                 AccessibilityElement* pElement = pContainer->GetElement(L"ButtonText");
926                                 if (pElement)
927                                 {
928                                         pElement->SetHint(elementString);
929                                 }
930                         }
931                 }
932
933                 return pButton;
934         }
935 private:
936 }; // _ButtonMaker
937
938 _ButtonRegister::_ButtonRegister()
939 {
940           _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
941           pUiBuilderControlTableManager->RegisterControl(L"Button", _ButtonMaker::GetInstance);
942 }
943 _ButtonRegister::~_ButtonRegister()
944 {
945           _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
946           pUiBuilderControlTableManager->UnregisterControl(L"Button");
947 }
948 static _ButtonRegister ButtonRegisterToUiBuilder;
949 }}} // Tizen::Ui::Controls