2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0/
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.
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"
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;
60 #define OPTIONKEY SOFTKEY_COUNT
62 namespace Tizen { namespace Ui { namespace Controls
65 const String _REQUEST_ORIENTATION_EVENT = L"RequestOrientationEvent";
68 _FormImpl::FormSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const
71 Dimension dimension(0, 0);
78 _FormImpl::FormSizeInfo::GetDefaultMinimumSizeF(_ControlOrientation orientation) const
81 FloatDimension dimension(0.0f, 0.0f);
88 _FormImpl::GetInstance(const Form& form)
90 return static_cast<const _FormImpl*> (form._pControlImpl);
94 _FormImpl::GetInstance(Form& form)
96 return static_cast<_FormImpl*> (form._pControlImpl);
99 _FormImpl::_FormImpl(Form* pPublic, _Form* pCore, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout)
100 : _ContainerImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout)
102 , __pFormBackEventListener(null)
103 , __pFormMenuEventListener(null)
105 , __pImeOriAgent(null)
106 , __pLeftSoftkeyActionEvent(null)
107 , __pRightSoftkeyActionEvent(null)
108 , __pOptionMenuActionEvent(null)
112 int appType = _AppInfo::GetAppType();
113 if (appType & _APP_TYPE_IME_APP)
115 __pImeOriAgent = _ImeOrientationAgent::CreateInstanceN(*pPublic);
116 SysTryReturnVoidResult(NID_UI_CTRL, __pImeOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
120 __pOriAgent = _OrientationAgent::CreateInstanceN(*pPublic);
121 SysTryReturnVoidResult(NID_UI_CTRL, __pOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
125 _FormImpl::~_FormImpl(void)
129 delete __pImeOriAgent;
130 __pImeOriAgent = null;
139 if (__pLeftSoftkeyActionEvent)
141 delete __pLeftSoftkeyActionEvent;
142 __pLeftSoftkeyActionEvent = null;
145 if (__pRightSoftkeyActionEvent)
147 delete __pRightSoftkeyActionEvent;
148 __pRightSoftkeyActionEvent = null;
151 if (__pOptionMenuActionEvent)
153 delete __pOptionMenuActionEvent;
154 __pOptionMenuActionEvent = null;
157 __leftSoftkeyActionList.RemoveAll(false);
158 __rightSoftkeyActionList.RemoveAll(false);
170 _FormImpl::CreateFormImplN(Form* pControl, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout)
172 result r = E_SUCCESS;
173 _VisualElement* pVisualElement = null;
175 _Form* pCore = _Form::CreateFormN();
177 SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); // [ToDo] interpret last result.
179 _FormImpl* pImpl = new (std::nothrow) _FormImpl(pControl, pCore, pPublicPortraitLayout, pPublicLandscapeLayout);
181 r = _ControlImpl::CheckConstruction(pCore, pImpl);
182 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
184 const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
185 const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
187 _ControlOrientation orientation = pCore->GetOrientation();
189 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
191 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Form), portraitSize, orientation);
195 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Form), landscapeSize, orientation);
197 SysAssert(r == E_SUCCESS);
199 pCore->SetFormOrientationStatusEventListener(pImpl);
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.
207 SetLastResult(E_SUCCESS);
219 _FormImpl::GetPublicClassName(void) const
221 return "Tizen::Ui::Controls::Form";
225 _FormImpl::GetPublic(void) const
227 return static_cast<const Form&>(_ControlImpl::GetPublic());
231 _FormImpl::GetPublic(void)
233 return static_cast<Form&>(_ControlImpl::GetPublic());
237 _FormImpl::GetCore(void) const
239 return static_cast<const _Form&>(_ControlImpl::GetCore());
243 _FormImpl::GetCore(void)
245 return static_cast<_Form&>(_ControlImpl::GetCore());
249 _FormImpl::GetFocusControl(void)
255 _FormImpl::GetFormStyle(void) const
257 return GetCore().GetFormStyle();
261 _FormImpl::HasIndicator(void) const
263 return GetCore().HasIndicator();
267 _FormImpl::SetFormStyle(unsigned long formStyle)
269 result r = E_SUCCESS;
271 _HeaderImpl* pHeader = GetHeader();
272 _FooterImpl* pFooter = GetFooter();
273 _TabImpl* pTabImpl = GetTabImpl();
275 if (IsAttachedToMainTree())
277 if (FORM_STYLE_INDICATOR & formStyle)
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.");
284 if ((formStyle & FORM_STYLE_INDICATOR) && (formStyle & FORM_STYLE_INDICATOR_AUTO_HIDE))
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.");
291 if (((formStyle & FORM_STYLE_TITLE) || (formStyle & FORM_STYLE_TEXT_TAB) || (formStyle & FORM_STYLE_ICON_TAB)) && (formStyle & FORM_STYLE_HEADER))
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.");
300 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
306 if (((formStyle & FORM_STYLE_SOFTKEY_0) || (formStyle & FORM_STYLE_SOFTKEY_1) || (formStyle & FORM_STYLE_OPTIONKEY)) && (formStyle & FORM_STYLE_FOOTER))
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.");
315 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
320 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
321 SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas.");
323 GetCore().SetFormStyle(formStyle);
325 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
327 if (FORM_STYLE_INDICATOR & formStyle)
329 GetCore().SetIndicatorShowState(true);
330 indicatorBounds = GetCore().GetIndicatorBoundsF();
331 GetCore().SetIndicatorAutoHide(false);
333 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
336 else if(FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle)
338 r = GetCore().SetIndicatorShowState(true);
339 r = GetCore().SetIndicatorAutoHide(true);
340 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
344 r = GetCore().SetIndicatorShowState(false);
345 r = GetCore().SetIndicatorAutoHide(false);
346 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
349 if (formStyle & FORM_STYLE_HEADER)
353 pHeader = CreateHeaderN();
354 SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
356 GetCore().SetHeader(&pHeader->GetCore());
357 GetCore().AdjustClientBounds();
359 if (GetCore().IsIndicatorTranslucent())
361 if (!GetCore().IsHeaderTranslucent())
363 indicatorBounds.height = 0.0f;
367 if (GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
369 indicatorBounds.height = 0.0f;
374 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
375 GetCore().SetHeaderBounds(bounds);
377 r = GetCore().AttachSystemChild(pHeader->GetCore());
378 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
381 else if (formStyle & FORM_STYLE_TITLE)
385 pHeader = CreateHeaderN();
386 SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
388 GetCore().SetHeader(&pHeader->GetCore());
389 GetCore().AdjustClientBounds();
391 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
392 GetCore().SetHeaderBounds(bounds);
394 r = GetCore().AttachSystemChild(pHeader->GetCore());
395 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
405 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
409 if (formStyle & FORM_STYLE_TEXT_TAB)
411 float titleHeight = 0.0f;
413 if (formStyle & FORM_STYLE_TITLE)
417 titleHeight = pHeader->GetBoundsF().height;
423 pTabImpl = CreateTabImplN();
424 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
426 float posY = indicatorBounds.height + titleHeight;
428 GetCore().SetTab(&pTabImpl->GetCore());
429 GetCore().AdjustClientBounds();
431 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
432 GetCore().SetTabBounds(bounds);
434 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
435 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
437 GetCore().SetTabStyle(_TAB_STYLE_TEXT);
439 else if (formStyle & FORM_STYLE_ICON_TAB)
441 float titleHeight = 0.0f;
443 if (formStyle & FORM_STYLE_TITLE)
447 titleHeight = pHeader->GetBoundsF().height;
453 pTabImpl = CreateTabImplN();
454 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
456 float posY = indicatorBounds.height + titleHeight;
458 GetCore().SetTab(&pTabImpl->GetCore());
459 GetCore().AdjustClientBounds();
461 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
462 GetCore().SetTabBounds(bounds);
464 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
465 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
467 GetCore().SetTabStyle(_TAB_STYLE_ICON);
475 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
479 if (formStyle & FORM_STYLE_FOOTER)
483 pFooter = CreateFooterN();
484 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
486 GetCore().SetFooter(&pFooter->GetCore());
487 GetCore().AdjustClientBounds();
489 FloatRectangle clientbounds = GetClientBoundsF();
490 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height, clientbounds.width, GetCore().GetToolbarHeightF(false));
492 GetCore().SetFooterBounds(bounds);
494 r = GetCore().AttachSystemChild(pFooter->GetCore());
495 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
498 else if (formStyle & FORM_STYLE_SOFTKEY_0 || formStyle & FORM_STYLE_SOFTKEY_1 || formStyle & FORM_STYLE_OPTIONKEY)
504 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
507 pFooter = GetFooter();
511 pFooter = CreateFooterN();
512 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
514 GetCore().SetFooter(&pFooter->GetCore());
515 GetCore().AdjustClientBounds();
517 FloatRectangle clientbounds = GetClientBoundsF();
518 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - GetCore().GetToolbarHeightF(false), clientbounds.width, GetCore().GetToolbarHeightF(false));
520 GetCore().SetFooterBounds(bounds);
522 r = GetCore().AttachSystemChild(pFooter->GetCore());
523 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
525 GetCore().CreateSoftkey(formStyle);
527 pFooter->GetCore().AddActionEventListener(*this);
537 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
538 GetCore().AdjustClientBounds();
542 GetCore().SetFormBackEventListener(this);
543 GetCore().SetFormMenuEventListener(this);
545 GetCore().AdjustClientBounds();
547 SetLastResult(E_SUCCESS);
553 _FormImpl::GetFooter(void) const
555 _Toolbar* pToolbar = __pForm->GetFooter();
556 if (pToolbar == null)
561 _FooterImpl* pFooterImpl = static_cast<_FooterImpl*>(pToolbar->GetUserData());
567 _FormImpl::GetHeader(void) const
569 _Toolbar* pToolbar = __pForm->GetHeader();
570 if (pToolbar == null)
575 _HeaderImpl* pHeaderImpl = static_cast<_HeaderImpl*>(pToolbar->GetUserData());
582 _FormImpl::GetTabImpl(void) const
584 _Tab* pTab = __pForm->GetTab();
590 _TabImpl* pTabImpl = static_cast<_TabImpl*>(pTab->GetUserData());
596 _FormImpl::GetTitleText(void) const
598 return GetCore().GetTitleText();
602 _FormImpl::GetTitleTextHorizontalAlignment(void) const
604 return GetCore().GetTitleTextHorizontalAlignment();
608 _FormImpl::HasFooter(void) const
610 return GetCore().HasFooter();
614 _FormImpl::HasHeader(void) const
616 return GetCore().HasHeader();
620 _FormImpl::HasTitle(void) const
622 return GetCore().HasTitle();
626 _FormImpl::HasTab(void) const
628 return GetCore().HasTab();
632 _FormImpl::IsIndicatorVisible(void) const
634 return GetCore().IsIndicatorVisible();
638 _FormImpl::IsHeaderVisible(void) const
640 return GetCore().IsHeaderVisible();
644 _FormImpl::IsFooterVisible(void) const
646 return GetCore().IsFooterVisible();
650 _FormImpl::IsIndicatorTranslucent(void) const
652 return GetCore().IsIndicatorTranslucent();
656 _FormImpl::IsHeaderTranslucent(void) const
658 return GetCore().IsHeaderTranslucent();
662 _FormImpl::IsFooterTranslucent(void) const
664 return GetCore().IsFooterTranslucent();
669 _FormImpl::IsTabTranslucent(void) const
671 return GetCore().IsTabTranslucent();
675 _FormImpl::SetActionBarsTranslucent(unsigned long actionBars, bool translucent)
677 return GetCore().SetActionBarsTranslucent(actionBars, translucent);
681 _FormImpl::SetActionBarsVisible(unsigned long actionBars, bool visible)
683 return GetCore().SetActionBarsVisible(actionBars, visible);
687 _FormImpl::SetTitleIcon(const Bitmap* pTitleBitmap)
689 return GetCore().SetTitleIcon(pTitleBitmap);
693 _FormImpl::SetTitleText(const String& title, HorizontalAlignment alignment)
695 return GetCore().SetTitleText(title, alignment);
699 _FormImpl::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType)
701 return GetCore().GetOverlayRegionN(rect, regionType);
705 _FormImpl::GetOverlayRegionN(const FloatRectangle& rect, OverlayRegionType regionType)
707 return GetCore().GetOverlayRegionN(rect, regionType);
711 _FormImpl::OnDraw(void)
715 __pOriAgent->FireOrientationEvent();
718 _ContainerImpl::OnDraw();
722 _FormImpl::OnKeyReleased(const _ControlImpl& source, _KeyCode keyCode)
727 if (GetCore().GetFooter() || GetCore().GetHeader())
729 if (__pFormBackEventListener)
731 Form* pForm = dynamic_cast <Form*>(&GetPublic());
734 __pFormBackEventListener->OnFormBackRequested(*pForm);
756 _FormImpl::OnActionPerformed(const _Control& source, int actionId)
758 if (GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetFormStyle() & FORM_STYLE_SOFTKEY_1 || GetFormStyle() & FORM_STYLE_OPTIONKEY)
760 Tizen::Base::Runtime::IEventArg* tempArg = null;
761 tempArg = _PublicActionEvent::CreateActionEventArgN(actionId);
762 SysTryReturnVoidResult(NID_UI_CTRL, tempArg , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create Eventarg.");
765 _PublicActionEvent* pSoftkeyActionEvent = null;
767 if (GetCore().GetFooter()->IsButtonSet(LEFT_BUTTON) && GetSoftkeyActionId(SOFTKEY_0) == actionId)
769 for (int i = 0; i < __leftSoftkeyActionList.GetCount(); i++)
771 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__leftSoftkeyActionList.GetAt(i));
773 if (pSoftkeyActionEvent)
775 pSoftkeyActionEvent->Fire(*tempArg);
781 if (GetCore().GetFooter()->IsButtonSet(RIGHT_BUTTON) && GetSoftkeyActionId(SOFTKEY_1) == actionId)
783 for (int i = 0; i < __rightSoftkeyActionList.GetCount(); i++)
785 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__rightSoftkeyActionList.GetAt(i));
787 if (pSoftkeyActionEvent)
789 pSoftkeyActionEvent->Fire(*tempArg);
795 if (GetCore().GetFooter()->IsButtonSet(MIDDLE_BUTTON) && GetOptionkeyActionId() == actionId)
797 if (__pOptionMenuActionEvent)
799 __pOptionMenuActionEvent->Fire(*tempArg);
811 _FormImpl::GetClientAreaCanvasN(void) const
813 return GetCore().GetClientAreaCanvasN();
817 _FormImpl::TranslateToClientAreaPosition(const Point& position) const
819 return GetCore().TranslateToClientAreaPosition(position);
823 _FormImpl::TranslateToClientAreaPosition(const FloatPoint& position) const
825 return GetCore().TranslateToClientAreaPosition(position);
829 _FormImpl::TranslateFromClientAreaPosition(const Point& clientPosition) const
831 return GetCore().TranslateFromClientAreaPosition(clientPosition);
835 _FormImpl::TranslateFromClientAreaPosition(const FloatPoint& clientPosition) const
837 return GetCore().TranslateFromClientAreaPosition(clientPosition);
841 _FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEventListener)
843 bool isBackButton = false;
845 Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/input.keys.back", isBackButton);
849 SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
852 __pFormBackEventListener = const_cast <IFormBackEventListener*>(pFormBackEventListener);
853 GetCore().SetFormBackEventListener(this);
854 result r = GetLastResult();
855 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
859 _FormImpl::SetFormMenuEventListener(const IFormMenuEventListener* pFormMenuEventListener)
861 bool isBackButton = false;
863 Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/input.keys.back", isBackButton);
867 SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
869 __pFormMenuEventListener = const_cast <IFormMenuEventListener*>(pFormMenuEventListener);
870 GetCore().SetFormMenuEventListener(this);
871 result r = GetLastResult();
872 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
876 _FormImpl::AddOrientationEventListener(IOrientationEventListener& listener)
880 __pOriAgent->AddListener(listener);
882 else if (__pImeOriAgent)
884 __pImeOriAgent->AddListener(listener);
889 _FormImpl::AddOptionkeyActionListener(const IActionEventListener& listener)
891 if (HasOptionkey() == false)
896 __pOptionMenuActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
898 SysTryReturnVoidResult(NID_UI_CTRL, __pOptionMenuActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
900 __pOptionMenuActionEvent->AddListener(listener);
904 _FormImpl::AddSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
906 _Softkey _softkey = ConvertSoftkey(softkey);
908 if (GetCore().CheckSoftkey(_softkey) == false)
913 if (softkey == SOFTKEY_0)
915 __pLeftSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
917 SysTryReturnVoidResult(NID_UI_CTRL, __pLeftSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
919 __pLeftSoftkeyActionEvent->AddListener(listener);
921 __leftSoftkeyActionList.Add(*__pLeftSoftkeyActionEvent);
923 else if (softkey == SOFTKEY_1)
925 __pRightSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
927 SysTryReturnVoidResult(NID_UI_CTRL, __pRightSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
929 __pRightSoftkeyActionEvent->AddListener(listener);
931 __rightSoftkeyActionList.Add(*__pRightSoftkeyActionEvent);
936 _FormImpl::RemoveOrientationEventListener(IOrientationEventListener& listener)
940 __pOriAgent->RemoveListener(listener);
942 else if (__pImeOriAgent)
944 __pImeOriAgent->RemoveListener(listener);
949 _FormImpl::RemoveOptionkeyActionListener(const IActionEventListener& listener)
951 if (HasOptionkey() == false)
956 if (__pOptionMenuActionEvent)
958 __pOptionMenuActionEvent->RemoveListener(listener);
963 _FormImpl::RemoveSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
965 _Softkey _softkey = ConvertSoftkey(softkey);
967 if (GetCore().CheckSoftkey(_softkey) == false)
972 if (softkey == SOFTKEY_0)
974 if (__pLeftSoftkeyActionEvent)
976 __pLeftSoftkeyActionEvent->RemoveListener(listener);
979 else if (softkey == SOFTKEY_1)
981 if (__pRightSoftkeyActionEvent)
983 __pRightSoftkeyActionEvent->RemoveListener(listener);
989 _FormImpl::SetOrientation(Orientation orientation)
993 __pOriAgent->SetMode(orientation);
998 _FormImpl::GetOrientation(void) const
1002 return __pOriAgent->GetMode();
1005 return ORIENTATION_NONE;
1009 _FormImpl::GetOrientationStatus(void) const
1013 return __pOriAgent->GetStatus();
1015 else if (__pImeOriAgent)
1017 return __pImeOriAgent->GetStatus();
1020 return ORIENTATION_STATUS_NONE;
1024 _FormImpl::UpdateOrientationStatus(bool draw)
1028 __pOriAgent->Update(draw);
1033 _FormImpl::UpdateOrientation(void)
1037 __pOriAgent->UpdateOrientation();
1042 _FormImpl::UpdateOrientation(int angle)
1044 SysLog(NID_UI_CTRL, "[Ime Rotation]");
1048 __pImeOriAgent->UpdateOrientation(angle);
1053 _FormImpl::HasOptionkey(void) const
1055 return GetCore().HasOptionkey();
1059 _FormImpl::HasSoftkey(Softkey softkey) const
1061 _Softkey _softkey = ConvertSoftkey(softkey);
1063 return GetCore().HasSoftkey(_softkey);
1067 _FormImpl::SetSoftkeyEnabled(Softkey softkey, bool enable)
1069 _Softkey _softkey = ConvertSoftkey(softkey);
1071 result r = GetCore().SetSoftkeyEnabled(_softkey, enable);
1072 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1078 _FormImpl::IsSoftkeyEnabled(Softkey softkey) const
1080 _Softkey _softkey = ConvertSoftkey(softkey);
1082 return GetCore().IsSoftkeyEnabled(_softkey);
1086 _FormImpl::GetSoftkeyActionId(Softkey softkey) const
1088 _Softkey _softkey = ConvertSoftkey(softkey);
1090 return GetCore().GetSoftkeyActionId(_softkey);
1094 _FormImpl::GetOptionkeyActionId(void) const
1096 return GetCore().GetOptionkeyActionId();
1100 _FormImpl::GetSoftkeyText(Softkey softkey) const
1102 _Softkey _softkey = ConvertSoftkey(softkey);
1104 return GetCore().GetSoftkeyText(_softkey);
1108 _FormImpl::SetOptionkeyActionId(int actionId)
1110 result r = GetCore().SetOptionkeyActionId(actionId);
1111 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1117 _FormImpl::SetSoftkeyActionId(Softkey softkey, int actionId)
1119 _Softkey _softkey = ConvertSoftkey(softkey);
1121 result r = GetCore().SetSoftkeyActionId(_softkey, actionId);
1122 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1128 _FormImpl::SetSoftkeyText(Softkey softkey, const String& text)
1130 _Softkey _softkey = ConvertSoftkey(softkey);
1132 result r = GetCore().SetSoftkeyText(_softkey, text);
1133 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1139 _FormImpl::SetSoftkeyIcon(Softkey softkey, const Bitmap& pNormalBitmap, const Bitmap* ppPressedBitmap)
1141 _Softkey _softkey = ConvertSoftkey(softkey);
1143 result r = GetCore().SetSoftkeyIcon(_softkey, pNormalBitmap, ppPressedBitmap);
1144 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1150 _FormImpl::OnChangeLayout(_ControlOrientation orientation)
1152 FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1153 FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
1155 // Adjust the position of the partial Frame.
1156 _FrameImpl* pFrameImpl = dynamic_cast<_FrameImpl*>(GetParent());
1159 FrameShowMode frameShowMode = pFrameImpl->GetShowMode();
1161 if ((frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
1163 bool movable = pFrameImpl->GetCore().IsMovable();
1164 pFrameImpl->GetCore().SetMovable(true);
1166 FloatPoint prevPoint = pFrameImpl->GetPositionF();
1168 FloatPoint curPoint(0.0f, 0.0f);
1170 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1172 if (prevPoint.x < 0.0f)
1174 curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;
1178 curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
1181 if (prevPoint.y < 0.0f)
1183 curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
1187 curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
1192 if (prevPoint.x < 0.0f)
1194 curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
1198 curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;
1201 if (prevPoint.y < 0.0f)
1203 curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
1207 curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
1211 pFrameImpl->SetPosition(curPoint);
1213 portraitSize = pFrameImpl->GetSizeF();
1214 landscapeSize = portraitSize;
1216 pFrameImpl->GetCore().SetMovable(movable);
1221 _ContainerImpl::OnChangeLayout(orientation);
1222 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1224 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1226 SetSize(portraitSize);
1230 SetSize(landscapeSize);
1233 float indicatorheight = 0.0f;
1235 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1236 _Indicator* pIndicator = GetCore().GetIndicator();
1237 if (GetCore().HasIndicator())
1241 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1243 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1247 GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1248 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1251 GetCore().AdjustClientBounds();
1255 pIndicator->OnChangeLayout(orientation);
1259 float adjHeight = 0.0f;
1261 if (GetCore().HasHeader())
1263 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1264 if (GetCore().IsIndicatorVisible())
1266 indicatorBounds = GetCore().GetIndicatorBoundsF();
1267 if (GetCore().IsIndicatorTranslucent())
1269 if (!GetCore().IsHeaderTranslucent())
1271 indicatorBounds.height = 0.0f;
1275 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1277 indicatorBounds.height = 0.0f;
1283 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1284 GetCore().SetHeaderBounds(bounds);
1287 if (GetCore().HasTab()) // Ki-Dong,Hong.Temp
1289 float titleHeight = 0.0f;
1291 if (GetCore().GetFormStyle() & FORM_STYLE_TITLE)
1293 if (GetCore().HasHeader())
1295 _HeaderImpl* pHeaderImpl = GetHeader();
1298 titleHeight = pHeaderImpl->GetBoundsF().height;
1303 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1305 if (GetCore().IsIndicatorVisible())
1307 indicatorBounds = GetCore().GetIndicatorBoundsF();
1308 if (GetCore().IsIndicatorTranslucent())
1310 if (!GetCore().IsHeaderTranslucent())
1312 indicatorBounds.height = 0.0f;
1316 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1318 indicatorBounds.height = 0.0f;
1324 float posY = indicatorBounds.height + titleHeight;
1326 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1327 GetCore().SetTabBounds(bounds);
1330 if (GetCore().HasFooter())
1332 if (GetCore().GetFooter()->GetVisibleState() && !GetCore().IsFooterTranslucent())
1338 adjHeight = GetCore().GetToolbarHeightF(false);
1341 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1342 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1344 adjHeight = GetCore().GetToolbarHeightF(false);
1347 FloatRectangle bounds(0.0f, GetClientBoundsF().y + GetClientBoundsF().height - adjHeight,
1348 GetClientBoundsF().width, GetCore().GetToolbarHeightF(false));
1349 GetCore().SetFooterBounds(bounds);
1354 _FormImpl::CreateHeaderN(void)
1356 result r = E_SUCCESS;
1358 Header* pHeader = new (std::nothrow) Header;
1359 SysTryReturn(NID_UI_CTRL, pHeader, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1361 r = pHeader->Construct();
1362 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1364 _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*pHeader);
1366 SetLastResult(E_SUCCESS);
1372 _FormImpl::CreateFooterN(void)
1374 result r = E_SUCCESS;
1376 Footer* pFooter = new (std::nothrow) Footer;
1377 SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1379 r = pFooter->Construct();
1380 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1382 _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*pFooter);
1384 SetLastResult(E_SUCCESS);
1389 // Ki-Dong,Hong.Temp
1391 _FormImpl::CreateTabImplN(void)
1393 //result r = E_SUCCESS;
1395 //Tab* pTab = new (std::nothrow) Tab;
1396 //SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
1398 //r = pTab->Construct();
1399 //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Unable to consturct tab.");
1401 //return pTab->GetTabImpl();
1402 Tab* pTab = _TabImpl::CreateTabN();
1403 SysTryReturn(NID_UI_CTRL, pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1405 _TabImpl* pTabImpl = _TabImpl::GetInstance(*pTab);
1407 SetLastResult(E_SUCCESS);
1413 _FormImpl::DeflateClientRectHeight(int height)
1415 return GetCore().DeflateClientRectHeight(height);
1419 _FormImpl::DeflateClientRectHeight(float height)
1421 return GetCore().DeflateClientRectHeight(height);
1425 _FormImpl::RemoveHeader(void)
1427 _HeaderImpl* pHeaderImpl = GetHeader();
1431 __pForm->RemoveHeader();
1432 result r = GetLastResult();
1433 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1434 Header* pHeader = pHeaderImpl->GetHeader();
1445 _FormImpl::RemoveFooter(void)
1447 _FooterImpl* pFooterImpl = GetFooter();
1451 __pForm->RemoveFooter();
1452 result r = GetLastResult();
1453 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1454 Footer* pFooter = pFooterImpl->GetFooter();
1466 // Ki-Dong,Hong.Temp
1468 _FormImpl::RemoveTabImpl(void)
1470 _TabImpl* pTabImpl = GetTabImpl();
1474 __pForm->RemoveTab();
1475 result r = GetLastResult();
1476 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1477 Tab* pTab = pTabImpl->GetTab();
1479 pTabImpl->DeleteTab(pTab);
1490 _FormImpl::GetDataBindingContextN(void) const
1492 return _DataBindingContextImpl::GetDataBindingContextN(*this);
1496 _FormImpl::OnAttaching(const _Control* pParent)
1498 result r = E_SUCCESS;
1499 _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>((pParent)));
1500 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1502 SysTryReturnResult(NID_UI_CTRL, pFrame != null, E_INVALID_ARG, "A Form which has FORM_STYLE_INDICATOR style cannot be added to a container except Frame.");
1504 r = _ControlImpl::OnAttaching(pParent);
1509 _FormImpl::OnAttachedToMainTree(void)
1511 result r = E_SUCCESS;
1514 r = GetCore().AttachedToMainTree();
1515 r = _ContainerImpl::OnAttachedToMainTree();
1517 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1519 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1521 indicatorBounds = GetCore().GetIndicatorBoundsF();
1522 r = GetLastResult();
1523 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1526 _HeaderImpl* pHeader = GetHeader();
1527 _FooterImpl* pFooter = GetFooter();
1528 _TabImpl* pTabImpl = GetTabImpl();
1532 if (GetCore().IsIndicatorTranslucent())
1534 if (!GetCore().IsHeaderTranslucent())
1536 indicatorBounds.height = 0.0f;
1540 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
1542 indicatorBounds.height = 0.0f;
1546 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1547 GetCore().SetHeaderBounds(bounds);
1550 float titleHeight = 0.0f;
1554 titleHeight = pHeader->GetBoundsF().height;
1559 float posY = indicatorBounds.height + titleHeight;
1561 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1562 GetCore().SetTabBounds(bounds);
1567 float adjHeight = 0.0f;
1569 if (!(GetCore().GetFooter()->GetVisibleState()) || GetCore().IsFooterTranslucent())
1571 adjHeight = GetCore().GetToolbarHeightF(false);
1574 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1575 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1577 adjHeight = GetCore().GetToolbarHeightF(false);
1580 FloatRectangle clientbounds = GetClientBoundsF();
1581 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - adjHeight, clientbounds.width, GetCore().GetToolbarHeightF(false));
1583 GetCore().SetFooterBounds(bounds);
1586 UpdateOrientationStatus();
1590 __pOriAgent->RequestOrientationEvent();
1597 _FormImpl::OnDetachingFromMainTree(void)
1599 result r = E_SUCCESS;
1600 r = GetCore().DetachingFromMainTree();
1601 r = _ContainerImpl::OnDetachingFromMainTree();
1607 _FormImpl::OnNotifiedN(const _ControlImpl& source, IList* pArgs)
1609 String* pString = dynamic_cast <Tizen::Base::String*>(pArgs->GetAt(0));
1612 if (*pString == _REQUEST_ORIENTATION_EVENT)
1616 __pOriAgent->FireOrientationEvent();
1619 pArgs->RemoveAll(true);
1630 _FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source)
1632 if (__pFormBackEventListener)
1634 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1635 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1638 __pFormBackEventListener->OnFormBackRequested(*pForm);
1648 _FormImpl::OnFormMenuRequested(Tizen::Ui::Controls::_Form& source)
1650 if (__pFormMenuEventListener)
1652 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1653 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1656 __pFormMenuEventListener->OnFormMenuRequested(*pForm);
1666 _FormImpl::OnFormOrientationStatusRequested(void)
1668 _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
1669 SysAssert(pImplManager);
1671 OrientationStatus status = ORIENTATION_STATUS_PORTRAIT;
1672 int appType = _AppInfo::GetAppType();
1673 if (!(appType & _APP_TYPE_IME_APP))
1675 status = pImplManager->GetOrientationStatus(GetOrientation());
1681 _FormImpl::IsOpaque(void) const
1688 _FormImpl::ConvertSoftkey(Softkey softkey) const
1692 if (softkey == SOFTKEY_0)
1694 _softkey = _SOFTKEY_0;
1696 else if (softkey == SOFTKEY_1)
1698 _softkey = _SOFTKEY_1;
1702 _softkey = _SOFTKEY_COUNT;
1709 _FormImpl::SetNotificationTrayOpenEnabled(bool enable)
1711 return GetCore().SetNotificationTrayOpenEnabled(enable);
1715 _FormImpl::IsNotificationTrayOpenEnabled(void) const
1717 return GetCore().IsNotificationTrayOpenEnabled();
1721 : public _UiBuilderControlMaker
1724 _FormMaker(_UiBuilder* uibuilder)
1725 : _UiBuilderControlMaker(uibuilder){};
1726 virtual ~_FormMaker()
1729 static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1731 _FormMaker* pFormMaker = new (std::nothrow) _FormMaker(uibuilder);
1735 virtual Control* Make(_UiBuilderControl* pControl)
1737 _UiBuilderControlLayout* pControlProperty = null;
1738 result r = E_SUCCESS;
1741 Tizen::Base::String elementString;
1742 bool isTitleAlign = false;
1745 HorizontalAlignment align = ALIGNMENT_CENTER;
1746 Form* pForm = (Form*) GetContainer();
1748 // Get control manager
1749 _ControlManager* pControlManager = _ControlManager::GetInstance();
1750 if (pControlManager == null)
1752 SysLog(NID_UI_CTRL, "Unable to get the control manager.n");
1755 FloatDimension screenSize = pControlManager->GetScreenSizeF();
1758 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(0.0f, 0.0f, screenSize.width, screenSize.height);
1759 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(0.0f, 0.0f, screenSize.height, screenSize.width);
1761 // Get device orientation
1762 app_device_orientation_e deviceOrientation = app_get_device_orientation();
1763 bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270);
1767 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE);
1771 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1774 if (pControlProperty == null)
1776 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Can't read attributes");
1780 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1781 Tizen::Base::String styleString;
1782 styleString = pControlProperty->GetStyle();
1784 if (styleString.Contains(L"FORM_STYLE_TITLE"))
1786 style |= FORM_STYLE_TITLE;
1788 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_0"))
1790 style |= FORM_STYLE_SOFTKEY_0;
1792 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_1"))
1794 style |= FORM_STYLE_SOFTKEY_1;
1796 if (styleString.Contains(L"FORM_STYLE_OPTIONKEY"))
1798 style |= FORM_STYLE_OPTIONKEY;
1800 if (styleString.Contains(L"FORM_STYLE_INDICATOR"))
1802 if (styleString.Contains(L"FORM_STYLE_INDICATOR_AUTO_HIDE"))
1804 style |= FORM_STYLE_INDICATOR_AUTO_HIDE;
1808 style |= FORM_STYLE_INDICATOR;
1811 if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
1813 style |= FORM_STYLE_TEXT_TAB;
1815 if (styleString.Contains(L"FORM_STYLE_ICON_TAB"))
1817 style |= FORM_STYLE_ICON_TAB;
1819 if (styleString.Contains(L"FORM_STYLE_HEADER"))
1821 style |= FORM_STYLE_HEADER;
1823 if (styleString.Contains(L"FORM_STYLE_FOOTER"))
1825 style |= FORM_STYLE_FOOTER;
1828 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1829 __pLayoutMaker->GetLayoutType(pControlProperty, layoutType);
1830 if (layoutType == UIBUILDER_LAYOUT_NONE)
1833 r = pForm->Construct(style);
1837 Layout* pPortraitLayout = null;
1838 Layout* pLandscapeLayout = null;
1839 result tempResult = E_SUCCESS;
1840 tempResult = __pLayoutMaker->GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout);
1841 if (E_SUCCESS == tempResult)
1843 r = pForm->Construct(*pPortraitLayout, *pLandscapeLayout, style);
1850 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1852 if (__pLayoutMaker->GetLayoutType(pControlProperty, layoutType) == false)
1857 if ( layoutType == UIBUILDER_LAYOUT_GRID)
1859 for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
1861 GridLayout* pGridLayout = null;
1862 pControlProperty = pControl->GetAttribute(i);
1864 if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT)
1866 pGridLayout = dynamic_cast<GridLayout*>(pPortraitLayout);
1870 pGridLayout = dynamic_cast<GridLayout*>(pLandscapeLayout);
1872 __pLayoutMaker->SetGridLayoutContainerProperty(pGridLayout, pControlProperty);
1875 delete pPortraitLayout;
1876 if (pPortraitLayout != pLandscapeLayout)
1878 delete pLandscapeLayout;
1884 SysLog(NID_UI_CTRL, "Failed to create Form.");
1889 if (pControl->GetElement(L"titleAlign", elementString))
1891 if (elementString.Equals(L"ALIGN_CENTER", false))
1893 align = ALIGNMENT_CENTER;
1895 else if (elementString.Equals(L"ALIGN_RIGHT", false))
1897 align = ALIGNMENT_RIGHT;
1901 align = ALIGNMENT_LEFT;
1903 isTitleAlign = true;
1906 if (style & FORM_STYLE_TITLE)
1908 if (pControl->GetElement(L"title", elementString))
1912 pForm->SetTitleText(elementString, align);
1916 pForm->SetTitleText(elementString);
1923 pForm->SetTitleText(L"", align);
1927 pForm->SetTitleText(L"");
1932 if (pControl->GetElement(L"titleIcon", elementString))
1934 Bitmap* pBitmap = null;
1935 pBitmap = LoadBitmapN(elementString);
1936 if (pBitmap != null)
1938 r = pForm->SetTitleIcon(pBitmap);
1942 SysLog(NID_UI_CTRL, "Failed to set TitleIcon.");
1947 if (pControl->GetElement(L"softKey0Text", elementString))
1949 pForm->SetSoftkeyText(SOFTKEY_0, elementString);
1951 if (pControl->GetElement(L"softKey1Text", elementString))
1953 pForm->SetSoftkeyText(SOFTKEY_1, elementString);
1955 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
1957 Base::Integer::Parse(elementString, opacity);
1959 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
1961 ConvertStringToColor32(elementString, opacity, color);
1962 pForm->SetBackgroundColor(color);
1967 r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color);
1970 pForm->SetBackgroundColor(color);
1974 pForm->SetBackgroundColor(0xff000000);
1978 if (pControl->GetElement(L"softKey0Icon", elementString) || pControl->GetElement(L"softKey0NormalIcon", elementString))
1980 Bitmap* pNormalBitmap = null;
1981 Bitmap* pPressedBitmap = null;
1982 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1984 if (pNormalBitmap != null)
1986 if (pControl->GetElement(L"softKey0PressedIcon", elementString))
1988 pPressedBitmap = LoadBitmapN(elementString);
1991 if (pPressedBitmap != null)
1993 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, pPressedBitmap);
1994 delete pNormalBitmap;
1995 delete pPressedBitmap;
1999 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, null);
2000 delete pNormalBitmap;
2004 if (pControl->GetElement(L"softKey1Icon", elementString) || pControl->GetElement(L"softKey1NormalIcon", elementString))
2006 Bitmap* pNormalBitmap = null;
2007 Bitmap* pPressedBitmap = null;
2008 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2010 if (pNormalBitmap != null)
2012 if (pControl->GetElement(L"softKey1PressedIcon", elementString))
2014 pPressedBitmap = LoadBitmapN(elementString); // __image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2017 if (pPressedBitmap != null)
2019 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, pPressedBitmap);
2020 delete pNormalBitmap;
2021 delete pPressedBitmap;
2025 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, null);
2026 delete pNormalBitmap;
2031 if (pControl->GetElement(L"Orientation", elementString) || pControl->GetElement(L"orientation", elementString))
2034 //ORIENTATION_PORTRAIT,
2035 //ORIENTATION_LANDSACPE,
2036 //ORIENTATION_PORTRAIT_REVERSE,
2037 //ORIENTATION_LANDSACPE_REVERSE,
2038 //ORIENTATION_AUTO = 6,
2039 //ORIENTATION_AUTO_FOUR_DIRECTION = 8,
2041 if (elementString.Equals(L"Automatic:2Dir", false) || elementString.Equals(L"Automatic", false))
2043 pForm->SetOrientation(ORIENTATION_AUTOMATIC);
2045 else if (elementString.Equals(L"Automatic:4Dir", false))
2047 pForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
2049 else if (elementString.Equals(L"Landscape", false))
2051 pForm->SetOrientation(ORIENTATION_LANDSCAPE);
2052 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2054 else if (elementString.Equals(L"Landscape:Reverse", false))
2056 pForm->SetOrientation(ORIENTATION_LANDSCAPE_REVERSE);
2057 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2059 else if (elementString.Equals(L"Portrait", false))
2061 pForm->SetOrientation(ORIENTATION_PORTRAIT);
2062 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2064 else if (elementString.Equals(L"Portrait:Reverse", false))
2066 pForm->SetOrientation(ORIENTATION_PORTRAIT_REVERSE);
2067 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2071 if (style & FORM_STYLE_HEADER)
2073 if (pControl->GetElement(L"translucentHeader", elementString))
2075 if (elementString.Equals(L"true", false))
2077 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_HEADER, true);
2082 if (style & FORM_STYLE_FOOTER)
2084 if (pControl->GetElement(L"translucentFooter", elementString))
2086 if (elementString.Equals(L"true", false))
2088 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_FOOTER, true);
2093 if (style & FORM_STYLE_INDICATOR)
2095 if (pControl->GetElement(L"translucentIndicator", elementString))
2097 if (elementString.Equals(L"true", false))
2099 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
2109 _FormRegister::_FormRegister()
2111 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2112 pUiBuilderControlTableManager->RegisterControl(L"Form", _FormMaker::GetInstance);
2114 _FormRegister::~_FormRegister()
2116 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2117 pUiBuilderControlTableManager->UnregisterControl(L"Form");
2119 static _FormRegister FormRegisterToUiBuilder;
2120 }}} // Tizen::Ui::Controls