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