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.
19 * @file FUi_ContainerImpl.cpp
20 * @brief This is the implementation file for _ContainerImpl class.
23 #include <FUiLayout.h>
24 #include <FBaseSysLog.h>
25 #include <FApp_AppInfo.h>
26 #include "FUi_ContainerImpl.h"
27 #include "FUi_WindowImpl.h"
28 #include "FUi_Control.h"
29 #include "FUi_CoordinateSystemUtils.h"
30 #include "FUi_LayoutImpl.h"
32 using namespace Tizen::App;
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
35 using namespace Tizen::Graphics;
37 namespace Tizen { namespace Ui {
40 _ContainerImpl::CreateContainerImplN(Container* pPublic)
44 _Control* pCore = _Control::CreateControlN();
45 result r = GetLastResult();
46 SysTryReturn(NID_UI, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r));
48 _ContainerImpl* pImpl = new (std::nothrow) _ContainerImpl(pPublic, pCore);
49 r = CheckConstruction(pCore, pImpl);
50 SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
56 _ContainerImpl::CreateContainerImplN(Container* pPublic, const Rectangle& bounds,
57 const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout,
58 bool resizable, bool movable)
62 _Control* pCore = _Control::CreateControlN();
63 SysTryReturn(NID_UI, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
65 _ContainerImpl* pImpl =
66 new (std::nothrow) _ContainerImpl(pPublic, pCore, bounds,
67 pPublicPortraitLayout, pPublicLandscapeLayout,
69 r = CheckConstruction(pCore, pImpl);
70 SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
78 _ContainerImpl::CreateContainerImplN(Container* pPublic, const FloatRectangle& bounds,
79 const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout,
80 bool resizable, bool movable)
84 _Control* pCore = _Control::CreateControlN();
85 SysTryReturn(NID_UI, pCore, null, E_SYSTEM, "[%s] Propagating.", GetErrorMessage(r));
87 _ContainerImpl* pImpl =
88 new (std::nothrow) _ContainerImpl(pPublic, pCore, bounds,
89 pPublicPortraitLayout, pPublicLandscapeLayout,
91 r = CheckConstruction(pCore, pImpl);
92 SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
100 _ContainerImpl::GetInstance(Container& container)
102 return static_cast <_ContainerImpl*> (container._pControlImpl);
105 const _ContainerImpl*
106 _ContainerImpl::GetInstance(const Container& container)
108 return static_cast <const _ContainerImpl*> (container._pControlImpl);
111 _ContainerImpl::~_ContainerImpl(void)
118 RemoveAllChildren(true);
122 _ContainerImpl::GetPublicClassName(void) const
124 return "Tizen::Ui::Container";
128 _ContainerImpl::GetPublic(void) const
130 return static_cast <const Container&>(_ControlImpl::GetPublic());
134 _ContainerImpl::GetPublic(void)
136 return static_cast <Container&>(_ControlImpl::GetPublic());
139 // E_INVALID_ARG, E_OUT_OF_MEMORY
141 _ContainerImpl::AddChild(_ControlImpl* pChild, bool transferOwnership)
144 result r = E_SUCCESS;
147 pChild != null, E_INVALID_ARG,
148 E_INVALID_ARG, "[E_INVALID_ARG] The specified child is not constructed.");
151 IsChildAttachable(*pChild), E_INVALID_ARG,
152 E_INVALID_ARG, "[E_INVALID_ARG] %s cannot be a child of %s.",
153 pChild->GetPublicClassName(), GetPublicClassName());
155 _ContainerImpl* pOldParent = pChild->GetParent();
158 (pOldParent != this), E_INVALID_ARG,
159 E_INVALID_ARG, "[E_INVALID_ARG] The child control is already attached to this container.");
162 pOldParent == null, E_INVALID_ARG,
163 E_INVALID_ARG, "[E_INVALID_ARG] Unable to add the child which already has another parent.");
165 r = __controlPublics.Add(pChild->GetPublic());
168 SysAssert(r == E_OUT_OF_MEMORY); // I can't beleve Tizen::Base.
169 SysLogException(NID_UI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
170 return E_OUT_OF_MEMORY;
173 r = GetCore().AttachChild(pChild->GetCore());
174 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r));
180 _ContainerImpl::Destroy(void)
182 result r = E_SUCCESS;
184 _ContainerImpl* pParent = GetParent();
187 r = pParent->RemoveChild(this, false);
191 _Control* pParent = GetCore().GetParent();
194 ControlList& children = pParent->GetChildList();
195 r = children.Remove(&GetCore());
198 RemoveAllChildren(true);
199 Container* pContainer = &GetPublic();
207 _ContainerImpl::RemoveControl(_ControlImpl* pChild, bool deallocate)
210 result r = E_SUCCESS;
212 _ContainerImpl* pChildContainer = dynamic_cast <_ContainerImpl*>(pChild);
215 _ContainerImpl* pParent = pChildContainer->GetParent();
216 SysTryReturn(NID_UI, pParent, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The control is not a child of this container.");
218 r = pParent->RemoveChild(pChildContainer, false);
219 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
220 pChildContainer->RemoveAllChildren(true);
222 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
225 Container* pContainer = &pChildContainer->GetPublic();
232 SysTryReturn(NID_UI, pChild, E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified child is not constructed.");
233 r = RemoveChild(pChild, deallocate);
234 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
241 _ContainerImpl::RemoveChild(_ControlImpl* pChild, bool deallocate)
244 result r = E_SUCCESS;
247 pChild != null, E_INVALID_ARG,
248 E_INVALID_ARG, "[E_INVALID_ARG] The specified child is not constructed.");
250 if (pChild->GetCore().GetArea() == _CONTROL_AREA_SYSTEM)
255 GetChildIndex(pChild);
257 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
259 r = GetCore().DetachChild(pChild->GetCore());
260 SysAssert(r == E_SUCCESS);
262 r = __controlPublics.Remove(pChild->GetPublic(), deallocate);
263 SysAssert(r == E_SUCCESS);
269 _ContainerImpl::RemoveControl(int index)
272 result r = E_SUCCESS;
274 _ControlImpl* pChild = GetChild(index); // Find child control.
276 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
278 _ContainerImpl* pChildContainer = dynamic_cast <_ContainerImpl*>(pChild);
281 _ContainerImpl* pParent = pChildContainer->GetParent();
284 r = pParent->RemoveChild(pChildContainer, false);
285 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
287 pChildContainer->RemoveAllChildren(true);
289 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
290 Container* pContainer = &pChildContainer->GetPublic();
296 r = RemoveChild(index);
297 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
304 _ContainerImpl::RemoveChild(int index)
307 result r = E_SUCCESS;
309 _ControlImpl* pChild = GetChild(index); // Find child control.
311 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
314 SysTryReturn(NID_UI, pChild, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] The child to remove is null.");
316 GetCore().DetachChild(pChild->GetCore());
317 SysAssert(GetLastResult() == E_SUCCESS);
319 r = __controlPublics.Remove(pChild->GetPublic(), true);
320 SysAssert(r == E_SUCCESS);
326 _ContainerImpl::DeleteAllChildren(_ContainerImpl* pChild, bool detachSystemChild, ArrayList* pChildrenList)
328 ArrayList* pList = static_cast <ArrayList*>(pChild->GetChildrenPublic());
329 int count = pList->GetCount();
330 for (int index = count - 1; index >= 0; index--)
332 Control* pControl = static_cast <Control*>(pList->GetAt(index));
335 Container* pContainer = dynamic_cast <Container*>(pControl);
336 result r = GetLastResult();
339 SysAssert(r == E_OUT_OF_RANGE);
340 SysLogException(NID_UI,
341 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range (index = %d, count = %d.)",
342 index, GetChildCount());
348 _ContainerImpl* pContainerImpl = _ContainerImpl::GetInstance(*pContainer);
349 ArrayList* pContainerChildrenList = static_cast <ArrayList*>(pContainerImpl->GetChildrenPublic());
350 int childrenCount = pContainerChildrenList->GetCount();
352 if (childrenCount > 0)
354 DeleteAllChildren(pContainerImpl, detachSystemChild, pContainerChildrenList);
356 r = pChildrenList->Remove(*pContainer, true);
357 SysAssert(r == E_SUCCESS);
361 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(*pControl);
364 if (detachSystemChild || pControlImpl->GetCore().GetArea() != _CONTROL_AREA_SYSTEM)
366 r = pChildrenList->Remove(*pControl, true);
367 SysAssert(r == E_SUCCESS);
376 _ContainerImpl::RemoveAllChildren(bool detachSystemChild, bool callOnDetachingFromMaintree)
378 if (callOnDetachingFromMaintree && !GetCore().IsPostOrderTraversal())
380 GetCore().GetControlDelegate().OnDetachingFromMainTree();
382 GetCore().DetachAllChildren(detachSystemChild, true);
383 SysAssert(GetLastResult() == E_SUCCESS);
384 if (callOnDetachingFromMaintree && GetCore().IsPostOrderTraversal())
386 GetCore().GetControlDelegate().OnDetachingFromMainTree();
388 ArrayList* pChildrenList = static_cast <ArrayList*>(GetChildrenPublic());
389 DeleteAllChildren(this, detachSystemChild, pChildrenList);
393 _ContainerImpl::MoveChildToTop(const _ControlImpl& child)
396 result r = E_SUCCESS;
399 child.GetParent() == this, E_INVALID_ARG,
400 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
402 r = GetCore().MoveChildToTop(child.GetCore());
403 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
405 r = __controlPublics.Remove(child.GetPublic());
406 SysAssert(r == E_SUCCESS);
408 r = __controlPublics.Add(child.GetPublic());
409 SysAssert(r == E_SUCCESS);
415 _ContainerImpl::MoveChildBefore(const _ControlImpl& targetChild, const _ControlImpl& child)
418 result r = E_SUCCESS;
422 targetChild.GetParent() == this, E_INVALID_ARG,
423 E_INVALID_ARG, "[E_INVALID_ARG] Not my targetChild.");
426 child.GetParent() == this, E_INVALID_ARG,
427 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
429 r = GetCore().MoveChildBefore(targetChild.GetCore(), child.GetCore());
430 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
432 r = __controlPublics.Remove(child.GetPublic());
433 SysAssert(r == E_SUCCESS);
435 r = __controlPublics.IndexOf(targetChild.GetPublic(), index);
436 SysAssert(r == E_SUCCESS);
438 r = __controlPublics.InsertAt(child.GetPublic(), index);
439 SysAssert(r == E_SUCCESS);
444 Tizen::Base::Collection::IList*
445 _ContainerImpl::GetChildrenPublic(void) const
448 return const_cast <LinkedList*>(&__controlPublics);
453 _ContainerImpl::GetChild(int index) const
457 const Control* pControl = static_cast <const Control*>(__controlPublics.GetAt(index));
458 result r = GetLastResult();
461 SysAssert(r == E_OUT_OF_RANGE); // I can't beleve Tizen::Base.
462 SysLogException(NID_UI,
463 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range (index = %d, count = %d.)",
464 index, GetChildCount());
471 return const_cast <_ControlImpl*>(_ControlImpl::GetInstance(*pControl));
475 _ContainerImpl::SearchControlByName(const Tizen::Base::String& name, bool recursive, bool searchMyself) const
479 if (searchMyself == true || (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat()))
481 if (name.CompareTo(GetName()) == 0)
483 return const_cast <_ContainerImpl*>(this);
487 _ControlImpl* pChildFound = null;
488 for (int i = 0; i < __controlPublics.GetCount(); ++i)
490 _ControlImpl* pChild = GetChild(i);
498 _ContainerImpl* pChildAsContainer = dynamic_cast <_ContainerImpl*>(pChild);
499 if (pChildAsContainer && recursive)
501 pChildFound = pChildAsContainer->SearchControlByName(name, true, true);
502 if (pChildFound != null)
507 else if (name.CompareTo(pChild->GetName()) == 0)
509 pChildFound = pChild;
517 // [ToDo] Check if the public Container leaves the out-param index as it is.
519 _ContainerImpl::GetChildIndex(const _ControlImpl* pChild) const
523 result r = __controlPublics.IndexOf(pChild->GetPublic(), index);
526 SysAssert(r == E_OBJ_NOT_FOUND);
527 SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The control is not a child of this container.");
535 _ContainerImpl::GetChildCount(void) const
538 return __controlPublics.GetCount();
542 _ContainerImpl::GetPublicPortraitLayoutN(void) const
546 Layout* pLayout = _LayoutImpl::CreatePublicLayoutN(__portraitLayout);
547 result r = GetLastResult();
548 SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
554 _ContainerImpl::GetPublicLandscapeLayoutN(void) const
558 Layout* pLayout = _LayoutImpl::CreatePublicLayoutN(__landscapeLayout);
559 result r = GetLastResult();
560 SysTryReturn(NID_UI, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
566 _ContainerImpl::GetPublicLayoutN(void) const
568 return (GetCore().GetOrientation() == _CONTROL_ORIENTATION_LANDSCAPE) ?
569 GetPublicLandscapeLayoutN() : GetPublicPortraitLayoutN();
573 _ContainerImpl::SetChildAt(const _ControlImpl* pChild, int index)
576 result r = E_SUCCESS;
579 pChild, E_INVALID_ARG,
580 E_INVALID_ARG, "[E_INVALID_ARG] The specified child is not constructed.");
582 // In API 2.0, (0 <= index) was not checked but checked at the ArrayList::SetAt().
583 // So, I check the case here. No problem.
585 (0 <= index && index < GetCore().GetChildCount()), E_OUT_OF_RANGE,
586 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range (index = %d, count = %d)",
587 index, GetCore().GetChildCount());
589 // [ToDo] 2.0 bug: The error should be E_INVALID_ARG.
590 // And I think this must be checked before the range check.
591 _ContainerImpl* pParent = pChild->GetParent();
593 pParent == this, E_SYSTEM,
594 E_SYSTEM, "[E_SYSTEM] The container is not the parent of the specified control.");
596 int oldIndex = GetCore().GetChildIndex(pChild->GetCore());
597 SysAssert(GetLastResult() == E_SUCCESS);
599 if (index == oldIndex)
604 r = __controlPublics.SetAt(pChild->GetPublic(), index);
605 SysAssert(r == E_SUCCESS);
607 _Control* pTargetChild = GetCore().GetChild(index);
608 SysAssert(pTargetChild);
610 r = GetCore().MoveChildBefore(*pTargetChild, pChild->GetCore());
611 SysAssert(r == E_SUCCESS);
617 _ContainerImpl::IsAncestorOf(const _ControlImpl* pChild) const
619 SysTryReturn(NID_UI, pChild, false, E_INVALID_ARG, "[E_INVALID_ARG] The specified child is not constructed.");
620 return GetCore().IsAncestorOf(pChild->GetCore());
624 _ContainerImpl::OnDraw(void)
626 GetPublic().OnClearBackground();
628 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
633 GetPublic().OnDraw();
637 _ContainerImpl::OnChangeLayout(_ControlOrientation orientation)
639 result r = E_SUCCESS;
640 _ControlImpl::OnChangeLayout(orientation);
642 if (orientation == _CONTROL_ORIENTATION_PORTRAIT && !__portraitLayout.IsNull())
644 r = GetCore().SetCurrentLayout(__portraitLayout->GetCore());
645 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to set up the current layout as portrait");
647 else if (orientation == _CONTROL_ORIENTATION_LANDSCAPE && !__landscapeLayout.IsNull())
649 r = GetCore().SetCurrentLayout(__landscapeLayout->GetCore());
650 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to set up the current layout as landscape.");
655 _ContainerImpl::OnVisibleStateChanging(void)
657 GetPublic().OnShowStateChanging(GetVisibleState());
658 _ControlImpl::OnVisibleStateChanging();
662 _ContainerImpl::OnVisibleStateChanged(void)
664 _ControlImpl::OnVisibleStateChanged();
665 GetPublic().OnShowStateChanged(GetVisibleState());
669 _ContainerImpl::OnBoundsChanging(const Rectangle& bounds)
671 _ContainerImpl* pChild = _ContainerImpl::GetInstance(GetPublic());
674 GetPublic().OnBoundsChanging(_CoordinateSystemUtils::ConvertToInteger(__oldBounds), bounds);
677 return _ControlImpl::OnBoundsChanging(bounds);
681 _ContainerImpl::OnBoundsChanging(const FloatRectangle& bounds)
683 _ContainerImpl* pChild = _ContainerImpl::GetInstance(GetPublic());
686 GetPublic().OnBoundsChanging(__oldBounds, bounds);
688 return _ControlImpl::OnBoundsChanging(bounds);
692 _ContainerImpl::OnBoundsChanged(void)
694 _ControlImpl::OnBoundsChanged();
695 _ContainerImpl* pChild = _ContainerImpl::GetInstance(GetPublic());
698 GetPublic().OnBoundsChanged(_CoordinateSystemUtils::ConvertToInteger(__oldBounds), GetBounds());
699 GetPublic().OnBoundsChanged(__oldBounds, GetBoundsF());
704 _ContainerImpl::OnEvaluateSize(Dimension& evaluatedSize)
706 _ContainerImpl* pChild = _ContainerImpl::GetInstance(GetPublic());
709 GetPublic().OnEvaluateSize(evaluatedSize);
711 _ControlImpl::OnEvaluateSize(evaluatedSize);
715 _ContainerImpl::OnEvaluateSize(FloatDimension& evaluatedSize)
717 _ContainerImpl* pChild = _ContainerImpl::GetInstance(GetPublic());
718 bool changed = false;
721 changed = GetPublic().OnEvaluateSize(evaluatedSize);
723 _ControlImpl::OnEvaluateSize(evaluatedSize);
728 _ContainerImpl::CallOnDraw(void)
730 if (!_AppInfo::IsOspCompat())
737 _ContainerImpl::Initialize(Control* pPublic, _Control* pCore, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout)
739 result r = GetLastResult();
745 _SharedPtr <Tizen::Ui::_LayoutImpl> spPortraitLayout;
746 _SharedPtr <Tizen::Ui::_LayoutImpl> spLandscapeLayout;
748 // Check if all or none
750 (pPublicPortraitLayout && pPublicLandscapeLayout) ||
751 (!pPublicPortraitLayout && !pPublicLandscapeLayout)
754 if (pPublicPortraitLayout)
756 r = SetLayout(*pCore, _CONTROL_ORIENTATION_PORTRAIT, pPublicPortraitLayout);
762 r = pCore->SetCurrentLayout(__portraitLayout->GetCore());
763 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, E_SYSTEM, "[E_SYSTEM] Failed to set up the current layout.");
766 if (pPublicLandscapeLayout)
768 r = SetLayout(*pCore, _CONTROL_ORIENTATION_LANDSCAPE, pPublicLandscapeLayout);
776 _ContainerImpl::_ContainerImpl(Control* pPublic, _Control* pCore, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout)
777 : _ControlImpl(pPublic, pCore)
779 Initialize(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout);
782 _ContainerImpl::_ContainerImpl(Control* pPublic, _Control* pCore, const Rectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable)
783 : _ControlImpl(pPublic, pCore)
785 result r = E_SUCCESS;
787 Initialize(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout);
795 bool allOrNone = (pPublicPortraitLayout && pPublicLandscapeLayout) || (!pPublicPortraitLayout && !pPublicLandscapeLayout);
796 SysAssert(allOrNone);
798 r = SetBounds(bounds);
799 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
801 pCore->SetResizable(resizable);
802 pCore->SetMovable(movable);
805 _ContainerImpl::_ContainerImpl(Control* pPublic, _Control* pCore, const FloatRectangle& bounds, const Layout* pPublicPortraitLayout, const Layout* pPublicLandscapeLayout, bool resizable, bool movable)
806 : _ControlImpl(pPublic, pCore)
808 result r = E_SUCCESS;
810 Initialize(pPublic, pCore, pPublicPortraitLayout, pPublicLandscapeLayout);
818 bool allOrNone = (pPublicPortraitLayout && pPublicLandscapeLayout) || (!pPublicPortraitLayout && !pPublicLandscapeLayout);
819 SysAssert(allOrNone);
821 r = SetBounds(bounds);
822 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
824 pCore->SetResizable(resizable);
825 pCore->SetMovable(movable);
829 _ContainerImpl::SetLayout(_Control& core, _ControlOrientation orientation, const Layout* pPublicLayout)
831 SysAssert(pPublicLayout);
833 result r = E_SUCCESS;
835 const char* orientationStatus = (orientation == _CONTROL_ORIENTATION_PORTRAIT) ?
836 "portrait" : "landscape";
838 _SharedPtr <Tizen::Ui::_LayoutImpl>& spLayout = (orientation == _CONTROL_ORIENTATION_PORTRAIT) ?
839 __portraitLayout : __landscapeLayout;
841 spLayout = _LayoutImpl::GetLayoutImpl(const_cast <Layout*>(pPublicLayout));
843 !spLayout.IsNull(), E_INVALID_ARG,
844 E_INVALID_ARG, "[E_INVALID_ARG] The %s layout is invalid object", orientationStatus);
846 r = core.AddLayout(spLayout->GetCore());
852 SysLogException(NID_UI, E_INVALID_ARG, "[E_INVALID_ARG] The %s layout is already used.", orientationStatus);
855 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Failed to add the %s layout.", orientationStatus);
865 _ContainerImpl::IsChildAttachable(_ControlImpl& child) const
867 if (dynamic_cast <_WindowImpl*>(&child) != null)
877 _ContainerImpl::SetControlAlwaysOnTop(Control& control, bool alwaysOnTop)
879 _ControlImpl* pChild = _ControlImpl::GetInstance(control);
881 pChild, E_INVALID_ARG,
882 E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not constructed.");
884 _Control& childCore = pChild->GetCore();
885 const bool atBottom = childCore.GetLayer() == _CONTROL_LAYER_CLIENT_BOTTOM;
887 if (atBottom && !alwaysOnTop)
889 SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The bottom child cannot be reset.");
890 return E_INVALID_OPERATION;
894 GetCore().SetChildAlwaysOnTop(childCore) :
895 GetCore().ResetChildLayer(childCore);
899 _ContainerImpl::SetControlAlwaysAtBottom(Control& control, bool alwaysAtBottom)
901 _ControlImpl* pChild = _ControlImpl::GetInstance(control);
903 pChild, E_INVALID_ARG,
904 E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not constructed.");
906 _Control& childCore = pChild->GetCore();
907 const bool onTop = childCore.GetLayer() == _CONTROL_LAYER_CLIENT_TOP;
909 if (onTop && !alwaysAtBottom)
911 SysLogException(NID_UI, E_INVALID_OPERATION, "[E_INVALID_OPERATION] The top child cannot be reset.");
912 return E_INVALID_OPERATION;
915 return alwaysAtBottom ?
916 GetCore().SetChildAlwaysAtBottom(childCore) :
917 GetCore().ResetChildLayer(childCore);
921 _ContainerImpl::IsControlAlwaysAtBottom(const Control& control) const
923 const _ControlImpl* pChild = _ControlImpl::GetInstance(control);
926 E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not constructed.");
929 pChild->GetParent() == this, false,
930 E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not a child of this container.");
932 return pChild->GetCore().GetLayer() == _CONTROL_LAYER_CLIENT_BOTTOM;
936 _ContainerImpl::IsControlAlwaysOnTop(const Control& control) const
938 const _ControlImpl* pChild = _ControlImpl::GetInstance(control);
941 E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not constructed.");
944 pChild->GetParent() == this, false,
945 E_INVALID_ARG, "[E_INVALID_ARG] The specified chlid control is not a child of this container.");
947 return pChild->GetCore().GetLayer() == _CONTROL_LAYER_CLIENT_TOP;