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 GetCore().SetIndicatorAutoHide(true);
340 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
344 r = GetCore().SetIndicatorShowState(false);
345 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 bool isBackButton = false;
847 Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/input.keys.back", isBackButton);
851 SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
854 __pFormBackEventListener = const_cast <IFormBackEventListener*>(pFormBackEventListener);
855 GetCore().SetFormBackEventListener(this);
856 result r = GetLastResult();
857 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
861 _FormImpl::SetFormMenuEventListener(const IFormMenuEventListener* pFormMenuEventListener)
863 bool isMenuButton = false;
865 Tizen::System::SystemInfo::GetValue(L"http://tizen.org/feature/input.keys.menu", isMenuButton);
869 SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
871 __pFormMenuEventListener = const_cast <IFormMenuEventListener*>(pFormMenuEventListener);
872 GetCore().SetFormMenuEventListener(this);
873 result r = GetLastResult();
874 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
878 _FormImpl::AddOrientationEventListener(IOrientationEventListener& listener)
882 __pOriAgent->AddListener(listener);
884 else if (__pImeOriAgent)
886 __pImeOriAgent->AddListener(listener);
891 _FormImpl::AddOptionkeyActionListener(const IActionEventListener& listener)
893 if (HasOptionkey() == false)
898 __pOptionMenuActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
900 SysTryReturnVoidResult(NID_UI_CTRL, __pOptionMenuActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
902 __pOptionMenuActionEvent->AddListener(listener);
906 _FormImpl::AddSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
908 _Softkey _softkey = ConvertSoftkey(softkey);
910 if (GetCore().CheckSoftkey(_softkey) == false)
915 if (softkey == SOFTKEY_0)
917 __pLeftSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
919 SysTryReturnVoidResult(NID_UI_CTRL, __pLeftSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
921 __pLeftSoftkeyActionEvent->AddListener(listener);
923 __leftSoftkeyActionList.Add(*__pLeftSoftkeyActionEvent);
925 else if (softkey == SOFTKEY_1)
927 __pRightSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
929 SysTryReturnVoidResult(NID_UI_CTRL, __pRightSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
931 __pRightSoftkeyActionEvent->AddListener(listener);
933 __rightSoftkeyActionList.Add(*__pRightSoftkeyActionEvent);
938 _FormImpl::RemoveOrientationEventListener(IOrientationEventListener& listener)
942 __pOriAgent->RemoveListener(listener);
944 else if (__pImeOriAgent)
946 __pImeOriAgent->RemoveListener(listener);
951 _FormImpl::RemoveOptionkeyActionListener(const IActionEventListener& listener)
953 if (HasOptionkey() == false)
958 if (__pOptionMenuActionEvent)
960 __pOptionMenuActionEvent->RemoveListener(listener);
965 _FormImpl::RemoveSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
967 _Softkey _softkey = ConvertSoftkey(softkey);
969 if (GetCore().CheckSoftkey(_softkey) == false)
974 if (softkey == SOFTKEY_0)
976 if (__pLeftSoftkeyActionEvent)
978 __pLeftSoftkeyActionEvent->RemoveListener(listener);
981 else if (softkey == SOFTKEY_1)
983 if (__pRightSoftkeyActionEvent)
985 __pRightSoftkeyActionEvent->RemoveListener(listener);
991 _FormImpl::SetOrientation(Orientation orientation)
995 __pOriAgent->SetMode(orientation);
1000 _FormImpl::GetOrientation(void) const
1004 return __pOriAgent->GetMode();
1007 return ORIENTATION_NONE;
1011 _FormImpl::GetOrientationStatus(void) const
1015 return __pOriAgent->GetStatus();
1017 else if (__pImeOriAgent)
1019 return __pImeOriAgent->GetStatus();
1022 return ORIENTATION_STATUS_NONE;
1026 _FormImpl::UpdateOrientationStatus(bool draw)
1030 __pOriAgent->Update(draw);
1035 _FormImpl::UpdateOrientation(void)
1039 __pOriAgent->UpdateOrientation();
1044 _FormImpl::UpdateOrientation(int angle)
1046 SysLog(NID_UI_CTRL, "[Ime Rotation]");
1050 __pImeOriAgent->UpdateOrientation(angle);
1055 _FormImpl::HasOptionkey(void) const
1057 return GetCore().HasOptionkey();
1061 _FormImpl::HasSoftkey(Softkey softkey) const
1063 _Softkey _softkey = ConvertSoftkey(softkey);
1065 return GetCore().HasSoftkey(_softkey);
1069 _FormImpl::SetSoftkeyEnabled(Softkey softkey, bool enable)
1071 _Softkey _softkey = ConvertSoftkey(softkey);
1073 result r = GetCore().SetSoftkeyEnabled(_softkey, enable);
1074 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1080 _FormImpl::IsSoftkeyEnabled(Softkey softkey) const
1082 _Softkey _softkey = ConvertSoftkey(softkey);
1084 return GetCore().IsSoftkeyEnabled(_softkey);
1088 _FormImpl::GetSoftkeyActionId(Softkey softkey) const
1090 _Softkey _softkey = ConvertSoftkey(softkey);
1092 return GetCore().GetSoftkeyActionId(_softkey);
1096 _FormImpl::GetOptionkeyActionId(void) const
1098 return GetCore().GetOptionkeyActionId();
1102 _FormImpl::GetSoftkeyText(Softkey softkey) const
1104 _Softkey _softkey = ConvertSoftkey(softkey);
1106 return GetCore().GetSoftkeyText(_softkey);
1110 _FormImpl::SetOptionkeyActionId(int actionId)
1112 result r = GetCore().SetOptionkeyActionId(actionId);
1113 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1119 _FormImpl::SetSoftkeyActionId(Softkey softkey, int actionId)
1121 _Softkey _softkey = ConvertSoftkey(softkey);
1123 result r = GetCore().SetSoftkeyActionId(_softkey, actionId);
1124 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1130 _FormImpl::SetSoftkeyText(Softkey softkey, const String& text)
1132 _Softkey _softkey = ConvertSoftkey(softkey);
1134 result r = GetCore().SetSoftkeyText(_softkey, text);
1135 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1141 _FormImpl::SetSoftkeyIcon(Softkey softkey, const Bitmap& pNormalBitmap, const Bitmap* ppPressedBitmap)
1143 _Softkey _softkey = ConvertSoftkey(softkey);
1145 result r = GetCore().SetSoftkeyIcon(_softkey, pNormalBitmap, ppPressedBitmap);
1146 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1152 _FormImpl::OnChangeLayout(_ControlOrientation orientation)
1154 FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1155 FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
1157 // Adjust the position of the partial Frame.
1158 _FrameImpl* pFrameImpl = dynamic_cast<_FrameImpl*>(GetParent());
1161 FrameShowMode frameShowMode = pFrameImpl->GetShowMode();
1163 if ((frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
1165 bool movable = pFrameImpl->GetCore().IsMovable();
1166 pFrameImpl->GetCore().SetMovable(true);
1168 FloatPoint prevPoint = pFrameImpl->GetPositionF();
1170 FloatPoint curPoint(0.0f, 0.0f);
1172 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1174 if (prevPoint.x < 0.0f)
1176 curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;
1180 curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
1183 if (prevPoint.y < 0.0f)
1185 curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
1189 curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
1194 if (prevPoint.x < 0.0f)
1196 curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
1200 curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;
1203 if (prevPoint.y < 0.0f)
1205 curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
1209 curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
1213 pFrameImpl->SetPosition(curPoint);
1215 portraitSize = pFrameImpl->GetSizeF();
1216 landscapeSize = portraitSize;
1218 pFrameImpl->GetCore().SetMovable(movable);
1223 _ContainerImpl::OnChangeLayout(orientation);
1224 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1226 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1228 SetSize(portraitSize);
1232 SetSize(landscapeSize);
1235 float indicatorheight = 0.0f;
1237 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1238 _Indicator* pIndicator = GetCore().GetIndicator();
1239 if (GetCore().HasIndicator())
1243 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1245 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1249 GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1250 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1253 GetCore().AdjustClientBounds();
1257 pIndicator->OnChangeLayout(orientation);
1261 float adjHeight = 0.0f;
1263 if (GetCore().HasHeader())
1265 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1266 if (GetCore().IsIndicatorVisible())
1268 indicatorBounds = GetCore().GetIndicatorBoundsF();
1269 if (GetCore().IsIndicatorTranslucent())
1271 if (!GetCore().IsHeaderTranslucent())
1273 indicatorBounds.height = 0.0f;
1277 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1279 indicatorBounds.height = 0.0f;
1285 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1286 GetCore().SetHeaderBounds(bounds);
1289 if (GetCore().HasTab()) // Ki-Dong,Hong.Temp
1291 float titleHeight = 0.0f;
1293 if (GetCore().GetFormStyle() & FORM_STYLE_TITLE)
1295 if (GetCore().HasHeader())
1297 _HeaderImpl* pHeaderImpl = GetHeader();
1300 titleHeight = pHeaderImpl->GetBoundsF().height;
1305 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1307 if (GetCore().IsIndicatorVisible())
1309 indicatorBounds = GetCore().GetIndicatorBoundsF();
1310 if (GetCore().IsIndicatorTranslucent())
1312 if (!GetCore().IsHeaderTranslucent())
1314 indicatorBounds.height = 0.0f;
1318 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1320 indicatorBounds.height = 0.0f;
1326 float posY = indicatorBounds.height + titleHeight;
1328 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1329 GetCore().SetTabBounds(bounds);
1332 if (GetCore().HasFooter())
1334 if (GetCore().GetFooter()->GetVisibleState() && !GetCore().IsFooterTranslucent())
1340 adjHeight = GetCore().GetToolbarHeightF(false);
1343 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1344 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1346 adjHeight = GetCore().GetToolbarHeightF(false);
1349 FloatRectangle bounds(0.0f, GetClientBoundsF().y + GetClientBoundsF().height - adjHeight,
1350 GetClientBoundsF().width, GetCore().GetToolbarHeightF(false));
1351 GetCore().SetFooterBounds(bounds);
1356 _FormImpl::CreateHeaderN(void)
1358 result r = E_SUCCESS;
1360 Header* pHeader = new (std::nothrow) Header;
1361 SysTryReturn(NID_UI_CTRL, pHeader, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1363 r = pHeader->Construct();
1364 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1366 _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*pHeader);
1368 SetLastResult(E_SUCCESS);
1374 _FormImpl::CreateFooterN(void)
1376 result r = E_SUCCESS;
1378 Footer* pFooter = new (std::nothrow) Footer;
1379 SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1381 r = pFooter->Construct();
1382 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1384 _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*pFooter);
1386 SetLastResult(E_SUCCESS);
1391 // Ki-Dong,Hong.Temp
1393 _FormImpl::CreateTabImplN(void)
1395 //result r = E_SUCCESS;
1397 //Tab* pTab = new (std::nothrow) Tab;
1398 //SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
1400 //r = pTab->Construct();
1401 //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Unable to consturct tab.");
1403 //return pTab->GetTabImpl();
1404 Tab* pTab = _TabImpl::CreateTabN();
1405 SysTryReturn(NID_UI_CTRL, pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1407 _TabImpl* pTabImpl = _TabImpl::GetInstance(*pTab);
1409 SetLastResult(E_SUCCESS);
1415 _FormImpl::DeflateClientRectHeight(int height)
1417 return GetCore().DeflateClientRectHeight(height);
1421 _FormImpl::DeflateClientRectHeight(float height)
1423 return GetCore().DeflateClientRectHeight(height);
1427 _FormImpl::RemoveHeader(void)
1429 _HeaderImpl* pHeaderImpl = GetHeader();
1433 __pForm->RemoveHeader();
1434 result r = GetLastResult();
1435 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1436 Header* pHeader = pHeaderImpl->GetHeader();
1447 _FormImpl::RemoveFooter(void)
1449 _FooterImpl* pFooterImpl = GetFooter();
1453 __pForm->RemoveFooter();
1454 result r = GetLastResult();
1455 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1456 Footer* pFooter = pFooterImpl->GetFooter();
1468 // Ki-Dong,Hong.Temp
1470 _FormImpl::RemoveTabImpl(void)
1472 _TabImpl* pTabImpl = GetTabImpl();
1476 __pForm->RemoveTab();
1477 result r = GetLastResult();
1478 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1479 Tab* pTab = pTabImpl->GetTab();
1481 pTabImpl->DeleteTab(pTab);
1492 _FormImpl::GetDataBindingContextN(void) const
1494 return _DataBindingContextImpl::GetDataBindingContextN(*this);
1498 _FormImpl::OnAttaching(const _Control* pParent)
1500 result r = E_SUCCESS;
1501 _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>((pParent)));
1502 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1504 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.");
1506 r = _ControlImpl::OnAttaching(pParent);
1511 _FormImpl::OnAttachedToMainTree(void)
1513 result r = E_SUCCESS;
1516 r = GetCore().AttachedToMainTree();
1517 r = _ContainerImpl::OnAttachedToMainTree();
1519 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1521 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1523 indicatorBounds = GetCore().GetIndicatorBoundsF();
1524 r = GetLastResult();
1525 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1528 _HeaderImpl* pHeader = GetHeader();
1529 _FooterImpl* pFooter = GetFooter();
1530 _TabImpl* pTabImpl = GetTabImpl();
1534 if (GetCore().IsIndicatorTranslucent())
1536 if (!GetCore().IsHeaderTranslucent())
1538 indicatorBounds.height = 0.0f;
1542 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
1544 indicatorBounds.height = 0.0f;
1548 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1549 GetCore().SetHeaderBounds(bounds);
1552 float titleHeight = 0.0f;
1556 titleHeight = pHeader->GetBoundsF().height;
1561 float posY = indicatorBounds.height + titleHeight;
1563 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1564 GetCore().SetTabBounds(bounds);
1569 float adjHeight = 0.0f;
1571 if (!(GetCore().GetFooter()->GetVisibleState()) || GetCore().IsFooterTranslucent())
1573 adjHeight = GetCore().GetToolbarHeightF(false);
1576 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1577 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1579 adjHeight = GetCore().GetToolbarHeightF(false);
1582 FloatRectangle clientbounds = GetClientBoundsF();
1583 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - adjHeight, clientbounds.width, GetCore().GetToolbarHeightF(false));
1585 GetCore().SetFooterBounds(bounds);
1588 UpdateOrientationStatus();
1592 __pOriAgent->RequestOrientationEvent();
1599 _FormImpl::OnDetachingFromMainTree(void)
1601 result r = E_SUCCESS;
1602 r = GetCore().DetachingFromMainTree();
1603 r = _ContainerImpl::OnDetachingFromMainTree();
1609 _FormImpl::OnNotifiedN(const _ControlImpl& source, IList* pArgs)
1611 String* pString = dynamic_cast <Tizen::Base::String*>(pArgs->GetAt(0));
1614 if (*pString == _REQUEST_ORIENTATION_EVENT)
1618 __pOriAgent->FireOrientationEvent();
1621 pArgs->RemoveAll(true);
1632 _FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source)
1634 if (__pFormBackEventListener)
1636 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1637 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1640 __pFormBackEventListener->OnFormBackRequested(*pForm);
1650 _FormImpl::OnFormMenuRequested(Tizen::Ui::Controls::_Form& source)
1652 if (__pFormMenuEventListener)
1654 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1655 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1658 __pFormMenuEventListener->OnFormMenuRequested(*pForm);
1668 _FormImpl::OnFormOrientationStatusRequested(void)
1670 _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
1671 SysAssert(pImplManager);
1673 OrientationStatus status = ORIENTATION_STATUS_PORTRAIT;
1674 int appType = _AppInfo::GetAppType();
1675 if (!(appType & _APP_TYPE_IME_APP))
1677 status = pImplManager->GetOrientationStatus(GetOrientation());
1683 _FormImpl::IsOpaque(void) const
1690 _FormImpl::ConvertSoftkey(Softkey softkey) const
1694 if (softkey == SOFTKEY_0)
1696 _softkey = _SOFTKEY_0;
1698 else if (softkey == SOFTKEY_1)
1700 _softkey = _SOFTKEY_1;
1704 _softkey = _SOFTKEY_COUNT;
1711 _FormImpl::SetNotificationTrayOpenEnabled(bool enable)
1713 return GetCore().SetNotificationTrayOpenEnabled(enable);
1717 _FormImpl::IsNotificationTrayOpenEnabled(void) const
1719 return GetCore().IsNotificationTrayOpenEnabled();
1723 : public _UiBuilderControlMaker
1726 _FormMaker(_UiBuilder* uibuilder)
1727 : _UiBuilderControlMaker(uibuilder){};
1728 virtual ~_FormMaker()
1731 static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1733 _FormMaker* pFormMaker = new (std::nothrow) _FormMaker(uibuilder);
1737 virtual Control* Make(_UiBuilderControl* pControl)
1739 _UiBuilderControlLayout* pControlProperty = null;
1740 result r = E_SUCCESS;
1743 Tizen::Base::String elementString;
1744 bool isTitleAlign = false;
1747 HorizontalAlignment align = ALIGNMENT_CENTER;
1748 Form* pForm = (Form*) GetContainer();
1750 // Get control manager
1751 _ControlManager* pControlManager = _ControlManager::GetInstance();
1752 if (pControlManager == null)
1754 SysLog(NID_UI_CTRL, "Unable to get the control manager.n");
1757 FloatDimension screenSize = pControlManager->GetScreenSizeF();
1760 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(0.0f, 0.0f, screenSize.width, screenSize.height);
1761 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(0.0f, 0.0f, screenSize.height, screenSize.width);
1763 // Get device orientation
1764 app_device_orientation_e deviceOrientation = app_get_device_orientation();
1765 bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270);
1769 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE);
1773 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1776 if (pControlProperty == null)
1778 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Can't read attributes");
1782 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1783 Tizen::Base::String styleString;
1784 styleString = pControlProperty->GetStyle();
1786 if (styleString.Contains(L"FORM_STYLE_TITLE"))
1788 style |= FORM_STYLE_TITLE;
1790 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_0"))
1792 style |= FORM_STYLE_SOFTKEY_0;
1794 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_1"))
1796 style |= FORM_STYLE_SOFTKEY_1;
1798 if (styleString.Contains(L"FORM_STYLE_OPTIONKEY"))
1800 style |= FORM_STYLE_OPTIONKEY;
1802 if (styleString.Contains(L"FORM_STYLE_INDICATOR"))
1804 if (styleString.Contains(L"FORM_STYLE_INDICATOR_AUTO_HIDE"))
1806 style |= FORM_STYLE_INDICATOR_AUTO_HIDE;
1810 style |= FORM_STYLE_INDICATOR;
1813 if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
1815 style |= FORM_STYLE_TEXT_TAB;
1817 if (styleString.Contains(L"FORM_STYLE_ICON_TAB"))
1819 style |= FORM_STYLE_ICON_TAB;
1821 if (styleString.Contains(L"FORM_STYLE_HEADER"))
1823 style |= FORM_STYLE_HEADER;
1825 if (styleString.Contains(L"FORM_STYLE_FOOTER"))
1827 style |= FORM_STYLE_FOOTER;
1830 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1831 __pLayoutMaker->GetLayoutType(pControlProperty, layoutType);
1832 if (layoutType == UIBUILDER_LAYOUT_NONE)
1835 r = pForm->Construct(style);
1839 Layout* pPortraitLayout = null;
1840 Layout* pLandscapeLayout = null;
1841 result tempResult = E_SUCCESS;
1842 tempResult = __pLayoutMaker->GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout);
1843 if (E_SUCCESS == tempResult)
1845 r = pForm->Construct(*pPortraitLayout, *pLandscapeLayout, style);
1852 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1854 if (__pLayoutMaker->GetLayoutType(pControlProperty, layoutType) == false)
1859 if ( layoutType == UIBUILDER_LAYOUT_GRID)
1861 for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
1863 GridLayout* pGridLayout = null;
1864 pControlProperty = pControl->GetAttribute(i);
1866 if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT)
1868 pGridLayout = dynamic_cast<GridLayout*>(pPortraitLayout);
1872 pGridLayout = dynamic_cast<GridLayout*>(pLandscapeLayout);
1874 __pLayoutMaker->SetGridLayoutContainerProperty(pGridLayout, pControlProperty);
1877 delete pPortraitLayout;
1878 if (pPortraitLayout != pLandscapeLayout)
1880 delete pLandscapeLayout;
1886 SysLog(NID_UI_CTRL, "Failed to create Form.");
1891 if (pControl->GetElement(L"titleAlign", elementString))
1893 if (elementString.Equals(L"ALIGN_CENTER", false))
1895 align = ALIGNMENT_CENTER;
1897 else if (elementString.Equals(L"ALIGN_RIGHT", false))
1899 align = ALIGNMENT_RIGHT;
1903 align = ALIGNMENT_LEFT;
1905 isTitleAlign = true;
1908 if (style & FORM_STYLE_TITLE)
1910 if (pControl->GetElement(L"title", elementString))
1914 pForm->SetTitleText(elementString, align);
1918 pForm->SetTitleText(elementString);
1925 pForm->SetTitleText(L"", align);
1929 pForm->SetTitleText(L"");
1934 if (pControl->GetElement(L"titleIcon", elementString))
1936 Bitmap* pBitmap = null;
1937 pBitmap = LoadBitmapN(elementString);
1938 if (pBitmap != null)
1940 r = pForm->SetTitleIcon(pBitmap);
1944 SysLog(NID_UI_CTRL, "Failed to set TitleIcon.");
1949 if (pControl->GetElement(L"softKey0Text", elementString))
1951 pForm->SetSoftkeyText(SOFTKEY_0, elementString);
1953 if (pControl->GetElement(L"softKey1Text", elementString))
1955 pForm->SetSoftkeyText(SOFTKEY_1, elementString);
1957 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
1959 Base::Integer::Parse(elementString, opacity);
1961 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
1963 ConvertStringToColor32(elementString, opacity, color);
1964 pForm->SetBackgroundColor(color);
1969 r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color);
1972 pForm->SetBackgroundColor(color);
1976 pForm->SetBackgroundColor(0xff000000);
1980 if (pControl->GetElement(L"softKey0Icon", elementString) || pControl->GetElement(L"softKey0NormalIcon", elementString))
1982 Bitmap* pNormalBitmap = null;
1983 Bitmap* pPressedBitmap = null;
1984 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1986 if (pNormalBitmap != null)
1988 if (pControl->GetElement(L"softKey0PressedIcon", elementString))
1990 pPressedBitmap = LoadBitmapN(elementString);
1993 if (pPressedBitmap != null)
1995 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, pPressedBitmap);
1996 delete pNormalBitmap;
1997 delete pPressedBitmap;
2001 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, null);
2002 delete pNormalBitmap;
2006 if (pControl->GetElement(L"softKey1Icon", elementString) || pControl->GetElement(L"softKey1NormalIcon", elementString))
2008 Bitmap* pNormalBitmap = null;
2009 Bitmap* pPressedBitmap = null;
2010 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2012 if (pNormalBitmap != null)
2014 if (pControl->GetElement(L"softKey1PressedIcon", elementString))
2016 pPressedBitmap = LoadBitmapN(elementString); // __image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2019 if (pPressedBitmap != null)
2021 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, pPressedBitmap);
2022 delete pNormalBitmap;
2023 delete pPressedBitmap;
2027 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, null);
2028 delete pNormalBitmap;
2033 if (pControl->GetElement(L"Orientation", elementString) || pControl->GetElement(L"orientation", elementString))
2036 //ORIENTATION_PORTRAIT,
2037 //ORIENTATION_LANDSACPE,
2038 //ORIENTATION_PORTRAIT_REVERSE,
2039 //ORIENTATION_LANDSACPE_REVERSE,
2040 //ORIENTATION_AUTO = 6,
2041 //ORIENTATION_AUTO_FOUR_DIRECTION = 8,
2043 if (elementString.Equals(L"Automatic:2Dir", false) || elementString.Equals(L"Automatic", false))
2045 pForm->SetOrientation(ORIENTATION_AUTOMATIC);
2047 else if (elementString.Equals(L"Automatic:4Dir", false))
2049 pForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
2051 else if (elementString.Equals(L"Landscape", false))
2053 pForm->SetOrientation(ORIENTATION_LANDSCAPE);
2054 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2056 else if (elementString.Equals(L"Landscape:Reverse", false))
2058 pForm->SetOrientation(ORIENTATION_LANDSCAPE_REVERSE);
2059 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2061 else if (elementString.Equals(L"Portrait", false))
2063 pForm->SetOrientation(ORIENTATION_PORTRAIT);
2064 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2066 else if (elementString.Equals(L"Portrait:Reverse", false))
2068 pForm->SetOrientation(ORIENTATION_PORTRAIT_REVERSE);
2069 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2073 if (style & FORM_STYLE_HEADER)
2075 if (pControl->GetElement(L"translucentHeader", elementString))
2077 if (elementString.Equals(L"true", false))
2079 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_HEADER, true);
2084 if (style & FORM_STYLE_FOOTER)
2086 if (pControl->GetElement(L"translucentFooter", elementString))
2088 if (elementString.Equals(L"true", false))
2090 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_FOOTER, true);
2095 if (style & FORM_STYLE_INDICATOR)
2097 if (pControl->GetElement(L"translucentIndicator", elementString))
2099 if (elementString.Equals(L"true", false))
2101 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
2111 _FormRegister::_FormRegister()
2113 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2114 pUiBuilderControlTableManager->RegisterControl(L"Form", _FormMaker::GetInstance);
2116 _FormRegister::~_FormRegister()
2118 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2119 pUiBuilderControlTableManager->UnregisterControl(L"Form");
2121 static _FormRegister FormRegisterToUiBuilder;
2122 }}} // Tizen::Ui::Controls