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