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));
380 GetCore().SetFormBackEventListener(this);
383 else if (formStyle & FORM_STYLE_TITLE)
387 pHeader = CreateHeaderN();
388 SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
390 GetCore().SetHeader(&pHeader->GetCore());
391 GetCore().AdjustClientBounds();
393 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
394 GetCore().SetHeaderBounds(bounds);
396 r = GetCore().AttachSystemChild(pHeader->GetCore());
397 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
407 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
411 if (formStyle & FORM_STYLE_TEXT_TAB)
413 float titleHeight = 0.0f;
415 if (formStyle & FORM_STYLE_TITLE)
419 titleHeight = pHeader->GetBoundsF().height;
425 pTabImpl = CreateTabImplN();
426 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
428 float posY = indicatorBounds.height + titleHeight;
430 GetCore().SetTab(&pTabImpl->GetCore());
431 GetCore().AdjustClientBounds();
433 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
434 GetCore().SetTabBounds(bounds);
436 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
437 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
439 GetCore().SetTabStyle(_TAB_STYLE_TEXT);
441 else if (formStyle & FORM_STYLE_ICON_TAB)
443 float titleHeight = 0.0f;
445 if (formStyle & FORM_STYLE_TITLE)
449 titleHeight = pHeader->GetBoundsF().height;
455 pTabImpl = CreateTabImplN();
456 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
458 float posY = indicatorBounds.height + titleHeight;
460 GetCore().SetTab(&pTabImpl->GetCore());
461 GetCore().AdjustClientBounds();
463 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
464 GetCore().SetTabBounds(bounds);
466 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
467 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
469 GetCore().SetTabStyle(_TAB_STYLE_ICON);
477 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
481 if (formStyle & FORM_STYLE_FOOTER)
485 pFooter = CreateFooterN();
486 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
488 GetCore().SetFooter(&pFooter->GetCore());
489 GetCore().AdjustClientBounds();
491 FloatRectangle clientbounds = GetClientBoundsF();
492 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height, clientbounds.width, GetCore().GetToolbarHeightF(false));
494 GetCore().SetFooterBounds(bounds);
496 r = GetCore().AttachSystemChild(pFooter->GetCore());
497 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
499 GetCore().SetFormBackEventListener(this);
500 GetCore().SetFormMenuEventListener(this);
503 else if (formStyle & FORM_STYLE_SOFTKEY_0 || formStyle & FORM_STYLE_SOFTKEY_1 || formStyle & FORM_STYLE_OPTIONKEY)
509 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
512 pFooter = GetFooter();
516 pFooter = CreateFooterN();
517 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
519 GetCore().SetFooter(&pFooter->GetCore());
520 GetCore().AdjustClientBounds();
522 FloatRectangle clientbounds = GetClientBoundsF();
523 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - GetCore().GetToolbarHeightF(false), clientbounds.width, GetCore().GetToolbarHeightF(false));
525 GetCore().SetFooterBounds(bounds);
527 r = GetCore().AttachSystemChild(pFooter->GetCore());
528 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
530 GetCore().CreateSoftkey(formStyle);
532 pFooter->GetCore().AddActionEventListener(*this);
542 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
543 GetCore().AdjustClientBounds();
547 GetCore().AdjustClientBounds();
549 SetLastResult(E_SUCCESS);
555 _FormImpl::GetFooter(void) const
557 _Toolbar* pToolbar = __pForm->GetFooter();
558 if (pToolbar == null)
563 _FooterImpl* pFooterImpl = static_cast<_FooterImpl*>(pToolbar->GetUserData());
569 _FormImpl::GetHeader(void) const
571 _Toolbar* pToolbar = __pForm->GetHeader();
572 if (pToolbar == null)
577 _HeaderImpl* pHeaderImpl = static_cast<_HeaderImpl*>(pToolbar->GetUserData());
584 _FormImpl::GetTabImpl(void) const
586 _Tab* pTab = __pForm->GetTab();
592 _TabImpl* pTabImpl = static_cast<_TabImpl*>(pTab->GetUserData());
598 _FormImpl::GetTitleText(void) const
600 return GetCore().GetTitleText();
604 _FormImpl::GetTitleTextHorizontalAlignment(void) const
606 return GetCore().GetTitleTextHorizontalAlignment();
610 _FormImpl::HasFooter(void) const
612 return GetCore().HasFooter();
616 _FormImpl::HasHeader(void) const
618 return GetCore().HasHeader();
622 _FormImpl::HasTitle(void) const
624 return GetCore().HasTitle();
628 _FormImpl::HasTab(void) const
630 return GetCore().HasTab();
634 _FormImpl::IsIndicatorVisible(void) const
636 return GetCore().IsIndicatorVisible();
640 _FormImpl::IsHeaderVisible(void) const
642 return GetCore().IsHeaderVisible();
646 _FormImpl::IsFooterVisible(void) const
648 return GetCore().IsFooterVisible();
652 _FormImpl::IsIndicatorTranslucent(void) const
654 return GetCore().IsIndicatorTranslucent();
658 _FormImpl::IsHeaderTranslucent(void) const
660 return GetCore().IsHeaderTranslucent();
664 _FormImpl::IsFooterTranslucent(void) const
666 return GetCore().IsFooterTranslucent();
671 _FormImpl::IsTabTranslucent(void) const
673 return GetCore().IsTabTranslucent();
677 _FormImpl::SetActionBarsTranslucent(unsigned long actionBars, bool translucent)
679 return GetCore().SetActionBarsTranslucent(actionBars, translucent);
683 _FormImpl::SetActionBarsVisible(unsigned long actionBars, bool visible)
685 return GetCore().SetActionBarsVisible(actionBars, visible);
689 _FormImpl::SetTitleIcon(const Bitmap* pTitleBitmap)
691 return GetCore().SetTitleIcon(pTitleBitmap);
695 _FormImpl::SetTitleText(const String& title, HorizontalAlignment alignment)
697 return GetCore().SetTitleText(title, alignment);
701 _FormImpl::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType)
703 return GetCore().GetOverlayRegionN(rect, regionType);
707 _FormImpl::GetOverlayRegionN(const FloatRectangle& rect, OverlayRegionType regionType)
709 return GetCore().GetOverlayRegionN(rect, regionType);
713 _FormImpl::OnDraw(void)
717 __pOriAgent->FireOrientationEvent();
720 _ContainerImpl::OnDraw();
724 _FormImpl::OnKeyReleased(const _ControlImpl& source, _KeyCode keyCode)
729 if (GetCore().GetFooter() || GetCore().GetHeader())
731 if (__pFormBackEventListener)
733 Form* pForm = dynamic_cast <Form*>(&GetPublic());
736 __pFormBackEventListener->OnFormBackRequested(*pForm);
758 _FormImpl::OnActionPerformed(const _Control& source, int actionId)
760 if (GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetFormStyle() & FORM_STYLE_SOFTKEY_1 || GetFormStyle() & FORM_STYLE_OPTIONKEY)
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.");
767 _PublicActionEvent* pSoftkeyActionEvent = null;
769 if (GetCore().GetFooter()->IsButtonSet(LEFT_BUTTON) && GetSoftkeyActionId(SOFTKEY_0) == actionId)
771 for (int i = 0; i < __leftSoftkeyActionList.GetCount(); i++)
773 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__leftSoftkeyActionList.GetAt(i));
775 if (pSoftkeyActionEvent)
777 pSoftkeyActionEvent->Fire(*tempArg);
783 if (GetCore().GetFooter()->IsButtonSet(RIGHT_BUTTON) && GetSoftkeyActionId(SOFTKEY_1) == actionId)
785 for (int i = 0; i < __rightSoftkeyActionList.GetCount(); i++)
787 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__rightSoftkeyActionList.GetAt(i));
789 if (pSoftkeyActionEvent)
791 pSoftkeyActionEvent->Fire(*tempArg);
797 if (GetCore().GetFooter()->IsButtonSet(MIDDLE_BUTTON) && GetOptionkeyActionId() == actionId)
799 if (__pOptionMenuActionEvent)
801 __pOptionMenuActionEvent->Fire(*tempArg);
813 _FormImpl::GetClientAreaCanvasN(void) const
815 return GetCore().GetClientAreaCanvasN();
819 _FormImpl::TranslateToClientAreaPosition(const Point& position) const
821 return GetCore().TranslateToClientAreaPosition(position);
825 _FormImpl::TranslateToClientAreaPosition(const FloatPoint& position) const
827 return GetCore().TranslateToClientAreaPosition(position);
831 _FormImpl::TranslateFromClientAreaPosition(const Point& clientPosition) const
833 return GetCore().TranslateFromClientAreaPosition(clientPosition);
837 _FormImpl::TranslateFromClientAreaPosition(const FloatPoint& clientPosition) const
839 return GetCore().TranslateFromClientAreaPosition(clientPosition);
843 _FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEventListener)
845 SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
846 __pFormBackEventListener = const_cast <IFormBackEventListener*>(pFormBackEventListener);
847 GetCore().SetFormBackEventListener(this);
848 result r = GetLastResult();
849 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
853 _FormImpl::SetFormMenuEventListener(const IFormMenuEventListener* pFormMenuEventListener)
855 SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
856 __pFormMenuEventListener = const_cast <IFormMenuEventListener*>(pFormMenuEventListener);
857 GetCore().SetFormMenuEventListener(this);
858 result r = GetLastResult();
859 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
863 _FormImpl::AddOrientationEventListener(IOrientationEventListener& listener)
867 __pOriAgent->AddListener(listener);
869 else if (__pImeOriAgent)
871 __pImeOriAgent->AddListener(listener);
876 _FormImpl::AddOptionkeyActionListener(const IActionEventListener& listener)
878 if (HasOptionkey() == false)
883 __pOptionMenuActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
885 SysTryReturnVoidResult(NID_UI_CTRL, __pOptionMenuActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
887 __pOptionMenuActionEvent->AddListener(listener);
891 _FormImpl::AddSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
893 _Softkey _softkey = ConvertSoftkey(softkey);
895 if (GetCore().CheckSoftkey(_softkey) == false)
900 if (softkey == SOFTKEY_0)
902 __pLeftSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
904 SysTryReturnVoidResult(NID_UI_CTRL, __pLeftSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
906 __pLeftSoftkeyActionEvent->AddListener(listener);
908 __leftSoftkeyActionList.Add(*__pLeftSoftkeyActionEvent);
910 else if (softkey == SOFTKEY_1)
912 __pRightSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
914 SysTryReturnVoidResult(NID_UI_CTRL, __pRightSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
916 __pRightSoftkeyActionEvent->AddListener(listener);
918 __rightSoftkeyActionList.Add(*__pRightSoftkeyActionEvent);
923 _FormImpl::RemoveOrientationEventListener(IOrientationEventListener& listener)
927 __pOriAgent->RemoveListener(listener);
929 else if (__pImeOriAgent)
931 __pImeOriAgent->RemoveListener(listener);
936 _FormImpl::RemoveOptionkeyActionListener(const IActionEventListener& listener)
938 if (HasOptionkey() == false)
943 if (__pOptionMenuActionEvent)
945 __pOptionMenuActionEvent->RemoveListener(listener);
950 _FormImpl::RemoveSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
952 _Softkey _softkey = ConvertSoftkey(softkey);
954 if (GetCore().CheckSoftkey(_softkey) == false)
959 if (softkey == SOFTKEY_0)
961 if (__pLeftSoftkeyActionEvent)
963 __pLeftSoftkeyActionEvent->RemoveListener(listener);
966 else if (softkey == SOFTKEY_1)
968 if (__pRightSoftkeyActionEvent)
970 __pRightSoftkeyActionEvent->RemoveListener(listener);
976 _FormImpl::SetOrientation(Orientation orientation)
980 __pOriAgent->SetMode(orientation);
985 _FormImpl::GetOrientation(void) const
989 return __pOriAgent->GetMode();
992 return ORIENTATION_NONE;
996 _FormImpl::GetOrientationStatus(void) const
1000 return __pOriAgent->GetStatus();
1002 else if (__pImeOriAgent)
1004 return __pImeOriAgent->GetStatus();
1007 return ORIENTATION_STATUS_NONE;
1011 _FormImpl::UpdateOrientationStatus(bool draw)
1015 __pOriAgent->Update(draw);
1020 _FormImpl::UpdateOrientation(void)
1024 __pOriAgent->UpdateOrientation();
1029 _FormImpl::UpdateOrientation(int angle)
1031 SysLog(NID_UI_CTRL, "[Ime Rotation]");
1035 __pImeOriAgent->UpdateOrientation(angle);
1040 _FormImpl::HasOptionkey(void) const
1042 return GetCore().HasOptionkey();
1046 _FormImpl::HasSoftkey(Softkey softkey) const
1048 _Softkey _softkey = ConvertSoftkey(softkey);
1050 return GetCore().HasSoftkey(_softkey);
1054 _FormImpl::SetSoftkeyEnabled(Softkey softkey, bool enable)
1056 _Softkey _softkey = ConvertSoftkey(softkey);
1058 result r = GetCore().SetSoftkeyEnabled(_softkey, enable);
1059 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1065 _FormImpl::IsSoftkeyEnabled(Softkey softkey) const
1067 _Softkey _softkey = ConvertSoftkey(softkey);
1069 return GetCore().IsSoftkeyEnabled(_softkey);
1073 _FormImpl::GetSoftkeyActionId(Softkey softkey) const
1075 _Softkey _softkey = ConvertSoftkey(softkey);
1077 return GetCore().GetSoftkeyActionId(_softkey);
1081 _FormImpl::GetOptionkeyActionId(void) const
1083 return GetCore().GetOptionkeyActionId();
1087 _FormImpl::GetSoftkeyText(Softkey softkey) const
1089 _Softkey _softkey = ConvertSoftkey(softkey);
1091 return GetCore().GetSoftkeyText(_softkey);
1095 _FormImpl::SetOptionkeyActionId(int actionId)
1097 result r = GetCore().SetOptionkeyActionId(actionId);
1098 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1104 _FormImpl::SetSoftkeyActionId(Softkey softkey, int actionId)
1106 _Softkey _softkey = ConvertSoftkey(softkey);
1108 result r = GetCore().SetSoftkeyActionId(_softkey, actionId);
1109 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1115 _FormImpl::SetSoftkeyText(Softkey softkey, const String& text)
1117 _Softkey _softkey = ConvertSoftkey(softkey);
1119 result r = GetCore().SetSoftkeyText(_softkey, text);
1120 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1126 _FormImpl::SetSoftkeyIcon(Softkey softkey, const Bitmap& pNormalBitmap, const Bitmap* ppPressedBitmap)
1128 _Softkey _softkey = ConvertSoftkey(softkey);
1130 result r = GetCore().SetSoftkeyIcon(_softkey, pNormalBitmap, ppPressedBitmap);
1131 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1137 _FormImpl::OnChangeLayout(_ControlOrientation orientation)
1139 FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1140 FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
1142 // Adjust the position of the partial Frame.
1143 _FrameImpl* pFrameImpl = dynamic_cast<_FrameImpl*>(GetParent());
1146 FrameShowMode frameShowMode = pFrameImpl->GetShowMode();
1148 if ((frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
1150 bool movable = pFrameImpl->GetCore().IsMovable();
1151 pFrameImpl->GetCore().SetMovable(true);
1153 FloatPoint prevPoint = pFrameImpl->GetPositionF();
1155 FloatPoint curPoint(0.0f, 0.0f);
1157 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1159 if (prevPoint.x < 0.0f)
1161 curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;
1165 curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
1168 if (prevPoint.y < 0.0f)
1170 curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
1174 curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
1179 if (prevPoint.x < 0.0f)
1181 curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
1185 curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;
1188 if (prevPoint.y < 0.0f)
1190 curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
1194 curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
1198 pFrameImpl->SetPosition(curPoint);
1200 portraitSize = pFrameImpl->GetSizeF();
1201 landscapeSize = portraitSize;
1203 pFrameImpl->GetCore().SetMovable(movable);
1208 _ContainerImpl::OnChangeLayout(orientation);
1209 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1211 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1213 SetSize(portraitSize);
1217 SetSize(landscapeSize);
1220 float indicatorheight = 0.0f;
1222 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1223 _Indicator* pIndicator = GetCore().GetIndicator();
1224 if (GetCore().HasIndicator())
1228 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1230 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1234 GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1235 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1238 GetCore().AdjustClientBounds();
1242 pIndicator->OnChangeLayout(orientation);
1246 float adjHeight = 0.0f;
1248 if (GetCore().HasHeader())
1250 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1251 if (GetCore().IsIndicatorVisible())
1253 indicatorBounds = GetCore().GetIndicatorBoundsF();
1254 if (GetCore().IsIndicatorTranslucent())
1256 if (!GetCore().IsHeaderTranslucent())
1258 indicatorBounds.height = 0.0f;
1262 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1264 indicatorBounds.height = 0.0f;
1270 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1271 GetCore().SetHeaderBounds(bounds);
1274 if (GetCore().HasTab()) // Ki-Dong,Hong.Temp
1276 float titleHeight = 0.0f;
1278 if (GetCore().GetFormStyle() & FORM_STYLE_TITLE)
1280 if (GetCore().HasHeader())
1282 _HeaderImpl* pHeaderImpl = GetHeader();
1285 titleHeight = pHeaderImpl->GetBoundsF().height;
1290 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1292 if (GetCore().IsIndicatorVisible())
1294 indicatorBounds = GetCore().GetIndicatorBoundsF();
1295 if (GetCore().IsIndicatorTranslucent())
1297 if (!GetCore().IsHeaderTranslucent())
1299 indicatorBounds.height = 0.0f;
1303 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1305 indicatorBounds.height = 0.0f;
1311 float posY = indicatorBounds.height + titleHeight;
1313 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1314 GetCore().SetTabBounds(bounds);
1317 if (GetCore().HasFooter())
1319 if (GetCore().GetFooter()->GetVisibleState() && !GetCore().IsFooterTranslucent())
1325 adjHeight = GetCore().GetToolbarHeightF(false);
1328 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1329 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1331 adjHeight = GetCore().GetToolbarHeightF(false);
1334 FloatRectangle bounds(0.0f, GetClientBoundsF().y + GetClientBoundsF().height - adjHeight,
1335 GetClientBoundsF().width, GetCore().GetToolbarHeightF(false));
1336 GetCore().SetFooterBounds(bounds);
1341 _FormImpl::CreateHeaderN(void)
1343 result r = E_SUCCESS;
1345 Header* pHeader = new (std::nothrow) Header;
1346 SysTryReturn(NID_UI_CTRL, pHeader, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1348 r = pHeader->Construct();
1349 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1351 _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*pHeader);
1353 SetLastResult(E_SUCCESS);
1359 _FormImpl::CreateFooterN(void)
1361 result r = E_SUCCESS;
1363 Footer* pFooter = new (std::nothrow) Footer;
1364 SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1366 r = pFooter->Construct();
1367 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1369 _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*pFooter);
1371 SetLastResult(E_SUCCESS);
1376 // Ki-Dong,Hong.Temp
1378 _FormImpl::CreateTabImplN(void)
1380 //result r = E_SUCCESS;
1382 //Tab* pTab = new (std::nothrow) Tab;
1383 //SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
1385 //r = pTab->Construct();
1386 //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Unable to consturct tab.");
1388 //return pTab->GetTabImpl();
1389 Tab* pTab = _TabImpl::CreateTabN();
1390 SysTryReturn(NID_UI_CTRL, pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1392 _TabImpl* pTabImpl = _TabImpl::GetInstance(*pTab);
1394 SetLastResult(E_SUCCESS);
1400 _FormImpl::DeflateClientRectHeight(int height)
1402 return GetCore().DeflateClientRectHeight(height);
1406 _FormImpl::DeflateClientRectHeight(float height)
1408 return GetCore().DeflateClientRectHeight(height);
1412 _FormImpl::RemoveHeader(void)
1414 _HeaderImpl* pHeaderImpl = GetHeader();
1418 __pForm->RemoveHeader();
1419 result r = GetLastResult();
1420 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1421 Header* pHeader = pHeaderImpl->GetHeader();
1432 _FormImpl::RemoveFooter(void)
1434 _FooterImpl* pFooterImpl = GetFooter();
1438 __pForm->RemoveFooter();
1439 result r = GetLastResult();
1440 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1441 Footer* pFooter = pFooterImpl->GetFooter();
1453 // Ki-Dong,Hong.Temp
1455 _FormImpl::RemoveTabImpl(void)
1457 _TabImpl* pTabImpl = GetTabImpl();
1461 __pForm->RemoveTab();
1462 result r = GetLastResult();
1463 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1464 Tab* pTab = pTabImpl->GetTab();
1466 pTabImpl->DeleteTab(pTab);
1477 _FormImpl::GetDataBindingContextN(void) const
1479 return _DataBindingContextImpl::GetDataBindingContextN(*this);
1483 _FormImpl::OnAttaching(const _Control* pParent)
1485 result r = E_SUCCESS;
1486 _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>((pParent)));
1487 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1489 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.");
1491 r = _ControlImpl::OnAttaching(pParent);
1496 _FormImpl::OnAttachedToMainTree(void)
1498 result r = E_SUCCESS;
1501 r = GetCore().AttachedToMainTree();
1502 r = _ContainerImpl::OnAttachedToMainTree();
1504 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1506 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1508 indicatorBounds = GetCore().GetIndicatorBoundsF();
1509 r = GetLastResult();
1510 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1513 _HeaderImpl* pHeader = GetHeader();
1514 _FooterImpl* pFooter = GetFooter();
1515 _TabImpl* pTabImpl = GetTabImpl();
1519 if (GetCore().IsIndicatorTranslucent())
1521 if (!GetCore().IsHeaderTranslucent())
1523 indicatorBounds.height = 0.0f;
1527 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
1529 indicatorBounds.height = 0.0f;
1533 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1534 GetCore().SetHeaderBounds(bounds);
1537 float titleHeight = 0.0f;
1541 titleHeight = pHeader->GetBoundsF().height;
1546 float posY = indicatorBounds.height + titleHeight;
1548 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1549 GetCore().SetTabBounds(bounds);
1554 float adjHeight = 0.0f;
1556 if (!(GetCore().GetFooter()->GetVisibleState()) || GetCore().IsFooterTranslucent())
1558 adjHeight = GetCore().GetToolbarHeightF(false);
1561 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1562 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1564 adjHeight = GetCore().GetToolbarHeightF(false);
1567 FloatRectangle clientbounds = GetClientBoundsF();
1568 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - adjHeight, clientbounds.width, GetCore().GetToolbarHeightF(false));
1570 GetCore().SetFooterBounds(bounds);
1573 UpdateOrientationStatus();
1577 __pOriAgent->RequestOrientationEvent();
1584 _FormImpl::OnDetachingFromMainTree(void)
1586 result r = E_SUCCESS;
1587 r = GetCore().DetachingFromMainTree();
1588 r = _ContainerImpl::OnDetachingFromMainTree();
1594 _FormImpl::OnNotifiedN(const _ControlImpl& source, IList* pArgs)
1596 String* pString = dynamic_cast <Tizen::Base::String*>(pArgs->GetAt(0));
1599 if (*pString == _REQUEST_ORIENTATION_EVENT)
1603 __pOriAgent->FireOrientationEvent();
1606 pArgs->RemoveAll(true);
1617 _FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source)
1619 if (__pFormBackEventListener)
1621 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1622 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1625 __pFormBackEventListener->OnFormBackRequested(*pForm);
1635 _FormImpl::OnFormMenuRequested(Tizen::Ui::Controls::_Form& source)
1637 if (__pFormMenuEventListener)
1639 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1640 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1643 __pFormMenuEventListener->OnFormMenuRequested(*pForm);
1653 _FormImpl::OnFormOrientationStatusRequested(void)
1655 _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
1656 SysAssert(pImplManager);
1658 OrientationStatus status = ORIENTATION_STATUS_PORTRAIT;
1659 int appType = _AppInfo::GetAppType();
1660 if (!(appType & _APP_TYPE_IME_APP))
1662 status = pImplManager->GetOrientationStatus(GetOrientation());
1668 _FormImpl::IsOpaque(void) const
1675 _FormImpl::ConvertSoftkey(Softkey softkey) const
1679 if (softkey == SOFTKEY_0)
1681 _softkey = _SOFTKEY_0;
1683 else if (softkey == SOFTKEY_1)
1685 _softkey = _SOFTKEY_1;
1689 _softkey = _SOFTKEY_COUNT;
1696 _FormImpl::SetNotificationTrayOpenEnabled(bool enable)
1698 return GetCore().SetNotificationTrayOpenEnabled(enable);
1702 _FormImpl::IsNotificationTrayOpenEnabled(void) const
1704 return GetCore().IsNotificationTrayOpenEnabled();
1708 : public _UiBuilderControlMaker
1711 _FormMaker(_UiBuilder* uibuilder)
1712 : _UiBuilderControlMaker(uibuilder){};
1713 virtual ~_FormMaker()
1716 static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1718 _FormMaker* pFormMaker = new (std::nothrow) _FormMaker(uibuilder);
1722 virtual Control* Make(_UiBuilderControl* pControl)
1724 _UiBuilderControlLayout* pControlProperty = null;
1725 result r = E_SUCCESS;
1728 Tizen::Base::String elementString;
1729 bool isTitleAlign = false;
1732 HorizontalAlignment align = ALIGNMENT_CENTER;
1733 Form* pForm = (Form*) GetContainer();
1735 // Get control manager
1736 _ControlManager* pControlManager = _ControlManager::GetInstance();
1737 if (pControlManager == null)
1739 SysLog(NID_UI_CTRL, "Unable to get the control manager.n");
1742 FloatDimension screenSize = pControlManager->GetScreenSizeF();
1745 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(0.0f, 0.0f, screenSize.width, screenSize.height);
1746 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(0.0f, 0.0f, screenSize.height, screenSize.width);
1748 // Get device orientation
1749 app_device_orientation_e deviceOrientation = app_get_device_orientation();
1750 bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270);
1754 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE);
1758 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1761 if (pControlProperty == null)
1763 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Can't read attributes");
1767 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1768 Tizen::Base::String styleString;
1769 styleString = pControlProperty->GetStyle();
1771 if (styleString.Contains(L"FORM_STYLE_TITLE"))
1773 style |= FORM_STYLE_TITLE;
1775 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_0"))
1777 style |= FORM_STYLE_SOFTKEY_0;
1779 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_1"))
1781 style |= FORM_STYLE_SOFTKEY_1;
1783 if (styleString.Contains(L"FORM_STYLE_OPTIONKEY"))
1785 style |= FORM_STYLE_OPTIONKEY;
1787 if (styleString.Contains(L"FORM_STYLE_INDICATOR"))
1789 if (styleString.Contains(L"FORM_STYLE_INDICATOR_AUTO_HIDE"))
1791 style |= FORM_STYLE_INDICATOR_AUTO_HIDE;
1795 style |= FORM_STYLE_INDICATOR;
1798 if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
1800 style |= FORM_STYLE_TEXT_TAB;
1802 if (styleString.Contains(L"FORM_STYLE_ICON_TAB"))
1804 style |= FORM_STYLE_ICON_TAB;
1806 if (styleString.Contains(L"FORM_STYLE_HEADER"))
1808 style |= FORM_STYLE_HEADER;
1810 if (styleString.Contains(L"FORM_STYLE_FOOTER"))
1812 style |= FORM_STYLE_FOOTER;
1815 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1816 __pLayoutMaker->GetLayoutType(pControlProperty, layoutType);
1817 if (layoutType == UIBUILDER_LAYOUT_NONE)
1820 r = pForm->Construct(style);
1824 Layout* pPortraitLayout = null;
1825 Layout* pLandscapeLayout = null;
1826 result tempResult = E_SUCCESS;
1827 tempResult = __pLayoutMaker->GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout);
1828 if (E_SUCCESS == tempResult)
1830 r = pForm->Construct(*pPortraitLayout, *pLandscapeLayout, style);
1837 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1839 if (__pLayoutMaker->GetLayoutType(pControlProperty, layoutType) == false)
1844 if ( layoutType == UIBUILDER_LAYOUT_GRID)
1846 for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
1848 GridLayout* pGridLayout = null;
1849 pControlProperty = pControl->GetAttribute(i);
1851 if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT)
1853 pGridLayout = dynamic_cast<GridLayout*>(pPortraitLayout);
1857 pGridLayout = dynamic_cast<GridLayout*>(pLandscapeLayout);
1859 __pLayoutMaker->SetGridLayoutContainerProperty(pGridLayout, pControlProperty);
1862 delete pPortraitLayout;
1863 if (pPortraitLayout != pLandscapeLayout)
1865 delete pLandscapeLayout;
1871 SysLog(NID_UI_CTRL, "Failed to create Form.");
1876 if (pControl->GetElement(L"titleAlign", elementString))
1878 if (elementString.Equals(L"ALIGN_CENTER", false))
1880 align = ALIGNMENT_CENTER;
1882 else if (elementString.Equals(L"ALIGN_RIGHT", false))
1884 align = ALIGNMENT_RIGHT;
1888 align = ALIGNMENT_LEFT;
1890 isTitleAlign = true;
1893 if (style & FORM_STYLE_TITLE)
1895 if (pControl->GetElement(L"title", elementString))
1899 pForm->SetTitleText(elementString, align);
1903 pForm->SetTitleText(elementString);
1910 pForm->SetTitleText(L"", align);
1914 pForm->SetTitleText(L"");
1919 if (pControl->GetElement(L"titleIcon", elementString))
1921 Bitmap* pBitmap = null;
1922 pBitmap = LoadBitmapN(elementString);
1923 if (pBitmap != null)
1925 r = pForm->SetTitleIcon(pBitmap);
1929 SysLog(NID_UI_CTRL, "Failed to set TitleIcon.");
1934 if (pControl->GetElement(L"softKey0Text", elementString))
1936 pForm->SetSoftkeyText(SOFTKEY_0, elementString);
1938 if (pControl->GetElement(L"softKey1Text", elementString))
1940 pForm->SetSoftkeyText(SOFTKEY_1, elementString);
1942 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
1944 Base::Integer::Parse(elementString, opacity);
1946 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
1948 ConvertStringToColor32(elementString, opacity, color);
1949 pForm->SetBackgroundColor(color);
1954 r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color);
1957 pForm->SetBackgroundColor(color);
1961 pForm->SetBackgroundColor(0xff000000);
1965 if (pControl->GetElement(L"softKey0Icon", elementString) || pControl->GetElement(L"softKey0NormalIcon", elementString))
1967 Bitmap* pNormalBitmap = null;
1968 Bitmap* pPressedBitmap = null;
1969 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1971 if (pNormalBitmap != null)
1973 if (pControl->GetElement(L"softKey0PressedIcon", elementString))
1975 pPressedBitmap = LoadBitmapN(elementString);
1978 if (pPressedBitmap != null)
1980 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, pPressedBitmap);
1981 delete pNormalBitmap;
1982 delete pPressedBitmap;
1986 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, null);
1987 delete pNormalBitmap;
1991 if (pControl->GetElement(L"softKey1Icon", elementString) || pControl->GetElement(L"softKey1NormalIcon", elementString))
1993 Bitmap* pNormalBitmap = null;
1994 Bitmap* pPressedBitmap = null;
1995 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1997 if (pNormalBitmap != null)
1999 if (pControl->GetElement(L"softKey1PressedIcon", elementString))
2001 pPressedBitmap = LoadBitmapN(elementString); // __image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2004 if (pPressedBitmap != null)
2006 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, pPressedBitmap);
2007 delete pNormalBitmap;
2008 delete pPressedBitmap;
2012 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, null);
2013 delete pNormalBitmap;
2018 if (pControl->GetElement(L"Orientation", elementString) || pControl->GetElement(L"orientation", elementString))
2021 //ORIENTATION_PORTRAIT,
2022 //ORIENTATION_LANDSACPE,
2023 //ORIENTATION_PORTRAIT_REVERSE,
2024 //ORIENTATION_LANDSACPE_REVERSE,
2025 //ORIENTATION_AUTO = 6,
2026 //ORIENTATION_AUTO_FOUR_DIRECTION = 8,
2028 if (elementString.Equals(L"Automatic:2Dir", false) || elementString.Equals(L"Automatic", false))
2030 pForm->SetOrientation(ORIENTATION_AUTOMATIC);
2032 else if (elementString.Equals(L"Automatic:4Dir", false))
2034 pForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
2036 else if (elementString.Equals(L"Landscape", false))
2038 pForm->SetOrientation(ORIENTATION_LANDSCAPE);
2039 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2041 else if (elementString.Equals(L"Landscape:Reverse", false))
2043 pForm->SetOrientation(ORIENTATION_LANDSCAPE_REVERSE);
2044 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2046 else if (elementString.Equals(L"Portrait", false))
2048 pForm->SetOrientation(ORIENTATION_PORTRAIT);
2049 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2051 else if (elementString.Equals(L"Portrait:Reverse", false))
2053 pForm->SetOrientation(ORIENTATION_PORTRAIT_REVERSE);
2054 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2058 if (style & FORM_STYLE_HEADER)
2060 if (pControl->GetElement(L"translucentHeader", elementString))
2062 if (elementString.Equals(L"true", false))
2064 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_HEADER, true);
2069 if (style & FORM_STYLE_FOOTER)
2071 if (pControl->GetElement(L"translucentFooter", elementString))
2073 if (elementString.Equals(L"true", false))
2075 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_FOOTER, true);
2080 if (style & FORM_STYLE_INDICATOR)
2082 if (pControl->GetElement(L"translucentIndicator", elementString))
2084 if (elementString.Equals(L"true", false))
2086 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
2096 _FormRegister::_FormRegister()
2098 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2099 pUiBuilderControlTableManager->RegisterControl(L"Form", _FormMaker::GetInstance);
2101 _FormRegister::~_FormRegister()
2103 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2104 pUiBuilderControlTableManager->UnregisterControl(L"Form");
2106 static _FormRegister FormRegisterToUiBuilder;
2107 }}} // Tizen::Ui::Controls