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