2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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)
104 , __pImeOriAgent(null)
105 , __pLeftSoftkeyActionEvent(null)
106 , __pRightSoftkeyActionEvent(null)
107 , __pOptionMenuActionEvent(null)
111 int appType = _AppInfo::GetAppType();
112 if (appType & _APP_TYPE_IME_APP)
114 __pImeOriAgent = _ImeOrientationAgent::CreateInstanceN(*pPublic);
115 SysTryReturnVoidResult(NID_UI_CTRL, __pImeOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
119 __pOriAgent = _OrientationAgent::CreateInstanceN(*pPublic);
120 SysTryReturnVoidResult(NID_UI_CTRL, __pOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
124 _FormImpl::~_FormImpl(void)
128 delete __pImeOriAgent;
129 __pImeOriAgent = null;
138 if (__pLeftSoftkeyActionEvent)
140 delete __pLeftSoftkeyActionEvent;
141 __pLeftSoftkeyActionEvent = null;
144 if (__pRightSoftkeyActionEvent)
146 delete __pRightSoftkeyActionEvent;
147 __pRightSoftkeyActionEvent = null;
150 if (__pOptionMenuActionEvent)
152 delete __pOptionMenuActionEvent;
153 __pOptionMenuActionEvent = null;
156 __leftSoftkeyActionList.RemoveAll(false);
157 __rightSoftkeyActionList.RemoveAll(false);
169 _FormImpl::CreateFormImplN(Form* pControl, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout)
171 result r = E_SUCCESS;
172 _VisualElement* pVisualElement = null;
174 _Form* pCore = _Form::CreateFormN();
176 SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); // [ToDo] interpret last result.
178 _FormImpl* pImpl = new (std::nothrow) _FormImpl(pControl, pCore, pPublicPortraitLayout, pPublicLandscapeLayout);
180 r = _ControlImpl::CheckConstruction(pCore, pImpl);
181 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
183 const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
184 const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
186 _ControlOrientation orientation = pCore->GetOrientation();
188 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
190 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Form), portraitSize, orientation);
194 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Form), landscapeSize, orientation);
196 SysAssert(r == E_SUCCESS);
198 // Make surface opaque.
199 pVisualElement = pCore->GetVisualElement();
200 SysTryCatch(NID_UI_CTRL, pVisualElement, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
201 r = pVisualElement->SetSurfaceOpaque(true);
202 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); // [ToDo] interpret last result.
204 SetLastResult(E_SUCCESS);
216 _FormImpl::GetPublicClassName(void) const
218 return "Tizen::Ui::Controls::Form";
222 _FormImpl::GetPublic(void) const
224 return static_cast<const Form&>(_ControlImpl::GetPublic());
228 _FormImpl::GetPublic(void)
230 return static_cast<Form&>(_ControlImpl::GetPublic());
234 _FormImpl::GetCore(void) const
236 return static_cast<const _Form&>(_ControlImpl::GetCore());
240 _FormImpl::GetCore(void)
242 return static_cast<_Form&>(_ControlImpl::GetCore());
246 _FormImpl::GetFocusControl(void)
252 _FormImpl::GetFormStyle(void) const
254 return GetCore().GetFormStyle();
258 _FormImpl::HasIndicator(void) const
260 return GetCore().HasIndicator();
264 _FormImpl::SetFormStyle(unsigned long formStyle)
266 result r = E_SUCCESS;
268 _HeaderImpl* pHeader = GetHeader();
269 _FooterImpl* pFooter = GetFooter();
270 _TabImpl* pTabImpl = GetTabImpl();
272 if (IsAttachedToMainTree())
274 if (FORM_STYLE_INDICATOR & formStyle)
276 _Frame* pFrame = dynamic_cast<_Frame*>(GetCore().GetParent());
277 SysTryReturnVoidResult(NID_UI_CTRL, pFrame != null, E_INVALID_ARG, "A Form which has FORM_STYLE_INDICATOR style cannot be added to a container except Frame.");
281 if ((formStyle & FORM_STYLE_INDICATOR) && (formStyle & FORM_STYLE_INDICATOR_AUTO_HIDE))
283 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.");
288 if (((formStyle & FORM_STYLE_TITLE) || (formStyle & FORM_STYLE_TEXT_TAB) || (formStyle & FORM_STYLE_ICON_TAB)) && (formStyle & FORM_STYLE_HEADER))
290 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.");
297 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
303 if (((formStyle & FORM_STYLE_SOFTKEY_0) || (formStyle & FORM_STYLE_SOFTKEY_1) || (formStyle & FORM_STYLE_OPTIONKEY)) && (formStyle & FORM_STYLE_FOOTER))
305 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.");
312 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
317 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
318 SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas.");
320 GetCore().SetFormStyle(formStyle);
322 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
324 if (FORM_STYLE_INDICATOR & formStyle)
326 GetCore().SetIndicatorShowState(true);
327 indicatorBounds = GetCore().GetIndicatorBoundsF();
329 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
332 else if(FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle)
334 r = GetCore().SetIndicatorShowState(false, true);
335 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
339 r = GetCore().SetIndicatorShowState(false);
340 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
343 if (formStyle & FORM_STYLE_HEADER)
347 pHeader = CreateHeaderN();
348 SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
350 GetCore().SetHeader(&pHeader->GetCore());
351 GetCore().AdjustClientBounds();
353 if (GetCore().IsIndicatorTranslucent())
355 if (!GetCore().IsHeaderTranslucent())
357 indicatorBounds.height = 0.0f;
361 if (GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
363 indicatorBounds.height = 0.0f;
368 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
369 GetCore().SetHeaderBounds(bounds);
371 r = GetCore().AttachSystemChild(pHeader->GetCore());
372 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
374 GetCore().SetFormBackEventListener(this);
377 else if (formStyle & FORM_STYLE_TITLE)
381 pHeader = CreateHeaderN();
382 SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
384 GetCore().SetHeader(&pHeader->GetCore());
385 GetCore().AdjustClientBounds();
387 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
388 GetCore().SetHeaderBounds(bounds);
390 r = GetCore().AttachSystemChild(pHeader->GetCore());
391 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
401 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
405 if (formStyle & FORM_STYLE_TEXT_TAB)
407 float titleHeight = 0.0f;
409 if (formStyle & FORM_STYLE_TITLE)
413 titleHeight = pHeader->GetBoundsF().height;
419 pTabImpl = CreateTabImplN();
420 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
422 float posY = indicatorBounds.height + titleHeight;
424 GetCore().SetTab(&pTabImpl->GetCore());
425 GetCore().AdjustClientBounds();
427 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
428 GetCore().SetTabBounds(bounds);
430 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
431 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
433 GetCore().SetTabStyle(_TAB_STYLE_TEXT);
435 else if (formStyle & FORM_STYLE_ICON_TAB)
437 float titleHeight = 0.0f;
439 if (formStyle & FORM_STYLE_TITLE)
443 titleHeight = pHeader->GetBoundsF().height;
449 pTabImpl = CreateTabImplN();
450 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
452 float posY = indicatorBounds.height + titleHeight;
454 GetCore().SetTab(&pTabImpl->GetCore());
455 GetCore().AdjustClientBounds();
457 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
458 GetCore().SetTabBounds(bounds);
460 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
461 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
463 GetCore().SetTabStyle(_TAB_STYLE_ICON);
471 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
475 if (formStyle & FORM_STYLE_FOOTER)
479 pFooter = CreateFooterN();
480 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
482 GetCore().SetFooter(&pFooter->GetCore());
483 GetCore().AdjustClientBounds();
485 FloatRectangle clientbounds = GetClientBoundsF();
486 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height, clientbounds.width, GetCore().GetToolbarHeightF(false));
488 GetCore().SetFooterBounds(bounds);
490 r = GetCore().AttachSystemChild(pFooter->GetCore());
491 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
493 GetCore().SetFormBackEventListener(this);
496 else if (formStyle & FORM_STYLE_SOFTKEY_0 || formStyle & FORM_STYLE_SOFTKEY_1 || formStyle & FORM_STYLE_OPTIONKEY)
502 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
505 pFooter = GetFooter();
509 pFooter = CreateFooterN();
510 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
512 GetCore().SetFooter(&pFooter->GetCore());
513 GetCore().AdjustClientBounds();
515 FloatRectangle clientbounds = GetClientBoundsF();
516 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - GetCore().GetToolbarHeightF(false), clientbounds.width, GetCore().GetToolbarHeightF(false));
518 GetCore().SetFooterBounds(bounds);
520 r = GetCore().AttachSystemChild(pFooter->GetCore());
521 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
523 GetCore().CreateSoftkey(formStyle);
525 pFooter->GetCore().AddActionEventListener(*this);
535 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
536 GetCore().AdjustClientBounds();
540 GetCore().AdjustClientBounds();
542 SetLastResult(E_SUCCESS);
548 _FormImpl::GetFooter(void) const
550 _Toolbar* pToolbar = __pForm->GetFooter();
551 if (pToolbar == null)
556 _FooterImpl* pFooterImpl = static_cast<_FooterImpl*>(pToolbar->GetUserData());
562 _FormImpl::GetHeader(void) const
564 _Toolbar* pToolbar = __pForm->GetHeader();
565 if (pToolbar == null)
570 _HeaderImpl* pHeaderImpl = static_cast<_HeaderImpl*>(pToolbar->GetUserData());
577 _FormImpl::GetTabImpl(void) const
579 _Tab* pTab = __pForm->GetTab();
585 _TabImpl* pTabImpl = static_cast<_TabImpl*>(pTab->GetUserData());
591 _FormImpl::GetTitleText(void) const
593 return GetCore().GetTitleText();
597 _FormImpl::GetTitleTextHorizontalAlignment(void) const
599 return GetCore().GetTitleTextHorizontalAlignment();
603 _FormImpl::HasFooter(void) const
605 return GetCore().HasFooter();
609 _FormImpl::HasHeader(void) const
611 return GetCore().HasHeader();
615 _FormImpl::HasTitle(void) const
617 return GetCore().HasTitle();
621 _FormImpl::HasTab(void) const
623 return GetCore().HasTab();
627 _FormImpl::IsIndicatorVisible(void) const
629 return GetCore().IsIndicatorVisible();
633 _FormImpl::IsHeaderVisible(void) const
635 return GetCore().IsHeaderVisible();
639 _FormImpl::IsFooterVisible(void) const
641 return GetCore().IsFooterVisible();
645 _FormImpl::IsIndicatorTranslucent(void) const
647 return GetCore().IsIndicatorTranslucent();
651 _FormImpl::IsHeaderTranslucent(void) const
653 return GetCore().IsHeaderTranslucent();
657 _FormImpl::IsFooterTranslucent(void) const
659 return GetCore().IsFooterTranslucent();
664 _FormImpl::IsTabTranslucent(void) const
666 return GetCore().IsTabTranslucent();
670 _FormImpl::SetActionBarsTranslucent(unsigned long actionBars, bool translucent)
672 return GetCore().SetActionBarsTranslucent(actionBars, translucent);
676 _FormImpl::SetActionBarsVisible(unsigned long actionBars, bool visible)
678 return GetCore().SetActionBarsVisible(actionBars, visible);
682 _FormImpl::SetTitleIcon(const Bitmap* pTitleBitmap)
684 return GetCore().SetTitleIcon(pTitleBitmap);
688 _FormImpl::SetTitleText(const String& title, HorizontalAlignment alignment)
690 return GetCore().SetTitleText(title, alignment);
694 _FormImpl::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType)
696 return GetCore().GetOverlayRegionN(rect, regionType);
700 _FormImpl::GetOverlayRegionN(const FloatRectangle& rect, OverlayRegionType regionType)
702 return GetCore().GetOverlayRegionN(rect, regionType);
706 _FormImpl::OnDraw(void)
710 __pOriAgent->FireOrientationEvent();
713 _ContainerImpl::OnDraw();
717 _FormImpl::OnKeyReleased(const _ControlImpl& source, _KeyCode keyCode)
722 if (GetCore().GetFooter() || GetCore().GetHeader())
724 if (__pFormBackEventListener)
726 Form* pForm = dynamic_cast <Form*>(&GetPublic());
729 __pFormBackEventListener->OnFormBackRequested(*pForm);
751 _FormImpl::OnActionPerformed(const _Control& source, int actionId)
753 if (GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetFormStyle() & FORM_STYLE_SOFTKEY_1 || GetFormStyle() & FORM_STYLE_OPTIONKEY)
755 Tizen::Base::Runtime::IEventArg* tempArg = null;
756 tempArg = _PublicActionEvent::CreateActionEventArgN(actionId);
757 SysTryReturnVoidResult(NID_UI_CTRL, tempArg , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create Eventarg.");
760 _PublicActionEvent* pSoftkeyActionEvent = null;
762 if (GetCore().GetFooter()->IsButtonSet(LEFT_BUTTON) && GetSoftkeyActionId(SOFTKEY_0) == actionId)
764 for (int i = 0; i < __leftSoftkeyActionList.GetCount(); i++)
766 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__leftSoftkeyActionList.GetAt(i));
768 if (pSoftkeyActionEvent)
770 pSoftkeyActionEvent->Fire(*tempArg);
776 if (GetCore().GetFooter()->IsButtonSet(RIGHT_BUTTON) && GetSoftkeyActionId(SOFTKEY_1) == actionId)
778 for (int i = 0; i < __rightSoftkeyActionList.GetCount(); i++)
780 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__rightSoftkeyActionList.GetAt(i));
782 if (pSoftkeyActionEvent)
784 pSoftkeyActionEvent->Fire(*tempArg);
790 if (GetCore().GetFooter()->IsButtonSet(MIDDLE_BUTTON) && GetOptionkeyActionId() == actionId)
792 if (__pOptionMenuActionEvent)
794 __pOptionMenuActionEvent->Fire(*tempArg);
806 _FormImpl::GetClientAreaCanvasN(void) const
808 return GetCore().GetClientAreaCanvasN();
812 _FormImpl::TranslateToClientAreaPosition(const Point& position) const
814 return GetCore().TranslateToClientAreaPosition(position);
818 _FormImpl::TranslateToClientAreaPosition(const FloatPoint& position) const
820 return GetCore().TranslateToClientAreaPosition(position);
824 _FormImpl::TranslateFromClientAreaPosition(const Point& clientPosition) const
826 return GetCore().TranslateFromClientAreaPosition(clientPosition);
830 _FormImpl::TranslateFromClientAreaPosition(const FloatPoint& clientPosition) const
832 return GetCore().TranslateFromClientAreaPosition(clientPosition);
836 _FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEventListener)
838 SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
839 __pFormBackEventListener = const_cast <IFormBackEventListener*>(pFormBackEventListener);
840 GetCore().SetFormBackEventListener(this);
841 result r = GetLastResult();
842 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
846 _FormImpl::AddOrientationEventListener(IOrientationEventListener& listener)
850 __pOriAgent->AddListener(listener);
852 else if (__pImeOriAgent)
854 __pImeOriAgent->AddListener(listener);
859 _FormImpl::AddOptionkeyActionListener(const IActionEventListener& listener)
861 if (HasOptionkey() == false)
866 __pOptionMenuActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
868 SysTryReturnVoidResult(NID_UI_CTRL, __pOptionMenuActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
870 __pOptionMenuActionEvent->AddListener(listener);
874 _FormImpl::AddSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
876 _Softkey _softkey = ConvertSoftkey(softkey);
878 if (GetCore().CheckSoftkey(_softkey) == false)
883 if (softkey == SOFTKEY_0)
885 __pLeftSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
887 SysTryReturnVoidResult(NID_UI_CTRL, __pLeftSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
889 __pLeftSoftkeyActionEvent->AddListener(listener);
891 __leftSoftkeyActionList.Add(*__pLeftSoftkeyActionEvent);
893 else if (softkey == SOFTKEY_1)
895 __pRightSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
897 SysTryReturnVoidResult(NID_UI_CTRL, __pRightSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
899 __pRightSoftkeyActionEvent->AddListener(listener);
901 __rightSoftkeyActionList.Add(*__pRightSoftkeyActionEvent);
906 _FormImpl::RemoveOrientationEventListener(IOrientationEventListener& listener)
910 __pOriAgent->RemoveListener(listener);
912 else if (__pImeOriAgent)
914 __pImeOriAgent->RemoveListener(listener);
919 _FormImpl::RemoveOptionkeyActionListener(const IActionEventListener& listener)
921 if (HasOptionkey() == false)
926 if (__pOptionMenuActionEvent)
928 __pOptionMenuActionEvent->RemoveListener(listener);
933 _FormImpl::RemoveSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
935 _Softkey _softkey = ConvertSoftkey(softkey);
937 if (GetCore().CheckSoftkey(_softkey) == false)
942 if (softkey == SOFTKEY_0)
944 if (__pLeftSoftkeyActionEvent)
946 __pLeftSoftkeyActionEvent->RemoveListener(listener);
949 else if (softkey == SOFTKEY_1)
951 if (__pRightSoftkeyActionEvent)
953 __pRightSoftkeyActionEvent->RemoveListener(listener);
959 _FormImpl::SetOrientation(Orientation orientation)
963 __pOriAgent->SetMode(orientation);
968 _FormImpl::GetOrientation(void) const
972 return __pOriAgent->GetMode();
975 return ORIENTATION_NONE;
979 _FormImpl::GetOrientationStatus(void) const
983 return __pOriAgent->GetStatus();
986 return ORIENTATION_STATUS_NONE;
990 _FormImpl::UpdateOrientationStatus(bool draw)
994 __pOriAgent->Update(draw);
998 #if defined(WINDOW_BASE_ROTATE)
1000 _FormImpl::UpdateOrientation(void)
1004 __pOriAgent->UpdateOrientation();
1010 _FormImpl::UpdateOrientation(int angle)
1012 SysLog(NID_UI_CTRL, "[Ime Rotation]");
1016 __pImeOriAgent->UpdateOrientation(angle);
1021 _FormImpl::HasOptionkey(void) const
1023 return GetCore().HasOptionkey();
1027 _FormImpl::HasSoftkey(Softkey softkey) const
1029 _Softkey _softkey = ConvertSoftkey(softkey);
1031 return GetCore().HasSoftkey(_softkey);
1035 _FormImpl::SetSoftkeyEnabled(Softkey softkey, bool enable)
1037 _Softkey _softkey = ConvertSoftkey(softkey);
1039 result r = GetCore().SetSoftkeyEnabled(_softkey, enable);
1040 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1046 _FormImpl::IsSoftkeyEnabled(Softkey softkey) const
1048 _Softkey _softkey = ConvertSoftkey(softkey);
1050 return GetCore().IsSoftkeyEnabled(_softkey);
1054 _FormImpl::GetSoftkeyActionId(Softkey softkey) const
1056 _Softkey _softkey = ConvertSoftkey(softkey);
1058 return GetCore().GetSoftkeyActionId(_softkey);
1062 _FormImpl::GetOptionkeyActionId(void) const
1064 return GetCore().GetOptionkeyActionId();
1068 _FormImpl::GetSoftkeyText(Softkey softkey) const
1070 _Softkey _softkey = ConvertSoftkey(softkey);
1072 return GetCore().GetSoftkeyText(_softkey);
1076 _FormImpl::SetOptionkeyActionId(int actionId)
1078 result r = GetCore().SetOptionkeyActionId(actionId);
1079 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1085 _FormImpl::SetSoftkeyActionId(Softkey softkey, int actionId)
1087 _Softkey _softkey = ConvertSoftkey(softkey);
1089 result r = GetCore().SetSoftkeyActionId(_softkey, actionId);
1090 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1096 _FormImpl::SetSoftkeyText(Softkey softkey, const String& text)
1098 _Softkey _softkey = ConvertSoftkey(softkey);
1100 result r = GetCore().SetSoftkeyText(_softkey, text);
1101 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1107 _FormImpl::SetSoftkeyIcon(Softkey softkey, const Bitmap& pNormalBitmap, const Bitmap* ppPressedBitmap)
1109 _Softkey _softkey = ConvertSoftkey(softkey);
1111 result r = GetCore().SetSoftkeyIcon(_softkey, pNormalBitmap, ppPressedBitmap);
1112 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1118 _FormImpl::OnChangeLayout(_ControlOrientation orientation)
1120 const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1121 const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
1123 // Adjust the position of the partial Frame.
1124 _FrameImpl* pFrameImpl = dynamic_cast<_FrameImpl*>(GetParent());
1127 FrameShowMode frameShowMode = pFrameImpl->GetShowMode();
1129 if ((frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
1131 bool movable = pFrameImpl->GetCore().IsMovable();
1132 pFrameImpl->GetCore().SetMovable(true);
1134 FloatPoint prevPoint = pFrameImpl->GetPositionF();
1135 FloatDimension prevSize = pFrameImpl->GetSizeF();
1137 FloatPoint curPoint(0.0f, 0.0f);
1139 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1141 if (prevPoint.x < 0.0f)
1143 float prevGap = prevSize.width + prevPoint.x;
1144 float curGap = portraitSize.width / portraitSize.height * prevGap;
1146 curPoint.x = curGap - prevSize.width;
1150 curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
1153 if (prevPoint.y < 0.0f)
1155 float prevGap = prevSize.height + prevPoint.y;
1156 float curGap = portraitSize.height / portraitSize.width * prevGap;
1158 curPoint.y = curGap - prevSize.height;
1162 curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
1167 if (prevPoint.x < 0.0f)
1169 float prevGap = prevSize.width + prevPoint.x;
1170 float curGap = portraitSize.height / portraitSize.width * prevGap;
1172 curPoint.x = curGap - prevSize.width;
1176 curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;
1179 if (prevPoint.y < 0.0f)
1181 float prevGap = prevSize.height + prevPoint.y;
1182 float curGap = portraitSize.width / portraitSize.height * prevGap;
1184 curPoint.y = curGap - prevSize.height;
1188 curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
1192 pFrameImpl->SetPosition(curPoint);
1194 pFrameImpl->GetCore().SetMovable(movable);
1199 _ContainerImpl::OnChangeLayout(orientation);
1200 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1202 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1204 SetSize(portraitSize);
1208 SetSize(landscapeSize);
1211 float indicatorheight = 0.0f;
1213 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1214 if (GetCore().HasIndicator())
1216 _Indicator* pIndicator = GetCore().GetIndicator();
1219 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1221 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1225 GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1226 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1229 GetCore().AdjustClientBounds();
1233 float adjHeight = 0.0f;
1235 if (GetCore().HasHeader())
1237 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1238 if (GetCore().IsIndicatorVisible())
1240 indicatorBounds = GetCore().GetIndicatorBoundsF();
1241 if (GetCore().IsIndicatorTranslucent())
1243 if (!GetCore().IsHeaderTranslucent())
1245 indicatorBounds.height = 0.0f;
1249 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1251 indicatorBounds.height = 0.0f;
1257 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1258 GetCore().SetHeaderBounds(bounds);
1261 if (GetCore().HasTab()) // Ki-Dong,Hong.Temp
1263 float titleHeight = 0.0f;
1265 if (GetCore().GetFormStyle() & FORM_STYLE_TITLE)
1267 if (GetCore().HasHeader())
1269 _HeaderImpl* pHeaderImpl = GetHeader();
1272 titleHeight = pHeaderImpl->GetBoundsF().height;
1277 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1279 if (GetCore().IsIndicatorVisible())
1281 indicatorBounds = GetCore().GetIndicatorBoundsF();
1284 float posY = indicatorBounds.height + titleHeight;
1286 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1287 GetCore().SetTabBounds(bounds);
1290 if (GetCore().HasFooter())
1292 if (GetCore().GetFooter()->GetVisibleState() && !GetCore().IsFooterTranslucent())
1298 adjHeight = GetCore().GetToolbarHeightF(false);
1301 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1302 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1304 adjHeight = GetCore().GetToolbarHeightF(false);
1307 FloatRectangle bounds(0.0f, GetClientBoundsF().y + GetClientBoundsF().height - adjHeight,
1308 GetClientBoundsF().width, GetCore().GetToolbarHeightF(false));
1309 GetCore().SetFooterBounds(bounds);
1314 _FormImpl::CreateHeaderN(void)
1316 result r = E_SUCCESS;
1318 Header* pHeader = new (std::nothrow) Header;
1319 SysTryReturn(NID_UI_CTRL, pHeader, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1321 r = pHeader->Construct();
1322 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1324 _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*pHeader);
1326 SetLastResult(E_SUCCESS);
1332 _FormImpl::CreateFooterN(void)
1334 result r = E_SUCCESS;
1336 Footer* pFooter = new (std::nothrow) Footer;
1337 SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1339 r = pFooter->Construct();
1340 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1342 _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*pFooter);
1344 SetLastResult(E_SUCCESS);
1349 // Ki-Dong,Hong.Temp
1351 _FormImpl::CreateTabImplN(void)
1353 //result r = E_SUCCESS;
1355 //Tab* pTab = new (std::nothrow) Tab;
1356 //SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
1358 //r = pTab->Construct();
1359 //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Unable to consturct tab.");
1361 //return pTab->GetTabImpl();
1362 Tab* pTab = _TabImpl::CreateTabN();
1363 SysTryReturn(NID_UI_CTRL, pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1365 _TabImpl* pTabImpl = _TabImpl::GetInstance(*pTab);
1367 SetLastResult(E_SUCCESS);
1373 _FormImpl::DeflateClientRectHeight(int height)
1375 return GetCore().DeflateClientRectHeight(height);
1379 _FormImpl::DeflateClientRectHeight(float height)
1381 return GetCore().DeflateClientRectHeight(height);
1385 _FormImpl::RemoveHeader(void)
1387 _HeaderImpl* pHeaderImpl = GetHeader();
1391 __pForm->RemoveHeader();
1392 result r = GetLastResult();
1393 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1394 Header* pHeader = pHeaderImpl->GetHeader();
1405 _FormImpl::RemoveFooter(void)
1407 _FooterImpl* pFooterImpl = GetFooter();
1411 __pForm->RemoveFooter();
1412 result r = GetLastResult();
1413 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1414 Footer* pFooter = pFooterImpl->GetFooter();
1426 // Ki-Dong,Hong.Temp
1428 _FormImpl::RemoveTabImpl(void)
1430 _TabImpl* pTabImpl = GetTabImpl();
1434 __pForm->RemoveTab();
1435 result r = GetLastResult();
1436 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1437 Tab* pTab = pTabImpl->GetTab();
1439 pTabImpl->DeleteTab(pTab);
1450 _FormImpl::GetDataBindingContextN(void) const
1452 return _DataBindingContextImpl::GetDataBindingContextN(*this);
1456 _FormImpl::OnAttaching(const _Control* pParent)
1458 result r = E_SUCCESS;
1459 _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>((pParent)));
1460 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1462 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.");
1464 r = _ControlImpl::OnAttaching(pParent);
1469 _FormImpl::OnAttachedToMainTree(void)
1471 result r = E_SUCCESS;
1474 r = GetCore().AttachedToMainTree();
1475 r = _ContainerImpl::OnAttachedToMainTree();
1477 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1479 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1481 indicatorBounds = GetCore().GetIndicatorBoundsF();
1482 r = GetLastResult();
1483 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1486 _HeaderImpl* pHeader = GetHeader();
1487 _FooterImpl* pFooter = GetFooter();
1488 _TabImpl* pTabImpl = GetTabImpl();
1492 if (GetCore().IsIndicatorTranslucent())
1494 if (!GetCore().IsHeaderTranslucent())
1496 indicatorBounds.height = 0.0f;
1500 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
1502 indicatorBounds.height = 0.0f;
1506 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1507 GetCore().SetHeaderBounds(bounds);
1510 float titleHeight = 0.0f;
1514 titleHeight = pHeader->GetBoundsF().height;
1519 float posY = indicatorBounds.height + titleHeight;
1521 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1522 GetCore().SetTabBounds(bounds);
1527 float adjHeight = 0.0f;
1529 if (!(GetCore().GetFooter()->GetVisibleState()) || GetCore().IsFooterTranslucent())
1531 adjHeight = GetCore().GetToolbarHeightF(false);
1534 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1535 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1537 adjHeight = GetCore().GetToolbarHeightF(false);
1540 FloatRectangle clientbounds = GetClientBoundsF();
1541 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - adjHeight, clientbounds.width, GetCore().GetToolbarHeightF(false));
1543 GetCore().SetFooterBounds(bounds);
1546 UpdateOrientationStatus();
1550 __pOriAgent->RequestOrientationEvent();
1557 _FormImpl::OnDetachingFromMainTree(void)
1559 result r = E_SUCCESS;
1560 r = GetCore().DetachingFromMainTree();
1561 r = _ContainerImpl::OnDetachingFromMainTree();
1567 _FormImpl::OnNotifiedN(const _ControlImpl& source, IList* pArgs)
1569 String* pString = dynamic_cast <Tizen::Base::String*>(pArgs->GetAt(0));
1572 if (*pString == _REQUEST_ORIENTATION_EVENT)
1576 __pOriAgent->FireOrientationEvent();
1579 pArgs->RemoveAll(true);
1590 _FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source)
1592 if (__pFormBackEventListener)
1594 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1595 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1598 __pFormBackEventListener->OnFormBackRequested(*pForm);
1608 _FormImpl::IsOpaque(void) const
1615 _FormImpl::ConvertSoftkey(Softkey softkey) const
1619 if (softkey == SOFTKEY_0)
1621 _softkey = _SOFTKEY_0;
1623 else if (softkey == SOFTKEY_1)
1625 _softkey = _SOFTKEY_1;
1629 _softkey = _SOFTKEY_COUNT;
1636 _FormImpl::SetNotificationTrayOpenEnabled(bool enable)
1638 return GetCore().SetNotificationTrayOpenEnabled(enable);
1642 _FormImpl::IsNotificationTrayOpenEnabled(void) const
1644 return GetCore().IsNotificationTrayOpenEnabled();
1648 : public _UiBuilderControlMaker
1651 _FormMaker(_UiBuilder* uibuilder)
1652 : _UiBuilderControlMaker(uibuilder){};
1653 virtual ~_FormMaker()
1656 static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1658 _FormMaker* pFormMaker = new (std::nothrow) _FormMaker(uibuilder);
1662 virtual Control* Make(_UiBuilderControl* pControl)
1664 _UiBuilderControlLayout* pControlProperty = null;
1665 result r = E_SUCCESS;
1668 Tizen::Base::String elementString;
1669 bool isTitleAlign = false;
1672 HorizontalAlignment align = ALIGNMENT_CENTER;
1673 Form* pForm = (Form*) GetContainer();
1675 // Get control manager
1676 _ControlManager* pControlManager = _ControlManager::GetInstance();
1677 if (pControlManager == null)
1679 SysLog(NID_UI_CTRL, "Unable to get the control manager.n");
1682 FloatDimension screenSize = pControlManager->GetScreenSizeF();
1685 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(0.0f, 0.0f, screenSize.width, screenSize.height);
1686 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(0.0f, 0.0f, screenSize.height, screenSize.width);
1688 // Get device orientation
1689 app_device_orientation_e deviceOrientation = app_get_device_orientation();
1690 bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270);
1694 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE);
1698 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1701 if (pControlProperty == null)
1703 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Can't read attributes");
1707 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1708 Tizen::Base::String styleString;
1709 styleString = pControlProperty->GetStyle();
1711 if (styleString.Contains(L"FORM_STYLE_TITLE"))
1713 style |= FORM_STYLE_TITLE;
1715 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_0"))
1717 style |= FORM_STYLE_SOFTKEY_0;
1719 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_1"))
1721 style |= FORM_STYLE_SOFTKEY_1;
1723 if (styleString.Contains(L"FORM_STYLE_OPTIONKEY"))
1725 style |= FORM_STYLE_OPTIONKEY;
1727 if (styleString.Contains(L"FORM_STYLE_INDICATOR"))
1729 if (styleString.Contains(L"FORM_STYLE_INDICATOR_AUTO_HIDE"))
1731 style |= FORM_STYLE_INDICATOR_AUTO_HIDE;
1735 style |= FORM_STYLE_INDICATOR;
1738 if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
1740 style |= FORM_STYLE_TEXT_TAB;
1742 if (styleString.Contains(L"FORM_STYLE_ICON_TAB"))
1744 style |= FORM_STYLE_ICON_TAB;
1746 if (styleString.Contains(L"FORM_STYLE_HEADER"))
1748 style |= FORM_STYLE_HEADER;
1750 if (styleString.Contains(L"FORM_STYLE_FOOTER"))
1752 style |= FORM_STYLE_FOOTER;
1755 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1756 __pLayoutMaker->GetLayoutType(pControlProperty, layoutType);
1757 if (layoutType == UIBUILDER_LAYOUT_NONE)
1760 r = pForm->Construct(style);
1764 Layout* pPortraitLayout = null;
1765 Layout* pLandscapeLayout = null;
1766 result tempResult = E_SUCCESS;
1767 tempResult = __pLayoutMaker->GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout);
1768 if (E_SUCCESS == tempResult)
1770 r = pForm->Construct(*pPortraitLayout, *pLandscapeLayout, style);
1777 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1779 if (__pLayoutMaker->GetLayoutType(pControlProperty, layoutType) == false)
1784 if ( layoutType == UIBUILDER_LAYOUT_GRID)
1786 for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
1788 GridLayout* pGridLayout = null;
1789 pControlProperty = pControl->GetAttribute(i);
1791 if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT)
1793 pGridLayout = dynamic_cast<GridLayout*>(pPortraitLayout);
1797 pGridLayout = dynamic_cast<GridLayout*>(pLandscapeLayout);
1799 __pLayoutMaker->SetGridLayoutContainerProperty(pGridLayout, pControlProperty);
1802 delete pPortraitLayout;
1803 if (pPortraitLayout != pLandscapeLayout)
1805 delete pLandscapeLayout;
1811 SysLog(NID_UI_CTRL, "Failed to create Form.");
1816 if (pControl->GetElement(L"titleAlign", elementString))
1818 if (elementString.Equals(L"ALIGN_CENTER", false))
1820 align = ALIGNMENT_CENTER;
1822 else if (elementString.Equals(L"ALIGN_RIGHT", false))
1824 align = ALIGNMENT_RIGHT;
1828 align = ALIGNMENT_LEFT;
1830 isTitleAlign = true;
1833 if (style & FORM_STYLE_TITLE)
1835 if (pControl->GetElement(L"title", elementString))
1839 pForm->SetTitleText(elementString, align);
1843 pForm->SetTitleText(elementString);
1850 pForm->SetTitleText(L"", align);
1854 pForm->SetTitleText(L"");
1859 if (pControl->GetElement(L"titleIcon", elementString))
1861 Bitmap* pBitmap = null;
1862 pBitmap = LoadBitmapN(elementString);
1863 if (pBitmap != null)
1865 r = pForm->SetTitleIcon(pBitmap);
1869 SysLog(NID_UI_CTRL, "Failed to set TitleIcon.");
1874 if (pControl->GetElement(L"softKey0Text", elementString))
1876 pForm->SetSoftkeyText(SOFTKEY_0, elementString);
1878 if (pControl->GetElement(L"softKey1Text", elementString))
1880 pForm->SetSoftkeyText(SOFTKEY_1, elementString);
1882 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
1884 Base::Integer::Parse(elementString, opacity);
1886 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
1888 ConvertStringToColor32(elementString, opacity, color);
1889 pForm->SetBackgroundColor(color);
1894 r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color);
1897 pForm->SetBackgroundColor(color);
1901 pForm->SetBackgroundColor(0xff000000);
1905 if (pControl->GetElement(L"softKey0Icon", elementString) || pControl->GetElement(L"softKey0NormalIcon", elementString))
1907 Bitmap* pNormalBitmap = null;
1908 Bitmap* pPressedBitmap = null;
1909 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1911 if (pNormalBitmap != null)
1913 if (pControl->GetElement(L"softKey0PressedIcon", elementString))
1915 pPressedBitmap = LoadBitmapN(elementString);
1918 if (pPressedBitmap != null)
1920 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, pPressedBitmap);
1921 delete pNormalBitmap;
1922 delete pPressedBitmap;
1926 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, null);
1927 delete pNormalBitmap;
1931 if (pControl->GetElement(L"softKey1Icon", elementString) || pControl->GetElement(L"softKey1NormalIcon", elementString))
1933 Bitmap* pNormalBitmap = null;
1934 Bitmap* pPressedBitmap = null;
1935 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1937 if (pNormalBitmap != null)
1939 if (pControl->GetElement(L"softKey1PressedIcon", elementString))
1941 pPressedBitmap = LoadBitmapN(elementString); // __image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1944 if (pPressedBitmap != null)
1946 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, pPressedBitmap);
1947 delete pNormalBitmap;
1948 delete pPressedBitmap;
1952 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, null);
1953 delete pNormalBitmap;
1958 if (pControl->GetElement(L"Orientation", elementString) || pControl->GetElement(L"orientation", elementString))
1961 //ORIENTATION_PORTRAIT,
1962 //ORIENTATION_LANDSACPE,
1963 //ORIENTATION_PORTRAIT_REVERSE,
1964 //ORIENTATION_LANDSACPE_REVERSE,
1965 //ORIENTATION_AUTO = 6,
1966 //ORIENTATION_AUTO_FOUR_DIRECTION = 8,
1968 if (elementString.Equals(L"Automatic:2Dir", false) || elementString.Equals(L"Automatic", false))
1970 pForm->SetOrientation(ORIENTATION_AUTOMATIC);
1972 else if (elementString.Equals(L"Automatic:4Dir", false))
1974 pForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
1976 else if (elementString.Equals(L"Landscape", false))
1978 pForm->SetOrientation(ORIENTATION_LANDSCAPE);
1979 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
1981 else if (elementString.Equals(L"Landscape:Reverse", false))
1983 pForm->SetOrientation(ORIENTATION_LANDSCAPE_REVERSE);
1984 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
1986 else if (elementString.Equals(L"Portrait", false))
1988 pForm->SetOrientation(ORIENTATION_PORTRAIT);
1989 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
1991 else if (elementString.Equals(L"Portrait:Reverse", false))
1993 pForm->SetOrientation(ORIENTATION_PORTRAIT_REVERSE);
1994 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
1998 if (style & FORM_STYLE_HEADER)
2000 if (pControl->GetElement(L"translucentHeader", elementString))
2002 if (elementString.Equals(L"true", false))
2004 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_HEADER, true);
2009 if (style & FORM_STYLE_FOOTER)
2011 if (pControl->GetElement(L"translucentFooter", elementString))
2013 if (elementString.Equals(L"true", false))
2015 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_FOOTER, true);
2020 if (style & FORM_STYLE_INDICATOR)
2022 if (pControl->GetElement(L"translucentIndicator", elementString))
2024 if (elementString.Equals(L"true", false))
2026 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
2036 _FormRegister::_FormRegister()
2038 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2039 pUiBuilderControlTableManager->RegisterControl(L"Form", _FormMaker::GetInstance);
2041 _FormRegister::~_FormRegister()
2043 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2044 pUiBuilderControlTableManager->UnregisterControl(L"Form");
2046 static _FormRegister FormRegisterToUiBuilder;
2047 }}} // Tizen::Ui::Controls