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