Merge "modified Focus UI on MessageBox" into tizen_2.2
[platform/framework/native/uifw.git] / src / ui / controls / FUiCtrl_FormImpl.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 #include <app.h>
19 #include <new>
20 #include <FUiControls.h>
21 #include <FBaseInteger.h>
22 #include <FBaseColLinkedListT.h>
23 #include <FUiCtrlHeader.h>
24 #include <FUiCtrlFooter.h>
25 #include <FUiCtrlTab.h>
26 #include <FUiLayout.h>
27 #include <FBaseSysLog.h>
28 #include <FApp_AppInfo.h>
29 #include <FGrpFloatRectangle.h>
30 #include "FUi_LayoutImpl.h"
31 #include "FUi_LayoutLayoutMaker.h"
32 #include "FUi_EcoreEvasMgr.h"
33 #include "FUi_EcoreEvas.h"
34 #include "FUi_ControlImplManager.h"
35 #include "FUi_OrientationAgent.h"
36 #include "FUi_ImeOrientationAgent.h"
37 #include "FUi_UiBuilder.h"
38 #include "FUi_CoordinateSystemUtils.h"
39 #include "FUi_DataBindingContextImpl.h"
40 #include "FUi_ResourceSizeInfo.h"
41 #include "FUi_ResourceManager.h"
42 #include "FUiAnim_VisualElement.h"
43 #include "FUiCtrl_FormImpl.h"
44 #include "FUiCtrl_HeaderImpl.h"
45 #include "FUiCtrl_FooterImpl.h"
46 #include "FUiCtrl_Form.h"
47 #include "FUiCtrl_Frame.h"
48 #include "FUiCtrl_FrameImpl.h"
49 #include "FUiCtrl_TabImpl.h"
50 #include "FUiCtrl_Indicator.h"
51
52 using namespace Tizen::App;
53 using namespace Tizen::Base;
54 using namespace Tizen::Base::Runtime;
55 using namespace Tizen::Base::Collection;
56 using namespace Tizen::Graphics;
57 using namespace Tizen::Ui;
58 using namespace Tizen::Ui::Animations;
59
60 #define OPTIONKEY       SOFTKEY_COUNT
61
62 namespace Tizen { namespace Ui { namespace Controls
63 {
64
65 const String _REQUEST_ORIENTATION_EVENT = L"RequestOrientationEvent";
66
67 Dimension
68 _FormImpl::FormSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const
69 {
70         result r = E_SUCCESS;
71         Dimension dimension(0, 0);
72         SetLastResult(r);
73
74         return dimension;
75 }
76
77 FloatDimension
78 _FormImpl::FormSizeInfo::GetDefaultMinimumSizeF(_ControlOrientation orientation) const
79 {
80         result r = E_SUCCESS;
81         FloatDimension dimension(0.0f, 0.0f);
82         SetLastResult(r);
83
84         return dimension;
85 }
86
87 const _FormImpl*
88 _FormImpl::GetInstance(const Form& form)
89 {
90         return static_cast<const _FormImpl*> (form._pControlImpl);
91 }
92
93 _FormImpl*
94 _FormImpl::GetInstance(Form& form)
95 {
96         return static_cast<_FormImpl*> (form._pControlImpl);
97 }
98
99 _FormImpl::_FormImpl(Form* pPublic, _Form* pCore, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout)
100         : _ContainerImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout)
101         , __pForm(null)
102         , __pFormBackEventListener(null)
103         , __pFormMenuEventListener(null)
104         , __pOriAgent(null)
105         , __pImeOriAgent(null)
106         , __pLeftSoftkeyActionEvent(null)
107         , __pRightSoftkeyActionEvent(null)
108         , __pOptionMenuActionEvent(null)
109 {
110         __pForm = pCore;
111
112         int appType = _AppInfo::GetAppType();
113         if (appType & _APP_TYPE_IME_APP)
114         {
115                 __pImeOriAgent = _ImeOrientationAgent::CreateInstanceN(*pPublic);
116                 SysTryReturnVoidResult(NID_UI_CTRL, __pImeOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
117         }
118         else
119         {
120                 __pOriAgent = _OrientationAgent::CreateInstanceN(*pPublic);
121                 SysTryReturnVoidResult(NID_UI_CTRL, __pOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
122         }
123 }
124
125 _FormImpl::~_FormImpl(void)
126 {
127         if (__pImeOriAgent)
128         {
129                 delete __pImeOriAgent;
130                 __pImeOriAgent = null;
131         }
132
133         if (__pOriAgent)
134         {
135                 delete __pOriAgent;
136                 __pOriAgent = null;
137         }
138
139         if (__pLeftSoftkeyActionEvent)
140         {
141                 delete __pLeftSoftkeyActionEvent;
142                 __pLeftSoftkeyActionEvent = null;
143         }
144
145         if (__pRightSoftkeyActionEvent)
146         {
147                 delete __pRightSoftkeyActionEvent;
148                 __pRightSoftkeyActionEvent = null;
149         }
150
151         if (__pOptionMenuActionEvent)
152         {
153                 delete __pOptionMenuActionEvent;
154                 __pOptionMenuActionEvent = null;
155         }
156
157         __leftSoftkeyActionList.RemoveAll(false);
158         __rightSoftkeyActionList.RemoveAll(false);
159
160         RemoveHeader();
161         RemoveFooter();
162         RemoveTabImpl();
163
164         __pForm = null;
165
166         ClearLastResult();
167 }
168
169 _FormImpl*
170 _FormImpl::CreateFormImplN(Form* pControl, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout)
171 {
172         result r = E_SUCCESS;
173         _VisualElement* pVisualElement = null;
174
175         _Form* pCore = _Form::CreateFormN();
176         r = GetLastResult();
177         SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); // [ToDo] interpret last result.
178
179         _FormImpl* pImpl = new (std::nothrow) _FormImpl(pControl, pCore, pPublicPortraitLayout, pPublicLandscapeLayout);
180
181         r = _ControlImpl::CheckConstruction(pCore, pImpl);
182         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
183
184         const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
185         const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
186
187         _ControlOrientation orientation = pCore->GetOrientation();
188
189         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
190         {
191                 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Form), portraitSize, orientation);
192         }
193         else
194         {
195                 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Form), landscapeSize, orientation);
196         }
197         SysAssert(r == E_SUCCESS);
198
199         pCore->SetFormOrientationStatusEventListener(pImpl);
200
201         // Make surface opaque.
202         pVisualElement = pCore->GetVisualElement();
203         SysTryCatch(NID_UI_CTRL, pVisualElement, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
204         r = pVisualElement->SetSurfaceOpaque(true);
205         SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); // [ToDo] interpret last result.
206
207         SetLastResult(E_SUCCESS);
208
209         return pImpl;
210
211 CATCH:
212         delete pCore;
213         delete pImpl;
214
215         return null;
216 }
217
218 const char*
219 _FormImpl::GetPublicClassName(void) const
220 {
221         return "Tizen::Ui::Controls::Form";
222 }
223
224 const Form&
225 _FormImpl::GetPublic(void) const
226 {
227         return static_cast<const Form&>(_ControlImpl::GetPublic());
228 }
229
230 Form&
231 _FormImpl::GetPublic(void)
232 {
233         return static_cast<Form&>(_ControlImpl::GetPublic());
234 }
235
236 const _Form&
237 _FormImpl::GetCore(void) const
238 {
239         return static_cast<const _Form&>(_ControlImpl::GetCore());
240 }
241
242 _Form&
243 _FormImpl::GetCore(void)
244 {
245         return static_cast<_Form&>(_ControlImpl::GetCore());
246 }
247
248 _ControlImpl*
249 _FormImpl::GetFocusControl(void)
250 {
251         return null;
252 }
253
254 unsigned long
255 _FormImpl::GetFormStyle(void) const
256 {
257         return GetCore().GetFormStyle();
258 }
259
260 bool
261 _FormImpl::HasIndicator(void) const
262 {
263         return GetCore().HasIndicator();
264 }
265
266 void
267 _FormImpl::SetFormStyle(unsigned long formStyle)
268 {
269         result r = E_SUCCESS;
270
271         _HeaderImpl* pHeader = GetHeader();
272         _FooterImpl* pFooter = GetFooter();
273         _TabImpl* pTabImpl = GetTabImpl();
274
275         if (IsAttachedToMainTree())
276         {
277                 if (FORM_STYLE_INDICATOR & formStyle)
278                 {
279                         _Frame* pFrame = dynamic_cast<_Frame*>(GetCore().GetParent());
280                         SysTryReturnVoidResult(NID_UI_CTRL, pFrame != null, E_INVALID_ARG, "A Form which has FORM_STYLE_INDICATOR style cannot be added to a container except Frame.");
281                 }
282         }
283
284         if ((formStyle & FORM_STYLE_INDICATOR) && (formStyle & FORM_STYLE_INDICATOR_AUTO_HIDE))
285         {
286                 SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid form style. FORM_STYLE_INDICATOR and FORM_STYLE_INDICATOR_AUTO_HIDE can't use each other.");
287                 return;
288         }
289
290         // check formstyle
291         if (((formStyle & FORM_STYLE_TITLE) || (formStyle & FORM_STYLE_TEXT_TAB) || (formStyle & FORM_STYLE_ICON_TAB)) && (formStyle & FORM_STYLE_HEADER))
292         {
293                 SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid form style. FORM_STYLE_TITLE, FORM_STYLE_TEXT_TAB or FORM_STYLE_ICON_TAB and FORM_STYLE_HEADER can't use each other.");
294
295                 // remove Header
296                 if (pHeader)
297                 {
298                         RemoveHeader();
299                         r = GetLastResult();
300                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
301                 }
302
303                 return;
304         }
305
306         if (((formStyle & FORM_STYLE_SOFTKEY_0) || (formStyle & FORM_STYLE_SOFTKEY_1) || (formStyle & FORM_STYLE_OPTIONKEY)) && (formStyle & FORM_STYLE_FOOTER))
307         {
308                 SysLogException(NID_UI_CTRL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid form style. FORM_STYLE_SOFTKEY0, FORM_STYLE_SOFTKEY_1 or FORM_STYLE_OPTIONKEY and FORM_STYLE_FOOTER can't use each other.");
309
310                 // remove Footer
311                 if (pFooter)
312                 {
313                         RemoveFooter();
314                         r = GetLastResult();
315                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
316                 }
317                 return;
318         }
319
320         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
321         SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas.");
322
323         GetCore().SetFormStyle(formStyle);
324
325         FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
326
327         if (FORM_STYLE_INDICATOR & formStyle)
328         {
329                 GetCore().SetIndicatorShowState(true);
330                 indicatorBounds = GetCore().GetIndicatorBoundsF();
331
332                 if (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle)
333                 {
334                         GetCore().SetIndicatorAutoHide(false, true);
335                 }
336                 else
337                 {
338                         GetCore().SetIndicatorAutoHide(false, false);
339                 }
340                 r = GetLastResult();
341                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
342
343         }
344         else
345         {
346                 if ((FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle) && (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle))
347                 {
348                         r = GetCore().SetIndicatorShowState(true);
349                         GetCore().SetIndicatorAutoHide(true, true);
350                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
351                 }
352                 else
353                 {
354                         if (FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle)
355                         {
356                                 r = GetCore().SetIndicatorShowState(true);
357                                 GetCore().SetIndicatorAutoHide(true, false);
358                                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
359                         }
360                         else if(FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle)
361                         {
362                                 r = GetCore().SetIndicatorShowState(true);
363                                 GetCore().SetIndicatorAutoHide(false, true);
364                                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
365                         }
366                         else
367                         {
368                                 r = GetCore().SetIndicatorShowState(false);
369                                 GetCore().SetIndicatorAutoHide(false, false);
370                                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
371                         }
372                 }
373         }
374
375         if (formStyle & FORM_STYLE_HEADER)
376         {
377                 if (!pHeader)
378                 {
379                         pHeader = CreateHeaderN();
380                         SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
381
382                         GetCore().SetHeader(&pHeader->GetCore());
383                         GetCore().AdjustClientBounds();
384
385                         if (GetCore().IsIndicatorTranslucent())
386                         {
387                                 if (!GetCore().IsHeaderTranslucent())
388                                 {
389                                         indicatorBounds.height = 0.0f;
390                                 }
391                                 else
392                                 {
393                                         if (GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
394                                         {
395                                                 indicatorBounds.height = 0.0f;
396                                         }
397                                 }
398                         }
399
400                         FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
401                         GetCore().SetHeaderBounds(bounds);
402
403                         r = GetCore().AttachSystemChild(pHeader->GetCore());
404                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
405
406                         GetCore().SetFormBackEventListener(this);
407                 }
408         }
409         else if (formStyle & FORM_STYLE_TITLE)
410         {
411                 if (!pHeader)
412                 {
413                         pHeader = CreateHeaderN();
414                         SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
415
416                         GetCore().SetHeader(&pHeader->GetCore());
417                         GetCore().AdjustClientBounds();
418
419                         FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
420                         GetCore().SetHeaderBounds(bounds);
421
422                         r = GetCore().AttachSystemChild(pHeader->GetCore());
423                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
424                 }
425         }
426         else
427         {
428                 // remove Header
429                 if (pHeader)
430                 {
431                         RemoveHeader();
432                         r = GetLastResult();
433                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
434                 }
435         }
436
437         if (formStyle & FORM_STYLE_TEXT_TAB)
438         {
439                 float titleHeight = 0.0f;
440
441                 if (formStyle & FORM_STYLE_TITLE)
442                 {
443                         if (pHeader)
444                         {
445                                 titleHeight = pHeader->GetBoundsF().height;
446                         }
447                 }
448
449                 if (!pTabImpl)
450                 {
451                         pTabImpl = CreateTabImplN();
452                         SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
453
454                         float posY = indicatorBounds.height + titleHeight;
455
456                         GetCore().SetTab(&pTabImpl->GetCore());
457                         GetCore().AdjustClientBounds();
458
459                         FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
460                         GetCore().SetTabBounds(bounds);
461
462                         r = GetCore().AttachSystemChild(pTabImpl->GetCore());
463                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
464                 }
465                 GetCore().SetTabStyle(_TAB_STYLE_TEXT);
466         }
467         else if (formStyle & FORM_STYLE_ICON_TAB)
468         {
469                 float titleHeight = 0.0f;
470
471                 if (formStyle & FORM_STYLE_TITLE)
472                 {
473                         if (pHeader)
474                         {
475                                 titleHeight = pHeader->GetBoundsF().height;
476                         }
477                 }
478
479                 if (!pTabImpl)
480                 {
481                         pTabImpl = CreateTabImplN();
482                         SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
483
484                         float posY = indicatorBounds.height + titleHeight;
485
486                         GetCore().SetTab(&pTabImpl->GetCore());
487                         GetCore().AdjustClientBounds();
488
489                         FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
490                         GetCore().SetTabBounds(bounds);
491
492                         r = GetCore().AttachSystemChild(pTabImpl->GetCore());
493                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
494                 }
495                 GetCore().SetTabStyle(_TAB_STYLE_ICON);
496         }
497         else
498         {
499                 if (pTabImpl)
500                 {
501                         RemoveTabImpl();
502                         r = GetLastResult();
503                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
504                 }
505         }
506
507         if (formStyle & FORM_STYLE_FOOTER)
508         {
509                 if (!pFooter)
510                 {
511                         pFooter = CreateFooterN();
512                         SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
513
514                         GetCore().SetFooter(&pFooter->GetCore());
515                         GetCore().AdjustClientBounds();
516
517                         FloatRectangle clientbounds = GetClientBoundsF();
518                         FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height, clientbounds.width, GetCore().GetToolbarHeightF(false));
519
520                         GetCore().SetFooterBounds(bounds);
521
522                         r = GetCore().AttachSystemChild(pFooter->GetCore());
523                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
524
525                         GetCore().SetFormBackEventListener(this);
526                         GetCore().SetFormMenuEventListener(this);
527                 }
528         }
529         else if (formStyle & FORM_STYLE_SOFTKEY_0 || formStyle & FORM_STYLE_SOFTKEY_1 || formStyle & FORM_STYLE_OPTIONKEY)
530         {
531                 if (pFooter)
532                 {
533                         RemoveFooter();
534                         r = GetLastResult();
535                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
536                 }
537
538                 pFooter = GetFooter();
539
540                 if (!pFooter)
541                 {
542                         pFooter = CreateFooterN();
543                         SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
544
545                         GetCore().SetFooter(&pFooter->GetCore());
546                         GetCore().AdjustClientBounds();
547
548                         FloatRectangle clientbounds = GetClientBoundsF();
549                         FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - GetCore().GetToolbarHeightF(false), clientbounds.width, GetCore().GetToolbarHeightF(false));
550
551                         GetCore().SetFooterBounds(bounds);
552
553                         r = GetCore().AttachSystemChild(pFooter->GetCore());
554                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
555
556                         GetCore().CreateSoftkey(formStyle);
557
558                         pFooter->GetCore().AddActionEventListener(*this);
559                 }
560         }
561         else
562         {
563                 // remove Footer
564                 if (pFooter)
565                 {
566                         RemoveFooter();
567                         r = GetLastResult();
568                         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
569                         GetCore().AdjustClientBounds();
570                 }
571         }
572
573         GetCore().AdjustClientBounds();
574
575         SetLastResult(E_SUCCESS);
576
577         return;
578 }
579
580 _FooterImpl*
581 _FormImpl::GetFooter(void) const
582 {
583         _Toolbar* pToolbar = __pForm->GetFooter();
584         if (pToolbar == null)
585         {
586                 return null;
587         }
588
589         _FooterImpl* pFooterImpl = static_cast<_FooterImpl*>(pToolbar->GetUserData());
590
591         return pFooterImpl;
592 }
593
594 _HeaderImpl*
595 _FormImpl::GetHeader(void) const
596 {
597         _Toolbar* pToolbar = __pForm->GetHeader();
598         if (pToolbar == null)
599         {
600                 return null;
601         }
602
603         _HeaderImpl* pHeaderImpl = static_cast<_HeaderImpl*>(pToolbar->GetUserData());
604
605         return pHeaderImpl;
606 }
607
608 // Ki-Dong,Hong.Temp
609 _TabImpl*
610 _FormImpl::GetTabImpl(void) const
611 {
612         _Tab* pTab = __pForm->GetTab();
613         if (pTab == null)
614         {
615                 return null;
616         }
617
618         _TabImpl* pTabImpl = static_cast<_TabImpl*>(pTab->GetUserData());
619
620         return pTabImpl;
621 }
622
623 String
624 _FormImpl::GetTitleText(void) const
625 {
626         return GetCore().GetTitleText();
627 }
628
629 HorizontalAlignment
630 _FormImpl::GetTitleTextHorizontalAlignment(void) const
631 {
632         return GetCore().GetTitleTextHorizontalAlignment();
633 }
634
635 bool
636 _FormImpl::HasFooter(void) const
637 {
638         return GetCore().HasFooter();
639 }
640
641 bool
642 _FormImpl::HasHeader(void) const
643 {
644         return GetCore().HasHeader();
645 }
646
647 bool
648 _FormImpl::HasTitle(void) const
649 {
650         return GetCore().HasTitle();
651 }
652
653 bool
654 _FormImpl::HasTab(void) const
655 {
656         return GetCore().HasTab();
657 }
658
659 bool
660 _FormImpl::IsIndicatorVisible(void) const
661 {
662         return GetCore().IsIndicatorVisible();
663 }
664
665 bool
666 _FormImpl::IsHeaderVisible(void) const
667 {
668         return GetCore().IsHeaderVisible();
669 }
670
671 bool
672 _FormImpl::IsFooterVisible(void) const
673 {
674         return GetCore().IsFooterVisible();
675 }
676
677 bool
678 _FormImpl::IsIndicatorTranslucent(void) const
679 {
680         return GetCore().IsIndicatorTranslucent();
681 }
682
683 bool
684 _FormImpl::IsHeaderTranslucent(void) const
685 {
686         return GetCore().IsHeaderTranslucent();
687 }
688
689 bool
690 _FormImpl::IsFooterTranslucent(void) const
691 {
692         return GetCore().IsFooterTranslucent();
693 }
694
695 // Ki-Dong,Hong.Temp
696 bool
697 _FormImpl::IsTabTranslucent(void) const
698 {
699         return GetCore().IsTabTranslucent();
700 }
701
702 result
703 _FormImpl::SetActionBarsTranslucent(unsigned long actionBars, bool translucent)
704 {
705         return GetCore().SetActionBarsTranslucent(actionBars, translucent);
706 }
707
708 result
709 _FormImpl::SetActionBarsVisible(unsigned long actionBars, bool visible)
710 {
711         return GetCore().SetActionBarsVisible(actionBars, visible);
712 }
713
714 result
715 _FormImpl::SetTitleIcon(const Bitmap* pTitleBitmap)
716 {
717         return GetCore().SetTitleIcon(pTitleBitmap);
718 }
719
720 result
721 _FormImpl::SetTitleText(const String& title, HorizontalAlignment alignment)
722 {
723         return GetCore().SetTitleText(title, alignment);
724 }
725
726 OverlayRegion*
727 _FormImpl::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType)
728 {
729         return GetCore().GetOverlayRegionN(rect, regionType);
730 }
731
732 OverlayRegion*
733 _FormImpl::GetOverlayRegionN(const FloatRectangle& rect, OverlayRegionType regionType)
734 {
735         return GetCore().GetOverlayRegionN(rect, regionType);
736 }
737
738 void
739 _FormImpl::OnDraw(void)
740 {
741         if (__pOriAgent)
742         {
743                 __pOriAgent->FireOrientationEvent();
744         }
745
746         _ContainerImpl::OnDraw();
747 }
748
749 bool
750 _FormImpl::OnKeyReleased(const _ControlImpl& source, _KeyCode keyCode)
751 {
752         switch (keyCode)
753         {
754         case _KEY_BACKSPACE:
755                 if (GetCore().GetFooter() || GetCore().GetHeader())
756                 {
757                         if (__pFormBackEventListener)
758                         {
759                                 Form* pForm = dynamic_cast <Form*>(&GetPublic());
760                                 if (pForm)
761                                 {
762                                         __pFormBackEventListener->OnFormBackRequested(*pForm);
763                                 }
764                         }
765                         else
766                         {
767                                 break;
768                         }
769                 }
770                 else
771                 {
772                         break;
773                 }
774                 break;
775
776         default:
777                 return false;
778         }
779
780         return true;
781 }
782
783 void
784 _FormImpl::OnActionPerformed(const _Control& source, int actionId)
785 {
786         if (GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetFormStyle() & FORM_STYLE_SOFTKEY_1 || GetFormStyle() & FORM_STYLE_OPTIONKEY)
787         {
788                 Tizen::Base::Runtime::IEventArg* tempArg = null;
789                 tempArg = _PublicActionEvent::CreateActionEventArgN(actionId);
790                 SysTryReturnVoidResult(NID_UI_CTRL, tempArg , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create Eventarg.");
791                 bool fired = true;
792
793                 _PublicActionEvent* pSoftkeyActionEvent = null;
794
795                 if (GetCore().GetFooter()->IsButtonSet(LEFT_BUTTON) && GetSoftkeyActionId(SOFTKEY_0) == actionId)
796                 {
797                         for (int i = 0; i < __leftSoftkeyActionList.GetCount(); i++)
798                         {
799                                 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__leftSoftkeyActionList.GetAt(i));
800
801                                 if (pSoftkeyActionEvent)
802                                 {
803                                         pSoftkeyActionEvent->Fire(*tempArg);
804                                         fired = false;
805                                 }
806                         }
807                 }
808
809                 if (GetCore().GetFooter()->IsButtonSet(RIGHT_BUTTON) && GetSoftkeyActionId(SOFTKEY_1) == actionId)
810                 {
811                         for (int i = 0; i < __rightSoftkeyActionList.GetCount(); i++)
812                         {
813                                 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__rightSoftkeyActionList.GetAt(i));
814
815                                 if (pSoftkeyActionEvent)
816                                 {
817                                         pSoftkeyActionEvent->Fire(*tempArg);
818                                         fired = false;
819                                 }
820                         }
821                 }
822
823                 if (GetCore().GetFooter()->IsButtonSet(MIDDLE_BUTTON) && GetOptionkeyActionId() == actionId)
824                 {
825                         if (__pOptionMenuActionEvent)
826                         {
827                                 __pOptionMenuActionEvent->Fire(*tempArg);
828                                 fired = false;
829                         }
830                 }
831                 if (fired)
832                 {
833                         delete tempArg;
834                 }
835         }
836 }
837
838 Canvas*
839 _FormImpl::GetClientAreaCanvasN(void) const
840 {
841         return GetCore().GetClientAreaCanvasN();
842 }
843
844 Point
845 _FormImpl::TranslateToClientAreaPosition(const Point& position) const
846 {
847         return GetCore().TranslateToClientAreaPosition(position);
848 }
849
850 FloatPoint
851 _FormImpl::TranslateToClientAreaPosition(const FloatPoint& position) const
852 {
853         return GetCore().TranslateToClientAreaPosition(position);
854 }
855
856 Point
857 _FormImpl::TranslateFromClientAreaPosition(const Point& clientPosition) const
858 {
859         return GetCore().TranslateFromClientAreaPosition(clientPosition);
860 }
861
862 FloatPoint
863 _FormImpl::TranslateFromClientAreaPosition(const FloatPoint& clientPosition) const
864 {
865         return GetCore().TranslateFromClientAreaPosition(clientPosition);
866 }
867
868 void
869 _FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEventListener)
870 {
871         bool isBackButton = false;
872
873         Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/input.keys.back", isBackButton);
874
875         if(!isBackButton)
876         {
877                 SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
878         }
879
880         __pFormBackEventListener = const_cast <IFormBackEventListener*>(pFormBackEventListener);
881         GetCore().SetFormBackEventListener(this);
882         result r = GetLastResult();
883         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
884 }
885
886 void
887 _FormImpl::SetFormMenuEventListener(const IFormMenuEventListener* pFormMenuEventListener)
888 {
889         bool isMenuButton = false;
890
891         Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/input.keys.menu", isMenuButton);
892
893         if(!isMenuButton)
894         {
895                 SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
896         }
897         __pFormMenuEventListener = const_cast <IFormMenuEventListener*>(pFormMenuEventListener);
898         GetCore().SetFormMenuEventListener(this);
899         result r = GetLastResult();
900         SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
901 }
902
903 void
904 _FormImpl::AddOrientationEventListener(IOrientationEventListener& listener)
905 {
906         if (__pOriAgent)
907         {
908                 __pOriAgent->AddListener(listener);
909         }
910         else if (__pImeOriAgent)
911         {
912                 __pImeOriAgent->AddListener(listener);
913         }
914 }
915
916 void
917 _FormImpl::AddOptionkeyActionListener(const IActionEventListener& listener)
918 {
919         if (HasOptionkey() == false)
920         {
921                 return ;
922         }
923
924         __pOptionMenuActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
925
926         SysTryReturnVoidResult(NID_UI_CTRL, __pOptionMenuActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
927
928         __pOptionMenuActionEvent->AddListener(listener);
929 }
930
931 void
932 _FormImpl::AddSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
933 {
934         _Softkey _softkey = ConvertSoftkey(softkey);
935
936         if (GetCore().CheckSoftkey(_softkey) == false)
937         {
938                 return ;
939         }
940
941         if (softkey == SOFTKEY_0)
942         {
943                 __pLeftSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
944
945                 SysTryReturnVoidResult(NID_UI_CTRL, __pLeftSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
946
947                 __pLeftSoftkeyActionEvent->AddListener(listener);
948
949                 __leftSoftkeyActionList.Add(*__pLeftSoftkeyActionEvent);
950         }
951         else if (softkey == SOFTKEY_1)
952         {
953                 __pRightSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
954
955                 SysTryReturnVoidResult(NID_UI_CTRL, __pRightSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
956
957                 __pRightSoftkeyActionEvent->AddListener(listener);
958
959                 __rightSoftkeyActionList.Add(*__pRightSoftkeyActionEvent);
960         }
961 }
962
963 void
964 _FormImpl::RemoveOrientationEventListener(IOrientationEventListener& listener)
965 {
966         if (__pOriAgent)
967         {
968                 __pOriAgent->RemoveListener(listener);
969         }
970         else if (__pImeOriAgent)
971         {
972                 __pImeOriAgent->RemoveListener(listener);
973         }
974 }
975
976 void
977 _FormImpl::RemoveOptionkeyActionListener(const IActionEventListener& listener)
978 {
979         if (HasOptionkey() == false)
980         {
981                 return ;
982         }
983
984         if (__pOptionMenuActionEvent)
985         {
986                 __pOptionMenuActionEvent->RemoveListener(listener);
987         }
988 }
989
990 void
991 _FormImpl::RemoveSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
992 {
993         _Softkey _softkey = ConvertSoftkey(softkey);
994
995         if (GetCore().CheckSoftkey(_softkey) == false)
996         {
997                 return ;
998         }
999
1000         if (softkey == SOFTKEY_0)
1001         {
1002                 if (__pLeftSoftkeyActionEvent)
1003                 {
1004                         __pLeftSoftkeyActionEvent->RemoveListener(listener);
1005                 }
1006         }
1007         else if (softkey == SOFTKEY_1)
1008         {
1009                 if (__pRightSoftkeyActionEvent)
1010                 {
1011                         __pRightSoftkeyActionEvent->RemoveListener(listener);
1012                 }
1013         }
1014 }
1015
1016 void
1017 _FormImpl::SetOrientation(Orientation orientation)
1018 {
1019         if (__pOriAgent)
1020         {
1021                 __pOriAgent->SetMode(orientation);
1022         }
1023 }
1024
1025 Orientation
1026 _FormImpl::GetOrientation(void) const
1027 {
1028         if (__pOriAgent)
1029         {
1030                 return __pOriAgent->GetMode();
1031         }
1032
1033         return ORIENTATION_NONE;
1034 }
1035
1036 OrientationStatus
1037 _FormImpl::GetOrientationStatus(void) const
1038 {
1039         if (__pOriAgent)
1040         {
1041                 return __pOriAgent->GetStatus();
1042         }
1043         else if (__pImeOriAgent)
1044         {
1045                 return __pImeOriAgent->GetStatus();
1046         }
1047
1048         return ORIENTATION_STATUS_NONE;
1049 }
1050
1051 void
1052 _FormImpl::UpdateOrientationStatus(bool draw)
1053 {
1054         if (__pOriAgent)
1055         {
1056                 __pOriAgent->Update(draw);
1057         }
1058 }
1059
1060 void
1061 _FormImpl::UpdateOrientation(void)
1062 {
1063         if (__pOriAgent)
1064         {
1065                 __pOriAgent->UpdateOrientation();
1066         }
1067 }
1068
1069 void
1070 _FormImpl::UpdateOrientation(int angle)
1071 {
1072         SysLog(NID_UI_CTRL, "[Ime Rotation]");
1073
1074         if (__pImeOriAgent)
1075         {
1076                 __pImeOriAgent->UpdateOrientation(angle);
1077         }
1078 }
1079
1080 bool
1081 _FormImpl::HasOptionkey(void) const
1082 {
1083         return GetCore().HasOptionkey();
1084 }
1085
1086 bool
1087 _FormImpl::HasSoftkey(Softkey softkey) const
1088 {
1089         _Softkey _softkey = ConvertSoftkey(softkey);
1090
1091         return GetCore().HasSoftkey(_softkey);
1092 }
1093
1094 result
1095 _FormImpl::SetSoftkeyEnabled(Softkey softkey, bool enable)
1096 {
1097         _Softkey _softkey = ConvertSoftkey(softkey);
1098
1099         result r = GetCore().SetSoftkeyEnabled(_softkey, enable);
1100         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1101
1102         return r;
1103 }
1104
1105 bool
1106 _FormImpl::IsSoftkeyEnabled(Softkey softkey) const
1107 {
1108         _Softkey _softkey = ConvertSoftkey(softkey);
1109
1110         return GetCore().IsSoftkeyEnabled(_softkey);
1111 }
1112
1113 int
1114 _FormImpl::GetSoftkeyActionId(Softkey softkey) const
1115 {
1116         _Softkey _softkey = ConvertSoftkey(softkey);
1117
1118         return GetCore().GetSoftkeyActionId(_softkey);
1119 }
1120
1121 int
1122 _FormImpl::GetOptionkeyActionId(void) const
1123 {
1124         return GetCore().GetOptionkeyActionId();
1125 }
1126
1127 String
1128 _FormImpl::GetSoftkeyText(Softkey softkey) const
1129 {
1130         _Softkey _softkey = ConvertSoftkey(softkey);
1131
1132         return GetCore().GetSoftkeyText(_softkey);
1133 }
1134
1135 result
1136 _FormImpl::SetOptionkeyActionId(int actionId)
1137 {
1138         result r = GetCore().SetOptionkeyActionId(actionId);
1139         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1140
1141         return r;
1142 }
1143
1144 result
1145 _FormImpl::SetSoftkeyActionId(Softkey softkey, int actionId)
1146 {
1147         _Softkey _softkey = ConvertSoftkey(softkey);
1148
1149         result r = GetCore().SetSoftkeyActionId(_softkey, actionId);
1150         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1151
1152         return r;
1153 }
1154
1155 result
1156 _FormImpl::SetSoftkeyText(Softkey softkey, const String& text)
1157 {
1158         _Softkey _softkey = ConvertSoftkey(softkey);
1159
1160         result r = GetCore().SetSoftkeyText(_softkey, text);
1161         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1162
1163         return r;
1164 }
1165
1166 result
1167 _FormImpl::SetSoftkeyIcon(Softkey softkey, const Bitmap& pNormalBitmap, const Bitmap* ppPressedBitmap)
1168 {
1169         _Softkey _softkey = ConvertSoftkey(softkey);
1170
1171         result r = GetCore().SetSoftkeyIcon(_softkey, pNormalBitmap, ppPressedBitmap);
1172         SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1173
1174         return r;
1175 }
1176
1177 void
1178 _FormImpl::OnChangeLayout(_ControlOrientation orientation)
1179 {
1180         FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1181         FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
1182
1183         _FrameImpl* pFrameImpl = dynamic_cast<_FrameImpl*>(GetParent());
1184         if (pFrameImpl)
1185         {
1186                 FrameShowMode frameShowMode = pFrameImpl->GetShowMode();
1187
1188                 if ((frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
1189                 {
1190                         bool movable = pFrameImpl->GetCore().IsMovable();
1191                         pFrameImpl->GetCore().SetMovable(true);
1192
1193                         FloatPoint prevPoint = pFrameImpl->GetPositionF();
1194                         FloatPoint curPoint(prevPoint.x, prevPoint.y);
1195                         float ratio = portraitSize.width / portraitSize.height;
1196                         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1197                         {
1198                                 if (prevPoint.x > 0.0f)
1199                                 {
1200                                         curPoint.x = prevPoint.x * ratio;
1201                                 }
1202
1203                                 if (prevPoint.y > 0.0f)
1204                                 {
1205                                         curPoint.y = prevPoint.y / ratio;
1206                                 }
1207                         }
1208                         else
1209                         {
1210                                 if (prevPoint.x > 0.0f)
1211                                 {
1212                                         curPoint.x = prevPoint.x / ratio;
1213                                 }
1214
1215                                 if (prevPoint.y > 0.0f)
1216                                 {
1217                                         curPoint.y = prevPoint.y * ratio;
1218                                 }
1219                         }
1220
1221                         pFrameImpl->SetPosition(curPoint);
1222                         portraitSize = pFrameImpl->GetSizeF();
1223                         landscapeSize = portraitSize;
1224                         pFrameImpl->GetCore().SetMovable(movable);
1225                 }
1226         }
1227
1228         // Change layout.
1229         _ContainerImpl::OnChangeLayout(orientation);
1230         SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1231
1232         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1233         {
1234                 SetSize(portraitSize);
1235         }
1236         else
1237         {
1238                 SetSize(landscapeSize);
1239         }
1240
1241         float indicatorheight = 0.0f;
1242
1243         GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1244         _Indicator* pIndicator = GetCore().GetIndicator();
1245         if (GetCore().HasIndicator())
1246         {
1247                 if (pIndicator)
1248                 {
1249                         if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1250                         {
1251                                 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1252                                 if ((FORM_STYLE_INDICATOR & GetFormStyle()) || (FORM_STYLE_INDICATOR_AUTO_HIDE & GetFormStyle()))
1253                                 {
1254                                         GetCore().SetIndicatorShowState(true);
1255                                 }
1256                                 else
1257                                 {
1258                                         GetCore().SetIndicatorShowState(false);
1259                                 }
1260                         }
1261                         else
1262                         {
1263                                 if (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & GetFormStyle())
1264                                 {
1265                                         GetCore().SetIndicatorShowState(true);
1266                                 }
1267                         }
1268                 }
1269                 GetCore().AdjustClientBounds();
1270         }
1271         else
1272         {
1273                 GetCore().SetIndicatorShowState(false);
1274         }
1275         if (pIndicator)
1276         {
1277                 pIndicator->OnChangeLayout(orientation);
1278         }
1279
1280
1281         float adjHeight = 0.0f;
1282
1283         if (GetCore().HasHeader())
1284         {
1285                 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1286                 if (GetCore().IsIndicatorVisible())
1287                 {
1288                         indicatorBounds = GetCore().GetIndicatorBoundsF();
1289                         if (GetCore().IsIndicatorTranslucent())
1290                         {
1291                                 if (!GetCore().IsHeaderTranslucent())
1292                                 {
1293                                         indicatorBounds.height = 0.0f;
1294                                 }
1295                                 else
1296                                 {
1297                                         if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1298                                         {
1299                                                 indicatorBounds.height = 0.0f;
1300                                         }
1301                                 }
1302                         }
1303                 }
1304
1305                 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1306                 GetCore().SetHeaderBounds(bounds);
1307         }
1308
1309         if (GetCore().HasTab())                         // Ki-Dong,Hong.Temp
1310         {
1311                 float titleHeight = 0.0f;
1312
1313                 if (GetCore().GetFormStyle() & FORM_STYLE_TITLE)
1314                 {
1315                         if (GetCore().HasHeader())
1316                         {
1317                                 _HeaderImpl* pHeaderImpl = GetHeader();
1318                                 if (pHeaderImpl)
1319                                 {
1320                                         titleHeight = pHeaderImpl->GetBoundsF().height;
1321                                 }
1322                         }
1323                 }
1324
1325                 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1326
1327                 if (GetCore().IsIndicatorVisible())
1328                 {
1329                         indicatorBounds = GetCore().GetIndicatorBoundsF();
1330                         if (GetCore().IsIndicatorTranslucent())
1331                         {
1332                                 if (!GetCore().IsHeaderTranslucent())
1333                                 {
1334                                         indicatorBounds.height = 0.0f;
1335                                 }
1336                                 else
1337                                 {
1338                                         if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1339                                         {
1340                                                 indicatorBounds.height = 0.0f;
1341                                         }
1342                                 }
1343                         }
1344                 }
1345
1346                 float posY = indicatorBounds.height + titleHeight;
1347
1348                 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1349                 GetCore().SetTabBounds(bounds);
1350         }
1351
1352         if (GetCore().HasFooter())
1353         {
1354                 if (GetCore().GetFooter()->GetVisibleState() && !GetCore().IsFooterTranslucent())
1355                 {
1356                         adjHeight = 0.0f;
1357                 }
1358                 else
1359                 {
1360                         adjHeight = GetCore().GetToolbarHeightF(false);
1361                 }
1362
1363                 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1364                                 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1365                 {
1366                         adjHeight = GetCore().GetToolbarHeightF(false);
1367                 }
1368
1369                 FloatRectangle bounds(0.0f, GetClientBoundsF().y + GetClientBoundsF().height - adjHeight,
1370                                                                                 GetClientBoundsF().width, GetCore().GetToolbarHeightF(false));
1371                 GetCore().SetFooterBounds(bounds);
1372         }
1373 }
1374
1375 _HeaderImpl*
1376 _FormImpl::CreateHeaderN(void)
1377 {
1378         result r = E_SUCCESS;
1379
1380         Header* pHeader = new (std::nothrow) Header;
1381         SysTryReturn(NID_UI_CTRL, pHeader, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1382
1383         r = pHeader->Construct();
1384         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1385
1386         _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*pHeader);
1387
1388         SetLastResult(E_SUCCESS);
1389
1390         return pHeaderImpl;
1391 }
1392
1393 _FooterImpl*
1394 _FormImpl::CreateFooterN(void)
1395 {
1396         result r = E_SUCCESS;
1397
1398         Footer* pFooter = new (std::nothrow) Footer;
1399         SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1400
1401         r = pFooter->Construct();
1402         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1403
1404         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*pFooter);
1405
1406         SetLastResult(E_SUCCESS);
1407
1408         return pFooterImpl;
1409 }
1410
1411 // Ki-Dong,Hong.Temp
1412 _TabImpl*
1413 _FormImpl::CreateTabImplN(void)
1414 {
1415         //result r = E_SUCCESS;
1416
1417         //Tab* pTab = new (std::nothrow) Tab;
1418         //SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
1419
1420         //r = pTab->Construct();
1421         //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Unable to consturct tab.");
1422
1423         //return pTab->GetTabImpl();
1424         Tab* pTab = _TabImpl::CreateTabN();
1425         SysTryReturn(NID_UI_CTRL, pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1426
1427         _TabImpl* pTabImpl = _TabImpl::GetInstance(*pTab);
1428
1429         SetLastResult(E_SUCCESS);
1430
1431         return pTabImpl;
1432 }
1433
1434 bool
1435 _FormImpl::DeflateClientRectHeight(int height)
1436 {
1437         return GetCore().DeflateClientRectHeight(height);
1438 }
1439
1440 bool
1441 _FormImpl::DeflateClientRectHeight(float height)
1442 {
1443         return GetCore().DeflateClientRectHeight(height);
1444 }
1445
1446 bool
1447 _FormImpl::RemoveHeader(void)
1448 {
1449         _HeaderImpl* pHeaderImpl = GetHeader();
1450
1451         if (pHeaderImpl)
1452         {
1453                 __pForm->RemoveHeader();
1454                 result r = GetLastResult();
1455                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1456                 Header* pHeader = pHeaderImpl->GetHeader();
1457
1458                 delete pHeader;
1459         }
1460         else
1461                 return false;
1462
1463         return true;
1464 }
1465
1466 bool
1467 _FormImpl::RemoveFooter(void)
1468 {
1469         _FooterImpl* pFooterImpl = GetFooter();
1470
1471         if (pFooterImpl)
1472         {
1473                 __pForm->RemoveFooter();
1474                 result r = GetLastResult();
1475                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1476                 Footer* pFooter = pFooterImpl->GetFooter();
1477
1478                 delete pFooter;
1479         }
1480         else
1481         {
1482                 return false;
1483         }
1484
1485         return true;
1486 }
1487
1488 // Ki-Dong,Hong.Temp
1489 bool
1490 _FormImpl::RemoveTabImpl(void)
1491 {
1492         _TabImpl* pTabImpl = GetTabImpl();
1493
1494         if (pTabImpl)
1495         {
1496                 __pForm->RemoveTab();
1497                 result r = GetLastResult();
1498                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1499                 Tab* pTab = pTabImpl->GetTab();
1500
1501                 pTabImpl->DeleteTab(pTab);
1502         }
1503         else
1504         {
1505                 return false;
1506         }
1507
1508         return true;
1509 }
1510
1511 DataBindingContext*
1512 _FormImpl::GetDataBindingContextN(void) const
1513 {
1514         return _DataBindingContextImpl::GetDataBindingContextN(*this);
1515 }
1516
1517 result
1518 _FormImpl::OnAttaching(const _Control* pParent)
1519 {
1520         result r = E_SUCCESS;
1521         _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>((pParent)));
1522         if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1523         {
1524                 SysTryReturnResult(NID_UI_CTRL, pFrame != null, E_INVALID_ARG, "A Form which has FORM_STYLE_INDICATOR style cannot be added to a container except Frame.");
1525         }
1526         r = _ControlImpl::OnAttaching(pParent);
1527         return r;
1528 }
1529
1530 result
1531 _FormImpl::OnAttachedToMainTree(void)
1532 {
1533         result r = E_SUCCESS;
1534   SetFocused();
1535
1536   r = GetCore().AttachedToMainTree();
1537   r = _ContainerImpl::OnAttachedToMainTree();
1538
1539         FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1540
1541         if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1542         {
1543                 indicatorBounds = GetCore().GetIndicatorBoundsF();
1544                 r = GetLastResult();
1545                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1546         }
1547
1548         _HeaderImpl* pHeader = GetHeader();
1549         _FooterImpl* pFooter = GetFooter();
1550         _TabImpl* pTabImpl = GetTabImpl();
1551
1552         if (pHeader)
1553         {
1554                 if (GetCore().IsIndicatorTranslucent())
1555                 {
1556                         if (!GetCore().IsHeaderTranslucent())
1557                         {
1558                                 indicatorBounds.height = 0.0f;
1559                         }
1560                         else
1561                         {
1562                                 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
1563                                 {
1564                                         indicatorBounds.height = 0.0f;
1565                                 }
1566                         }
1567                 }
1568                 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1569                 GetCore().SetHeaderBounds(bounds);
1570         }
1571
1572         float titleHeight = 0.0f;
1573
1574         if (pHeader)
1575         {
1576                 titleHeight = pHeader->GetBoundsF().height;
1577         }
1578
1579         if (pTabImpl)
1580         {
1581                 float posY = indicatorBounds.height + titleHeight;
1582
1583                         FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1584                         GetCore().SetTabBounds(bounds);
1585         }
1586
1587         if (pFooter)
1588         {
1589                 float adjHeight = 0.0f;
1590
1591                 if (!(GetCore().GetFooter()->GetVisibleState()) || GetCore().IsFooterTranslucent())
1592                 {
1593                         adjHeight = GetCore().GetToolbarHeightF(false);
1594                 }
1595
1596                 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1597                                 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1598                 {
1599                         adjHeight = GetCore().GetToolbarHeightF(false);
1600                 }
1601
1602                 FloatRectangle clientbounds = GetClientBoundsF();
1603                 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - adjHeight, clientbounds.width, GetCore().GetToolbarHeightF(false));
1604
1605                 GetCore().SetFooterBounds(bounds);
1606         }
1607
1608         UpdateOrientationStatus();
1609
1610         if (__pOriAgent)
1611         {
1612                 __pOriAgent->RequestOrientationEvent();
1613         }
1614
1615         return r;
1616 }
1617
1618 result
1619 _FormImpl::OnDetachingFromMainTree(void)
1620 {
1621         result r = E_SUCCESS;
1622         r = GetCore().DetachingFromMainTree();
1623         r = _ContainerImpl::OnDetachingFromMainTree();
1624
1625         return r;
1626 }
1627
1628 bool
1629 _FormImpl::OnNotifiedN(const _ControlImpl& source, IList* pArgs)
1630 {
1631         String* pString = dynamic_cast <Tizen::Base::String*>(pArgs->GetAt(0));
1632         if (pString)
1633         {
1634                 if (*pString == _REQUEST_ORIENTATION_EVENT)
1635                 {
1636                         if (__pOriAgent)
1637                         {
1638                                 __pOriAgent->FireOrientationEvent();
1639                         }
1640
1641                         pArgs->RemoveAll(true);
1642                         delete pArgs;
1643
1644                         return true;
1645                 }
1646         }
1647
1648         return false;
1649 }
1650
1651 void
1652 _FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source)
1653 {
1654         if (__pFormBackEventListener)
1655         {
1656                 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1657                 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1658                 if (pForm)
1659                 {
1660                         __pFormBackEventListener->OnFormBackRequested(*pForm);
1661                 }
1662                 else
1663                 {
1664                         return;
1665                 }
1666         }
1667 }
1668
1669 void
1670 _FormImpl::OnFormMenuRequested(Tizen::Ui::Controls::_Form& source)
1671 {
1672         if (__pFormMenuEventListener)
1673         {
1674                 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1675                 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1676                 if (pForm)
1677                 {
1678                         __pFormMenuEventListener->OnFormMenuRequested(*pForm);
1679                 }
1680                 else
1681                 {
1682                         return;
1683                 }
1684         }
1685 }
1686
1687 OrientationStatus
1688 _FormImpl::OnFormOrientationStatusRequested(void)
1689 {
1690         _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
1691         SysAssert(pImplManager);
1692
1693         OrientationStatus status = ORIENTATION_STATUS_PORTRAIT;
1694         int appType = _AppInfo::GetAppType();
1695         if (!(appType & _APP_TYPE_IME_APP))
1696         {
1697                 status = pImplManager->GetOrientationStatus(GetOrientation());
1698         }
1699         return status;
1700 }
1701
1702 bool
1703 _FormImpl::IsOpaque(void) const
1704 {
1705         //return true;
1706         return false;
1707 }
1708
1709 _Softkey
1710 _FormImpl::ConvertSoftkey(Softkey softkey) const
1711 {
1712         _Softkey _softkey;
1713
1714         if (softkey == SOFTKEY_0)
1715         {
1716                 _softkey = _SOFTKEY_0;
1717         }
1718         else if (softkey == SOFTKEY_1)
1719         {
1720                 _softkey = _SOFTKEY_1;
1721         }
1722         else
1723         {
1724                 _softkey = _SOFTKEY_COUNT;
1725         }
1726
1727         return _softkey;
1728 }
1729
1730 result
1731 _FormImpl::SetNotificationTrayOpenEnabled(bool enable)
1732 {
1733         return GetCore().SetNotificationTrayOpenEnabled(enable);
1734 }
1735
1736 bool
1737 _FormImpl::IsNotificationTrayOpenEnabled(void) const
1738 {
1739         return GetCore().IsNotificationTrayOpenEnabled();
1740 }
1741
1742 class _FormMaker
1743         : public _UiBuilderControlMaker
1744 {
1745 public:
1746         _FormMaker(_UiBuilder* uibuilder)
1747                 : _UiBuilderControlMaker(uibuilder){};
1748         virtual ~_FormMaker()
1749         {
1750         };
1751         static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1752         {
1753                 _FormMaker* pFormMaker = new (std::nothrow) _FormMaker(uibuilder);
1754                 return pFormMaker;
1755         };
1756 protected:
1757         virtual Control* Make(_UiBuilderControl* pControl)
1758         {
1759                 _UiBuilderControlLayout* pControlProperty = null;
1760                 result r = E_SUCCESS;
1761                 int style = 0;
1762                 int opacity = 0;
1763                 Tizen::Base::String elementString;
1764                 bool isTitleAlign = false;
1765                 Color color;
1766
1767                 HorizontalAlignment align = ALIGNMENT_CENTER;
1768                 Form* pForm = (Form*) GetContainer();
1769
1770                 // Get control manager
1771                 _ControlManager* pControlManager = _ControlManager::GetInstance();
1772                 if (pControlManager == null)
1773                 {
1774                         SysLog(NID_UI_CTRL, "Unable to get the control manager.n");
1775                         return null;
1776                 }
1777                 FloatDimension screenSize = pControlManager->GetScreenSizeF();
1778
1779                 //Set rect
1780                 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(0.0f, 0.0f, screenSize.width, screenSize.height);
1781                 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(0.0f, 0.0f, screenSize.height, screenSize.width);
1782
1783                 // Get device orientation
1784                 app_device_orientation_e deviceOrientation = app_get_device_orientation();
1785                 bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270);
1786
1787                 if (isHorizontal)
1788                 {
1789                         pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE);
1790                 }
1791                 else
1792                 {
1793                         pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1794                 }
1795
1796                 if (pControlProperty == null)
1797                 {
1798                         SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Can't read attributes");
1799                         return null;
1800                 }
1801
1802                 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1803                 Tizen::Base::String styleString;
1804                 styleString = pControlProperty->GetStyle();
1805
1806                 if (styleString.Contains(L"FORM_STYLE_TITLE"))
1807                 {
1808                         style |= FORM_STYLE_TITLE;
1809                 }
1810                 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_0"))
1811                 {
1812                         style |= FORM_STYLE_SOFTKEY_0;
1813                 }
1814                 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_1"))
1815                 {
1816                         style |= FORM_STYLE_SOFTKEY_1;
1817                 }
1818                 if (styleString.Contains(L"FORM_STYLE_OPTIONKEY"))
1819                 {
1820                         style |= FORM_STYLE_OPTIONKEY;
1821                 }
1822                 if (styleString.Contains(L"FORM_STYLE_INDICATOR"))
1823                 {
1824                         if (styleString.Contains(L"FORM_STYLE_INDICATOR_AUTO_HIDE"))
1825                         {
1826                                 style |= FORM_STYLE_INDICATOR_AUTO_HIDE;
1827                         }
1828                         else
1829                         {
1830                                 style |= FORM_STYLE_INDICATOR;
1831                         }
1832                 }
1833                 if (styleString.Contains(L"FORM_STYLE_PORTRAIT_INDICATOR"))
1834                 {
1835                         if (styleString.Contains(L"FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE"))
1836                         {
1837                                 style |= FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE;
1838                         }
1839                         else
1840                         {
1841                                 style |= FORM_STYLE_PORTRAIT_INDICATOR;
1842                         }
1843                 }
1844                 if (styleString.Contains(L"FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE"))
1845                 {
1846                         style |= FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE;
1847                 }
1848                 if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
1849                 {
1850                         style |= FORM_STYLE_TEXT_TAB;
1851                 }
1852                 if (styleString.Contains(L"FORM_STYLE_ICON_TAB"))
1853                 {
1854                         style |= FORM_STYLE_ICON_TAB;
1855                 }
1856                 if (styleString.Contains(L"FORM_STYLE_HEADER"))
1857                 {
1858                         style |= FORM_STYLE_HEADER;
1859                 }
1860                 if (styleString.Contains(L"FORM_STYLE_FOOTER"))
1861                 {
1862                         style |= FORM_STYLE_FOOTER;
1863                 }
1864
1865                 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1866                 __pLayoutMaker->GetLayoutType(pControlProperty, layoutType);
1867                 if (layoutType == UIBUILDER_LAYOUT_NONE)
1868                 {
1869                         // Construct
1870                         r = pForm->Construct(style);
1871                 }
1872                 else
1873                 {
1874                         Layout* pPortraitLayout = null;
1875                         Layout* pLandscapeLayout = null;
1876                         result tempResult = E_SUCCESS;
1877                         tempResult = __pLayoutMaker->GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout);
1878                         if (E_SUCCESS == tempResult)
1879                         {
1880                                 r = pForm->Construct(*pPortraitLayout, *pLandscapeLayout, style);
1881                         }
1882                         else
1883                         {
1884                                 r = tempResult;
1885                         }
1886
1887                         _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1888
1889                         if (__pLayoutMaker->GetLayoutType(pControlProperty, layoutType) == false)
1890                         {
1891                                 return null;
1892                         }
1893
1894                         if ( layoutType == UIBUILDER_LAYOUT_GRID)
1895                         {
1896                                 for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
1897                                 {
1898                                         GridLayout* pGridLayout = null;
1899                                         pControlProperty = pControl->GetAttribute(i);
1900
1901                                         if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT)
1902                                         {
1903                                                 pGridLayout = dynamic_cast<GridLayout*>(pPortraitLayout);
1904                                         }
1905                                         else
1906                                         {
1907                                                 pGridLayout = dynamic_cast<GridLayout*>(pLandscapeLayout);
1908                                         }
1909                                         __pLayoutMaker->SetGridLayoutContainerProperty(pGridLayout, pControlProperty);
1910                                 }
1911                         }
1912                         delete pPortraitLayout;
1913                         if (pPortraitLayout != pLandscapeLayout)
1914                         {
1915                                 delete pLandscapeLayout;
1916                         }
1917                 }
1918
1919                 if (r != E_SUCCESS)
1920                 {
1921                         SysLog(NID_UI_CTRL, "Failed to create Form.");
1922                         return null;
1923                 }
1924
1925                 // Set Property
1926                 if (pControl->GetElement(L"titleAlign", elementString))
1927                 {
1928                         if (elementString.Equals(L"ALIGN_CENTER", false))
1929                         {
1930                                 align = ALIGNMENT_CENTER;
1931                         }
1932                         else if (elementString.Equals(L"ALIGN_RIGHT", false))
1933                         {
1934                                 align = ALIGNMENT_RIGHT;
1935                         }
1936                         else
1937                         {
1938                                 align = ALIGNMENT_LEFT;
1939                         }
1940                         isTitleAlign = true;
1941                 }
1942
1943                 if (style & FORM_STYLE_TITLE)
1944                 {
1945                         if (pControl->GetElement(L"title", elementString))
1946                         {
1947                                 if (isTitleAlign)
1948                                 {
1949                                         pForm->SetTitleText(elementString, align);
1950                                 }
1951                                 else
1952                                 {
1953                                         pForm->SetTitleText(elementString);
1954                                 }
1955                         }
1956                         else
1957                         {
1958                                 if (isTitleAlign)
1959                                 {
1960                                         pForm->SetTitleText(L"", align);
1961                                 }
1962                                 else
1963                                 {
1964                                         pForm->SetTitleText(L"");
1965                                 }
1966                         }
1967                 }
1968
1969                 if (pControl->GetElement(L"titleIcon", elementString))
1970                 {
1971                         Bitmap* pBitmap = null;
1972                         pBitmap = LoadBitmapN(elementString);
1973                         if (pBitmap != null)
1974                         {
1975                                 r = pForm->SetTitleIcon(pBitmap);
1976                                 delete pBitmap;
1977                                 if (IsFailed(r))
1978                                 {
1979                                         SysLog(NID_UI_CTRL, "Failed to set TitleIcon.");
1980                                 }
1981                         }
1982                 }
1983
1984                 if (pControl->GetElement(L"softKey0Text", elementString))
1985                 {
1986                         pForm->SetSoftkeyText(SOFTKEY_0, elementString);
1987                 }
1988                 if (pControl->GetElement(L"softKey1Text", elementString))
1989                 {
1990                         pForm->SetSoftkeyText(SOFTKEY_1, elementString);
1991                 }
1992                 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
1993                 {
1994                         Base::Integer::Parse(elementString, opacity);
1995                 }
1996                 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
1997                 {
1998                         ConvertStringToColor32(elementString, opacity, color);
1999                         pForm->SetBackgroundColor(color);
2000                 }
2001                 else
2002                 {
2003                         Color color;
2004                         r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color);
2005                         if (r == E_SUCCESS)
2006                         {
2007                                 pForm->SetBackgroundColor(color);
2008                         }
2009                         else
2010                         {
2011                                 pForm->SetBackgroundColor(0xff000000);
2012                         }
2013                 }
2014
2015                 if (pControl->GetElement(L"softKey0Icon", elementString) || pControl->GetElement(L"softKey0NormalIcon", elementString))
2016                 {
2017                         Bitmap* pNormalBitmap = null;
2018                         Bitmap* pPressedBitmap = null;
2019                         pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2020
2021                         if (pNormalBitmap != null)
2022                         {
2023                                 if (pControl->GetElement(L"softKey0PressedIcon", elementString))
2024                                 {
2025                                         pPressedBitmap = LoadBitmapN(elementString);
2026                                 }
2027
2028                                 if (pPressedBitmap != null)
2029                                 {
2030                                         pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, pPressedBitmap);
2031                                         delete pNormalBitmap;
2032                                         delete pPressedBitmap;
2033                                 }
2034                                 else
2035                                 {
2036                                         pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, null);
2037                                         delete pNormalBitmap;
2038                                 }
2039                         }
2040                 }
2041                 if (pControl->GetElement(L"softKey1Icon", elementString) || pControl->GetElement(L"softKey1NormalIcon", elementString))
2042                 {
2043                         Bitmap* pNormalBitmap = null;
2044                         Bitmap* pPressedBitmap = null;
2045                         pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2046
2047                         if (pNormalBitmap != null)
2048                         {
2049                                 if (pControl->GetElement(L"softKey1PressedIcon", elementString))
2050                                 {
2051                                         pPressedBitmap = LoadBitmapN(elementString); // __image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2052                                 }
2053
2054                                 if (pPressedBitmap != null)
2055                                 {
2056                                         pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, pPressedBitmap);
2057                                         delete pNormalBitmap;
2058                                         delete pPressedBitmap;
2059                                 }
2060                                 else
2061                                 {
2062                                         pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, null);
2063                                         delete pNormalBitmap;
2064                                 }
2065                         }
2066                 }
2067
2068                 if (pControl->GetElement(L"Orientation", elementString) || pControl->GetElement(L"orientation", elementString))
2069                 {
2070                         //ORIENTATION_NONE,
2071                         //ORIENTATION_PORTRAIT,
2072                         //ORIENTATION_LANDSACPE,
2073                         //ORIENTATION_PORTRAIT_REVERSE,
2074                         //ORIENTATION_LANDSACPE_REVERSE,
2075                         //ORIENTATION_AUTO = 6,
2076                         //ORIENTATION_AUTO_FOUR_DIRECTION = 8,
2077
2078                         if (elementString.Equals(L"Automatic:2Dir", false) || elementString.Equals(L"Automatic", false))
2079                         {
2080                                 pForm->SetOrientation(ORIENTATION_AUTOMATIC);
2081                         }
2082                         else if (elementString.Equals(L"Automatic:4Dir", false))
2083                         {
2084                                 pForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
2085                         }
2086                         else if (elementString.Equals(L"Landscape", false))
2087                         {
2088                                 pForm->SetOrientation(ORIENTATION_LANDSCAPE);
2089                                 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2090                         }
2091                         else if (elementString.Equals(L"Landscape:Reverse", false))
2092                         {
2093                                 pForm->SetOrientation(ORIENTATION_LANDSCAPE_REVERSE);
2094                                 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2095                         }
2096                         else if (elementString.Equals(L"Portrait", false))
2097                         {
2098                                 pForm->SetOrientation(ORIENTATION_PORTRAIT);
2099                                 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2100                         }
2101                         else if (elementString.Equals(L"Portrait:Reverse", false))
2102                         {
2103                                 pForm->SetOrientation(ORIENTATION_PORTRAIT_REVERSE);
2104                                 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2105                         }
2106                 }
2107
2108                 if (style & FORM_STYLE_HEADER)
2109                 {
2110                         if (pControl->GetElement(L"translucentHeader", elementString))
2111                         {
2112                                 if (elementString.Equals(L"true", false))
2113                                 {
2114                                         pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_HEADER, true);
2115                                 }
2116                         }
2117                 }
2118
2119                 if (style & FORM_STYLE_FOOTER)
2120                 {
2121                         if (pControl->GetElement(L"translucentFooter", elementString))
2122                         {
2123                                 if (elementString.Equals(L"true", false))
2124                                 {
2125                                         pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_FOOTER, true);
2126                                 }
2127                         }
2128                 }
2129
2130                 if (style & FORM_STYLE_INDICATOR)
2131                 {
2132                         if (pControl->GetElement(L"translucentIndicator", elementString))
2133                         {
2134                                 if (elementString.Equals(L"true", false))
2135                                 {
2136                                         pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
2137                                 }
2138                         }
2139                 }
2140
2141                 return pForm;
2142         }
2143
2144 };
2145
2146 _FormRegister::_FormRegister()
2147 {
2148         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2149         pUiBuilderControlTableManager->RegisterControl(L"Form", _FormMaker::GetInstance);
2150 }
2151 _FormRegister::~_FormRegister()
2152 {
2153         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2154         pUiBuilderControlTableManager->UnregisterControl(L"Form");
2155 }
2156 static _FormRegister FormRegisterToUiBuilder;
2157 }}} // Tizen::Ui::Controls