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
64 const wchar_t* _REQUEST_ORIENTATION_EVENT = L"RequestOrientationEvent";
67 namespace Tizen { namespace Ui { namespace Controls
71 _FormImpl::FormSizeInfo::GetDefaultMinimumSize(_ControlOrientation orientation) const
74 Dimension dimension(0, 0);
81 _FormImpl::FormSizeInfo::GetDefaultMinimumSizeF(_ControlOrientation orientation) const
84 FloatDimension dimension(0.0f, 0.0f);
91 _FormImpl::GetInstance(const Form& form)
93 return static_cast<const _FormImpl*> (form._pControlImpl);
97 _FormImpl::GetInstance(Form& form)
99 return static_cast<_FormImpl*> (form._pControlImpl);
102 _FormImpl::_FormImpl(Form* pPublic, _Form* pCore, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout)
103 : _ContainerImpl(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout)
105 , __pFormBackEventListener(null)
106 , __pFormMenuEventListener(null)
108 , __pImeOriAgent(null)
109 , __pLeftSoftkeyActionEvent(null)
110 , __pRightSoftkeyActionEvent(null)
111 , __pOptionMenuActionEvent(null)
115 int appType = _AppInfo::GetAppType();
116 if (appType & _APP_TYPE_IME_APP)
118 __pImeOriAgent = _ImeOrientationAgent::CreateInstanceN(*pPublic);
119 SysTryReturnVoidResult(NID_UI_CTRL, __pImeOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
123 __pOriAgent = _OrientationAgent::CreateInstanceN(*pPublic);
124 SysTryReturnVoidResult(NID_UI_CTRL, __pOriAgent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
128 _FormImpl::~_FormImpl(void)
132 delete __pImeOriAgent;
133 __pImeOriAgent = null;
142 if (__pLeftSoftkeyActionEvent)
144 delete __pLeftSoftkeyActionEvent;
145 __pLeftSoftkeyActionEvent = null;
148 if (__pRightSoftkeyActionEvent)
150 delete __pRightSoftkeyActionEvent;
151 __pRightSoftkeyActionEvent = null;
154 if (__pOptionMenuActionEvent)
156 delete __pOptionMenuActionEvent;
157 __pOptionMenuActionEvent = null;
160 __leftSoftkeyActionList.RemoveAll(false);
161 __rightSoftkeyActionList.RemoveAll(false);
173 _FormImpl::CreateFormImplN(Form* pControl, Layout* pPublicPortraitLayout, Layout* pPublicLandscapeLayout)
175 result r = E_SUCCESS;
176 _VisualElement* pVisualElement = null;
178 _Form* pCore = _Form::CreateFormN();
180 SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); // [ToDo] interpret last result.
182 _FormImpl* pImpl = new (std::nothrow) _FormImpl(pControl, pCore, pPublicPortraitLayout, pPublicLandscapeLayout);
184 r = _ControlImpl::CheckConstruction(pCore, pImpl);
185 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
187 const FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
188 const FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
190 _ControlOrientation orientation = pCore->GetOrientation();
192 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
194 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Form), portraitSize, orientation);
198 r = pImpl->InitializeBoundsPropertiesF(GET_SIZE_INFO(Form), landscapeSize, orientation);
200 SysAssert(r == E_SUCCESS);
202 pCore->SetFormOrientationStatusEventListener(pImpl);
204 // Make surface opaque.
205 pVisualElement = pCore->GetVisualElement();
206 SysTryCatch(NID_UI_CTRL, pVisualElement, , GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
207 r = pVisualElement->SetSurfaceOpaque(true);
208 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); // [ToDo] interpret last result.
210 SetLastResult(E_SUCCESS);
222 _FormImpl::GetPublicClassName(void) const
224 return "Tizen::Ui::Controls::Form";
228 _FormImpl::GetPublic(void) const
230 return static_cast<const Form&>(_ControlImpl::GetPublic());
234 _FormImpl::GetPublic(void)
236 return static_cast<Form&>(_ControlImpl::GetPublic());
240 _FormImpl::GetCore(void) const
242 return static_cast<const _Form&>(_ControlImpl::GetCore());
246 _FormImpl::GetCore(void)
248 return static_cast<_Form&>(_ControlImpl::GetCore());
252 _FormImpl::GetFocusControl(void)
258 _FormImpl::GetFormStyle(void) const
260 return GetCore().GetFormStyle();
264 _FormImpl::HasIndicator(void) const
266 return GetCore().HasIndicator();
270 _FormImpl::SetFormStyle(unsigned long formStyle)
272 result r = E_SUCCESS;
274 _HeaderImpl* pHeader = GetHeader();
275 _FooterImpl* pFooter = GetFooter();
276 _TabImpl* pTabImpl = GetTabImpl();
278 if (IsAttachedToMainTree())
280 if (FORM_STYLE_INDICATOR & formStyle)
282 _Frame* pFrame = dynamic_cast<_Frame*>(GetCore().GetParent());
283 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.");
287 if ((formStyle & FORM_STYLE_INDICATOR) && (formStyle & FORM_STYLE_INDICATOR_AUTO_HIDE))
289 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.");
294 if (((formStyle & FORM_STYLE_TITLE) || (formStyle & FORM_STYLE_TEXT_TAB) || (formStyle & FORM_STYLE_ICON_TAB)) && (formStyle & FORM_STYLE_HEADER))
296 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.");
303 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
309 if (((formStyle & FORM_STYLE_SOFTKEY_0) || (formStyle & FORM_STYLE_SOFTKEY_1) || (formStyle & FORM_STYLE_OPTIONKEY)) && (formStyle & FORM_STYLE_FOOTER))
311 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.");
318 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
323 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
324 SysTryReturnVoidResult(NID_UI_CTRL, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] Unable to get evas.");
326 GetCore().SetFormStyle(formStyle);
328 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
330 if (FORM_STYLE_INDICATOR & formStyle)
332 GetCore().SetIndicatorShowState(true);
333 indicatorBounds = GetCore().GetIndicatorBoundsF();
335 if (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle)
337 GetCore().SetIndicatorAutoHide(false, true);
341 if (OnFormOrientationStatusRequested() == ORIENTATION_STATUS_PORTRAIT || OnFormOrientationStatusRequested() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
343 GetCore().SetIndicatorShowState(true);
347 GetCore().SetIndicatorShowState(false);
350 GetCore().SetIndicatorAutoHide(false, false);
353 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
358 if ((FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle) && (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle))
360 r = GetCore().SetIndicatorShowState(true);
361 GetCore().SetIndicatorAutoHide(true, true);
362 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
366 if (FORM_STYLE_INDICATOR_AUTO_HIDE & formStyle)
368 r = GetCore().SetIndicatorShowState(true);
369 GetCore().SetIndicatorAutoHide(true, false);
370 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
372 else if(FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & formStyle)
374 r = GetCore().SetIndicatorShowState(true);
375 GetCore().SetIndicatorAutoHide(false, true);
376 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
380 r = GetCore().SetIndicatorShowState(false);
381 GetCore().SetIndicatorAutoHide(false, false);
382 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
387 if (formStyle & FORM_STYLE_HEADER)
391 pHeader = CreateHeaderN();
392 SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
394 GetCore().SetHeader(&pHeader->GetCore());
395 GetCore().AdjustClientBounds();
397 if (GetCore().IsIndicatorTranslucent())
399 if (!GetCore().IsHeaderTranslucent())
401 indicatorBounds.height = 0.0f;
405 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
407 indicatorBounds.height = 0.0f;
412 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
413 GetCore().SetHeaderBounds(bounds);
415 r = GetCore().AttachSystemChild(pHeader->GetCore());
416 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
418 GetCore().SetFormBackEventListener(this);
422 if (GetCore().IsIndicatorTranslucent())
424 if (!GetCore().IsHeaderTranslucent())
426 indicatorBounds.height = 0.0f;
430 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
432 indicatorBounds.height = 0.0f;
437 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
438 GetCore().SetHeaderBounds(bounds);
441 else if (formStyle & FORM_STYLE_TITLE)
445 pHeader = CreateHeaderN();
446 SysTryReturnVoidResult(NID_UI_CTRL, pHeader != null, r, "[%s] Propagating.", GetErrorMessage(r));
448 GetCore().SetHeader(&pHeader->GetCore());
449 GetCore().AdjustClientBounds();
451 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
452 GetCore().SetHeaderBounds(bounds);
454 r = GetCore().AttachSystemChild(pHeader->GetCore());
455 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
459 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
460 GetCore().SetHeaderBounds(bounds);
470 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
474 if (formStyle & FORM_STYLE_TEXT_TAB)
476 float titleHeight = 0.0f;
478 if (formStyle & FORM_STYLE_TITLE)
482 titleHeight = pHeader->GetBoundsF().height;
488 pTabImpl = CreateTabImplN();
489 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
491 float posY = indicatorBounds.height + titleHeight;
493 GetCore().SetTab(&pTabImpl->GetCore());
494 GetCore().AdjustClientBounds();
496 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
497 GetCore().SetTabBounds(bounds);
499 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
500 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
504 float posY = indicatorBounds.height + titleHeight;
506 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
507 GetCore().SetTabBounds(bounds);
509 GetCore().SetTabStyle(_TAB_STYLE_TEXT);
511 else if (formStyle & FORM_STYLE_ICON_TAB)
513 float titleHeight = 0.0f;
515 if (formStyle & FORM_STYLE_TITLE)
519 titleHeight = pHeader->GetBoundsF().height;
525 pTabImpl = CreateTabImplN();
526 SysTryReturnVoidResult(NID_UI_CTRL, pTabImpl != null, r, "[%s] Propagating.", GetErrorMessage(r));
528 float posY = indicatorBounds.height + titleHeight;
530 GetCore().SetTab(&pTabImpl->GetCore());
531 GetCore().AdjustClientBounds();
533 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
534 GetCore().SetTabBounds(bounds);
536 r = GetCore().AttachSystemChild(pTabImpl->GetCore());
537 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
541 float posY = indicatorBounds.height + titleHeight;
543 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
544 GetCore().SetTabBounds(bounds);
546 GetCore().SetTabStyle(_TAB_STYLE_ICON);
554 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
558 if (formStyle & FORM_STYLE_FOOTER)
562 pFooter = CreateFooterN();
563 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
565 GetCore().SetFooter(&pFooter->GetCore());
566 GetCore().AdjustClientBounds();
568 FloatRectangle clientbounds = GetClientBoundsF();
569 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height, clientbounds.width, GetCore().GetToolbarHeightF(false));
571 GetCore().SetFooterBounds(bounds);
573 r = GetCore().AttachSystemChild(pFooter->GetCore());
574 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
576 GetCore().SetFormBackEventListener(this);
577 GetCore().SetFormMenuEventListener(this);
581 FloatRectangle clientbounds = GetClientBoundsF();
582 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height, clientbounds.width, GetCore().GetToolbarHeightF(false));
584 GetCore().SetFooterBounds(bounds);
587 else if (formStyle & FORM_STYLE_SOFTKEY_0 || formStyle & FORM_STYLE_SOFTKEY_1 || formStyle & FORM_STYLE_OPTIONKEY)
593 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
596 pFooter = GetFooter();
600 pFooter = CreateFooterN();
601 SysTryReturnVoidResult(NID_UI_CTRL, pFooter != null, r, "[%s] Propagating.", GetErrorMessage(r));
603 GetCore().SetFooter(&pFooter->GetCore());
604 GetCore().AdjustClientBounds();
606 FloatRectangle clientbounds = GetClientBoundsF();
607 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - GetCore().GetToolbarHeightF(false), clientbounds.width, GetCore().GetToolbarHeightF(false));
609 GetCore().SetFooterBounds(bounds);
611 r = GetCore().AttachSystemChild(pFooter->GetCore());
612 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
614 GetCore().CreateSoftkey(formStyle);
616 pFooter->GetCore().AddActionEventListener(*this);
620 FloatRectangle clientbounds = GetClientBoundsF();
621 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - GetCore().GetToolbarHeightF(false), clientbounds.width, GetCore().GetToolbarHeightF(false));
623 GetCore().SetFooterBounds(bounds);
633 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
634 GetCore().AdjustClientBounds();
638 GetCore().AdjustClientBounds();
640 SetLastResult(E_SUCCESS);
646 _FormImpl::GetFooter(void) const
648 _Toolbar* pToolbar = __pForm->GetFooter();
649 if (pToolbar == null)
654 _FooterImpl* pFooterImpl = static_cast<_FooterImpl*>(pToolbar->GetUserData());
660 _FormImpl::GetHeader(void) const
662 _Toolbar* pToolbar = __pForm->GetHeader();
663 if (pToolbar == null)
668 _HeaderImpl* pHeaderImpl = static_cast<_HeaderImpl*>(pToolbar->GetUserData());
675 _FormImpl::GetTabImpl(void) const
677 _Tab* pTab = __pForm->GetTab();
683 _TabImpl* pTabImpl = static_cast<_TabImpl*>(pTab->GetUserData());
689 _FormImpl::GetTitleText(void) const
691 return GetCore().GetTitleText();
695 _FormImpl::GetTitleTextHorizontalAlignment(void) const
697 return GetCore().GetTitleTextHorizontalAlignment();
701 _FormImpl::HasFooter(void) const
703 return GetCore().HasFooter();
707 _FormImpl::HasHeader(void) const
709 return GetCore().HasHeader();
713 _FormImpl::HasTitle(void) const
715 return GetCore().HasTitle();
719 _FormImpl::HasTab(void) const
721 return GetCore().HasTab();
725 _FormImpl::IsIndicatorVisible(void) const
727 return GetCore().IsIndicatorVisible();
731 _FormImpl::IsHeaderVisible(void) const
733 return GetCore().IsHeaderVisible();
737 _FormImpl::IsFooterVisible(void) const
739 return GetCore().IsFooterVisible();
743 _FormImpl::IsIndicatorTranslucent(void) const
745 return GetCore().IsIndicatorTranslucent();
749 _FormImpl::IsHeaderTranslucent(void) const
751 return GetCore().IsHeaderTranslucent();
755 _FormImpl::IsFooterTranslucent(void) const
757 return GetCore().IsFooterTranslucent();
762 _FormImpl::IsTabTranslucent(void) const
764 return GetCore().IsTabTranslucent();
768 _FormImpl::SetActionBarsTranslucent(unsigned long actionBars, bool translucent)
770 return GetCore().SetActionBarsTranslucent(actionBars, translucent);
774 _FormImpl::SetActionBarsVisible(unsigned long actionBars, bool visible)
776 return GetCore().SetActionBarsVisible(actionBars, visible);
780 _FormImpl::SetTitleIcon(const Bitmap* pTitleBitmap)
782 return GetCore().SetTitleIcon(pTitleBitmap);
786 _FormImpl::SetTitleText(const String& title, HorizontalAlignment alignment)
788 return GetCore().SetTitleText(title, alignment);
792 _FormImpl::GetOverlayRegionN(const Rectangle& rect, OverlayRegionType regionType)
794 return GetCore().GetOverlayRegionN(rect, regionType);
798 _FormImpl::GetOverlayRegionN(const FloatRectangle& rect, OverlayRegionType regionType)
800 return GetCore().GetOverlayRegionN(rect, regionType);
804 _FormImpl::OnDraw(void)
808 __pOriAgent->FireOrientationEvent();
811 _ContainerImpl::OnDraw();
815 _FormImpl::OnKeyReleased(const _ControlImpl& source, _KeyCode keyCode)
820 if (GetCore().GetFooter() || GetCore().GetHeader())
822 if (__pFormBackEventListener)
824 Form* pForm = dynamic_cast <Form*>(&GetPublic());
827 __pFormBackEventListener->OnFormBackRequested(*pForm);
849 _FormImpl::OnActionPerformed(const _Control& source, int actionId)
851 if (GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetFormStyle() & FORM_STYLE_SOFTKEY_1 || GetFormStyle() & FORM_STYLE_OPTIONKEY)
853 Tizen::Base::Runtime::IEventArg* tempArg = null;
854 tempArg = _PublicActionEvent::CreateActionEventArgN(actionId);
855 SysTryReturnVoidResult(NID_UI_CTRL, tempArg , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Unable to create Eventarg.");
858 _PublicActionEvent* pSoftkeyActionEvent = null;
860 if (GetCore().GetFooter()->IsButtonSet(LEFT_BUTTON) && GetSoftkeyActionId(SOFTKEY_0) == actionId)
862 for (int i = 0; i < __leftSoftkeyActionList.GetCount(); i++)
864 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__leftSoftkeyActionList.GetAt(i));
866 if (pSoftkeyActionEvent)
868 pSoftkeyActionEvent->Fire(*tempArg);
874 if (GetCore().GetFooter()->IsButtonSet(RIGHT_BUTTON) && GetSoftkeyActionId(SOFTKEY_1) == actionId)
876 for (int i = 0; i < __rightSoftkeyActionList.GetCount(); i++)
878 pSoftkeyActionEvent = dynamic_cast<_PublicActionEvent*>(__rightSoftkeyActionList.GetAt(i));
880 if (pSoftkeyActionEvent)
882 pSoftkeyActionEvent->Fire(*tempArg);
888 if (GetCore().GetFooter()->IsButtonSet(MIDDLE_BUTTON) && GetOptionkeyActionId() == actionId)
890 if (__pOptionMenuActionEvent)
892 __pOptionMenuActionEvent->Fire(*tempArg);
904 _FormImpl::GetClientAreaCanvasN(void) const
906 return GetCore().GetClientAreaCanvasN();
910 _FormImpl::TranslateToClientAreaPosition(const Point& position) const
912 return GetCore().TranslateToClientAreaPosition(position);
916 _FormImpl::TranslateToClientAreaPosition(const FloatPoint& position) const
918 return GetCore().TranslateToClientAreaPosition(position);
922 _FormImpl::TranslateFromClientAreaPosition(const Point& clientPosition) const
924 return GetCore().TranslateFromClientAreaPosition(clientPosition);
928 _FormImpl::TranslateFromClientAreaPosition(const FloatPoint& clientPosition) const
930 return GetCore().TranslateFromClientAreaPosition(clientPosition);
934 _FormImpl::SetFormBackEventListener(const IFormBackEventListener* pFormBackEventListener)
936 __pFormBackEventListener = const_cast <IFormBackEventListener*>(pFormBackEventListener);
937 GetCore().SetFormBackEventListener(this);
938 result r = GetLastResult();
939 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
943 _FormImpl::SetFormMenuEventListener(const IFormMenuEventListener* pFormMenuEventListener)
945 __pFormMenuEventListener = const_cast <IFormMenuEventListener*>(pFormMenuEventListener);
946 GetCore().SetFormMenuEventListener(this);
947 result r = GetLastResult();
948 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
952 _FormImpl::AddOrientationEventListener(IOrientationEventListener& listener)
956 __pOriAgent->AddListener(listener);
958 else if (__pImeOriAgent)
960 __pImeOriAgent->AddListener(listener);
965 _FormImpl::AddOptionkeyActionListener(const IActionEventListener& listener)
967 if (HasOptionkey() == false)
972 __pOptionMenuActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
974 SysTryReturnVoidResult(NID_UI_CTRL, __pOptionMenuActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
976 __pOptionMenuActionEvent->AddListener(listener);
980 _FormImpl::AddSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
982 _Softkey _softkey = ConvertSoftkey(softkey);
984 if (GetCore().CheckSoftkey(_softkey) == false)
989 if (softkey == SOFTKEY_0)
991 __pLeftSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
993 SysTryReturnVoidResult(NID_UI_CTRL, __pLeftSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
995 __pLeftSoftkeyActionEvent->AddListener(listener);
997 __leftSoftkeyActionList.Add(*__pLeftSoftkeyActionEvent);
999 else if (softkey == SOFTKEY_1)
1001 __pRightSoftkeyActionEvent = _PublicActionEvent::CreateInstanceN(GetPublic());
1003 SysTryReturnVoidResult(NID_UI_CTRL, __pRightSoftkeyActionEvent != null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1005 __pRightSoftkeyActionEvent->AddListener(listener);
1007 __rightSoftkeyActionList.Add(*__pRightSoftkeyActionEvent);
1012 _FormImpl::RemoveOrientationEventListener(IOrientationEventListener& listener)
1016 __pOriAgent->RemoveListener(listener);
1018 else if (__pImeOriAgent)
1020 __pImeOriAgent->RemoveListener(listener);
1025 _FormImpl::RemoveOptionkeyActionListener(const IActionEventListener& listener)
1027 if (HasOptionkey() == false)
1032 if (__pOptionMenuActionEvent)
1034 __pOptionMenuActionEvent->RemoveListener(listener);
1039 _FormImpl::RemoveSoftkeyActionListener(Softkey softkey, const IActionEventListener& listener)
1041 _Softkey _softkey = ConvertSoftkey(softkey);
1043 if (GetCore().CheckSoftkey(_softkey) == false)
1048 if (softkey == SOFTKEY_0)
1050 if (__pLeftSoftkeyActionEvent)
1052 __pLeftSoftkeyActionEvent->RemoveListener(listener);
1055 else if (softkey == SOFTKEY_1)
1057 if (__pRightSoftkeyActionEvent)
1059 __pRightSoftkeyActionEvent->RemoveListener(listener);
1065 _FormImpl::SetOrientation(Orientation orientation)
1069 __pOriAgent->SetMode(orientation);
1074 _FormImpl::GetOrientation(void) const
1078 return __pOriAgent->GetMode();
1081 return ORIENTATION_NONE;
1085 _FormImpl::GetOrientationStatus(void) const
1089 return __pOriAgent->GetStatus();
1091 else if (__pImeOriAgent)
1093 return __pImeOriAgent->GetStatus();
1096 return ORIENTATION_STATUS_NONE;
1100 _FormImpl::UpdateOrientationStatus(bool draw)
1104 __pOriAgent->Update(draw);
1109 _FormImpl::UpdateOrientation(void)
1113 __pOriAgent->UpdateOrientation();
1118 _FormImpl::UpdateOrientation(int angle)
1120 SysLog(NID_UI_CTRL, "[Ime Rotation]");
1124 __pImeOriAgent->UpdateOrientation(angle);
1129 _FormImpl::HasOptionkey(void) const
1131 return GetCore().HasOptionkey();
1135 _FormImpl::HasSoftkey(Softkey softkey) const
1137 _Softkey _softkey = ConvertSoftkey(softkey);
1139 return GetCore().HasSoftkey(_softkey);
1143 _FormImpl::SetSoftkeyEnabled(Softkey softkey, bool enable)
1145 _Softkey _softkey = ConvertSoftkey(softkey);
1147 result r = GetCore().SetSoftkeyEnabled(_softkey, enable);
1148 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1154 _FormImpl::IsSoftkeyEnabled(Softkey softkey) const
1156 _Softkey _softkey = ConvertSoftkey(softkey);
1158 return GetCore().IsSoftkeyEnabled(_softkey);
1162 _FormImpl::GetSoftkeyActionId(Softkey softkey) const
1164 _Softkey _softkey = ConvertSoftkey(softkey);
1166 return GetCore().GetSoftkeyActionId(_softkey);
1170 _FormImpl::GetOptionkeyActionId(void) const
1172 return GetCore().GetOptionkeyActionId();
1176 _FormImpl::GetSoftkeyText(Softkey softkey) const
1178 _Softkey _softkey = ConvertSoftkey(softkey);
1180 return GetCore().GetSoftkeyText(_softkey);
1184 _FormImpl::SetOptionkeyActionId(int actionId)
1186 result r = GetCore().SetOptionkeyActionId(actionId);
1187 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1193 _FormImpl::SetSoftkeyActionId(Softkey softkey, int actionId)
1195 _Softkey _softkey = ConvertSoftkey(softkey);
1197 result r = GetCore().SetSoftkeyActionId(_softkey, actionId);
1198 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1204 _FormImpl::SetSoftkeyText(Softkey softkey, const String& text)
1206 _Softkey _softkey = ConvertSoftkey(softkey);
1208 result r = GetCore().SetSoftkeyText(_softkey, text);
1209 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1215 _FormImpl::SetSoftkeyIcon(Softkey softkey, const Bitmap& pNormalBitmap, const Bitmap* ppPressedBitmap)
1217 _Softkey _softkey = ConvertSoftkey(softkey);
1219 result r = GetCore().SetSoftkeyIcon(_softkey, pNormalBitmap, ppPressedBitmap);
1220 SysTryLog(NID_UI_CTRL, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
1226 _FormImpl::OnChangeLayout(_ControlOrientation orientation)
1228 FloatDimension portraitSize = _ControlManager::GetInstance()->_ControlManager::GetScreenSizeF();
1229 FloatDimension landscapeSize = FloatDimension(portraitSize.height, portraitSize.width);
1231 _FrameImpl* pFrameImpl = dynamic_cast<_FrameImpl*>(GetParent());
1234 FrameShowMode frameShowMode = pFrameImpl->GetShowMode();
1236 if ((frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN) || (frameShowMode == FRAME_SHOW_MODE_PARTIAL_SCREEN_FLOATING))
1238 bool movable = pFrameImpl->GetCore().IsMovable();
1239 pFrameImpl->GetCore().SetMovable(true);
1241 FloatPoint prevPoint = pFrameImpl->GetPositionF();
1242 FloatPoint curPoint(prevPoint.x, prevPoint.y);
1243 float ratio = portraitSize.width / portraitSize.height;
1244 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1246 if (prevPoint.x > 0.0f)
1248 curPoint.x = prevPoint.x * ratio;
1251 if (prevPoint.y > 0.0f)
1253 curPoint.y = prevPoint.y / ratio;
1258 if (prevPoint.x > 0.0f)
1260 curPoint.x = prevPoint.x / ratio;
1263 if (prevPoint.y > 0.0f)
1265 curPoint.y = prevPoint.y * ratio;
1271 //pFrameImpl->SetPosition(curPoint);
1272 portraitSize = pFrameImpl->GetSizeF();
1273 landscapeSize = portraitSize;
1274 pFrameImpl->GetCore().SetMovable(movable);
1275 pFrameImpl->GetCore().SetFloatingOrientation(orientation);
1280 _ContainerImpl::OnChangeLayout(orientation);
1281 SysTryReturnVoidResult(NID_UI_CTRL, GetLastResult() == E_SUCCESS, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1283 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1285 SetSize(portraitSize);
1289 SetSize(landscapeSize);
1292 DeflateClientRectHeight(0.0f);
1294 float indicatorheight = 0.0f;
1296 GET_SHAPE_CONFIG(FORM::INDICATOR_HEIGHT, GetCore().GetOrientation(), indicatorheight);
1297 _Indicator* pIndicator = GetCore().GetIndicator();
1301 pIndicator->SetBounds(FloatRectangle(0.0f, 0.0f, GetClientBoundsF().width, indicatorheight));
1304 if (GetCore().HasIndicator())
1308 pIndicator->SetIndicatorOrientation(orientation);
1309 if (orientation == _CONTROL_ORIENTATION_PORTRAIT)
1311 if ((FORM_STYLE_INDICATOR & GetFormStyle()) || (FORM_STYLE_INDICATOR_AUTO_HIDE & GetFormStyle()))
1313 GetCore().SetIndicatorShowState(true);
1317 GetCore().SetIndicatorShowState(false);
1322 if (FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE & GetFormStyle())
1324 GetCore().SetIndicatorShowState(true);
1328 GetCore().SetIndicatorShowState(false);
1332 GetCore().AdjustClientBounds();
1336 GetCore().SetIndicatorShowState(false);
1340 pIndicator->OnChangeLayout(orientation);
1343 float adjHeight = 0.0f;
1345 if (GetCore().HasHeader())
1347 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1348 if (GetCore().IsIndicatorVisible())
1350 indicatorBounds = GetCore().GetIndicatorBoundsF();
1351 if (GetCore().IsIndicatorTranslucent())
1353 if (!GetCore().IsHeaderTranslucent())
1355 indicatorBounds.height = 0.0f;
1359 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1361 indicatorBounds.height = 0.0f;
1365 if (FORM_STYLE_INDICATOR_AUTO_HIDE & GetFormStyle())
1367 indicatorBounds.height = 0.0f;
1374 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1375 GetCore().SetHeaderBounds(bounds);
1378 if (GetCore().HasTab()) // Ki-Dong,Hong.Temp
1380 float titleHeight = 0.0f;
1382 if (GetCore().GetFormStyle() & FORM_STYLE_TITLE)
1384 if (GetCore().HasHeader())
1386 _HeaderImpl* pHeaderImpl = GetHeader();
1389 titleHeight = pHeaderImpl->GetBoundsF().height;
1394 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1396 if (GetCore().IsIndicatorVisible())
1398 indicatorBounds = GetCore().GetIndicatorBoundsF();
1399 if (GetCore().IsIndicatorTranslucent())
1401 if (!GetCore().IsHeaderTranslucent())
1403 indicatorBounds.height = 0.0f;
1407 if (orientation == _CONTROL_ORIENTATION_LANDSCAPE)
1409 indicatorBounds.height = 0.0f;
1415 float posY = indicatorBounds.height + titleHeight;
1417 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1418 GetCore().SetTabBounds(bounds);
1421 if (GetCore().HasFooter())
1423 if (GetCore().GetFooter()->GetVisibleState() && !GetCore().IsFooterTranslucent())
1429 adjHeight = GetCore().GetToolbarHeightF(false);
1432 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1433 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1435 adjHeight = GetCore().GetToolbarHeightF(false);
1438 FloatRectangle bounds(0.0f, GetClientBoundsF().y + GetClientBoundsF().height - adjHeight,
1439 GetClientBoundsF().width, GetCore().GetToolbarHeightF(false));
1440 GetCore().SetFooterBounds(bounds);
1445 _FormImpl::CreateHeaderN(void)
1447 result r = E_SUCCESS;
1449 Header* pHeader = new (std::nothrow) Header;
1450 SysTryReturn(NID_UI_CTRL, pHeader, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1452 r = pHeader->Construct();
1453 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1455 _HeaderImpl* pHeaderImpl = _HeaderImpl::GetInstance(*pHeader);
1457 SetLastResult(E_SUCCESS);
1463 _FormImpl::CreateFooterN(void)
1465 result r = E_SUCCESS;
1467 Footer* pFooter = new (std::nothrow) Footer;
1468 SysTryReturn(NID_UI_CTRL, pFooter, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
1470 r = pFooter->Construct();
1471 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
1473 _FooterImpl* pFooterImpl = _FooterImpl::GetInstance(*pFooter);
1475 SetLastResult(E_SUCCESS);
1480 // Ki-Dong,Hong.Temp
1482 _FormImpl::CreateTabImplN(void)
1484 //result r = E_SUCCESS;
1486 //Tab* pTab = new (std::nothrow) Tab;
1487 //SysTryReturn(NID_UI_CTRL, pTab, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
1489 //r = pTab->Construct();
1490 //SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, E_SYSTEM, "[E_SYSTEM] Unable to consturct tab.");
1492 //return pTab->GetTabImpl();
1493 Tab* pTab = _TabImpl::CreateTabN();
1494 SysTryReturn(NID_UI_CTRL, pTab, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
1496 _TabImpl* pTabImpl = _TabImpl::GetInstance(*pTab);
1498 SetLastResult(E_SUCCESS);
1504 _FormImpl::DeflateClientRectHeight(int height)
1506 return GetCore().DeflateClientRectHeight(height);
1510 _FormImpl::DeflateClientRectHeight(float height)
1512 return GetCore().DeflateClientRectHeight(height);
1516 _FormImpl::RemoveHeader(void)
1518 _HeaderImpl* pHeaderImpl = GetHeader();
1522 __pForm->RemoveHeader();
1523 result r = GetLastResult();
1524 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1525 Header* pHeader = pHeaderImpl->GetHeader();
1536 _FormImpl::RemoveFooter(void)
1538 _FooterImpl* pFooterImpl = GetFooter();
1542 __pForm->RemoveFooter();
1543 result r = GetLastResult();
1544 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1545 Footer* pFooter = pFooterImpl->GetFooter();
1557 // Ki-Dong,Hong.Temp
1559 _FormImpl::RemoveTabImpl(void)
1561 _TabImpl* pTabImpl = GetTabImpl();
1565 __pForm->RemoveTab();
1566 result r = GetLastResult();
1567 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, false, r, "[%s] Propagating.", GetErrorMessage(r));
1568 Tab* pTab = pTabImpl->GetTab();
1570 pTabImpl->DeleteTab(pTab);
1581 _FormImpl::GetDataBindingContextN(void) const
1583 return _DataBindingContextImpl::GetDataBindingContextN(*this);
1587 _FormImpl::OnAttaching(const _Control* pParent)
1589 result r = E_SUCCESS;
1590 _Frame* pFrame = dynamic_cast<_Frame*>(const_cast<_Control*>((pParent)));
1591 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1593 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.");
1595 r = _ControlImpl::OnAttaching(pParent);
1600 _FormImpl::OnAttachedToMainTree(void)
1602 result r = E_SUCCESS;
1605 r = GetCore().AttachedToMainTree();
1606 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1608 r = _ContainerImpl::OnAttachedToMainTree();
1609 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1611 FloatRectangle indicatorBounds(0.0f, 0.0f, 0.0f, 0.0f);
1613 if (FORM_STYLE_INDICATOR & GetCore().GetFormStyle())
1615 indicatorBounds = GetCore().GetIndicatorBoundsF();
1616 r = GetLastResult();
1617 SysTryReturnResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1620 _HeaderImpl* pHeader = GetHeader();
1621 _FooterImpl* pFooter = GetFooter();
1622 _TabImpl* pTabImpl = GetTabImpl();
1626 if (GetCore().IsIndicatorTranslucent())
1628 if (!GetCore().IsHeaderTranslucent())
1630 indicatorBounds.height = 0.0f;
1634 if (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE)
1636 indicatorBounds.height = 0.0f;
1640 FloatRectangle bounds(0.0f, indicatorBounds.height, GetClientBoundsF().width, GetCore().GetToolbarHeightF(true));
1641 GetCore().SetHeaderBounds(bounds);
1644 float titleHeight = 0.0f;
1648 titleHeight = pHeader->GetBoundsF().height;
1653 float posY = indicatorBounds.height + titleHeight;
1655 FloatRectangle bounds(0.0f, posY, GetClientBoundsF().width, GetCore().GetTabHeightF());
1656 GetCore().SetTabBounds(bounds);
1661 float adjHeight = 0.0f;
1663 if (!(GetCore().GetFooter()->GetVisibleState()) || GetCore().IsFooterTranslucent())
1665 adjHeight = GetCore().GetToolbarHeightF(false);
1668 if (!(GetCore().GetFormStyle() & FORM_STYLE_FOOTER || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_0 || GetCore().GetFormStyle() & FORM_STYLE_SOFTKEY_1
1669 || GetCore().GetFormStyle() & FORM_STYLE_OPTIONKEY))
1671 adjHeight = GetCore().GetToolbarHeightF(false);
1674 FloatRectangle clientbounds = GetClientBoundsF();
1675 FloatRectangle bounds(0.0f, clientbounds.y + clientbounds.height - adjHeight, clientbounds.width, GetCore().GetToolbarHeightF(false));
1677 GetCore().SetFooterBounds(bounds);
1680 UpdateOrientationStatus();
1684 __pOriAgent->RequestOrientationEvent();
1691 _FormImpl::OnDetachingFromMainTree(void)
1693 result r = E_SUCCESS;
1694 r = GetCore().DetachingFromMainTree();
1695 r = _ContainerImpl::OnDetachingFromMainTree();
1701 _FormImpl::OnNotifiedN(const _ControlImpl& source, IList* pArgs)
1703 String* pString = dynamic_cast <Tizen::Base::String*>(pArgs->GetAt(0));
1706 if (*pString == _REQUEST_ORIENTATION_EVENT)
1710 __pOriAgent->FireOrientationEvent();
1713 pArgs->RemoveAll(true);
1724 _FormImpl::OnFormBackRequested(Tizen::Ui::Controls::_Form& source)
1726 if (__pFormBackEventListener)
1728 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1729 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1732 __pFormBackEventListener->OnFormBackRequested(*pForm);
1742 _FormImpl::OnFormMenuRequested(Tizen::Ui::Controls::_Form& source)
1744 if (__pFormMenuEventListener)
1746 _FormImpl* pFormImpl = static_cast<_FormImpl*>(source.GetUserData());
1747 Form* pForm = dynamic_cast <Form*>(&pFormImpl->GetPublic());
1750 __pFormMenuEventListener->OnFormMenuRequested(*pForm);
1760 _FormImpl::OnFormOrientationStatusRequested(void)
1762 _ControlImplManager* pImplManager = _ControlImplManager::GetInstance();
1763 SysAssert(pImplManager);
1765 OrientationStatus status = ORIENTATION_STATUS_PORTRAIT;
1766 int appType = _AppInfo::GetAppType();
1767 if (!(appType & _APP_TYPE_IME_APP))
1769 status = pImplManager->GetOrientationStatus(GetOrientation());
1775 _FormImpl::IsOpaque(void) const
1782 _FormImpl::ConvertSoftkey(Softkey softkey) const
1786 if (softkey == SOFTKEY_0)
1788 _softkey = _SOFTKEY_0;
1790 else if (softkey == SOFTKEY_1)
1792 _softkey = _SOFTKEY_1;
1796 _softkey = _SOFTKEY_COUNT;
1803 _FormImpl::SetNotificationTrayOpenEnabled(bool enable)
1805 return GetCore().SetNotificationTrayOpenEnabled(enable);
1809 _FormImpl::IsNotificationTrayOpenEnabled(void) const
1811 return GetCore().IsNotificationTrayOpenEnabled();
1815 : public _UiBuilderControlMaker
1818 _FormMaker(_UiBuilder* uibuilder)
1819 : _UiBuilderControlMaker(uibuilder){};
1820 virtual ~_FormMaker()
1823 static _UiBuilderControlMaker* GetInstance(_UiBuilder* uibuilder)
1825 _FormMaker* pFormMaker = new (std::nothrow) _FormMaker(uibuilder);
1829 virtual Control* Make(_UiBuilderControl* pControl)
1831 _UiBuilderControlLayout* pControlProperty = null;
1832 result r = E_SUCCESS;
1835 Tizen::Base::String elementString;
1836 bool isTitleAlign = false;
1839 HorizontalAlignment align = ALIGNMENT_CENTER;
1840 Form* pForm = (Form*) GetContainer();
1842 // Get control manager
1843 _ControlManager* pControlManager = _ControlManager::GetInstance();
1844 if (pControlManager == null)
1846 SysLog(NID_UI_CTRL, "Unable to get the control manager.n");
1849 FloatDimension screenSize = pControlManager->GetScreenSizeF();
1852 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT))->SetRect(0.0f, 0.0f, screenSize.width, screenSize.height);
1853 (pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE))->SetRect(0.0f, 0.0f, screenSize.height, screenSize.width);
1855 // Get device orientation
1856 app_device_orientation_e deviceOrientation = app_get_device_orientation();
1857 bool isHorizontal = (deviceOrientation == APP_DEVICE_ORIENTATION_90) || (deviceOrientation == APP_DEVICE_ORIENTATION_270);
1861 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_LANDSCAPE);
1865 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1868 if (pControlProperty == null)
1870 SysLogException(NID_UI_CTRL, E_SYSTEM, "[E_SYSTEM] Can't read attributes");
1874 pControlProperty = pControl->GetAttribute(UIBUILDER_ATTRIBUTE_PORTRAIT);
1875 Tizen::Base::String styleString;
1876 styleString = pControlProperty->GetStyle();
1878 if (styleString.Contains(L"FORM_STYLE_TITLE"))
1880 style |= FORM_STYLE_TITLE;
1882 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_0"))
1884 style |= FORM_STYLE_SOFTKEY_0;
1886 if (styleString.Contains(L"FORM_STYLE_SOFTKEY_1"))
1888 style |= FORM_STYLE_SOFTKEY_1;
1890 if (styleString.Contains(L"FORM_STYLE_OPTIONKEY"))
1892 style |= FORM_STYLE_OPTIONKEY;
1894 if (styleString.Contains(L"FORM_STYLE_INDICATOR"))
1896 if (styleString.Contains(L"FORM_STYLE_INDICATOR_AUTO_HIDE"))
1898 style |= FORM_STYLE_INDICATOR_AUTO_HIDE;
1902 style |= FORM_STYLE_INDICATOR;
1905 if (styleString.Contains(L"FORM_STYLE_PORTRAIT_INDICATOR"))
1907 if (styleString.Contains(L"FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE"))
1909 style |= FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE;
1913 style |= FORM_STYLE_PORTRAIT_INDICATOR;
1916 if (styleString.Contains(L"FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE"))
1918 style |= FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE;
1920 if (styleString.Contains(L"FORM_STYLE_TEXT_TAB"))
1922 style |= FORM_STYLE_TEXT_TAB;
1924 if (styleString.Contains(L"FORM_STYLE_ICON_TAB"))
1926 style |= FORM_STYLE_ICON_TAB;
1928 if (styleString.Contains(L"FORM_STYLE_HEADER"))
1930 style |= FORM_STYLE_HEADER;
1932 if (styleString.Contains(L"FORM_STYLE_FOOTER"))
1934 style |= FORM_STYLE_FOOTER;
1937 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1938 __pLayoutMaker->GetLayoutType(pControlProperty, layoutType);
1939 if (layoutType == UIBUILDER_LAYOUT_NONE)
1942 r = pForm->Construct(style);
1946 Layout* pPortraitLayout = null;
1947 Layout* pLandscapeLayout = null;
1948 result tempResult = E_SUCCESS;
1949 tempResult = __pLayoutMaker->GetLayoutN(pControl, pPortraitLayout, pLandscapeLayout);
1950 if (E_SUCCESS == tempResult)
1952 r = pForm->Construct(*pPortraitLayout, *pLandscapeLayout, style);
1959 _UiBuilderLayoutType layoutType = UIBUILDER_LAYOUT_NONE;
1961 if (__pLayoutMaker->GetLayoutType(pControlProperty, layoutType) == false)
1966 if (layoutType == UIBUILDER_LAYOUT_GRID)
1968 for (int i = 0; i < UIBUILDER_ATTRIBUTE_NUM; i++)
1970 GridLayout* pGridLayout = null;
1971 pControlProperty = pControl->GetAttribute(i);
1973 if (i == UIBUILDER_ATTRIBUTE_PORTRAIT)
1975 pGridLayout = dynamic_cast<GridLayout*>(pPortraitLayout);
1979 pGridLayout = dynamic_cast<GridLayout*>(pLandscapeLayout);
1981 __pLayoutMaker->SetGridLayoutContainerProperty(pGridLayout, pControlProperty);
1984 delete pPortraitLayout;
1985 if (pPortraitLayout != pLandscapeLayout)
1987 delete pLandscapeLayout;
1993 SysLog(NID_UI_CTRL, "Failed to create Form.");
1998 if (pControl->GetElement(L"titleAlign", elementString))
2000 if (elementString.Equals(L"ALIGN_CENTER", false))
2002 align = ALIGNMENT_CENTER;
2004 else if (elementString.Equals(L"ALIGN_RIGHT", false))
2006 align = ALIGNMENT_RIGHT;
2010 align = ALIGNMENT_LEFT;
2012 isTitleAlign = true;
2015 if (style & FORM_STYLE_TITLE)
2017 if (pControl->GetElement(L"title", elementString))
2021 pForm->SetTitleText(elementString, align);
2025 pForm->SetTitleText(elementString);
2032 pForm->SetTitleText(L"", align);
2036 pForm->SetTitleText(L"");
2041 if (pControl->GetElement(L"titleIcon", elementString))
2043 Bitmap* pBitmap = null;
2044 pBitmap = LoadBitmapN(elementString);
2045 if (pBitmap != null)
2047 r = pForm->SetTitleIcon(pBitmap);
2051 SysLog(NID_UI_CTRL, "Failed to set TitleIcon.");
2056 if (pControl->GetElement(L"softKey0Text", elementString))
2058 pForm->SetSoftkeyText(SOFTKEY_0, elementString);
2060 if (pControl->GetElement(L"softKey1Text", elementString))
2062 pForm->SetSoftkeyText(SOFTKEY_1, elementString);
2064 if (pControl->GetElement(L"backgroundColorOpacity", elementString) || pControl->GetElement(L"BGColorOpacity", elementString))
2066 Base::Integer::Parse(elementString, opacity);
2068 if (pControl->GetElement(L"backgroundColor", elementString) || pControl->GetElement(L"BGColor", elementString))
2070 ConvertStringToColor32(elementString, opacity, color);
2071 pForm->SetBackgroundColor(color);
2076 r = GET_COLOR_CONFIG(FORM::BG_NORMAL,color);
2079 pForm->SetBackgroundColor(color);
2083 pForm->SetBackgroundColor(0xff000000);
2087 if (pControl->GetElement(L"softKey0Icon", elementString) || pControl->GetElement(L"softKey0NormalIcon", elementString))
2089 Bitmap* pNormalBitmap = null;
2090 Bitmap* pPressedBitmap = null;
2091 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2093 if (pNormalBitmap != null)
2095 if (pControl->GetElement(L"softKey0PressedIcon", elementString))
2097 pPressedBitmap = LoadBitmapN(elementString);
2100 if (pPressedBitmap != null)
2102 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, pPressedBitmap);
2103 delete pNormalBitmap;
2104 delete pPressedBitmap;
2108 pForm->SetSoftkeyIcon(SOFTKEY_0, *pNormalBitmap, null);
2109 delete pNormalBitmap;
2113 if (pControl->GetElement(L"softKey1Icon", elementString) || pControl->GetElement(L"softKey1NormalIcon", elementString))
2115 Bitmap* pNormalBitmap = null;
2116 Bitmap* pPressedBitmap = null;
2117 pNormalBitmap = LoadBitmapN(elementString); //__image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2119 if (pNormalBitmap != null)
2121 if (pControl->GetElement(L"softKey1PressedIcon", elementString))
2123 pPressedBitmap = LoadBitmapN(elementString); // __image->DecodeN(path,BITMAP_PIXEL_FORMAT_RGB565);
2126 if (pPressedBitmap != null)
2128 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, pPressedBitmap);
2129 delete pNormalBitmap;
2130 delete pPressedBitmap;
2134 pForm->SetSoftkeyIcon(SOFTKEY_1, *pNormalBitmap, null);
2135 delete pNormalBitmap;
2140 if (pControl->GetElement(L"Orientation", elementString) || pControl->GetElement(L"orientation", elementString))
2143 //ORIENTATION_PORTRAIT,
2144 //ORIENTATION_LANDSACPE,
2145 //ORIENTATION_PORTRAIT_REVERSE,
2146 //ORIENTATION_LANDSACPE_REVERSE,
2147 //ORIENTATION_AUTO = 6,
2148 //ORIENTATION_AUTO_FOUR_DIRECTION = 8,
2150 if (elementString.Equals(L"Automatic:2Dir", false) || elementString.Equals(L"Automatic", false))
2152 pForm->SetOrientation(ORIENTATION_AUTOMATIC);
2154 else if (elementString.Equals(L"Automatic:4Dir", false))
2156 pForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION);
2158 else if (elementString.Equals(L"Landscape", false))
2160 pForm->SetOrientation(ORIENTATION_LANDSCAPE);
2161 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2163 else if (elementString.Equals(L"Landscape:Reverse", false))
2165 pForm->SetOrientation(ORIENTATION_LANDSCAPE_REVERSE);
2166 SetUiBuilderRotateState(UIBUIDER_SCREEN_HORIZONTAL);
2168 else if (elementString.Equals(L"Portrait", false))
2170 pForm->SetOrientation(ORIENTATION_PORTRAIT);
2171 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2173 else if (elementString.Equals(L"Portrait:Reverse", false))
2175 pForm->SetOrientation(ORIENTATION_PORTRAIT_REVERSE);
2176 SetUiBuilderRotateState(UIBUIDER_SCREEN_VERTICAL);
2180 if (style & FORM_STYLE_HEADER)
2182 if (pControl->GetElement(L"translucentHeader", elementString))
2184 if (elementString.Equals(L"true", false))
2186 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_HEADER, true);
2191 if (style & FORM_STYLE_FOOTER)
2193 if (pControl->GetElement(L"translucentFooter", elementString))
2195 if (elementString.Equals(L"true", false))
2197 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_FOOTER, true);
2202 if (style & FORM_STYLE_INDICATOR)
2204 if (pControl->GetElement(L"translucentIndicator", elementString))
2206 if (elementString.Equals(L"true", false))
2208 pForm->SetActionBarsTranslucent(FORM_ACTION_BAR_INDICATOR, true);
2218 _FormRegister::_FormRegister()
2220 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2221 pUiBuilderControlTableManager->RegisterControl(L"Form", _FormMaker::GetInstance);
2223 _FormRegister::~_FormRegister()
2225 _UiBuilderControlTableManager* pUiBuilderControlTableManager = _UiBuilderControlTableManager::GetInstance();
2226 pUiBuilderControlTableManager->UnregisterControl(L"Form");
2228 static _FormRegister FormRegisterToUiBuilder;
2229 }}} // Tizen::Ui::Controls