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