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 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
335 else if(FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle)
337 r = GetCore().SetIndicatorShowState(false, true);
338 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
342 r = GetCore().SetIndicatorShowState(false);
343 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
346 if (formStyle & FORM_STYLE_HEADER)
350 pHeader = CreateHeaderN();
351 SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
353 GetCore().SetHeader(&pHeader->GetCore());
354 GetCore().AdjustClientBounds();
356 if (GetCore().IsIndicatorTranslucent())
358 if (!GetCore().IsHeaderTranslucent())
360 indicatorBounds.height = 0.0f;
364 if (GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
366 indicatorBounds.height = 0.0f;
371 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
372 GetCore().SetHeaderBounds(bounds);
374 r = GetCore().AttachSystemChild(pHeader->GetCore());
375 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
377 GetCore().SetFormBackEventListener(this);
380 else if (formStyle & FORM_STYLE_TITLE)
384 pHeader = CreateHeaderN();
385 SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
387 GetCore().SetHeader(&pHeader->GetCore());
388 GetCore().AdjustClientBounds();
390 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
391 GetCore().SetHeaderBounds(bounds);
393 r = GetCore().AttachSystemChild(pHeader->GetCore());
394 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
404 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
408 if (formStyle & FORM_STYLE_TEXT_TAB)
410 float titleHeight = 0.0f;
412 if (formStyle & FORM_STYLE_TITLE)
416 titleHeight = pHeader->GetBoundsF().height;
422 pTabImpl = CreateTabImplN();
423 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
425 float posY = indicatorBounds.height + titleHeight;
427 GetCore().SetTab(&pTabImpl->GetCore());
428 GetCore().AdjustClientBounds();
430 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
431 GetCore().SetTabBounds(bounds);
433 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
434 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
436 GetCore().SetTabStyle(_TAB_STYLE_TEXT);
438 else if (formStyle & FORM_STYLE_ICON_TAB)
440 float titleHeight = 0.0f;
442 if (formStyle & FORM_STYLE_TITLE)
446 titleHeight = pHeader->GetBoundsF().height;
452 pTabImpl = CreateTabImplN();
453 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
455 float posY = indicatorBounds.height + titleHeight;
457 GetCore().SetTab(&pTabImpl->GetCore());
458 GetCore().AdjustClientBounds();
460 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
461 GetCore().SetTabBounds(bounds);
463 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
464 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
466 GetCore().SetTabStyle(_TAB_STYLE_ICON);
474 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
478 if (formStyle & FORM_STYLE_FOOTER)
482 pFooter = CreateFooterN();
483 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
485 GetCore().SetFooter(&pFooter->GetCore());
486 GetCore().AdjustClientBounds();
488 FloatRectangle clientbounds = GetClientBoundsF();
489 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height, clientbounds.width, GetCore().GetToolbarHeightF(false));
491 GetCore().SetFooterBounds(bounds);
493 r = GetCore().AttachSystemChild(pFooter->GetCore());
494 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
496 GetCore().SetFormBackEventListener(this);
497 GetCore().SetFormMenuEventListener(this);
500 else if (formStyle & FORM_STYLE_SOFTKEY_0 || formStyle & FORM_STYLE_SOFTKEY_1 || formStyle & FORM_STYLE_OPTIONKEY)
506 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
509 pFooter = GetFooter();
513 pFooter = CreateFooterN();
514 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
516 GetCore().SetFooter(&pFooter->GetCore());
517 GetCore().AdjustClientBounds();
519 FloatRectangle clientbounds = GetClientBoundsF();
520 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - GetCore().GetToolbarHeightF(false), clientbounds.width, GetCore().GetToolbarHeightF(false));
522 GetCore().SetFooterBounds(bounds);
524 r = GetCore().AttachSystemChild(pFooter->GetCore());
525 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
527 GetCore().CreateSoftkey(formStyle);
529 pFooter->GetCore().AddActionEventListener(*this);
539 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
540 GetCore().AdjustClientBounds();
544 GetCore().AdjustClientBounds();
546 SetLastResult(E_SUCCESS);
552 _FormImpl::GetFooter(void) const
554 _Toolbar* pToolbar = __pForm->GetFooter();
555 if (pToolbar == null)
560 _FooterImpl* pFooterImpl = static_cast<_FooterImpl*>(pToolbar->GetUserData());
566 _FormImpl::GetHeader(void) const
568 _Toolbar* pToolbar = __pForm->GetHeader();
569 if (pToolbar == null)
574 _HeaderImpl* pHeaderImpl = static_cast<_HeaderImpl*>(pToolbar->GetUserData());
581 _FormImpl::GetTabImpl(void) const
583 _Tab* pTab = __pForm->GetTab();
589 _TabImpl* pTabImpl = static_cast<_TabImpl*>(pTab->GetUserData());
595 _FormImpl::GetTitleText(void) const
597 return GetCore().GetTitleText();
601 _FormImpl::GetTitleTextHorizontalAlignment(void) const
603 return GetCore().GetTitleTextHorizontalAlignment();
607 _FormImpl::HasFooter(void) const
609 return GetCore().HasFooter();
613 _FormImpl::HasHeader(void) const
615 return GetCore().HasHeader();
619 _FormImpl::HasTitle(void) const
621 return GetCore().HasTitle();
625 _FormImpl::HasTab(void) const
627 return GetCore().HasTab();
631 _FormImpl::IsIndicatorVisible(void) const
633 return GetCore().IsIndicatorVisible();
637 _FormImpl::IsHeaderVisible(void) const
639 return GetCore().IsHeaderVisible();
643 _FormImpl::IsFooterVisible(void) const
645 return GetCore().IsFooterVisible();
649 _FormImpl::IsIndicatorTranslucent(void) const
651 return GetCore().IsIndicatorTranslucent();
655 _FormImpl::IsHeaderTranslucent(void) const
657 return GetCore().IsHeaderTranslucent();
661 _FormImpl::IsFooterTranslucent(void) const
663 return GetCore().IsFooterTranslucent();
668 _FormImpl::IsTabTranslucent(void) const
670 return GetCore().IsTabTranslucent();
674 _FormImpl::SetActionBarsTranslucent(unsigned long actionBars, bool translucent)
676 return GetCore().SetActionBarsTranslucent(actionBars, translucent);
680 _FormImpl::SetActionBarsVisible(unsigned long actionBars, bool visible)
682 return GetCore().SetActionBarsVisible(actionBars, visible);
686 _FormImpl::SetTitleIcon(const Bitmap* pTitleBitmap)
688 return GetCore().SetTitleIcon(pTitleBitmap);
692 _FormImpl::SetTitleText(const String& title, HorizontalAlignment alignment)
694 return GetCore().SetTitleText(title, alignment);
698 _FormImpl::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType)
700 return GetCore().GetOverlayRegionN(rect, regionType);
704 _FormImpl::GetOverlayRegionN(const FloatRectangle& rect, OverlayRegionType regionType)
706 return GetCore().GetOverlayRegionN(rect, regionType);
710 _FormImpl::OnDraw(void)
714 __pOriAgent->FireOrientationEvent();
717 _ContainerImpl::OnDraw();
721 _FormImpl::OnKeyReleased(const _ControlImpl& source, _KeyCode keyCode)
726 if (GetCore().GetFooter() || GetCore().GetHeader())
728 if (__pFormBackEventListener)
730 Form* pForm = dynamic_cast <Form*>(&GetPublic());
733 __pFormBackEventListener->OnFormBackRequested(*pForm);
755 _FormImpl::OnActionPerformed(const _Control& source, int actionId)
757 if (GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetFormStyle() & FORM_STYLE_SOFTKEY_1 || GetFormStyle() & FORM_STYLE_OPTIONKEY)
759 Tizen::Base::Runtime::IEventArg* tempArg = null;
760 tempArg = _PublicActionEvent::CreateActionEventArgN(actionId);
761 SysTryReturnVoidResult(NID_UI_CTRL, tempArg , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create Eventarg.");
764 _PublicActionEvent* pSoftkeyActionEvent = null;
766 if (GetCore().GetFooter()->IsButtonSet(LEFT_BUTTON) && GetSoftkeyActionId(SOFTKEY_0) == actionId)
768 for (int i = 0; i < __leftSoftkeyActionList.GetCount(); i++)
770 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__leftSoftkeyActionList.GetAt(i));
772 if (pSoftkeyActionEvent)
774 pSoftkeyActionEvent->Fire(*tempArg);
780 if (GetCore().GetFooter()->IsButtonSet(RIGHT_BUTTON) && GetSoftkeyActionId(SOFTKEY_1) == actionId)
782 for (int i = 0; i < __rightSoftkeyActionList.GetCount(); i++)
784 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__rightSoftkeyActionList.GetAt(i));
786 if (pSoftkeyActionEvent)
788 pSoftkeyActionEvent->Fire(*tempArg);
794 if (GetCore().GetFooter()->IsButtonSet(MIDDLE_BUTTON) && GetOptionkeyActionId() == actionId)
796 if (__pOptionMenuActionEvent)
798 __pOptionMenuActionEvent->Fire(*tempArg);
810 _FormImpl::GetClientAreaCanvasN(void) const
812 return GetCore().GetClientAreaCanvasN();
816 _FormImpl::TranslateToClientAreaPosition(const Point& position) const
818 return GetCore().TranslateToClientAreaPosition(position);
822 _FormImpl::TranslateToClientAreaPosition(const FloatPoint& position) const
824 return GetCore().TranslateToClientAreaPosition(position);
828 _FormImpl::TranslateFromClientAreaPosition(const Point& clientPosition) const
830 return GetCore().TranslateFromClientAreaPosition(clientPosition);
834 _FormImpl::TranslateFromClientAreaPosition(const FloatPoint& clientPosition) const
836 return GetCore().TranslateFromClientAreaPosition(clientPosition);
840 _FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEventListener)
842 SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
843 __pFormBackEventListener = const_cast <IFormBackEventListener*>(pFormBackEventListener);
844 GetCore().SetFormBackEventListener(this);
845 result r = GetLastResult();
846 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
850 _FormImpl::SetFormMenuEventListener(const IFormMenuEventListener* pFormMenuEventListener)
852 SysTryReturnVoidResult(NID_UI_CTRL, GetFooter() || GetHeader(), E_INVALID_STATE, "[E_INVALID_STATE] Footer isn't constructed.");
853 __pFormMenuEventListener = const_cast <IFormMenuEventListener*>(pFormMenuEventListener);
854 GetCore().SetFormMenuEventListener(this);
855 result r = GetLastResult();
856 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
860 _FormImpl::AddOrientationEventListener(IOrientationEventListener& listener)
864 __pOriAgent->AddListener(listener);
866 else if (__pImeOriAgent)
868 __pImeOriAgent->AddListener(listener);
873 _FormImpl::AddOptionkeyActionListener(const IActionEventListener& listener)
875 if (HasOptionkey() == false)
880 __pOptionMenuActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
882 SysTryReturnVoidResult(NID_UI_CTRL, __pOptionMenuActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
884 __pOptionMenuActionEvent->AddListener(listener);
888 _FormImpl::AddSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
890 _Softkey _softkey = ConvertSoftkey(softkey);
892 if (GetCore().CheckSoftkey(_softkey) == false)
897 if (softkey == SOFTKEY_0)
899 __pLeftSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
901 SysTryReturnVoidResult(NID_UI_CTRL, __pLeftSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
903 __pLeftSoftkeyActionEvent->AddListener(listener);
905 __leftSoftkeyActionList.Add(*__pLeftSoftkeyActionEvent);
907 else if (softkey == SOFTKEY_1)
909 __pRightSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
911 SysTryReturnVoidResult(NID_UI_CTRL, __pRightSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
913 __pRightSoftkeyActionEvent->AddListener(listener);
915 __rightSoftkeyActionList.Add(*__pRightSoftkeyActionEvent);
920 _FormImpl::RemoveOrientationEventListener(IOrientationEventListener& listener)
924 __pOriAgent->RemoveListener(listener);
926 else if (__pImeOriAgent)
928 __pImeOriAgent->RemoveListener(listener);
933 _FormImpl::RemoveOptionkeyActionListener(const IActionEventListener& listener)
935 if (HasOptionkey() == false)
940 if (__pOptionMenuActionEvent)
942 __pOptionMenuActionEvent->RemoveListener(listener);
947 _FormImpl::RemoveSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
949 _Softkey _softkey = ConvertSoftkey(softkey);
951 if (GetCore().CheckSoftkey(_softkey) == false)
956 if (softkey == SOFTKEY_0)
958 if (__pLeftSoftkeyActionEvent)
960 __pLeftSoftkeyActionEvent->RemoveListener(listener);
963 else if (softkey == SOFTKEY_1)
965 if (__pRightSoftkeyActionEvent)
967 __pRightSoftkeyActionEvent->RemoveListener(listener);
973 _FormImpl::SetOrientation(Orientation orientation)
977 __pOriAgent->SetMode(orientation);
982 _FormImpl::GetOrientation(void) const
986 return __pOriAgent->GetMode();
989 return ORIENTATION_NONE;
993 _FormImpl::GetOrientationStatus(void) const
997 return __pOriAgent->GetStatus();
999 else if (__pImeOriAgent)
1001 return __pImeOriAgent->GetStatus();
1004 return ORIENTATION_STATUS_NONE;
1008 _FormImpl::UpdateOrientationStatus(bool draw)
1012 __pOriAgent->Update(draw);
1017 _FormImpl::UpdateOrientation(void)
1021 __pOriAgent->UpdateOrientation();
1026 _FormImpl::UpdateOrientation(int angle)
1028 SysLog(NID_UI_CTRL, "[Ime Rotation]");
1032 __pImeOriAgent->UpdateOrientation(angle);
1037 _FormImpl::HasOptionkey(void) const
1039 return GetCore().HasOptionkey();
1043 _FormImpl::HasSoftkey(Softkey softkey) const
1045 _Softkey _softkey = ConvertSoftkey(softkey);
1047 return GetCore().HasSoftkey(_softkey);
1051 _FormImpl::SetSoftkeyEnabled(Softkey softkey, bool enable)
1053 _Softkey _softkey = ConvertSoftkey(softkey);
1055 result r = GetCore().SetSoftkeyEnabled(_softkey, enable);
1056 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1062 _FormImpl::IsSoftkeyEnabled(Softkey softkey) const
1064 _Softkey _softkey = ConvertSoftkey(softkey);
1066 return GetCore().IsSoftkeyEnabled(_softkey);
1070 _FormImpl::GetSoftkeyActionId(Softkey softkey) const
1072 _Softkey _softkey = ConvertSoftkey(softkey);
1074 return GetCore().GetSoftkeyActionId(_softkey);
1078 _FormImpl::GetOptionkeyActionId(void) const
1080 return GetCore().GetOptionkeyActionId();
1084 _FormImpl::GetSoftkeyText(Softkey softkey) const
1086 _Softkey _softkey = ConvertSoftkey(softkey);
1088 return GetCore().GetSoftkeyText(_softkey);
1092 _FormImpl::SetOptionkeyActionId(int actionId)
1094 result r = GetCore().SetOptionkeyActionId(actionId);
1095 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1101 _FormImpl::SetSoftkeyActionId(Softkey softkey, int actionId)
1103 _Softkey _softkey = ConvertSoftkey(softkey);
1105 result r = GetCore().SetSoftkeyActionId(_softkey, actionId);
1106 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1112 _FormImpl::SetSoftkeyText(Softkey softkey, const String& text)
1114 _Softkey _softkey = ConvertSoftkey(softkey);
1116 result r = GetCore().SetSoftkeyText(_softkey, text);
1117 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1123 _FormImpl::SetSoftkeyIcon(Softkey softkey, const Bitmap& pNormalBitmap, const Bitmap* ppPressedBitmap)
1125 _Softkey _softkey = ConvertSoftkey(softkey);
1127 result r = GetCore().SetSoftkeyIcon(_softkey, pNormalBitmap, ppPressedBitmap);
1128 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1134 _FormImpl::OnChangeLayout(_ControlOrientation orientation)
1136 FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1137 FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
1139 // Adjust the position of the partial Frame.
1140 _FrameImpl* pFrameImpl = dynamic_cast<_FrameImpl*>(GetParent());
1143 FrameShowMode frameShowMode = pFrameImpl->GetShowMode();
1145 if ((frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
1147 bool movable = pFrameImpl->GetCore().IsMovable();
1148 pFrameImpl->GetCore().SetMovable(true);
1150 FloatPoint prevPoint = pFrameImpl->GetPositionF();
1152 FloatPoint curPoint(0.0f, 0.0f);
1154 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1156 if (prevPoint.x < 0.0f)
1158 curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;
1162 curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
1165 if (prevPoint.y < 0.0f)
1167 curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
1171 curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
1176 if (prevPoint.x < 0.0f)
1178 curPoint.x = portraitSize.width / portraitSize.height * prevPoint.x;
1182 curPoint.x = portraitSize.height / portraitSize.width * prevPoint.x;
1185 if (prevPoint.y < 0.0f)
1187 curPoint.y = portraitSize.height / portraitSize.width * prevPoint.y;
1191 curPoint.y = portraitSize.width / portraitSize.height * prevPoint.y;
1196 pFrameImpl->SetPosition(curPoint);
1198 portraitSize = pFrameImpl->GetSizeF();
1199 landscapeSize = portraitSize;
1201 pFrameImpl->GetCore().SetMovable(movable);
1206 _ContainerImpl::OnChangeLayout(orientation);
1207 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1209 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1211 SetSize(portraitSize);
1215 SetSize(landscapeSize);
1218 float indicatorheight = 0.0f;
1220 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1221 _Indicator* pIndicator = GetCore().GetIndicator();
1222 if (GetCore().HasIndicator())
1226 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1228 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1232 GET_SHAPE_CONFIG(FORM::INDICATOR_MINIMIZE_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1233 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1236 GetCore().AdjustClientBounds();
1240 pIndicator->OnChangeLayout(orientation);
1244 float adjHeight = 0.0f;
1246 if (GetCore().HasHeader())
1248 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1249 if (GetCore().IsIndicatorVisible())
1251 indicatorBounds = GetCore().GetIndicatorBoundsF();
1252 if (GetCore().IsIndicatorTranslucent())
1254 if (!GetCore().IsHeaderTranslucent())
1256 indicatorBounds.height = 0.0f;
1260 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1262 indicatorBounds.height = 0.0f;
1268 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1269 GetCore().SetHeaderBounds(bounds);
1272 if (GetCore().HasTab()) // Ki-Dong,Hong.Temp
1274 float titleHeight = 0.0f;
1276 if (GetCore().GetFormStyle() & FORM_STYLE_TITLE)
1278 if (GetCore().HasHeader())
1280 _HeaderImpl* pHeaderImpl = GetHeader();
1283 titleHeight = pHeaderImpl->GetBoundsF().height;
1288 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1290 if (GetCore().IsIndicatorVisible())
1292 indicatorBounds = GetCore().GetIndicatorBoundsF();
1293 if (GetCore().IsIndicatorTranslucent())
1295 if (!GetCore().IsHeaderTranslucent())
1297 indicatorBounds.height = 0.0f;
1301 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1303 indicatorBounds.height = 0.0f;
1309 float posY = indicatorBounds.height + titleHeight;
1311 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1312 GetCore().SetTabBounds(bounds);
1315 if (GetCore().HasFooter())
1317 if (GetCore().GetFooter()->GetVisibleState() && !GetCore().IsFooterTranslucent())
1323 adjHeight = GetCore().GetToolbarHeightF(false);
1326 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1327 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1329 adjHeight = GetCore().GetToolbarHeightF(false);
1332 FloatRectangle bounds(0.0f, GetClientBoundsF().y + GetClientBoundsF().height - adjHeight,
1333 GetClientBoundsF().width, GetCore().GetToolbarHeightF(false));
1334 GetCore().SetFooterBounds(bounds);
1339 _FormImpl::CreateHeaderN(void)
1341 result r = E_SUCCESS;
1343 Header* pHeader = new (std::nothrow) Header;
1344 SysTryReturn(NID_UI_CTRL, pHeader, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1346 r = pHeader->Construct();
1347 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1349 _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*pHeader);
1351 SetLastResult(E_SUCCESS);
1357 _FormImpl::CreateFooterN(void)
1359 result r = E_SUCCESS;
1361 Footer* pFooter = new (std::nothrow) Footer;
1362 SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1364 r = pFooter->Construct();
1365 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1367 _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*pFooter);
1369 SetLastResult(E_SUCCESS);
1374 // Ki-Dong,Hong.Temp
1376 _FormImpl::CreateTabImplN(void)
1378 //result r = E_SUCCESS;
1380 //Tab* pTab = new (std::nothrow) Tab;
1381 //SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
1383 //r = pTab->Construct();
1384 //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Unable to consturct tab.");
1386 //return pTab->GetTabImpl();
1387 Tab* pTab = _TabImpl::CreateTabN();
1388 SysTryReturn(NID_UI_CTRL, pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1390 _TabImpl* pTabImpl = _TabImpl::GetInstance(*pTab);
1392 SetLastResult(E_SUCCESS);
1398 _FormImpl::DeflateClientRectHeight(int height)
1400 return GetCore().DeflateClientRectHeight(height);
1404 _FormImpl::DeflateClientRectHeight(float height)
1406 return GetCore().DeflateClientRectHeight(height);
1410 _FormImpl::RemoveHeader(void)
1412 _HeaderImpl* pHeaderImpl = GetHeader();
1416 __pForm->RemoveHeader();
1417 result r = GetLastResult();
1418 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1419 Header* pHeader = pHeaderImpl->GetHeader();
1430 _FormImpl::RemoveFooter(void)
1432 _FooterImpl* pFooterImpl = GetFooter();
1436 __pForm->RemoveFooter();
1437 result r = GetLastResult();
1438 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1439 Footer* pFooter = pFooterImpl->GetFooter();
1451 // Ki-Dong,Hong.Temp
1453 _FormImpl::RemoveTabImpl(void)
1455 _TabImpl* pTabImpl = GetTabImpl();
1459 __pForm->RemoveTab();
1460 result r = GetLastResult();
1461 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1462 Tab* pTab = pTabImpl->GetTab();
1464 pTabImpl->DeleteTab(pTab);
1475 _FormImpl::GetDataBindingContextN(void) const
1477 return _DataBindingContextImpl::GetDataBindingContextN(*this);
1481 _FormImpl::OnAttaching(const _Control* pParent)
1483 result r = E_SUCCESS;
1484 _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>((pParent)));
1485 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1487 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.");
1489 r = _ControlImpl::OnAttaching(pParent);
1494 _FormImpl::OnAttachedToMainTree(void)
1496 result r = E_SUCCESS;
1499 r = GetCore().AttachedToMainTree();
1500 r = _ContainerImpl::OnAttachedToMainTree();
1502 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1504 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1506 indicatorBounds = GetCore().GetIndicatorBoundsF();
1507 r = GetLastResult();
1508 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1511 _HeaderImpl* pHeader = GetHeader();
1512 _FooterImpl* pFooter = GetFooter();
1513 _TabImpl* pTabImpl = GetTabImpl();
1517 if (GetCore().IsIndicatorTranslucent())
1519 if (!GetCore().IsHeaderTranslucent())
1521 indicatorBounds.height = 0.0f;
1525 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
1527 indicatorBounds.height = 0.0f;
1531 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1532 GetCore().SetHeaderBounds(bounds);
1535 float titleHeight = 0.0f;
1539 titleHeight = pHeader->GetBoundsF().height;
1544 float posY = indicatorBounds.height + titleHeight;
1546 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1547 GetCore().SetTabBounds(bounds);
1552 float adjHeight = 0.0f;
1554 if (!(GetCore().GetFooter()->GetVisibleState()) || GetCore().IsFooterTranslucent())
1556 adjHeight = GetCore().GetToolbarHeightF(false);
1559 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1560 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1562 adjHeight = GetCore().GetToolbarHeightF(false);
1565 FloatRectangle clientbounds = GetClientBoundsF();
1566 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - adjHeight, clientbounds.width, GetCore().GetToolbarHeightF(false));
1568 GetCore().SetFooterBounds(bounds);
1571 UpdateOrientationStatus();
1575 __pOriAgent->RequestOrientationEvent();
1582 _FormImpl::OnDetachingFromMainTree(void)
1584 result r = E_SUCCESS;
1585 r = GetCore().DetachingFromMainTree();
1586 r = _ContainerImpl::OnDetachingFromMainTree();
1592 _FormImpl::OnNotifiedN(const _ControlImpl& source, IList* pArgs)
1594 String* pString = dynamic_cast <Tizen::Base::String*>(pArgs->GetAt(0));
1597 if (*pString == _REQUEST_ORIENTATION_EVENT)
1601 __pOriAgent->FireOrientationEvent();
1604 pArgs->RemoveAll(true);
1615 _FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source)
1617 if (__pFormBackEventListener)
1619 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1620 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1623 __pFormBackEventListener->OnFormBackRequested(*pForm);
1633 _FormImpl::OnFormMenuRequested(Tizen::Ui::Controls::_Form& source)
1635 if (__pFormMenuEventListener)
1637 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1638 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1641 __pFormMenuEventListener->OnFormMenuRequested(*pForm);
1651 _FormImpl::OnFormOrientationStatusRequested(void)
1653 _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
1654 SysAssert(pImplManager);
1656 OrientationStatus status = ORIENTATION_STATUS_PORTRAIT;
1657 int appType = _AppInfo::GetAppType();
1658 if (!(appType & _APP_TYPE_IME_APP))
1660 status = pImplManager->GetOrientationStatus(GetOrientation());
1666 _FormImpl::IsOpaque(void) const
1673 _FormImpl::ConvertSoftkey(Softkey softkey) const
1677 if (softkey == SOFTKEY_0)
1679 _softkey = _SOFTKEY_0;
1681 else if (softkey == SOFTKEY_1)
1683 _softkey = _SOFTKEY_1;
1687 _softkey = _SOFTKEY_COUNT;
1694 _FormImpl::SetNotificationTrayOpenEnabled(bool enable)
1696 return GetCore().SetNotificationTrayOpenEnabled(enable);
1700 _FormImpl::IsNotificationTrayOpenEnabled(void) const
1702 return GetCore().IsNotificationTrayOpenEnabled();
1706 : public _UiBuilderControlMaker
1709 _FormMaker(_UiBuilder* uibuilder)
1710 : _UiBuilderControlMaker(uibuilder){};
1711 virtual ~_FormMaker()
1714 static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1716 _FormMaker* pFormMaker = new (std::nothrow) _FormMaker(uibuilder);
1720 virtual Control* Make(_UiBuilderControl* pControl)
1722 _UiBuilderControlLayout* pControlProperty = null;
1723 result r = E_SUCCESS;
1726 Tizen::Base::String elementString;
1727 bool isTitleAlign = false;
1730 HorizontalAlignment align = ALIGNMENT_CENTER;
1731 Form* pForm = (Form*) GetContainer();
1733 // Get control manager
1734 _ControlManager* pControlManager = _ControlManager::GetInstance();
1735 if (pControlManager == null)
1737 SysLog(NID_UI_CTRL, "Unable to get the control manager.n");
1740 FloatDimension screenSize = pControlManager->GetScreenSizeF();
1743 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(0.0f, 0.0f, screenSize.width, screenSize.height);
1744 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(0.0f, 0.0f, screenSize.height, screenSize.width);
1746 // Get device orientation
1747 app_device_orientation_e deviceOrientation = app_get_device_orientation();
1748 bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270);
1752 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE);
1756 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1759 if (pControlProperty == null)
1761 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Can't read attributes");
1765 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1766 Tizen::Base::String styleString;
1767 styleString = pControlProperty->GetStyle();
1769 if (styleString.Contains(L"FORM_STYLE_TITLE"))
1771 style |= FORM_STYLE_TITLE;
1773 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_0"))
1775 style |= FORM_STYLE_SOFTKEY_0;
1777 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_1"))
1779 style |= FORM_STYLE_SOFTKEY_1;
1781 if (styleString.Contains(L"FORM_STYLE_OPTIONKEY"))
1783 style |= FORM_STYLE_OPTIONKEY;
1785 if (styleString.Contains(L"FORM_STYLE_INDICATOR"))
1787 if (styleString.Contains(L"FORM_STYLE_INDICATOR_AUTO_HIDE"))
1789 style |= FORM_STYLE_INDICATOR_AUTO_HIDE;
1793 style |= FORM_STYLE_INDICATOR;
1796 if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
1798 style |= FORM_STYLE_TEXT_TAB;
1800 if (styleString.Contains(L"FORM_STYLE_ICON_TAB"))
1802 style |= FORM_STYLE_ICON_TAB;
1804 if (styleString.Contains(L"FORM_STYLE_HEADER"))
1806 style |= FORM_STYLE_HEADER;
1808 if (styleString.Contains(L"FORM_STYLE_FOOTER"))
1810 style |= FORM_STYLE_FOOTER;
1813 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1814 __pLayoutMaker->GetLayoutType(pControlProperty, layoutType);
1815 if (layoutType == UIBUILDER_LAYOUT_NONE)
1818 r = pForm->Construct(style);
1822 Layout* pPortraitLayout = null;
1823 Layout* pLandscapeLayout = null;
1824 result tempResult = E_SUCCESS;
1825 tempResult = __pLayoutMaker->GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout);
1826 if (E_SUCCESS == tempResult)
1828 r = pForm->Construct(*pPortraitLayout, *pLandscapeLayout, style);
1835 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1837 if (__pLayoutMaker->GetLayoutType(pControlProperty, layoutType) == false)
1842 if ( layoutType == UIBUILDER_LAYOUT_GRID)
1844 for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
1846 GridLayout* pGridLayout = null;
1847 pControlProperty = pControl->GetAttribute(i);
1849 if ( i == UIBUILDER_ATTRIBUTE_PORTRAIT)
1851 pGridLayout = dynamic_cast<GridLayout*>(pPortraitLayout);
1855 pGridLayout = dynamic_cast<GridLayout*>(pLandscapeLayout);
1857 __pLayoutMaker->SetGridLayoutContainerProperty(pGridLayout, pControlProperty);
1860 delete pPortraitLayout;
1861 if (pPortraitLayout != pLandscapeLayout)
1863 delete pLandscapeLayout;
1869 SysLog(NID_UI_CTRL, "Failed to create Form.");
1874 if (pControl->GetElement(L"titleAlign", elementString))
1876 if (elementString.Equals(L"ALIGN_CENTER", false))
1878 align = ALIGNMENT_CENTER;
1880 else if (elementString.Equals(L"ALIGN_RIGHT", false))
1882 align = ALIGNMENT_RIGHT;
1886 align = ALIGNMENT_LEFT;
1888 isTitleAlign = true;
1891 if (style & FORM_STYLE_TITLE)
1893 if (pControl->GetElement(L"title", elementString))
1897 pForm->SetTitleText(elementString, align);
1901 pForm->SetTitleText(elementString);
1908 pForm->SetTitleText(L"", align);
1912 pForm->SetTitleText(L"");
1917 if (pControl->GetElement(L"titleIcon", elementString))
1919 Bitmap* pBitmap = null;
1920 pBitmap = LoadBitmapN(elementString);
1921 if (pBitmap != null)
1923 r = pForm->SetTitleIcon(pBitmap);
1927 SysLog(NID_UI_CTRL, "Failed to set TitleIcon.");
1932 if (pControl->GetElement(L"softKey0Text", elementString))
1934 pForm->SetSoftkeyText(SOFTKEY_0, elementString);
1936 if (pControl->GetElement(L"softKey1Text", elementString))
1938 pForm->SetSoftkeyText(SOFTKEY_1, elementString);
1940 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
1942 Base::Integer::Parse(elementString, opacity);
1944 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
1946 ConvertStringToColor32(elementString, opacity, color);
1947 pForm->SetBackgroundColor(color);
1952 r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color);
1955 pForm->SetBackgroundColor(color);
1959 pForm->SetBackgroundColor(0xff000000);
1963 if (pControl->GetElement(L"softKey0Icon", elementString) || pControl->GetElement(L"softKey0NormalIcon", elementString))
1965 Bitmap* pNormalBitmap = null;
1966 Bitmap* pPressedBitmap = null;
1967 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1969 if (pNormalBitmap != null)
1971 if (pControl->GetElement(L"softKey0PressedIcon", elementString))
1973 pPressedBitmap = LoadBitmapN(elementString);
1976 if (pPressedBitmap != null)
1978 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, pPressedBitmap);
1979 delete pNormalBitmap;
1980 delete pPressedBitmap;
1984 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, null);
1985 delete pNormalBitmap;
1989 if (pControl->GetElement(L"softKey1Icon", elementString) || pControl->GetElement(L"softKey1NormalIcon", elementString))
1991 Bitmap* pNormalBitmap = null;
1992 Bitmap* pPressedBitmap = null;
1993 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
1995 if (pNormalBitmap != null)
1997 if (pControl->GetElement(L"softKey1PressedIcon", elementString))
1999 pPressedBitmap = LoadBitmapN(elementString); // __image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2002 if (pPressedBitmap != null)
2004 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, pPressedBitmap);
2005 delete pNormalBitmap;
2006 delete pPressedBitmap;
2010 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, null);
2011 delete pNormalBitmap;
2016 if (pControl->GetElement(L"Orientation", elementString) || pControl->GetElement(L"orientation", elementString))
2019 //ORIENTATION_PORTRAIT,
2020 //ORIENTATION_LANDSACPE,
2021 //ORIENTATION_PORTRAIT_REVERSE,
2022 //ORIENTATION_LANDSACPE_REVERSE,
2023 //ORIENTATION_AUTO = 6,
2024 //ORIENTATION_AUTO_FOUR_DIRECTION = 8,
2026 if (elementString.Equals(L"Automatic:2Dir", false) || elementString.Equals(L"Automatic", false))
2028 pForm->SetOrientation(ORIENTATION_AUTOMATIC);
2030 else if (elementString.Equals(L"Automatic:4Dir", false))
2032 pForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
2034 else if (elementString.Equals(L"Landscape", false))
2036 pForm->SetOrientation(ORIENTATION_LANDSCAPE);
2037 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2039 else if (elementString.Equals(L"Landscape:Reverse", false))
2041 pForm->SetOrientation(ORIENTATION_LANDSCAPE_REVERSE);
2042 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2044 else if (elementString.Equals(L"Portrait", false))
2046 pForm->SetOrientation(ORIENTATION_PORTRAIT);
2047 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2049 else if (elementString.Equals(L"Portrait:Reverse", false))
2051 pForm->SetOrientation(ORIENTATION_PORTRAIT_REVERSE);
2052 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2056 if (style & FORM_STYLE_HEADER)
2058 if (pControl->GetElement(L"translucentHeader", elementString))
2060 if (elementString.Equals(L"true", false))
2062 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_HEADER, true);
2067 if (style & FORM_STYLE_FOOTER)
2069 if (pControl->GetElement(L"translucentFooter", elementString))
2071 if (elementString.Equals(L"true", false))
2073 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_FOOTER, true);
2078 if (style & FORM_STYLE_INDICATOR)
2080 if (pControl->GetElement(L"translucentIndicator", elementString))
2082 if (elementString.Equals(L"true", false))
2084 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
2094 _FormRegister::_FormRegister()
2096 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2097 pUiBuilderControlTableManager->RegisterControl(L"Form", _FormMaker::GetInstance);
2099 _FormRegister::~_FormRegister()
2101 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2102 pUiBuilderControlTableManager->UnregisterControl(L"Form");
2104 static _FormRegister FormRegisterToUiBuilder;
2105 }}} // Tizen::Ui::Controls