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();
332 if (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle)
334 GetCore().SetIndicatorAutoHide(false, true);
338 GetCore().SetIndicatorAutoHide(false, false);
341 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
346 if ((FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle) && (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle))
348 r = GetCore().SetIndicatorShowState(true);
349 GetCore().SetIndicatorAutoHide(true, true);
350 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
354 if (FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle)
356 r = GetCore().SetIndicatorShowState(true);
357 GetCore().SetIndicatorAutoHide(true, false);
358 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
360 else if(FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle)
362 r = GetCore().SetIndicatorShowState(true);
363 GetCore().SetIndicatorAutoHide(false, true);
364 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
368 r = GetCore().SetIndicatorShowState(false);
369 GetCore().SetIndicatorAutoHide(false, false);
370 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
375 if (formStyle & FORM_STYLE_HEADER)
379 pHeader = CreateHeaderN();
380 SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
382 GetCore().SetHeader(&pHeader->GetCore());
383 GetCore().AdjustClientBounds();
385 if (GetCore().IsIndicatorTranslucent())
387 if (!GetCore().IsHeaderTranslucent())
389 indicatorBounds.height = 0.0f;
393 if (GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
395 indicatorBounds.height = 0.0f;
400 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
401 GetCore().SetHeaderBounds(bounds);
403 r = GetCore().AttachSystemChild(pHeader->GetCore());
404 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
406 GetCore().SetFormBackEventListener(this);
409 else if (formStyle & FORM_STYLE_TITLE)
413 pHeader = CreateHeaderN();
414 SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
416 GetCore().SetHeader(&pHeader->GetCore());
417 GetCore().AdjustClientBounds();
419 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
420 GetCore().SetHeaderBounds(bounds);
422 r = GetCore().AttachSystemChild(pHeader->GetCore());
423 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
433 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
437 if (formStyle & FORM_STYLE_TEXT_TAB)
439 float titleHeight = 0.0f;
441 if (formStyle & FORM_STYLE_TITLE)
445 titleHeight = pHeader->GetBoundsF().height;
451 pTabImpl = CreateTabImplN();
452 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
454 float posY = indicatorBounds.height + titleHeight;
456 GetCore().SetTab(&pTabImpl->GetCore());
457 GetCore().AdjustClientBounds();
459 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
460 GetCore().SetTabBounds(bounds);
462 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
463 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
465 GetCore().SetTabStyle(_TAB_STYLE_TEXT);
467 else if (formStyle & FORM_STYLE_ICON_TAB)
469 float titleHeight = 0.0f;
471 if (formStyle & FORM_STYLE_TITLE)
475 titleHeight = pHeader->GetBoundsF().height;
481 pTabImpl = CreateTabImplN();
482 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
484 float posY = indicatorBounds.height + titleHeight;
486 GetCore().SetTab(&pTabImpl->GetCore());
487 GetCore().AdjustClientBounds();
489 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
490 GetCore().SetTabBounds(bounds);
492 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
493 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
495 GetCore().SetTabStyle(_TAB_STYLE_ICON);
503 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
507 if (formStyle & FORM_STYLE_FOOTER)
511 pFooter = CreateFooterN();
512 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
514 GetCore().SetFooter(&pFooter->GetCore());
515 GetCore().AdjustClientBounds();
517 FloatRectangle clientbounds = GetClientBoundsF();
518 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height, clientbounds.width, GetCore().GetToolbarHeightF(false));
520 GetCore().SetFooterBounds(bounds);
522 r = GetCore().AttachSystemChild(pFooter->GetCore());
523 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
525 GetCore().SetFormBackEventListener(this);
526 GetCore().SetFormMenuEventListener(this);
529 else if (formStyle & FORM_STYLE_SOFTKEY_0 || formStyle & FORM_STYLE_SOFTKEY_1 || formStyle & FORM_STYLE_OPTIONKEY)
535 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
538 pFooter = GetFooter();
542 pFooter = CreateFooterN();
543 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
545 GetCore().SetFooter(&pFooter->GetCore());
546 GetCore().AdjustClientBounds();
548 FloatRectangle clientbounds = GetClientBoundsF();
549 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - GetCore().GetToolbarHeightF(false), clientbounds.width, GetCore().GetToolbarHeightF(false));
551 GetCore().SetFooterBounds(bounds);
553 r = GetCore().AttachSystemChild(pFooter->GetCore());
554 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
556 GetCore().CreateSoftkey(formStyle);
558 pFooter->GetCore().AddActionEventListener(*this);
568 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
569 GetCore().AdjustClientBounds();
573 GetCore().AdjustClientBounds();
575 SetLastResult(E_SUCCESS);
581 _FormImpl::GetFooter(void) const
583 _Toolbar* pToolbar = __pForm->GetFooter();
584 if (pToolbar == null)
589 _FooterImpl* pFooterImpl = static_cast<_FooterImpl*>(pToolbar->GetUserData());
595 _FormImpl::GetHeader(void) const
597 _Toolbar* pToolbar = __pForm->GetHeader();
598 if (pToolbar == null)
603 _HeaderImpl* pHeaderImpl = static_cast<_HeaderImpl*>(pToolbar->GetUserData());
610 _FormImpl::GetTabImpl(void) const
612 _Tab* pTab = __pForm->GetTab();
618 _TabImpl* pTabImpl = static_cast<_TabImpl*>(pTab->GetUserData());
624 _FormImpl::GetTitleText(void) const
626 return GetCore().GetTitleText();
630 _FormImpl::GetTitleTextHorizontalAlignment(void) const
632 return GetCore().GetTitleTextHorizontalAlignment();
636 _FormImpl::HasFooter(void) const
638 return GetCore().HasFooter();
642 _FormImpl::HasHeader(void) const
644 return GetCore().HasHeader();
648 _FormImpl::HasTitle(void) const
650 return GetCore().HasTitle();
654 _FormImpl::HasTab(void) const
656 return GetCore().HasTab();
660 _FormImpl::IsIndicatorVisible(void) const
662 return GetCore().IsIndicatorVisible();
666 _FormImpl::IsHeaderVisible(void) const
668 return GetCore().IsHeaderVisible();
672 _FormImpl::IsFooterVisible(void) const
674 return GetCore().IsFooterVisible();
678 _FormImpl::IsIndicatorTranslucent(void) const
680 return GetCore().IsIndicatorTranslucent();
684 _FormImpl::IsHeaderTranslucent(void) const
686 return GetCore().IsHeaderTranslucent();
690 _FormImpl::IsFooterTranslucent(void) const
692 return GetCore().IsFooterTranslucent();
697 _FormImpl::IsTabTranslucent(void) const
699 return GetCore().IsTabTranslucent();
703 _FormImpl::SetActionBarsTranslucent(unsigned long actionBars, bool translucent)
705 return GetCore().SetActionBarsTranslucent(actionBars, translucent);
709 _FormImpl::SetActionBarsVisible(unsigned long actionBars, bool visible)
711 return GetCore().SetActionBarsVisible(actionBars, visible);
715 _FormImpl::SetTitleIcon(const Bitmap* pTitleBitmap)
717 return GetCore().SetTitleIcon(pTitleBitmap);
721 _FormImpl::SetTitleText(const String& title, HorizontalAlignment alignment)
723 return GetCore().SetTitleText(title, alignment);
727 _FormImpl::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType)
729 return GetCore().GetOverlayRegionN(rect, regionType);
733 _FormImpl::GetOverlayRegionN(const FloatRectangle& rect, OverlayRegionType regionType)
735 return GetCore().GetOverlayRegionN(rect, regionType);
739 _FormImpl::OnDraw(void)
743 __pOriAgent->FireOrientationEvent();
746 _ContainerImpl::OnDraw();
750 _FormImpl::OnKeyReleased(const _ControlImpl& source, _KeyCode keyCode)
755 if (GetCore().GetFooter() || GetCore().GetHeader())
757 if (__pFormBackEventListener)
759 Form* pForm = dynamic_cast <Form*>(&GetPublic());
762 __pFormBackEventListener->OnFormBackRequested(*pForm);
784 _FormImpl::OnActionPerformed(const _Control& source, int actionId)
786 if (GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetFormStyle() & FORM_STYLE_SOFTKEY_1 || GetFormStyle() & FORM_STYLE_OPTIONKEY)
788 Tizen::Base::Runtime::IEventArg* tempArg = null;
789 tempArg = _PublicActionEvent::CreateActionEventArgN(actionId);
790 SysTryReturnVoidResult(NID_UI_CTRL, tempArg , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create Eventarg.");
793 _PublicActionEvent* pSoftkeyActionEvent = null;
795 if (GetCore().GetFooter()->IsButtonSet(LEFT_BUTTON) && GetSoftkeyActionId(SOFTKEY_0) == actionId)
797 for (int i = 0; i < __leftSoftkeyActionList.GetCount(); i++)
799 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__leftSoftkeyActionList.GetAt(i));
801 if (pSoftkeyActionEvent)
803 pSoftkeyActionEvent->Fire(*tempArg);
809 if (GetCore().GetFooter()->IsButtonSet(RIGHT_BUTTON) && GetSoftkeyActionId(SOFTKEY_1) == actionId)
811 for (int i = 0; i < __rightSoftkeyActionList.GetCount(); i++)
813 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__rightSoftkeyActionList.GetAt(i));
815 if (pSoftkeyActionEvent)
817 pSoftkeyActionEvent->Fire(*tempArg);
823 if (GetCore().GetFooter()->IsButtonSet(MIDDLE_BUTTON) && GetOptionkeyActionId() == actionId)
825 if (__pOptionMenuActionEvent)
827 __pOptionMenuActionEvent->Fire(*tempArg);
839 _FormImpl::GetClientAreaCanvasN(void) const
841 return GetCore().GetClientAreaCanvasN();
845 _FormImpl::TranslateToClientAreaPosition(const Point& position) const
847 return GetCore().TranslateToClientAreaPosition(position);
851 _FormImpl::TranslateToClientAreaPosition(const FloatPoint& position) const
853 return GetCore().TranslateToClientAreaPosition(position);
857 _FormImpl::TranslateFromClientAreaPosition(const Point& clientPosition) const
859 return GetCore().TranslateFromClientAreaPosition(clientPosition);
863 _FormImpl::TranslateFromClientAreaPosition(const FloatPoint& clientPosition) const
865 return GetCore().TranslateFromClientAreaPosition(clientPosition);
869 _FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEventListener)
871 __pFormBackEventListener = const_cast <IFormBackEventListener*>(pFormBackEventListener);
872 GetCore().SetFormBackEventListener(this);
873 result r = GetLastResult();
874 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
878 _FormImpl::SetFormMenuEventListener(const IFormMenuEventListener* pFormMenuEventListener)
880 __pFormMenuEventListener = const_cast <IFormMenuEventListener*>(pFormMenuEventListener);
881 GetCore().SetFormMenuEventListener(this);
882 result r = GetLastResult();
883 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
887 _FormImpl::AddOrientationEventListener(IOrientationEventListener& listener)
891 __pOriAgent->AddListener(listener);
893 else if (__pImeOriAgent)
895 __pImeOriAgent->AddListener(listener);
900 _FormImpl::AddOptionkeyActionListener(const IActionEventListener& listener)
902 if (HasOptionkey() == false)
907 __pOptionMenuActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
909 SysTryReturnVoidResult(NID_UI_CTRL, __pOptionMenuActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
911 __pOptionMenuActionEvent->AddListener(listener);
915 _FormImpl::AddSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
917 _Softkey _softkey = ConvertSoftkey(softkey);
919 if (GetCore().CheckSoftkey(_softkey) == false)
924 if (softkey == SOFTKEY_0)
926 __pLeftSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
928 SysTryReturnVoidResult(NID_UI_CTRL, __pLeftSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
930 __pLeftSoftkeyActionEvent->AddListener(listener);
932 __leftSoftkeyActionList.Add(*__pLeftSoftkeyActionEvent);
934 else if (softkey == SOFTKEY_1)
936 __pRightSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
938 SysTryReturnVoidResult(NID_UI_CTRL, __pRightSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
940 __pRightSoftkeyActionEvent->AddListener(listener);
942 __rightSoftkeyActionList.Add(*__pRightSoftkeyActionEvent);
947 _FormImpl::RemoveOrientationEventListener(IOrientationEventListener& listener)
951 __pOriAgent->RemoveListener(listener);
953 else if (__pImeOriAgent)
955 __pImeOriAgent->RemoveListener(listener);
960 _FormImpl::RemoveOptionkeyActionListener(const IActionEventListener& listener)
962 if (HasOptionkey() == false)
967 if (__pOptionMenuActionEvent)
969 __pOptionMenuActionEvent->RemoveListener(listener);
974 _FormImpl::RemoveSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
976 _Softkey _softkey = ConvertSoftkey(softkey);
978 if (GetCore().CheckSoftkey(_softkey) == false)
983 if (softkey == SOFTKEY_0)
985 if (__pLeftSoftkeyActionEvent)
987 __pLeftSoftkeyActionEvent->RemoveListener(listener);
990 else if (softkey == SOFTKEY_1)
992 if (__pRightSoftkeyActionEvent)
994 __pRightSoftkeyActionEvent->RemoveListener(listener);
1000 _FormImpl::SetOrientation(Orientation orientation)
1004 __pOriAgent->SetMode(orientation);
1009 _FormImpl::GetOrientation(void) const
1013 return __pOriAgent->GetMode();
1016 return ORIENTATION_NONE;
1020 _FormImpl::GetOrientationStatus(void) const
1024 return __pOriAgent->GetStatus();
1026 else if (__pImeOriAgent)
1028 return __pImeOriAgent->GetStatus();
1031 return ORIENTATION_STATUS_NONE;
1035 _FormImpl::UpdateOrientationStatus(bool draw)
1039 __pOriAgent->Update(draw);
1044 _FormImpl::UpdateOrientation(void)
1048 __pOriAgent->UpdateOrientation();
1053 _FormImpl::UpdateOrientation(int angle)
1055 SysLog(NID_UI_CTRL, "[Ime Rotation]");
1059 __pImeOriAgent->UpdateOrientation(angle);
1064 _FormImpl::HasOptionkey(void) const
1066 return GetCore().HasOptionkey();
1070 _FormImpl::HasSoftkey(Softkey softkey) const
1072 _Softkey _softkey = ConvertSoftkey(softkey);
1074 return GetCore().HasSoftkey(_softkey);
1078 _FormImpl::SetSoftkeyEnabled(Softkey softkey, bool enable)
1080 _Softkey _softkey = ConvertSoftkey(softkey);
1082 result r = GetCore().SetSoftkeyEnabled(_softkey, enable);
1083 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1089 _FormImpl::IsSoftkeyEnabled(Softkey softkey) const
1091 _Softkey _softkey = ConvertSoftkey(softkey);
1093 return GetCore().IsSoftkeyEnabled(_softkey);
1097 _FormImpl::GetSoftkeyActionId(Softkey softkey) const
1099 _Softkey _softkey = ConvertSoftkey(softkey);
1101 return GetCore().GetSoftkeyActionId(_softkey);
1105 _FormImpl::GetOptionkeyActionId(void) const
1107 return GetCore().GetOptionkeyActionId();
1111 _FormImpl::GetSoftkeyText(Softkey softkey) const
1113 _Softkey _softkey = ConvertSoftkey(softkey);
1115 return GetCore().GetSoftkeyText(_softkey);
1119 _FormImpl::SetOptionkeyActionId(int actionId)
1121 result r = GetCore().SetOptionkeyActionId(actionId);
1122 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1128 _FormImpl::SetSoftkeyActionId(Softkey softkey, int actionId)
1130 _Softkey _softkey = ConvertSoftkey(softkey);
1132 result r = GetCore().SetSoftkeyActionId(_softkey, actionId);
1133 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1139 _FormImpl::SetSoftkeyText(Softkey softkey, const String& text)
1141 _Softkey _softkey = ConvertSoftkey(softkey);
1143 result r = GetCore().SetSoftkeyText(_softkey, text);
1144 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1150 _FormImpl::SetSoftkeyIcon(Softkey softkey, const Bitmap& pNormalBitmap, const Bitmap* ppPressedBitmap)
1152 _Softkey _softkey = ConvertSoftkey(softkey);
1154 result r = GetCore().SetSoftkeyIcon(_softkey, pNormalBitmap, ppPressedBitmap);
1155 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1161 _FormImpl::OnChangeLayout(_ControlOrientation orientation)
1163 FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1164 FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
1166 _FrameImpl* pFrameImpl = dynamic_cast<_FrameImpl*>(GetParent());
1169 FrameShowMode frameShowMode = pFrameImpl->GetShowMode();
1171 if ((frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
1173 bool movable = pFrameImpl->GetCore().IsMovable();
1174 pFrameImpl->GetCore().SetMovable(true);
1176 FloatPoint prevPoint = pFrameImpl->GetPositionF();
1177 FloatPoint curPoint(prevPoint.x, prevPoint.y);
1178 float ratio = portraitSize.width / portraitSize.height;
1179 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1181 if (prevPoint.x > 0.0f)
1183 curPoint.x = prevPoint.x * ratio;
1186 if (prevPoint.y > 0.0f)
1188 curPoint.y = prevPoint.y / ratio;
1193 if (prevPoint.x > 0.0f)
1195 curPoint.x = prevPoint.x / ratio;
1198 if (prevPoint.y > 0.0f)
1200 curPoint.y = prevPoint.y * ratio;
1204 pFrameImpl->SetPosition(curPoint);
1205 portraitSize = pFrameImpl->GetSizeF();
1206 landscapeSize = portraitSize;
1207 pFrameImpl->GetCore().SetMovable(movable);
1212 _ContainerImpl::OnChangeLayout(orientation);
1213 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1215 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1217 SetSize(portraitSize);
1221 SetSize(landscapeSize);
1224 float indicatorheight = 0.0f;
1226 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1227 _Indicator* pIndicator = GetCore().GetIndicator();
1228 if (GetCore().HasIndicator())
1232 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1234 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1235 if ((FORM_STYLE_INDICATOR & GetFormStyle()) || (FORM_STYLE_INDICATOR_AUTO_HIDE & GetFormStyle()))
1237 GetCore().SetIndicatorShowState(true);
1241 GetCore().SetIndicatorShowState(false);
1246 if (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & GetFormStyle())
1248 GetCore().SetIndicatorShowState(true);
1252 GetCore().AdjustClientBounds();
1256 GetCore().SetIndicatorShowState(false);
1260 pIndicator->OnChangeLayout(orientation);
1264 float adjHeight = 0.0f;
1266 if (GetCore().HasHeader())
1268 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1269 if (GetCore().IsIndicatorVisible())
1271 indicatorBounds = GetCore().GetIndicatorBoundsF();
1272 if (GetCore().IsIndicatorTranslucent())
1274 if (!GetCore().IsHeaderTranslucent())
1276 indicatorBounds.height = 0.0f;
1280 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1282 indicatorBounds.height = 0.0f;
1286 if (FORM_STYLE_INDICATOR_AUTO_HIDE & GetFormStyle())
1295 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1296 GetCore().SetHeaderBounds(bounds);
1299 if (GetCore().HasTab()) // Ki-Dong,Hong.Temp
1301 float titleHeight = 0.0f;
1303 if (GetCore().GetFormStyle() & FORM_STYLE_TITLE)
1305 if (GetCore().HasHeader())
1307 _HeaderImpl* pHeaderImpl = GetHeader();
1310 titleHeight = pHeaderImpl->GetBoundsF().height;
1315 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1317 if (GetCore().IsIndicatorVisible())
1319 indicatorBounds = GetCore().GetIndicatorBoundsF();
1320 if (GetCore().IsIndicatorTranslucent())
1322 if (!GetCore().IsHeaderTranslucent())
1324 indicatorBounds.height = 0.0f;
1328 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1330 indicatorBounds.height = 0.0f;
1336 float posY = indicatorBounds.height + titleHeight;
1338 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1339 GetCore().SetTabBounds(bounds);
1342 if (GetCore().HasFooter())
1344 if (GetCore().GetFooter()->GetVisibleState() && !GetCore().IsFooterTranslucent())
1350 adjHeight = GetCore().GetToolbarHeightF(false);
1353 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1354 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1356 adjHeight = GetCore().GetToolbarHeightF(false);
1359 FloatRectangle bounds(0.0f, GetClientBoundsF().y + GetClientBoundsF().height - adjHeight,
1360 GetClientBoundsF().width, GetCore().GetToolbarHeightF(false));
1361 GetCore().SetFooterBounds(bounds);
1366 _FormImpl::CreateHeaderN(void)
1368 result r = E_SUCCESS;
1370 Header* pHeader = new (std::nothrow) Header;
1371 SysTryReturn(NID_UI_CTRL, pHeader, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1373 r = pHeader->Construct();
1374 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1376 _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*pHeader);
1378 SetLastResult(E_SUCCESS);
1384 _FormImpl::CreateFooterN(void)
1386 result r = E_SUCCESS;
1388 Footer* pFooter = new (std::nothrow) Footer;
1389 SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1391 r = pFooter->Construct();
1392 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1394 _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*pFooter);
1396 SetLastResult(E_SUCCESS);
1401 // Ki-Dong,Hong.Temp
1403 _FormImpl::CreateTabImplN(void)
1405 //result r = E_SUCCESS;
1407 //Tab* pTab = new (std::nothrow) Tab;
1408 //SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
1410 //r = pTab->Construct();
1411 //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Unable to consturct tab.");
1413 //return pTab->GetTabImpl();
1414 Tab* pTab = _TabImpl::CreateTabN();
1415 SysTryReturn(NID_UI_CTRL, pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1417 _TabImpl* pTabImpl = _TabImpl::GetInstance(*pTab);
1419 SetLastResult(E_SUCCESS);
1425 _FormImpl::DeflateClientRectHeight(int height)
1427 return GetCore().DeflateClientRectHeight(height);
1431 _FormImpl::DeflateClientRectHeight(float height)
1433 return GetCore().DeflateClientRectHeight(height);
1437 _FormImpl::RemoveHeader(void)
1439 _HeaderImpl* pHeaderImpl = GetHeader();
1443 __pForm->RemoveHeader();
1444 result r = GetLastResult();
1445 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1446 Header* pHeader = pHeaderImpl->GetHeader();
1457 _FormImpl::RemoveFooter(void)
1459 _FooterImpl* pFooterImpl = GetFooter();
1463 __pForm->RemoveFooter();
1464 result r = GetLastResult();
1465 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1466 Footer* pFooter = pFooterImpl->GetFooter();
1478 // Ki-Dong,Hong.Temp
1480 _FormImpl::RemoveTabImpl(void)
1482 _TabImpl* pTabImpl = GetTabImpl();
1486 __pForm->RemoveTab();
1487 result r = GetLastResult();
1488 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1489 Tab* pTab = pTabImpl->GetTab();
1491 pTabImpl->DeleteTab(pTab);
1502 _FormImpl::GetDataBindingContextN(void) const
1504 return _DataBindingContextImpl::GetDataBindingContextN(*this);
1508 _FormImpl::OnAttaching(const _Control* pParent)
1510 result r = E_SUCCESS;
1511 _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>((pParent)));
1512 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1514 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.");
1516 r = _ControlImpl::OnAttaching(pParent);
1521 _FormImpl::OnAttachedToMainTree(void)
1523 result r = E_SUCCESS;
1526 r = GetCore().AttachedToMainTree();
1527 r = _ContainerImpl::OnAttachedToMainTree();
1529 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1531 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1533 indicatorBounds = GetCore().GetIndicatorBoundsF();
1534 r = GetLastResult();
1535 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1538 _HeaderImpl* pHeader = GetHeader();
1539 _FooterImpl* pFooter = GetFooter();
1540 _TabImpl* pTabImpl = GetTabImpl();
1544 if (GetCore().IsIndicatorTranslucent())
1546 if (!GetCore().IsHeaderTranslucent())
1548 indicatorBounds.height = 0.0f;
1552 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
1554 indicatorBounds.height = 0.0f;
1558 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1559 GetCore().SetHeaderBounds(bounds);
1562 float titleHeight = 0.0f;
1566 titleHeight = pHeader->GetBoundsF().height;
1571 float posY = indicatorBounds.height + titleHeight;
1573 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1574 GetCore().SetTabBounds(bounds);
1579 float adjHeight = 0.0f;
1581 if (!(GetCore().GetFooter()->GetVisibleState()) || GetCore().IsFooterTranslucent())
1583 adjHeight = GetCore().GetToolbarHeightF(false);
1586 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1587 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1589 adjHeight = GetCore().GetToolbarHeightF(false);
1592 FloatRectangle clientbounds = GetClientBoundsF();
1593 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - adjHeight, clientbounds.width, GetCore().GetToolbarHeightF(false));
1595 GetCore().SetFooterBounds(bounds);
1598 UpdateOrientationStatus();
1602 __pOriAgent->RequestOrientationEvent();
1609 _FormImpl::OnDetachingFromMainTree(void)
1611 result r = E_SUCCESS;
1612 r = GetCore().DetachingFromMainTree();
1613 r = _ContainerImpl::OnDetachingFromMainTree();
1619 _FormImpl::OnNotifiedN(const _ControlImpl& source, IList* pArgs)
1621 String* pString = dynamic_cast <Tizen::Base::String*>(pArgs->GetAt(0));
1624 if (*pString == _REQUEST_ORIENTATION_EVENT)
1628 __pOriAgent->FireOrientationEvent();
1631 pArgs->RemoveAll(true);
1642 _FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source)
1644 if (__pFormBackEventListener)
1646 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1647 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1650 __pFormBackEventListener->OnFormBackRequested(*pForm);
1660 _FormImpl::OnFormMenuRequested(Tizen::Ui::Controls::_Form& source)
1662 if (__pFormMenuEventListener)
1664 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1665 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1668 __pFormMenuEventListener->OnFormMenuRequested(*pForm);
1678 _FormImpl::OnFormOrientationStatusRequested(void)
1680 _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
1681 SysAssert(pImplManager);
1683 OrientationStatus status = ORIENTATION_STATUS_PORTRAIT;
1684 int appType = _AppInfo::GetAppType();
1685 if (!(appType & _APP_TYPE_IME_APP))
1687 status = pImplManager->GetOrientationStatus(GetOrientation());
1693 _FormImpl::IsOpaque(void) const
1700 _FormImpl::ConvertSoftkey(Softkey softkey) const
1704 if (softkey == SOFTKEY_0)
1706 _softkey = _SOFTKEY_0;
1708 else if (softkey == SOFTKEY_1)
1710 _softkey = _SOFTKEY_1;
1714 _softkey = _SOFTKEY_COUNT;
1721 _FormImpl::SetNotificationTrayOpenEnabled(bool enable)
1723 return GetCore().SetNotificationTrayOpenEnabled(enable);
1727 _FormImpl::IsNotificationTrayOpenEnabled(void) const
1729 return GetCore().IsNotificationTrayOpenEnabled();
1733 : public _UiBuilderControlMaker
1736 _FormMaker(_UiBuilder* uibuilder)
1737 : _UiBuilderControlMaker(uibuilder){};
1738 virtual ~_FormMaker()
1741 static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1743 _FormMaker* pFormMaker = new (std::nothrow) _FormMaker(uibuilder);
1747 virtual Control* Make(_UiBuilderControl* pControl)
1749 _UiBuilderControlLayout* pControlProperty = null;
1750 result r = E_SUCCESS;
1753 Tizen::Base::String elementString;
1754 bool isTitleAlign = false;
1757 HorizontalAlignment align = ALIGNMENT_CENTER;
1758 Form* pForm = (Form*) GetContainer();
1760 // Get control manager
1761 _ControlManager* pControlManager = _ControlManager::GetInstance();
1762 if (pControlManager == null)
1764 SysLog(NID_UI_CTRL, "Unable to get the control manager.n");
1767 FloatDimension screenSize = pControlManager->GetScreenSizeF();
1770 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(0.0f, 0.0f, screenSize.width, screenSize.height);
1771 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(0.0f, 0.0f, screenSize.height, screenSize.width);
1773 // Get device orientation
1774 app_device_orientation_e deviceOrientation = app_get_device_orientation();
1775 bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270);
1779 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE);
1783 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1786 if (pControlProperty == null)
1788 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Can't read attributes");
1792 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1793 Tizen::Base::String styleString;
1794 styleString = pControlProperty->GetStyle();
1796 if (styleString.Contains(L"FORM_STYLE_TITLE"))
1798 style |= FORM_STYLE_TITLE;
1800 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_0"))
1802 style |= FORM_STYLE_SOFTKEY_0;
1804 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_1"))
1806 style |= FORM_STYLE_SOFTKEY_1;
1808 if (styleString.Contains(L"FORM_STYLE_OPTIONKEY"))
1810 style |= FORM_STYLE_OPTIONKEY;
1812 if (styleString.Contains(L"FORM_STYLE_INDICATOR"))
1814 if (styleString.Contains(L"FORM_STYLE_INDICATOR_AUTO_HIDE"))
1816 style |= FORM_STYLE_INDICATOR_AUTO_HIDE;
1820 style |= FORM_STYLE_INDICATOR;
1823 if (styleString.Contains(L"FORM_STYLE_PORTRAIT_INDICATOR"))
1825 if (styleString.Contains(L"FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE"))
1827 style |= FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE;
1831 style |= FORM_STYLE_PORTRAIT_INDICATOR;
1834 if (styleString.Contains(L"FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE"))
1836 style |= FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE;
1838 if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
1840 style |= FORM_STYLE_TEXT_TAB;
1842 if (styleString.Contains(L"FORM_STYLE_ICON_TAB"))
1844 style |= FORM_STYLE_ICON_TAB;
1846 if (styleString.Contains(L"FORM_STYLE_HEADER"))
1848 style |= FORM_STYLE_HEADER;
1850 if (styleString.Contains(L"FORM_STYLE_FOOTER"))
1852 style |= FORM_STYLE_FOOTER;
1855 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1856 __pLayoutMaker->GetLayoutType(pControlProperty, layoutType);
1857 if (layoutType == UIBUILDER_LAYOUT_NONE)
1860 r = pForm->Construct(style);
1864 Layout* pPortraitLayout = null;
1865 Layout* pLandscapeLayout = null;
1866 result tempResult = E_SUCCESS;
1867 tempResult = __pLayoutMaker->GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout);
1868 if (E_SUCCESS == tempResult)
1870 r = pForm->Construct(*pPortraitLayout, *pLandscapeLayout, style);
1877 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1879 if (__pLayoutMaker->GetLayoutType(pControlProperty, layoutType) == false)
1884 if ( layoutType == UIBUILDER_LAYOUT_GRID)
1886 for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
1888 GridLayout* pGridLayout = null;
1889 pControlProperty = pControl->GetAttribute(i);
1891 if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT)
1893 pGridLayout = dynamic_cast<GridLayout*>(pPortraitLayout);
1897 pGridLayout = dynamic_cast<GridLayout*>(pLandscapeLayout);
1899 __pLayoutMaker->SetGridLayoutContainerProperty(pGridLayout, pControlProperty);
1902 delete pPortraitLayout;
1903 if (pPortraitLayout != pLandscapeLayout)
1905 delete pLandscapeLayout;
1911 SysLog(NID_UI_CTRL, "Failed to create Form.");
1916 if (pControl->GetElement(L"titleAlign", elementString))
1918 if (elementString.Equals(L"ALIGN_CENTER", false))
1920 align = ALIGNMENT_CENTER;
1922 else if (elementString.Equals(L"ALIGN_RIGHT", false))
1924 align = ALIGNMENT_RIGHT;
1928 align = ALIGNMENT_LEFT;
1930 isTitleAlign = true;
1933 if (style & FORM_STYLE_TITLE)
1935 if (pControl->GetElement(L"title", elementString))
1939 pForm->SetTitleText(elementString, align);
1943 pForm->SetTitleText(elementString);
1950 pForm->SetTitleText(L"", align);
1954 pForm->SetTitleText(L"");
1959 if (pControl->GetElement(L"titleIcon", elementString))
1961 Bitmap* pBitmap = null;
1962 pBitmap = LoadBitmapN(elementString);
1963 if (pBitmap != null)
1965 r = pForm->SetTitleIcon(pBitmap);
1969 SysLog(NID_UI_CTRL, "Failed to set TitleIcon.");
1974 if (pControl->GetElement(L"softKey0Text", elementString))
1976 pForm->SetSoftkeyText(SOFTKEY_0, elementString);
1978 if (pControl->GetElement(L"softKey1Text", elementString))
1980 pForm->SetSoftkeyText(SOFTKEY_1, elementString);
1982 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
1984 Base::Integer::Parse(elementString, opacity);
1986 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
1988 ConvertStringToColor32(elementString, opacity, color);
1989 pForm->SetBackgroundColor(color);
1994 r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color);
1997 pForm->SetBackgroundColor(color);
2001 pForm->SetBackgroundColor(0xff000000);
2005 if (pControl->GetElement(L"softKey0Icon", elementString) || pControl->GetElement(L"softKey0NormalIcon", elementString))
2007 Bitmap* pNormalBitmap = null;
2008 Bitmap* pPressedBitmap = null;
2009 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2011 if (pNormalBitmap != null)
2013 if (pControl->GetElement(L"softKey0PressedIcon", elementString))
2015 pPressedBitmap = LoadBitmapN(elementString);
2018 if (pPressedBitmap != null)
2020 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, pPressedBitmap);
2021 delete pNormalBitmap;
2022 delete pPressedBitmap;
2026 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, null);
2027 delete pNormalBitmap;
2031 if (pControl->GetElement(L"softKey1Icon", elementString) || pControl->GetElement(L"softKey1NormalIcon", elementString))
2033 Bitmap* pNormalBitmap = null;
2034 Bitmap* pPressedBitmap = null;
2035 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2037 if (pNormalBitmap != null)
2039 if (pControl->GetElement(L"softKey1PressedIcon", elementString))
2041 pPressedBitmap = LoadBitmapN(elementString); // __image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2044 if (pPressedBitmap != null)
2046 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, pPressedBitmap);
2047 delete pNormalBitmap;
2048 delete pPressedBitmap;
2052 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, null);
2053 delete pNormalBitmap;
2058 if (pControl->GetElement(L"Orientation", elementString) || pControl->GetElement(L"orientation", elementString))
2061 //ORIENTATION_PORTRAIT,
2062 //ORIENTATION_LANDSACPE,
2063 //ORIENTATION_PORTRAIT_REVERSE,
2064 //ORIENTATION_LANDSACPE_REVERSE,
2065 //ORIENTATION_AUTO = 6,
2066 //ORIENTATION_AUTO_FOUR_DIRECTION = 8,
2068 if (elementString.Equals(L"Automatic:2Dir", false) || elementString.Equals(L"Automatic", false))
2070 pForm->SetOrientation(ORIENTATION_AUTOMATIC);
2072 else if (elementString.Equals(L"Automatic:4Dir", false))
2074 pForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
2076 else if (elementString.Equals(L"Landscape", false))
2078 pForm->SetOrientation(ORIENTATION_LANDSCAPE);
2079 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2081 else if (elementString.Equals(L"Landscape:Reverse", false))
2083 pForm->SetOrientation(ORIENTATION_LANDSCAPE_REVERSE);
2084 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2086 else if (elementString.Equals(L"Portrait", false))
2088 pForm->SetOrientation(ORIENTATION_PORTRAIT);
2089 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2091 else if (elementString.Equals(L"Portrait:Reverse", false))
2093 pForm->SetOrientation(ORIENTATION_PORTRAIT_REVERSE);
2094 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2098 if (style & FORM_STYLE_HEADER)
2100 if (pControl->GetElement(L"translucentHeader", elementString))
2102 if (elementString.Equals(L"true", false))
2104 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_HEADER, true);
2109 if (style & FORM_STYLE_FOOTER)
2111 if (pControl->GetElement(L"translucentFooter", elementString))
2113 if (elementString.Equals(L"true", false))
2115 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_FOOTER, true);
2120 if (style & FORM_STYLE_INDICATOR)
2122 if (pControl->GetElement(L"translucentIndicator", elementString))
2124 if (elementString.Equals(L"true", false))
2126 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
2136 _FormRegister::_FormRegister()
2138 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2139 pUiBuilderControlTableManager->RegisterControl(L"Form", _FormMaker::GetInstance);
2141 _FormRegister::~_FormRegister()
2143 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2144 pUiBuilderControlTableManager->UnregisterControl(L"Form");
2146 static _FormRegister FormRegisterToUiBuilder;
2147 }}} // Tizen::Ui::Controls