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