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 _FrameImpl* pFrameImpl = dynamic_cast<_FrameImpl*>(GetParent());
1160 FrameShowMode frameShowMode = pFrameImpl->GetShowMode();
1162 if ((frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
1164 bool movable = pFrameImpl->GetCore().IsMovable();
1165 pFrameImpl->GetCore().SetMovable(true);
1167 FloatPoint prevPoint = pFrameImpl->GetPositionF();
1168 FloatPoint curPoint(prevPoint.x, prevPoint.y);
1169 float ratio = portraitSize.width / portraitSize.height;
1170 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1172 if (prevPoint.x > 0.0f)
1174 curPoint.x = prevPoint.x * ratio;
1177 if (prevPoint.y > 0.0f)
1179 curPoint.y = prevPoint.y / ratio;
1184 if (prevPoint.x > 0.0f)
1186 curPoint.x = prevPoint.x / ratio;
1189 if (prevPoint.y > 0.0f)
1191 curPoint.y = prevPoint.y * ratio;
1195 pFrameImpl->SetPosition(curPoint);
1196 portraitSize = pFrameImpl->GetSizeF();
1197 landscapeSize = portraitSize;
1198 pFrameImpl->GetCore().SetMovable(movable);
1203 _ContainerImpl::OnChangeLayout(orientation);
1204 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1206 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1208 SetSize(portraitSize);
1212 SetSize(landscapeSize);
1215 float indicatorheight = 0.0f;
1217 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1218 _Indicator* pIndicator = GetCore().GetIndicator();
1219 if (GetCore().HasIndicator())
1223 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1225 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1229 GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1230 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1233 GetCore().AdjustClientBounds();
1237 pIndicator->OnChangeLayout(orientation);
1241 float adjHeight = 0.0f;
1243 if (GetCore().HasHeader())
1245 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1246 if (GetCore().IsIndicatorVisible())
1248 indicatorBounds = GetCore().GetIndicatorBoundsF();
1249 if (GetCore().IsIndicatorTranslucent())
1251 if (!GetCore().IsHeaderTranslucent())
1253 indicatorBounds.height = 0.0f;
1257 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1259 indicatorBounds.height = 0.0f;
1265 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1266 GetCore().SetHeaderBounds(bounds);
1269 if (GetCore().HasTab()) // Ki-Dong,Hong.Temp
1271 float titleHeight = 0.0f;
1273 if (GetCore().GetFormStyle() & FORM_STYLE_TITLE)
1275 if (GetCore().HasHeader())
1277 _HeaderImpl* pHeaderImpl = GetHeader();
1280 titleHeight = pHeaderImpl->GetBoundsF().height;
1285 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1287 if (GetCore().IsIndicatorVisible())
1289 indicatorBounds = GetCore().GetIndicatorBoundsF();
1290 if (GetCore().IsIndicatorTranslucent())
1292 if (!GetCore().IsHeaderTranslucent())
1294 indicatorBounds.height = 0.0f;
1298 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1300 indicatorBounds.height = 0.0f;
1306 float posY = indicatorBounds.height + titleHeight;
1308 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1309 GetCore().SetTabBounds(bounds);
1312 if (GetCore().HasFooter())
1314 if (GetCore().GetFooter()->GetVisibleState() && !GetCore().IsFooterTranslucent())
1320 adjHeight = GetCore().GetToolbarHeightF(false);
1323 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1324 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1326 adjHeight = GetCore().GetToolbarHeightF(false);
1329 FloatRectangle bounds(0.0f, GetClientBoundsF().y + GetClientBoundsF().height - adjHeight,
1330 GetClientBoundsF().width, GetCore().GetToolbarHeightF(false));
1331 GetCore().SetFooterBounds(bounds);
1336 _FormImpl::CreateHeaderN(void)
1338 result r = E_SUCCESS;
1340 Header* pHeader = new (std::nothrow) Header;
1341 SysTryReturn(NID_UI_CTRL, pHeader, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1343 r = pHeader->Construct();
1344 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1346 _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*pHeader);
1348 SetLastResult(E_SUCCESS);
1354 _FormImpl::CreateFooterN(void)
1356 result r = E_SUCCESS;
1358 Footer* pFooter = new (std::nothrow) Footer;
1359 SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1361 r = pFooter->Construct();
1362 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1364 _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*pFooter);
1366 SetLastResult(E_SUCCESS);
1371 // Ki-Dong,Hong.Temp
1373 _FormImpl::CreateTabImplN(void)
1375 //result r = E_SUCCESS;
1377 //Tab* pTab = new (std::nothrow) Tab;
1378 //SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
1380 //r = pTab->Construct();
1381 //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Unable to consturct tab.");
1383 //return pTab->GetTabImpl();
1384 Tab* pTab = _TabImpl::CreateTabN();
1385 SysTryReturn(NID_UI_CTRL, pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1387 _TabImpl* pTabImpl = _TabImpl::GetInstance(*pTab);
1389 SetLastResult(E_SUCCESS);
1395 _FormImpl::DeflateClientRectHeight(int height)
1397 return GetCore().DeflateClientRectHeight(height);
1401 _FormImpl::DeflateClientRectHeight(float height)
1403 return GetCore().DeflateClientRectHeight(height);
1407 _FormImpl::RemoveHeader(void)
1409 _HeaderImpl* pHeaderImpl = GetHeader();
1413 __pForm->RemoveHeader();
1414 result r = GetLastResult();
1415 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1416 Header* pHeader = pHeaderImpl->GetHeader();
1427 _FormImpl::RemoveFooter(void)
1429 _FooterImpl* pFooterImpl = GetFooter();
1433 __pForm->RemoveFooter();
1434 result r = GetLastResult();
1435 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1436 Footer* pFooter = pFooterImpl->GetFooter();
1448 // Ki-Dong,Hong.Temp
1450 _FormImpl::RemoveTabImpl(void)
1452 _TabImpl* pTabImpl = GetTabImpl();
1456 __pForm->RemoveTab();
1457 result r = GetLastResult();
1458 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1459 Tab* pTab = pTabImpl->GetTab();
1461 pTabImpl->DeleteTab(pTab);
1472 _FormImpl::GetDataBindingContextN(void) const
1474 return _DataBindingContextImpl::GetDataBindingContextN(*this);
1478 _FormImpl::OnAttaching(const _Control* pParent)
1480 result r = E_SUCCESS;
1481 _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>((pParent)));
1482 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1484 SysTryReturnResult(NID_UI_CTRL, pFrame != null, E_INVALID_ARG, "A Form which has FORM_STYLE_INDICATOR style cannot be added to a container except Frame.");
1486 r = _ControlImpl::OnAttaching(pParent);
1491 _FormImpl::OnAttachedToMainTree(void)
1493 result r = E_SUCCESS;
1496 r = GetCore().AttachedToMainTree();
1497 r = _ContainerImpl::OnAttachedToMainTree();
1499 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1501 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1503 indicatorBounds = GetCore().GetIndicatorBoundsF();
1504 r = GetLastResult();
1505 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1508 _HeaderImpl* pHeader = GetHeader();
1509 _FooterImpl* pFooter = GetFooter();
1510 _TabImpl* pTabImpl = GetTabImpl();
1514 if (GetCore().IsIndicatorTranslucent())
1516 if (!GetCore().IsHeaderTranslucent())
1518 indicatorBounds.height = 0.0f;
1522 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
1524 indicatorBounds.height = 0.0f;
1528 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1529 GetCore().SetHeaderBounds(bounds);
1532 float titleHeight = 0.0f;
1536 titleHeight = pHeader->GetBoundsF().height;
1541 float posY = indicatorBounds.height + titleHeight;
1543 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1544 GetCore().SetTabBounds(bounds);
1549 float adjHeight = 0.0f;
1551 if (!(GetCore().GetFooter()->GetVisibleState()) || GetCore().IsFooterTranslucent())
1553 adjHeight = GetCore().GetToolbarHeightF(false);
1556 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1557 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1559 adjHeight = GetCore().GetToolbarHeightF(false);
1562 FloatRectangle clientbounds = GetClientBoundsF();
1563 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - adjHeight, clientbounds.width, GetCore().GetToolbarHeightF(false));
1565 GetCore().SetFooterBounds(bounds);
1568 UpdateOrientationStatus();
1572 __pOriAgent->RequestOrientationEvent();
1579 _FormImpl::OnDetachingFromMainTree(void)
1581 result r = E_SUCCESS;
1582 r = GetCore().DetachingFromMainTree();
1583 r = _ContainerImpl::OnDetachingFromMainTree();
1589 _FormImpl::OnNotifiedN(const _ControlImpl& source, IList* pArgs)
1591 String* pString = dynamic_cast <Tizen::Base::String*>(pArgs->GetAt(0));
1594 if (*pString == _REQUEST_ORIENTATION_EVENT)
1598 __pOriAgent->FireOrientationEvent();
1601 pArgs->RemoveAll(true);
1612 _FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source)
1614 if (__pFormBackEventListener)
1616 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1617 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1620 __pFormBackEventListener->OnFormBackRequested(*pForm);
1630 _FormImpl::OnFormMenuRequested(Tizen::Ui::Controls::_Form& source)
1632 if (__pFormMenuEventListener)
1634 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1635 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1638 __pFormMenuEventListener->OnFormMenuRequested(*pForm);
1648 _FormImpl::OnFormOrientationStatusRequested(void)
1650 _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
1651 SysAssert(pImplManager);
1653 OrientationStatus status = ORIENTATION_STATUS_PORTRAIT;
1654 int appType = _AppInfo::GetAppType();
1655 if (!(appType & _APP_TYPE_IME_APP))
1657 status = pImplManager->GetOrientationStatus(GetOrientation());
1663 _FormImpl::IsOpaque(void) const
1670 _FormImpl::ConvertSoftkey(Softkey softkey) const
1674 if (softkey == SOFTKEY_0)
1676 _softkey = _SOFTKEY_0;
1678 else if (softkey == SOFTKEY_1)
1680 _softkey = _SOFTKEY_1;
1684 _softkey = _SOFTKEY_COUNT;
1691 _FormImpl::SetNotificationTrayOpenEnabled(bool enable)
1693 return GetCore().SetNotificationTrayOpenEnabled(enable);
1697 _FormImpl::IsNotificationTrayOpenEnabled(void) const
1699 return GetCore().IsNotificationTrayOpenEnabled();
1703 : public _UiBuilderControlMaker
1706 _FormMaker(_UiBuilder* uibuilder)
1707 : _UiBuilderControlMaker(uibuilder){};
1708 virtual ~_FormMaker()
1711 static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1713 _FormMaker* pFormMaker = new (std::nothrow) _FormMaker(uibuilder);
1717 virtual Control* Make(_UiBuilderControl* pControl)
1719 _UiBuilderControlLayout* pControlProperty = null;
1720 result r = E_SUCCESS;
1723 Tizen::Base::String elementString;
1724 bool isTitleAlign = false;
1727 HorizontalAlignment align = ALIGNMENT_CENTER;
1728 Form* pForm = (Form*) GetContainer();
1730 // Get control manager
1731 _ControlManager* pControlManager = _ControlManager::GetInstance();
1732 if (pControlManager == null)
1734 SysLog(NID_UI_CTRL, "Unable to get the control manager.n");
1737 FloatDimension screenSize = pControlManager->GetScreenSizeF();
1740 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(0.0f, 0.0f, screenSize.width, screenSize.height);
1741 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(0.0f, 0.0f, screenSize.height, screenSize.width);
1743 // Get device orientation
1744 app_device_orientation_e deviceOrientation = app_get_device_orientation();
1745 bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270);
1749 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE);
1753 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1756 if (pControlProperty == null)
1758 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Can't read attributes");
1762 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1763 Tizen::Base::String styleString;
1764 styleString = pControlProperty->GetStyle();
1766 if (styleString.Contains(L"FORM_STYLE_TITLE"))
1768 style |= FORM_STYLE_TITLE;
1770 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_0"))
1772 style |= FORM_STYLE_SOFTKEY_0;
1774 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_1"))
1776 style |= FORM_STYLE_SOFTKEY_1;
1778 if (styleString.Contains(L"FORM_STYLE_OPTIONKEY"))
1780 style |= FORM_STYLE_OPTIONKEY;
1782 if (styleString.Contains(L"FORM_STYLE_INDICATOR"))
1784 if (styleString.Contains(L"FORM_STYLE_INDICATOR_AUTO_HIDE"))
1786 style |= FORM_STYLE_INDICATOR_AUTO_HIDE;
1790 style |= FORM_STYLE_INDICATOR;
1793 if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
1795 style |= FORM_STYLE_TEXT_TAB;
1797 if (styleString.Contains(L"FORM_STYLE_ICON_TAB"))
1799 style |= FORM_STYLE_ICON_TAB;
1801 if (styleString.Contains(L"FORM_STYLE_HEADER"))
1803 style |= FORM_STYLE_HEADER;
1805 if (styleString.Contains(L"FORM_STYLE_FOOTER"))
1807 style |= FORM_STYLE_FOOTER;
1810 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1811 __pLayoutMaker->GetLayoutType(pControlProperty, layoutType);
1812 if (layoutType == UIBUILDER_LAYOUT_NONE)
1815 r = pForm->Construct(style);
1819 Layout* pPortraitLayout = null;
1820 Layout* pLandscapeLayout = null;
1821 result tempResult = E_SUCCESS;
1822 tempResult = __pLayoutMaker->GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout);
1823 if (E_SUCCESS == tempResult)
1825 r = pForm->Construct(*pPortraitLayout, *pLandscapeLayout, style);
1832 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1834 if (__pLayoutMaker->GetLayoutType(pControlProperty, layoutType) == false)
1839 if ( layoutType == UIBUILDER_LAYOUT_GRID)
1841 for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
1843 GridLayout* pGridLayout = null;
1844 pControlProperty = pControl->GetAttribute(i);
1846 if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT)
1848 pGridLayout = dynamic_cast<GridLayout*>(pPortraitLayout);
1852 pGridLayout = dynamic_cast<GridLayout*>(pLandscapeLayout);
1854 __pLayoutMaker->SetGridLayoutContainerProperty(pGridLayout, pControlProperty);
1857 delete pPortraitLayout;
1858 if (pPortraitLayout != pLandscapeLayout)
1860 delete pLandscapeLayout;
1866 SysLog(NID_UI_CTRL, "Failed to create Form.");
1871 if (pControl->GetElement(L"titleAlign", elementString))
1873 if (elementString.Equals(L"ALIGN_CENTER", false))
1875 align = ALIGNMENT_CENTER;
1877 else if (elementString.Equals(L"ALIGN_RIGHT", false))
1879 align = ALIGNMENT_RIGHT;
1883 align = ALIGNMENT_LEFT;
1885 isTitleAlign = true;
1888 if (style & FORM_STYLE_TITLE)
1890 if (pControl->GetElement(L"title", elementString))
1894 pForm->SetTitleText(elementString, align);
1898 pForm->SetTitleText(elementString);
1905 pForm->SetTitleText(L"", align);
1909 pForm->SetTitleText(L"");
1914 if (pControl->GetElement(L"titleIcon", elementString))
1916 Bitmap* pBitmap = null;
1917 pBitmap = LoadBitmapN(elementString);
1918 if (pBitmap != null)
1920 r = pForm->SetTitleIcon(pBitmap);
1924 SysLog(NID_UI_CTRL, "Failed to set TitleIcon.");
1929 if (pControl->GetElement(L"softKey0Text", elementString))
1931 pForm->SetSoftkeyText(SOFTKEY_0, elementString);
1933 if (pControl->GetElement(L"softKey1Text", elementString))
1935 pForm->SetSoftkeyText(SOFTKEY_1, elementString);
1937 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
1939 Base::Integer::Parse(elementString, opacity);
1941 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
1943 ConvertStringToColor32(elementString, opacity, color);
1944 pForm->SetBackgroundColor(color);
1949 r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color);
1952 pForm->SetBackgroundColor(color);
1956 pForm->SetBackgroundColor(0xff000000);
1960 if (pControl->GetElement(L"softKey0Icon", elementString) || pControl->GetElement(L"softKey0NormalIcon", elementString))
1962 Bitmap* pNormalBitmap = null;
1963 Bitmap* pPressedBitmap = null;
1964 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1966 if (pNormalBitmap != null)
1968 if (pControl->GetElement(L"softKey0PressedIcon", elementString))
1970 pPressedBitmap = LoadBitmapN(elementString);
1973 if (pPressedBitmap != null)
1975 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, pPressedBitmap);
1976 delete pNormalBitmap;
1977 delete pPressedBitmap;
1981 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, null);
1982 delete pNormalBitmap;
1986 if (pControl->GetElement(L"softKey1Icon", elementString) || pControl->GetElement(L"softKey1NormalIcon", elementString))
1988 Bitmap* pNormalBitmap = null;
1989 Bitmap* pPressedBitmap = null;
1990 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1992 if (pNormalBitmap != null)
1994 if (pControl->GetElement(L"softKey1PressedIcon", elementString))
1996 pPressedBitmap = LoadBitmapN(elementString); // __image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1999 if (pPressedBitmap != null)
2001 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, pPressedBitmap);
2002 delete pNormalBitmap;
2003 delete pPressedBitmap;
2007 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, null);
2008 delete pNormalBitmap;
2013 if (pControl->GetElement(L"Orientation", elementString) || pControl->GetElement(L"orientation", elementString))
2016 //ORIENTATION_PORTRAIT,
2017 //ORIENTATION_LANDSACPE,
2018 //ORIENTATION_PORTRAIT_REVERSE,
2019 //ORIENTATION_LANDSACPE_REVERSE,
2020 //ORIENTATION_AUTO = 6,
2021 //ORIENTATION_AUTO_FOUR_DIRECTION = 8,
2023 if (elementString.Equals(L"Automatic:2Dir", false) || elementString.Equals(L"Automatic", false))
2025 pForm->SetOrientation(ORIENTATION_AUTOMATIC);
2027 else if (elementString.Equals(L"Automatic:4Dir", false))
2029 pForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
2031 else if (elementString.Equals(L"Landscape", false))
2033 pForm->SetOrientation(ORIENTATION_LANDSCAPE);
2034 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2036 else if (elementString.Equals(L"Landscape:Reverse", false))
2038 pForm->SetOrientation(ORIENTATION_LANDSCAPE_REVERSE);
2039 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2041 else if (elementString.Equals(L"Portrait", false))
2043 pForm->SetOrientation(ORIENTATION_PORTRAIT);
2044 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2046 else if (elementString.Equals(L"Portrait:Reverse", false))
2048 pForm->SetOrientation(ORIENTATION_PORTRAIT_REVERSE);
2049 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2053 if (style & FORM_STYLE_HEADER)
2055 if (pControl->GetElement(L"translucentHeader", elementString))
2057 if (elementString.Equals(L"true", false))
2059 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_HEADER, true);
2064 if (style & FORM_STYLE_FOOTER)
2066 if (pControl->GetElement(L"translucentFooter", elementString))
2068 if (elementString.Equals(L"true", false))
2070 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_FOOTER, true);
2075 if (style & FORM_STYLE_INDICATOR)
2077 if (pControl->GetElement(L"translucentIndicator", elementString))
2079 if (elementString.Equals(L"true", false))
2081 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
2091 _FormRegister::_FormRegister()
2093 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2094 pUiBuilderControlTableManager->RegisterControl(L"Form", _FormMaker::GetInstance);
2096 _FormRegister::~_FormRegister()
2098 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2099 pUiBuilderControlTableManager->UnregisterControl(L"Form");
2101 static _FormRegister FormRegisterToUiBuilder;
2102 }}} // Tizen::Ui::Controls