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