Merge "Fixed jira issue." 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                                         else
1285                                         {
1286                                                 if (FORM_STYLE_INDICATOR_AUTO_HIDE & GetFormStyle())
1287                                                 {
1288                                                         adjHeight = 0.0f;
1289                                                 }
1290                                         }
1291                                 }
1292                         }
1293                 }
1294
1295                 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1296                 GetCore().SetHeaderBounds(bounds);
1297         }
1298
1299         if (GetCore().HasTab())                         // Ki-Dong,Hong.Temp
1300         {
1301                 float titleHeight = 0.0f;
1302
1303                 if (GetCore().GetFormStyle() & FORM_STYLE_TITLE)
1304                 {
1305                         if (GetCore().HasHeader())
1306                         {
1307                                 _HeaderImpl* pHeaderImpl = GetHeader();
1308                                 if (pHeaderImpl)
1309                                 {
1310                                         titleHeight = pHeaderImpl->GetBoundsF().height;
1311                                 }
1312                         }
1313                 }
1314
1315                 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1316
1317                 if (GetCore().IsIndicatorVisible())
1318                 {
1319                         indicatorBounds = GetCore().GetIndicatorBoundsF();
1320                         if (GetCore().IsIndicatorTranslucent())
1321                         {
1322                                 if (!GetCore().IsHeaderTranslucent())
1323                                 {
1324                                         indicatorBounds.height = 0.0f;
1325                                 }
1326                                 else
1327                                 {
1328                                         if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1329                                         {
1330                                                 indicatorBounds.height = 0.0f;
1331                                         }
1332                                 }
1333                         }
1334                 }
1335
1336                 float posY = indicatorBounds.height + titleHeight;
1337
1338                 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1339                 GetCore().SetTabBounds(bounds);
1340         }
1341
1342         if (GetCore().HasFooter())
1343         {
1344                 if (GetCore().GetFooter()->GetVisibleState() && !GetCore().IsFooterTranslucent())
1345                 {
1346                         adjHeight = 0.0f;
1347                 }
1348                 else
1349                 {
1350                         adjHeight = GetCore().GetToolbarHeightF(false);
1351                 }
1352
1353                 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1354                                 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1355                 {
1356                         adjHeight = GetCore().GetToolbarHeightF(false);
1357                 }
1358
1359                 FloatRectangle bounds(0.0f, GetClientBoundsF().y + GetClientBoundsF().height - adjHeight,
1360                                                                                 GetClientBoundsF().width, GetCore().GetToolbarHeightF(false));
1361                 GetCore().SetFooterBounds(bounds);
1362         }
1363 }
1364
1365 _HeaderImpl*
1366 _FormImpl::CreateHeaderN(void)
1367 {
1368         result r = E_SUCCESS;
1369
1370         Header* pHeader = new (std::nothrow) Header;
1371         SysTryReturn(NID_UI_CTRL, pHeader, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1372
1373         r = pHeader->Construct();
1374         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1375
1376         _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*pHeader);
1377
1378         SetLastResult(E_SUCCESS);
1379
1380         return pHeaderImpl;
1381 }
1382
1383 _FooterImpl*
1384 _FormImpl::CreateFooterN(void)
1385 {
1386         result r = E_SUCCESS;
1387
1388         Footer* pFooter = new (std::nothrow) Footer;
1389         SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1390
1391         r = pFooter->Construct();
1392         SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1393
1394         _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*pFooter);
1395
1396         SetLastResult(E_SUCCESS);
1397
1398         return pFooterImpl;
1399 }
1400
1401 // Ki-Dong,Hong.Temp
1402 _TabImpl*
1403 _FormImpl::CreateTabImplN(void)
1404 {
1405         //result r = E_SUCCESS;
1406
1407         //Tab* pTab = new (std::nothrow) Tab;
1408         //SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
1409
1410         //r = pTab->Construct();
1411         //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Unable to consturct tab.");
1412
1413         //return pTab->GetTabImpl();
1414         Tab* pTab = _TabImpl::CreateTabN();
1415         SysTryReturn(NID_UI_CTRL, pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1416
1417         _TabImpl* pTabImpl = _TabImpl::GetInstance(*pTab);
1418
1419         SetLastResult(E_SUCCESS);
1420
1421         return pTabImpl;
1422 }
1423
1424 bool
1425 _FormImpl::DeflateClientRectHeight(int height)
1426 {
1427         return GetCore().DeflateClientRectHeight(height);
1428 }
1429
1430 bool
1431 _FormImpl::DeflateClientRectHeight(float height)
1432 {
1433         return GetCore().DeflateClientRectHeight(height);
1434 }
1435
1436 bool
1437 _FormImpl::RemoveHeader(void)
1438 {
1439         _HeaderImpl* pHeaderImpl = GetHeader();
1440
1441         if (pHeaderImpl)
1442         {
1443                 __pForm->RemoveHeader();
1444                 result r = GetLastResult();
1445                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1446                 Header* pHeader = pHeaderImpl->GetHeader();
1447
1448                 delete pHeader;
1449         }
1450         else
1451                 return false;
1452
1453         return true;
1454 }
1455
1456 bool
1457 _FormImpl::RemoveFooter(void)
1458 {
1459         _FooterImpl* pFooterImpl = GetFooter();
1460
1461         if (pFooterImpl)
1462         {
1463                 __pForm->RemoveFooter();
1464                 result r = GetLastResult();
1465                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1466                 Footer* pFooter = pFooterImpl->GetFooter();
1467
1468                 delete pFooter;
1469         }
1470         else
1471         {
1472                 return false;
1473         }
1474
1475         return true;
1476 }
1477
1478 // Ki-Dong,Hong.Temp
1479 bool
1480 _FormImpl::RemoveTabImpl(void)
1481 {
1482         _TabImpl* pTabImpl = GetTabImpl();
1483
1484         if (pTabImpl)
1485         {
1486                 __pForm->RemoveTab();
1487                 result r = GetLastResult();
1488                 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1489                 Tab* pTab = pTabImpl->GetTab();
1490
1491                 pTabImpl->DeleteTab(pTab);
1492         }
1493         else
1494         {
1495                 return false;
1496         }
1497
1498         return true;
1499 }
1500
1501 DataBindingContext*
1502 _FormImpl::GetDataBindingContextN(void) const
1503 {
1504         return _DataBindingContextImpl::GetDataBindingContextN(*this);
1505 }
1506
1507 result
1508 _FormImpl::OnAttaching(const _Control* pParent)
1509 {
1510         result r = E_SUCCESS;
1511         _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>((pParent)));
1512         if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1513         {
1514                 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.");
1515         }
1516         r = _ControlImpl::OnAttaching(pParent);
1517         return r;
1518 }
1519
1520 result
1521 _FormImpl::OnAttachedToMainTree(void)
1522 {
1523         result r = E_SUCCESS;
1524   SetFocused();
1525
1526   r = GetCore().AttachedToMainTree();
1527   r = _ContainerImpl::OnAttachedToMainTree();
1528
1529         FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1530
1531         if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1532         {
1533                 indicatorBounds = GetCore().GetIndicatorBoundsF();
1534                 r = GetLastResult();
1535                 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1536         }
1537
1538         _HeaderImpl* pHeader = GetHeader();
1539         _FooterImpl* pFooter = GetFooter();
1540         _TabImpl* pTabImpl = GetTabImpl();
1541
1542         if (pHeader)
1543         {
1544                 if (GetCore().IsIndicatorTranslucent())
1545                 {
1546                         if (!GetCore().IsHeaderTranslucent())
1547                         {
1548                                 indicatorBounds.height = 0.0f;
1549                         }
1550                         else
1551                         {
1552                                 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
1553                                 {
1554                                         indicatorBounds.height = 0.0f;
1555                                 }
1556                         }
1557                 }
1558                 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1559                 GetCore().SetHeaderBounds(bounds);
1560         }
1561
1562         float titleHeight = 0.0f;
1563
1564         if (pHeader)
1565         {
1566                 titleHeight = pHeader->GetBoundsF().height;
1567         }
1568
1569         if (pTabImpl)
1570         {
1571                 float posY = indicatorBounds.height + titleHeight;
1572
1573                         FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1574                         GetCore().SetTabBounds(bounds);
1575         }
1576
1577         if (pFooter)
1578         {
1579                 float adjHeight = 0.0f;
1580
1581                 if (!(GetCore().GetFooter()->GetVisibleState()) || GetCore().IsFooterTranslucent())
1582                 {
1583                         adjHeight = GetCore().GetToolbarHeightF(false);
1584                 }
1585
1586                 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1587                                 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1588                 {
1589                         adjHeight = GetCore().GetToolbarHeightF(false);
1590                 }
1591
1592                 FloatRectangle clientbounds = GetClientBoundsF();
1593                 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - adjHeight, clientbounds.width, GetCore().GetToolbarHeightF(false));
1594
1595                 GetCore().SetFooterBounds(bounds);
1596         }
1597
1598         UpdateOrientationStatus();
1599
1600         if (__pOriAgent)
1601         {
1602                 __pOriAgent->RequestOrientationEvent();
1603         }
1604
1605         return r;
1606 }
1607
1608 result
1609 _FormImpl::OnDetachingFromMainTree(void)
1610 {
1611         result r = E_SUCCESS;
1612         r = GetCore().DetachingFromMainTree();
1613         r = _ContainerImpl::OnDetachingFromMainTree();
1614
1615         return r;
1616 }
1617
1618 bool
1619 _FormImpl::OnNotifiedN(const _ControlImpl& source, IList* pArgs)
1620 {
1621         String* pString = dynamic_cast <Tizen::Base::String*>(pArgs->GetAt(0));
1622         if (pString)
1623         {
1624                 if (*pString == _REQUEST_ORIENTATION_EVENT)
1625                 {
1626                         if (__pOriAgent)
1627                         {
1628                                 __pOriAgent->FireOrientationEvent();
1629                         }
1630
1631                         pArgs->RemoveAll(true);
1632                         delete pArgs;
1633
1634                         return true;
1635                 }
1636         }
1637
1638         return false;
1639 }
1640
1641 void
1642 _FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source)
1643 {
1644         if (__pFormBackEventListener)
1645         {
1646                 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1647                 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1648                 if (pForm)
1649                 {
1650                         __pFormBackEventListener->OnFormBackRequested(*pForm);
1651                 }
1652                 else
1653                 {
1654                         return;
1655                 }
1656         }
1657 }
1658
1659 void
1660 _FormImpl::OnFormMenuRequested(Tizen::Ui::Controls::_Form& source)
1661 {
1662         if (__pFormMenuEventListener)
1663         {
1664                 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1665                 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1666                 if (pForm)
1667                 {
1668                         __pFormMenuEventListener->OnFormMenuRequested(*pForm);
1669                 }
1670                 else
1671                 {
1672                         return;
1673                 }
1674         }
1675 }
1676
1677 OrientationStatus
1678 _FormImpl::OnFormOrientationStatusRequested(void)
1679 {
1680         _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
1681         SysAssert(pImplManager);
1682
1683         OrientationStatus status = ORIENTATION_STATUS_PORTRAIT;
1684         int appType = _AppInfo::GetAppType();
1685         if (!(appType & _APP_TYPE_IME_APP))
1686         {
1687                 status = pImplManager->GetOrientationStatus(GetOrientation());
1688         }
1689         return status;
1690 }
1691
1692 bool
1693 _FormImpl::IsOpaque(void) const
1694 {
1695         //return true;
1696         return false;
1697 }
1698
1699 _Softkey
1700 _FormImpl::ConvertSoftkey(Softkey softkey) const
1701 {
1702         _Softkey _softkey;
1703
1704         if (softkey == SOFTKEY_0)
1705         {
1706                 _softkey = _SOFTKEY_0;
1707         }
1708         else if (softkey == SOFTKEY_1)
1709         {
1710                 _softkey = _SOFTKEY_1;
1711         }
1712         else
1713         {
1714                 _softkey = _SOFTKEY_COUNT;
1715         }
1716
1717         return _softkey;
1718 }
1719
1720 result
1721 _FormImpl::SetNotificationTrayOpenEnabled(bool enable)
1722 {
1723         return GetCore().SetNotificationTrayOpenEnabled(enable);
1724 }
1725
1726 bool
1727 _FormImpl::IsNotificationTrayOpenEnabled(void) const
1728 {
1729         return GetCore().IsNotificationTrayOpenEnabled();
1730 }
1731
1732 class _FormMaker
1733         : public _UiBuilderControlMaker
1734 {
1735 public:
1736         _FormMaker(_UiBuilder* uibuilder)
1737                 : _UiBuilderControlMaker(uibuilder){};
1738         virtual ~_FormMaker()
1739         {
1740         };
1741         static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1742         {
1743                 _FormMaker* pFormMaker = new (std::nothrow) _FormMaker(uibuilder);
1744                 return pFormMaker;
1745         };
1746 protected:
1747         virtual Control* Make(_UiBuilderControl* pControl)
1748         {
1749                 _UiBuilderControlLayout* pControlProperty = null;
1750                 result r = E_SUCCESS;
1751                 int style = 0;
1752                 int opacity = 0;
1753                 Tizen::Base::String elementString;
1754                 bool isTitleAlign = false;
1755                 Color color;
1756
1757                 HorizontalAlignment align = ALIGNMENT_CENTER;
1758                 Form* pForm = (Form*) GetContainer();
1759
1760                 // Get control manager
1761                 _ControlManager* pControlManager = _ControlManager::GetInstance();
1762                 if (pControlManager == null)
1763                 {
1764                         SysLog(NID_UI_CTRL, "Unable to get the control manager.n");
1765                         return null;
1766                 }
1767                 FloatDimension screenSize = pControlManager->GetScreenSizeF();
1768
1769                 //Set rect
1770                 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(0.0f, 0.0f, screenSize.width, screenSize.height);
1771                 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(0.0f, 0.0f, screenSize.height, screenSize.width);
1772
1773                 // Get device orientation
1774                 app_device_orientation_e deviceOrientation = app_get_device_orientation();
1775                 bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270);
1776
1777                 if (isHorizontal)
1778                 {
1779                         pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE);
1780                 }
1781                 else
1782                 {
1783                         pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1784                 }
1785
1786                 if (pControlProperty == null)
1787                 {
1788                         SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Can't read attributes");
1789                         return null;
1790                 }
1791
1792                 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1793                 Tizen::Base::String styleString;
1794                 styleString = pControlProperty->GetStyle();
1795
1796                 if (styleString.Contains(L"FORM_STYLE_TITLE"))
1797                 {
1798                         style |= FORM_STYLE_TITLE;
1799                 }
1800                 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_0"))
1801                 {
1802                         style |= FORM_STYLE_SOFTKEY_0;
1803                 }
1804                 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_1"))
1805                 {
1806                         style |= FORM_STYLE_SOFTKEY_1;
1807                 }
1808                 if (styleString.Contains(L"FORM_STYLE_OPTIONKEY"))
1809                 {
1810                         style |= FORM_STYLE_OPTIONKEY;
1811                 }
1812                 if (styleString.Contains(L"FORM_STYLE_INDICATOR"))
1813                 {
1814                         if (styleString.Contains(L"FORM_STYLE_INDICATOR_AUTO_HIDE"))
1815                         {
1816                                 style |= FORM_STYLE_INDICATOR_AUTO_HIDE;
1817                         }
1818                         else
1819                         {
1820                                 style |= FORM_STYLE_INDICATOR;
1821                         }
1822                 }
1823                 if (styleString.Contains(L"FORM_STYLE_PORTRAIT_INDICATOR"))
1824                 {
1825                         if (styleString.Contains(L"FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE"))
1826                         {
1827                                 style |= FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE;
1828                         }
1829                         else
1830                         {
1831                                 style |= FORM_STYLE_PORTRAIT_INDICATOR;
1832                         }
1833                 }
1834                 if (styleString.Contains(L"FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE"))
1835                 {
1836                         style |= FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE;
1837                 }
1838                 if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
1839                 {
1840                         style |= FORM_STYLE_TEXT_TAB;
1841                 }
1842                 if (styleString.Contains(L"FORM_STYLE_ICON_TAB"))
1843                 {
1844                         style |= FORM_STYLE_ICON_TAB;
1845                 }
1846                 if (styleString.Contains(L"FORM_STYLE_HEADER"))
1847                 {
1848                         style |= FORM_STYLE_HEADER;
1849                 }
1850                 if (styleString.Contains(L"FORM_STYLE_FOOTER"))
1851                 {
1852                         style |= FORM_STYLE_FOOTER;
1853                 }
1854
1855                 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1856                 __pLayoutMaker->GetLayoutType(pControlProperty, layoutType);
1857                 if (layoutType == UIBUILDER_LAYOUT_NONE)
1858                 {
1859                         // Construct
1860                         r = pForm->Construct(style);
1861                 }
1862                 else
1863                 {
1864                         Layout* pPortraitLayout = null;
1865                         Layout* pLandscapeLayout = null;
1866                         result tempResult = E_SUCCESS;
1867                         tempResult = __pLayoutMaker->GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout);
1868                         if (E_SUCCESS == tempResult)
1869                         {
1870                                 r = pForm->Construct(*pPortraitLayout, *pLandscapeLayout, style);
1871                         }
1872                         else
1873                         {
1874                                 r = tempResult;
1875                         }
1876
1877                         _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1878
1879                         if (__pLayoutMaker->GetLayoutType(pControlProperty, layoutType) == false)
1880                         {
1881                                 return null;
1882                         }
1883
1884                         if ( layoutType == UIBUILDER_LAYOUT_GRID)
1885                         {
1886                                 for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
1887                                 {
1888                                         GridLayout* pGridLayout = null;
1889                                         pControlProperty = pControl->GetAttribute(i);
1890
1891                                         if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT)
1892                                         {
1893                                                 pGridLayout = dynamic_cast<GridLayout*>(pPortraitLayout);
1894                                         }
1895                                         else
1896                                         {
1897                                                 pGridLayout = dynamic_cast<GridLayout*>(pLandscapeLayout);
1898                                         }
1899                                         __pLayoutMaker->SetGridLayoutContainerProperty(pGridLayout, pControlProperty);
1900                                 }
1901                         }
1902                         delete pPortraitLayout;
1903                         if (pPortraitLayout != pLandscapeLayout)
1904                         {
1905                                 delete pLandscapeLayout;
1906                         }
1907                 }
1908
1909                 if (r != E_SUCCESS)
1910                 {
1911                         SysLog(NID_UI_CTRL, "Failed to create Form.");
1912                         return null;
1913                 }
1914
1915                 // Set Property
1916                 if (pControl->GetElement(L"titleAlign", elementString))
1917                 {
1918                         if (elementString.Equals(L"ALIGN_CENTER", false))
1919                         {
1920                                 align = ALIGNMENT_CENTER;
1921                         }
1922                         else if (elementString.Equals(L"ALIGN_RIGHT", false))
1923                         {
1924                                 align = ALIGNMENT_RIGHT;
1925                         }
1926                         else
1927                         {
1928                                 align = ALIGNMENT_LEFT;
1929                         }
1930                         isTitleAlign = true;
1931                 }
1932
1933                 if (style & FORM_STYLE_TITLE)
1934                 {
1935                         if (pControl->GetElement(L"title", elementString))
1936                         {
1937                                 if (isTitleAlign)
1938                                 {
1939                                         pForm->SetTitleText(elementString, align);
1940                                 }
1941                                 else
1942                                 {
1943                                         pForm->SetTitleText(elementString);
1944                                 }
1945                         }
1946                         else
1947                         {
1948                                 if (isTitleAlign)
1949                                 {
1950                                         pForm->SetTitleText(L"", align);
1951                                 }
1952                                 else
1953                                 {
1954                                         pForm->SetTitleText(L"");
1955                                 }
1956                         }
1957                 }
1958
1959                 if (pControl->GetElement(L"titleIcon", elementString))
1960                 {
1961                         Bitmap* pBitmap = null;
1962                         pBitmap = LoadBitmapN(elementString);
1963                         if (pBitmap != null)
1964                         {
1965                                 r = pForm->SetTitleIcon(pBitmap);
1966                                 delete pBitmap;
1967                                 if (IsFailed(r))
1968                                 {
1969                                         SysLog(NID_UI_CTRL, "Failed to set TitleIcon.");
1970                                 }
1971                         }
1972                 }
1973
1974                 if (pControl->GetElement(L"softKey0Text", elementString))
1975                 {
1976                         pForm->SetSoftkeyText(SOFTKEY_0, elementString);
1977                 }
1978                 if (pControl->GetElement(L"softKey1Text", elementString))
1979                 {
1980                         pForm->SetSoftkeyText(SOFTKEY_1, elementString);
1981                 }
1982                 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
1983                 {
1984                         Base::Integer::Parse(elementString, opacity);
1985                 }
1986                 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
1987                 {
1988                         ConvertStringToColor32(elementString, opacity, color);
1989                         pForm->SetBackgroundColor(color);
1990                 }
1991                 else
1992                 {
1993                         Color color;
1994                         r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color);
1995                         if (r == E_SUCCESS)
1996                         {
1997                                 pForm->SetBackgroundColor(color);
1998                         }
1999                         else
2000                         {
2001                                 pForm->SetBackgroundColor(0xff000000);
2002                         }
2003                 }
2004
2005                 if (pControl->GetElement(L"softKey0Icon", elementString) || pControl->GetElement(L"softKey0NormalIcon", elementString))
2006                 {
2007                         Bitmap* pNormalBitmap = null;
2008                         Bitmap* pPressedBitmap = null;
2009                         pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2010
2011                         if (pNormalBitmap != null)
2012                         {
2013                                 if (pControl->GetElement(L"softKey0PressedIcon", elementString))
2014                                 {
2015                                         pPressedBitmap = LoadBitmapN(elementString);
2016                                 }
2017
2018                                 if (pPressedBitmap != null)
2019                                 {
2020                                         pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, pPressedBitmap);
2021                                         delete pNormalBitmap;
2022                                         delete pPressedBitmap;
2023                                 }
2024                                 else
2025                                 {
2026                                         pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, null);
2027                                         delete pNormalBitmap;
2028                                 }
2029                         }
2030                 }
2031                 if (pControl->GetElement(L"softKey1Icon", elementString) || pControl->GetElement(L"softKey1NormalIcon", elementString))
2032                 {
2033                         Bitmap* pNormalBitmap = null;
2034                         Bitmap* pPressedBitmap = null;
2035                         pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2036
2037                         if (pNormalBitmap != null)
2038                         {
2039                                 if (pControl->GetElement(L"softKey1PressedIcon", elementString))
2040                                 {
2041                                         pPressedBitmap = LoadBitmapN(elementString); // __image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2042                                 }
2043
2044                                 if (pPressedBitmap != null)
2045                                 {
2046                                         pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, pPressedBitmap);
2047                                         delete pNormalBitmap;
2048                                         delete pPressedBitmap;
2049                                 }
2050                                 else
2051                                 {
2052                                         pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, null);
2053                                         delete pNormalBitmap;
2054                                 }
2055                         }
2056                 }
2057
2058                 if (pControl->GetElement(L"Orientation", elementString) || pControl->GetElement(L"orientation", elementString))
2059                 {
2060                         //ORIENTATION_NONE,
2061                         //ORIENTATION_PORTRAIT,
2062                         //ORIENTATION_LANDSACPE,
2063                         //ORIENTATION_PORTRAIT_REVERSE,
2064                         //ORIENTATION_LANDSACPE_REVERSE,
2065                         //ORIENTATION_AUTO = 6,
2066                         //ORIENTATION_AUTO_FOUR_DIRECTION = 8,
2067
2068                         if (elementString.Equals(L"Automatic:2Dir", false) || elementString.Equals(L"Automatic", false))
2069                         {
2070                                 pForm->SetOrientation(ORIENTATION_AUTOMATIC);
2071                         }
2072                         else if (elementString.Equals(L"Automatic:4Dir", false))
2073                         {
2074                                 pForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
2075                         }
2076                         else if (elementString.Equals(L"Landscape", false))
2077                         {
2078                                 pForm->SetOrientation(ORIENTATION_LANDSCAPE);
2079                                 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2080                         }
2081                         else if (elementString.Equals(L"Landscape:Reverse", false))
2082                         {
2083                                 pForm->SetOrientation(ORIENTATION_LANDSCAPE_REVERSE);
2084                                 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2085                         }
2086                         else if (elementString.Equals(L"Portrait", false))
2087                         {
2088                                 pForm->SetOrientation(ORIENTATION_PORTRAIT);
2089                                 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2090                         }
2091                         else if (elementString.Equals(L"Portrait:Reverse", false))
2092                         {
2093                                 pForm->SetOrientation(ORIENTATION_PORTRAIT_REVERSE);
2094                                 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2095                         }
2096                 }
2097
2098                 if (style & FORM_STYLE_HEADER)
2099                 {
2100                         if (pControl->GetElement(L"translucentHeader", elementString))
2101                         {
2102                                 if (elementString.Equals(L"true", false))
2103                                 {
2104                                         pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_HEADER, true);
2105                                 }
2106                         }
2107                 }
2108
2109                 if (style & FORM_STYLE_FOOTER)
2110                 {
2111                         if (pControl->GetElement(L"translucentFooter", elementString))
2112                         {
2113                                 if (elementString.Equals(L"true", false))
2114                                 {
2115                                         pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_FOOTER, true);
2116                                 }
2117                         }
2118                 }
2119
2120                 if (style & FORM_STYLE_INDICATOR)
2121                 {
2122                         if (pControl->GetElement(L"translucentIndicator", elementString))
2123                         {
2124                                 if (elementString.Equals(L"true", false))
2125                                 {
2126                                         pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
2127                                 }
2128                         }
2129                 }
2130
2131                 return pForm;
2132         }
2133
2134 };
2135
2136 _FormRegister::_FormRegister()
2137 {
2138         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2139         pUiBuilderControlTableManager->RegisterControl(L"Form", _FormMaker::GetInstance);
2140 }
2141 _FormRegister::~_FormRegister()
2142 {
2143         _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2144         pUiBuilderControlTableManager->UnregisterControl(L"Form");
2145 }
2146 static _FormRegister FormRegisterToUiBuilder;
2147 }}} // Tizen::Ui::Controls