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_Control.cpp
20 * @brief This is the implementation file for the _Control class.
25 #include <unique_ptr.h>
26 #include <FBaseColLinkedListT.h>
27 #include <FBaseColArrayListT.h>
28 #include <FBaseColHashMapT.h>
29 #include <FBaseSysLog.h>
30 #include <FGrpFloatRectangle.h>
31 #include <FUiAnimVisualElementContentProvider.h>
32 #include <FBase_Log.h>
33 #include <FGrp_BitmapImpl.h>
34 #include <FSys_SystemInfoImpl.h>
36 #include "FUi_Control.h"
37 #include "FUi_ControlManager.h"
38 #include "FUi_FocusManagerImpl.h"
39 #include "FUi_CoordinateSystemUtils.h"
40 #include "FUi_Window.h"
41 #include "FUi_EcoreEvasMgr.h"
42 #include "FUi_EcoreEvas.h"
43 #include "FUi_LayoutLayoutContainer.h"
44 #include "FUi_LayoutAbsoluteLayout.h"
45 #include "FUi_LayoutILayoutItemHandler.h"
46 #include "FUi_TouchManager.h"
47 #include "FUi_DataBindingContext.h"
48 #include "FUi_TouchLongPressGestureDetector.h"
49 #include "FUi_TouchTapGestureDetector.h"
50 #include "FUi_AccessibilityContainer.h"
51 #include "FUi_ResourceManager.h"
52 #include "FUiAnim_ControlVisualElement.h"
53 #include "FUiAnim_Debug.h"
54 #include "FUiAnim_VisualElement.h"
55 #include "FUiAnim_VisualElementImpl.h"
56 #include "FUiCtrl_Form.h"
57 #include "FUiCtrl_Frame.h"
58 #include "FUi_ContainerImpl.h"
59 #include "FUi_DragAndDropItem.h"
60 #include "FUi_UiEventManager.h"
61 #include "FUiAnim_MatrixUtil.h"
64 using namespace Tizen::Base;
65 using namespace Tizen::Base::Collection;
66 using namespace Tizen::Base::Runtime;
67 using namespace Tizen::Graphics;
68 using namespace Tizen::Ui;
69 using namespace Tizen::Ui::Animations;
70 using namespace Tizen::Ui::Controls;
75 GetZOrderGroupOfVisualElement(_ControlLayer layer)
79 case _CONTROL_LAYER_OVERLAY:
80 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL - 1;
81 case _CONTROL_LAYER_CLIENT_BOTTOM:
82 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL;
83 case _CONTROL_LAYER_NONE:
85 case _CONTROL_LAYER_CLIENT_MIDDLE:
86 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 1;
87 case _CONTROL_LAYER_CLIENT_TOP:
88 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 2;
89 case _CONTROL_LAYER_SYSTEM:
90 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 3;
93 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 1;
98 AdjustSizeToRange(float& width, float& height, const FloatDimension& minDim, const FloatDimension& maxDim)
100 bool changed = false;
101 if (width < minDim.width)
103 width = minDim.width;
106 if (height < minDim.height)
108 height = minDim.height;
112 if (width > maxDim.width)
114 width = maxDim.width;
117 if (height > maxDim.height)
119 height = maxDim.height;
127 AdjustSizeToRange(FloatDimension& dim, const FloatDimension& minDim, const FloatDimension& maxDim)
129 return AdjustSizeToRange(dim.width, dim.height, minDim, maxDim);
134 _ControlVisualElement*
135 CreateVisualElementN(void)
139 _ControlVisualElement* pVisualElement = new (std::nothrow) _ControlVisualElement;
140 SysTryReturn(NID_UI, pVisualElement, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
143 pVisualElement->ConstructControlVisualElement() == E_SUCCESS, ,
144 E_SYSTEM, "[E_SYSTEM] System error occurred.");
146 pVisualElement->SetImplicitAnimationEnabled(false);
147 pVisualElement->SetShowState(true);
148 pVisualElement->SetBackBufferEnabled(true);
149 pVisualElement->SetRedrawOnResizeEnabled(true);
150 pVisualElement->SetSurfaceOpaque(false);
152 return pVisualElement;
155 //delete pVisualElement;
156 pVisualElement->Destroy();
160 _Control::GestureMap*
161 CreateGestureMapN(void)
165 _Control::GestureMap* pGestureMap = new (std::nothrow) _Control::GestureMap;
166 SysTryReturn(NID_UI, pGestureMap, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
169 pGestureMap->Construct() == E_SUCCESS, ,
170 E_SYSTEM, "[E_SYSTEM] System error occurred.");
180 _Control::ControlList*
181 CreateControlListN(void)
185 _Control::ControlList* pControlList = new (std::nothrow) _Control::ControlList;
186 SysTryReturn(NID_UI, pControlList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
192 _Control::WindowList*
193 CreateWindowListN(void)
197 _Control::WindowList* pWindowList = new (std::nothrow) _Control::WindowList;
198 SysTryReturn(NID_UI, pWindowList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
205 _Layout::LayoutContainer*
206 CreateLayoutContainerN(_Layout::ILayoutItemHandler* pLayoutItemHandler)
209 result r = E_SUCCESS;
211 _Layout::LayoutContainer* pLayoutContainer = null;
212 _Layout::AbsoluteLayout* pAbsLayout = null;
214 pLayoutContainer = new (std::nothrow) _Layout::LayoutContainer();
215 SysTryReturn(NID_UI, pLayoutContainer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage");
216 if (IsFailed(GetLastResult()))
221 pAbsLayout = new (std::nothrow) _Layout::AbsoluteLayout();
222 SysTryCatch(NID_UI, pAbsLayout, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
223 if (IsFailed(GetLastResult()))
228 pLayoutContainer->SetItemHandler(pLayoutItemHandler);
230 r = pLayoutContainer->SetDefaultLayout(*pAbsLayout);
231 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error occurred.");
233 return pLayoutContainer;
237 delete pLayoutContainer;
242 } // Anonymous namespace
244 namespace Tizen { namespace Ui
247 IMPLEMENT_PROPERTY(_Control);
249 class _Control::ControlVisualElementContentProvider
250 : public VisualElementContentProvider
257 ControlVisualElementContentProvider(_Control& control)
262 virtual ~ControlVisualElementContentProvider(void)
266 virtual bool PrepareDraw(VisualElement& target)
268 _ControlVisualElement* pCVE = dynamic_cast <_ControlVisualElement*>(&target);
274 Color bgColor = __control.GetBackgroundColor();
276 pCVE->SetBackgroundColor(
278 (float) bgColor.GetRed() / 255.0f,
279 (float) bgColor.GetGreen() / 255.0f,
280 (float) bgColor.GetBlue() / 255.0f,
281 (float) bgColor.GetAlpha() / 255.0f
285 __control.GetControlDelegate().OnDraw();
287 target.SetFlushNeeded();
292 virtual HitTestResult HitTest(VisualElement& target, const FloatPoint& point)
294 return __control.GetControlDelegate().HitTest(point);
298 ControlVisualElementContentProvider(const ControlVisualElementContentProvider& rhs);
299 ControlVisualElementContentProvider& operator =(const ControlVisualElementContentProvider& rhs);
302 class _Control::ControlVisualElementEventListener
303 : public IVisualElementEventListener
306 ControlVisualElementEventListener(_Control& control)
311 virtual ~ControlVisualElementEventListener(void)
316 virtual void OnChildAttached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& child)
320 virtual void OnChildDetached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& child)
324 virtual void OnAttached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& parent)
328 virtual void OnDetached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& parent)
332 virtual result OnTransformChanging(Tizen::Ui::Animations::VisualElement& source, FloatMatrix4& newTransform)
337 virtual void OnTransformChanged(Tizen::Ui::Animations::VisualElement& source, const FloatMatrix4& previousTransform)
341 virtual result OnChildrenTransformChanging(Tizen::Ui::Animations::VisualElement& source, FloatMatrix4& newTransform)
343 for (int i = 0; i < __control.GetChildCount(); ++i)
345 _Control* pChild = __control.GetChild(i);
351 if (pChild->GetArea() == _CONTROL_AREA_SYSTEM)
353 _VisualElement* pVisualElement = pChild->GetVisualElement();
356 FloatMatrix4 inverseMatrix(newTransform);
357 _MatrixUtilInvert(inverseMatrix);
359 result r = pVisualElement->SetTransformMatrix(inverseMatrix);
371 virtual void OnChildrenTransformChanged(Tizen::Ui::Animations::VisualElement& source, const FloatMatrix4& previousTransform)
375 virtual result OnBoundsChanging(Tizen::Ui::Animations::VisualElement& source, FloatRectangle& newBounds)
380 virtual void OnBoundsChanged(Tizen::Ui::Animations::VisualElement& source, const FloatRectangle& previousBounds)
384 virtual void OnShowStateChanged(Tizen::Ui::Animations::VisualElement& source, bool previousShowState)
389 ControlVisualElementEventListener(const ControlVisualElementEventListener& rhs);
390 ControlVisualElementEventListener& operator =(const ControlVisualElementEventListener& rhs);
394 }; // ControlVisualElementEventListener
396 // Layout Item Handler
397 class _Control::LayoutItemHandler
398 : public _Layout::ILayoutItemHandler
401 LayoutItemHandler(_Control* pControl)
402 : __pControl(pControl)
404 SysAssert(__pControl);
407 void SetItemVisibleState(bool visible)
409 __pControl->SetVisibleState(visible);
412 result SetItemBounds(const FloatRectangle& rect)
414 SysAssert(__pControl->IsInSizeRange(FloatDimension(rect.width, rect.height)));
415 return __pControl->SetBoundsFinal(rect, false, true);
418 FloatRectangle GetItemBounds(void) const
420 return __pControl->GetBoundsF();
423 FloatRectangle GetItemClientBoundsFromSize(const FloatDimension& size) const
425 FloatRectangle clientBounds(0.0f, 0.0f, 0.0f, 0.0f);
426 __pControl->UpdateClientBounds(size, clientBounds);
430 FloatDimension GetItemContentSize(bool horizontalMode, bool verticalMode) const
432 FloatRectangle rect = __pControl->GetContentAreaBoundsF();
433 if (rect == FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
435 return __pControl->GetControlDelegate().GetContentSizeF(horizontalMode, verticalMode);
439 return FloatDimension(rect.width, rect.height);
443 FloatDimension GetItemMinimumSize(void) const
445 return __pControl->GetMinimumSizeF();
448 FloatDimension GetItemMaximumSize(void) const
450 return __pControl->GetMaximumSizeF();
453 result OnItemMeasure(float& width, float& height)
455 Dimension evaluatedSize(_CoordinateSystemUtils::ConvertToInteger(width), _CoordinateSystemUtils::ConvertToInteger(height));
456 FloatDimension evaluatedSizeF(width, height);
458 bool changed = __pControl->GetControlDelegate().OnEvaluateSize(evaluatedSizeF);
461 width = evaluatedSizeF.width;
462 height = evaluatedSizeF.height;
466 __pControl->GetControlDelegate().OnEvaluateSize(evaluatedSize);
468 if (evaluatedSize.width != (_CoordinateSystemUtils::ConvertToInteger(width)))
470 width = evaluatedSize.width;
472 if (evaluatedSize.height != (_CoordinateSystemUtils::ConvertToInteger(height)))
474 height = evaluatedSize.height;
482 LayoutItemHandler(const LayoutItemHandler& rhs);
483 LayoutItemHandler& operator =(const LayoutItemHandler& rhs);
486 _Control* __pControl;
487 }; // LayoutItemHandler
492 _Control::CreateControlN(void)
494 _Control* pControl = new (std::nothrow) _Control;
495 SysTryReturn(NID_UI, pControl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
496 if (IsFailed(GetLastResult()))
501 pControl->AcquireHandle();
503 SysAssert(GetLastResult() == E_SUCCESS);
512 _Control::ResetEventListeners(void)
514 __pFocusEventListener = this;
515 __pNotificationEventListener = this;
519 _Control::SetControlDelegate(_IControlDelegate& delegate)
521 __pControlDelegate = &delegate;
525 _Control::ResetControlDelegate(void)
527 __pControlDelegate = this;
531 _Control::GetControlDelegate(void) const
535 return const_cast<_Control&>(*this);
538 SysAssert(__pControlDelegate);
539 return *__pControlDelegate;
543 _Control::SetPropagatedTouchEventListener(_IPropagatedTouchEventListener* pListener)
545 __pPropagatedTouchEventListener = pListener;
548 _IPropagatedTouchEventListener*
549 _Control::GetPropagatedTouchEventListener(void) const
553 return const_cast<_Control*>(this);
556 SysAssert(__pPropagatedTouchEventListener);
557 return __pPropagatedTouchEventListener;
561 _Control::SetPropagatedKeyEventListener(_IPropagatedKeyEventListener* pListener)
563 __pPropagatedKeyEventListener = pListener;
566 _IPropagatedKeyEventListener*
567 _Control::GetPropagatedKeyEventListener(void) const
571 return const_cast<_Control*>(this);
574 SysAssert(__pPropagatedKeyEventListener);
575 return __pPropagatedKeyEventListener;
579 _Control::OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
585 _Control::OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
591 _Control::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
593 //SysLog(NID_UI, ">>> [core] OnKeyPressed(%d, %d)", keyInfo.GetKeyCode(), keyInfo.GetKeyModifier());
598 _Control::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
600 //SysLog(NID_UI, ">>> [core] OnKeyReleased(%d, %d)", keyInfo.GetKeyCode(), keyInfo.GetKeyModifier());
605 _Control::TranslateKeyEventInfo(const _Control& source, _KeyInfo& keyInfo)
610 _UiTouchEventDelivery
611 _Control::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
613 return _UI_TOUCH_EVENT_DELIVERY_YES;
616 _UiTouchEventDelivery
617 _Control::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
619 return _UI_TOUCH_EVENT_DELIVERY_YES;
622 _UiTouchEventDelivery
623 _Control::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
625 return _UI_TOUCH_EVENT_DELIVERY_YES;
628 _UiTouchEventDelivery
629 _Control::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
631 return _UI_TOUCH_EVENT_DELIVERY_YES;
634 _UiTouchEventDelivery
635 _Control::OnPreviewTouchWheeled(const _Control& source, const _TouchInfo& touchinfo)
637 return _UI_TOUCH_EVENT_DELIVERY_YES;
641 _Control::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
647 _Control::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
653 _Control::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
659 _Control::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
665 _Control::OnTouchWheeled(const _Control& source, const _TouchInfo& touchinfo)
671 _Control::OnFocusGained(const _Control& source)
673 bool isFocusMode = _FocusManagerImpl::GetInstance()->IsFocusModeStateEnabled();
674 bool isFocusalbeControl = _FocusManagerImpl::GetInstance()->IsFocusable(this);
675 if (isFocusMode && isFocusalbeControl)
683 _Control::OnFocusLost(const _Control& source)
685 if (__pFocusVisualElement)
687 __pFocusVisualElement->SetShowState(false);
692 _Control::OnTraversalControlFocusGained(void)
697 _Control::OnTraversalControlFocusLost(void)
702 _Control::OnPreviewNotifiedN(const _Control& source, IList* pArgs)
708 _Control::OnNotifiedN(const _Control& source, IList* pArgs)
714 _Control::IsMovable(void) const
721 _Control::IsResizable(void) const
728 _Control::GetContentSize(void) const
731 return Dimension(0, 0);
735 _Control::GetContentSizeF(bool horizontalMode, bool verticalMode) const
738 return FloatDimension(0.0f, 0.0f);
742 _Control::HitTest(const FloatPoint& point)
744 _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*__pVisualElement);
746 if (pVisualElementImpl)
748 if (pVisualElementImpl->HitTestI(point) == _VisualElementImpl::HITTEST_MATCH)
750 return HIT_TEST_MATCH;
754 return HIT_TEST_NOWHERE;
758 _Control::GetVerticalScrollPosition(void) const
764 _Control::GetHorizontalScrollPosition(void) const
770 _Control::GetOrientation(void) const
773 return __orientation;
777 _Control::OnDraw(void)
782 _Control::OnCanvasRequestedN(const FloatRectangle& bounds)
789 _Control::OnCapturedBitmapRequestedN(void)
796 _Control::OnAttaching(const _Control* pParent)
802 _Control::OnAttached(void)
808 _Control::OnAttachingToMainTree(const _Control* pParent)
814 _Control::OnPreAttachedToMainTree(void)
820 _Control::OnAttachedToMainTree(void)
826 _Control::OnDetachingFromMainTree(void)
832 _Control::OnAttachingFailed(const _Control& parent)
837 _Control::OnDetaching(void)
843 _Control::OnBoundsChanging(const Rectangle& bounds)
849 _Control::OnBoundsChanging(const FloatRectangle& bounds)
855 _Control::OnBoundsChanged(void)
861 _Control::OnEvaluateSize(Dimension& evaluatedSize)
867 _Control::OnEvaluateSize(FloatDimension& evaluatedSize)
873 _Control::OnParentBoundsChanged(const _Control& parent)
878 _Control::OnChildAttached(const _Control& child)
883 _Control::OnChildDetaching(const _Control& child)
888 _Control::OnChildDetached(const _Control& child)
893 _Control::OnChildBoundsChanged(const _Control& child)
898 _Control::OnChildVisibleStateChanged(const _Control& child)
903 _Control::OnChangeLayout(_ControlOrientation orientation)
908 _Control::OnChangeLayout(_ControlRotation rotation)
913 _Control::OnZOrderChanging(_ControlZOrderUpdate zOrderUpdate)
918 _Control::OnVisibleStateChanging(void)
923 _Control::OnVisibleStateChanged(void)
928 _Control::OnAncestorVisibleStateChanged(const _Control& control)
930 _TouchManager* pTouchManager = _TouchManager::GetInstance();
931 if (pTouchManager && IsVisible() == false && IsAttachedToMainTree() == true)
933 if(pTouchManager->GetTouchControlSource() == this)
935 SysLog(NID_UI, "VisibleState changed false, Call SetTouchCanceled");
936 pTouchManager->SetTouchCanceled(null);
938 _UiEventManager* pUiEventManager = _UiEventManager::GetInstance();
941 pUiEventManager->ClearEventQueue();
948 _Control::OnAncestorEnableStateChanged(const _Control& control)
953 _Control::OnAncestorInputEnableStateChanged(const _Control& control)
958 _Control::OnTouchPressHandled(const _Control& control)
963 _Control::OnTouchReleaseHandled(const _Control& control)
968 _Control::OnTouchMoveHandled(const _Control& control)
973 _Control::OnFontChanged(Tizen::Graphics::Font* pFont)
975 SetUpdateLayoutState(true);
979 _Control::OnFontInfoRequested(unsigned long& style, int& size)
984 _Control::OnFontInfoRequested(unsigned long& style, float& size)
989 _Control::OnBackgroundColorChanged(Color& backgroundColor)
994 _Control::OnFocusableStateChanged(bool focusalbeState)
999 _Control::OnFocusModeStateChanged(void)
1004 _Control::OnTouchCancelHandled(const _Control& control)
1009 _Control::Accept(Visitor& visitor)
1013 VisitType visitType = visitor.Visit(*this);
1020 case VISIT_DOWNWARD:
1021 for (int i = 0; i < GetChildCount(); ++i) // [Postpone] Keep handle list before iternation.
1023 _Control* pChild = GetChild(i);
1026 pChild->Accept(visitor);
1033 _Control* pParent = GetParent();
1036 pParent->Accept(visitor);
1047 _Control::Accept(Visitor& visitor) const
1049 const_cast <_Control*>(this)->Accept(visitor);
1053 _Control::InvalidateHierarchyRootWindow(_Control& control)
1055 control.__needRecalcRootWindow = true;
1056 control.__pRootWindow = null;
1058 for (int i = 0; i < control.GetChildCount(); ++i)
1060 _Control* pChild = control.GetChild(i);
1063 pChild->InvalidateHierarchyRootWindow(*pChild);
1069 _Control::InvalidateHierarchyAbsoluteBounds(_Control& control)
1071 control.__needRecalcAbsBounds = true;
1072 control.__needRecalcAbsBoundsF = true;
1074 for (int i = 0; i < control.GetChildCount(); ++i)
1076 _Control* pChild = control.GetChild(i);
1079 pChild->InvalidateHierarchyAbsoluteBounds(*pChild);
1085 _Control::Draw(bool recursive)
1089 Invalidate(recursive);
1090 GetVisualElement()->Draw();
1094 _Control::Show(void)
1096 GetVisualElement()->Flush();
1099 SysAssert(GetLastResult() == E_SUCCESS);
1103 _Control::ChangeLayout(_Control& control, _ControlOrientation orientation)
1105 if (control.__orientation != orientation)
1107 control.__orientation = orientation;
1108 control.GetControlDelegate().OnChangeLayout(orientation);
1111 for (int i = 0; i < control.GetChildCount(); ++i)
1113 _Control* pChild = control.GetChild(i);
1116 ChangeLayout(*pChild, orientation);
1122 _Control::ChangeLayout(_ControlOrientation orientation, bool callRotation)
1125 ChangeLayout(*this, orientation);
1127 if (callRotation == true)
1129 _ControlManager* pMgr = _ControlManager::GetInstance();
1132 _ControlRotation rotation = pMgr->GetOrientationStatus();
1133 ChangeLayout(rotation);
1139 _Control::ChangeLayout(_Control& control, _ControlRotation rotation)
1141 if (control.__rotation != rotation)
1143 control.__rotation = rotation;
1144 control.GetControlDelegate().OnChangeLayout(rotation);
1148 for (int i = 0; i < control.GetChildCount(); ++i)
1150 _Control* pChild = control.GetChild(i);
1153 ChangeLayout(*pChild, rotation);
1159 _Control::ChangeLayout(_ControlRotation rotation)
1162 ChangeLayout(*this, rotation);
1166 _Control::IsLayoutChangable(void) const
1172 _Control::IsOrientationRoot(void) const
1178 _Control::Invalidate(void)
1181 GetVisualElement()->InvalidateRectangle(null);
1185 _Control::Invalidate(bool recursive)
1190 _Layout::Layout* pLayout = GetLayout();
1193 pLayout->UpdateLayout();
1196 if (recursive == false)
1207 _Control::Invalidate(_Control& control)
1209 if (control.GetVisibleState() == false)
1214 control.Invalidate();
1217 int owneeCount = control.GetOwneeCount();
1218 for (int i = 0; i < owneeCount; ++i)
1220 _Window* pOwnee = control.GetOwnee(i);
1223 pOwnee->Invalidate(true);
1227 for (int i = 0; i < control.GetChildCount(); ++i)
1229 _Control* pChild = control.GetChild(i);
1232 pChild->Invalidate(*pChild);
1238 _Control::Invalidate(const Rectangle& rect)
1241 FloatRectangle rectf(rect.x, rect.y, rect.width, rect.height);
1242 GetVisualElement()->InvalidateRectangle(&rectf);
1244 __invalidatedBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
1248 _Control::Invalidate(const FloatRectangle& rect)
1251 FloatRectangle rectf(rect.x, rect.y, rect.width, rect.height);
1252 GetVisualElement()->InvalidateRectangle(&rectf);
1254 __invalidatedBounds = rect;
1258 _Control::Contains(const Point& point) const
1262 Rectangle bounds = GetBounds();
1263 bounds.x = bounds.y = 0;
1264 return bounds.Contains(point);
1268 _Control::Contains(const FloatPoint& point) const
1272 FloatRectangle bounds = GetBoundsF();
1273 bounds.x = bounds.y = 0;
1274 return bounds.Contains(point);
1279 _Control::PartialUpdateLayout(void)
1283 _Layout::Layout* pLayout = GetLayout();
1286 pLayout->PartialUpdateLayout();
1291 _Control::UpdateLayout(void)
1295 _Layout::Layout* pLayout = GetLayout();
1298 pLayout->UpdateLayout();
1303 _Control::SetChildAlwaysOnTop(_Control& child)
1307 SysTryReturn(NID_UI,
1308 child.GetParent() == this, E_INVALID_ARG,
1309 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1311 SysTryReturn(NID_UI,
1312 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1313 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1315 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_TOP)
1320 child.SetLayer(_CONTROL_LAYER_CLIENT_TOP);
1326 _Control::SetChildAlwaysAtBottom(_Control& child)
1330 SysTryReturn(NID_UI,
1331 child.GetParent() == this, E_INVALID_ARG,
1332 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1334 SysTryReturn(NID_UI,
1335 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1336 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1338 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_BOTTOM)
1343 child.SetLayer(_CONTROL_LAYER_CLIENT_BOTTOM);
1349 _Control::ResetChildLayer(_Control& child)
1353 SysTryReturn(NID_UI,
1354 child.GetParent() == this, E_INVALID_ARG,
1355 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1357 SysTryReturn(NID_UI,
1358 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1359 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1361 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_MIDDLE)
1366 child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE);
1373 _Control::AttachSystemChild(_Control& child)
1376 result r = E_SUCCESS;
1378 r = StartAttaching(child, _CONTROL_AREA_SYSTEM);
1384 ControlList& children = GetChildList();
1385 r = children.Add(&child);
1386 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1388 r = GetVisualElement()->AttachChild(*child.GetVisualElement());
1389 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1391 r = EndAttaching(child);
1392 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r));
1394 SysAssert(GetLastResult() == E_SUCCESS);
1400 _Control::DetachSystemChild(_Control& child)
1402 return DetachChild(child);
1406 _Control::HasParent(void) const
1408 return __pParent != null;
1412 _Control::GetArea(void) const
1419 _Control::GetLayer(void) const
1426 _Control::SetLayer(_ControlLayer layer)
1429 _VisualElementImpl* pImpl = _VisualElementImpl::GetInstance(*GetVisualElement());
1431 result r = pImpl->SetZOrderGroup(GetZOrderGroupOfVisualElement(layer));
1434 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1437 const _Control::ControlList&
1438 _Control::GetChildList() const
1440 return const_cast <_Control*>(this)->GetChildList();
1443 _Control::ControlList&
1444 _Control::GetChildList()
1446 return *__pChildren;
1450 _Control::IsCalledCallAttachingToMainTree(void) const
1452 return __isCalledCallOnAttachingToMainTree;
1456 _Control::SetCalledCallAttachingToMainTree(bool isAttaching)
1458 __isCalledCallOnAttachingToMainTree = isAttaching;
1462 _Control::IsCalledCallPreAttachedToMainTree(void) const
1464 return __isCalledCallOnPreAttachedToMainTree;
1468 _Control::IsCalledCallAttachedToMainTree(void) const
1470 return __isCalledCallOnAttachedToMainTree;
1474 _Control::SetCalledCallPreAttachedToMainTree(bool isAttached)
1476 __isCalledCallOnPreAttachedToMainTree = isAttached;
1480 _Control::SetCalledCallAttachedToMainTree(bool isAttached)
1482 __isCalledCallOnAttachedToMainTree = isAttached;
1486 _Control::CallOnAttachingToMainTree(_Control& control)
1488 result r = E_SUCCESS;
1490 ControlList& children = control.GetChildList();
1491 _Control* pChild = null;
1493 int childrenCount = children.GetCount();
1495 for (int index = 0; index < childrenCount; index++)
1497 r = children.GetAt(index, pChild);
1500 SysAssert(r == E_OUT_OF_RANGE);
1501 SysTryReturn(NID_UI,
1502 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1503 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1505 if (!pChild->IsCalledCallAttachingToMainTree())
1507 r = CallOnAttachingToMainTree(*pChild);
1508 pChild->SetCalledCallAttachingToMainTree(true);
1509 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1513 if (!control.IsCalledCallAttachingToMainTree())
1515 r = control.GetControlDelegate().OnAttachingToMainTree(this);
1516 control.SetCalledCallAttachingToMainTree(true);
1517 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1524 _Control::CallOnPreAttachedToMainTree(_Control& control)
1526 result r = E_SUCCESS;
1528 ControlList& children = control.GetChildList();
1529 _Control* pChild = null;
1531 int childrenCount = children.GetCount();
1533 for (int index = 0; index < childrenCount; index++)
1535 r = children.GetAt(index, pChild);
1538 SysAssert(r == E_OUT_OF_RANGE);
1539 SysTryReturn(NID_UI,
1540 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1541 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1544 if (!pChild->IsCalledCallPreAttachedToMainTree())
1546 r = CallOnPreAttachedToMainTree(*pChild);
1547 pChild->SetCalledCallPreAttachedToMainTree(true);
1551 if (!control.IsCalledCallPreAttachedToMainTree())
1553 r = control.GetControlDelegate().OnPreAttachedToMainTree();
1554 control.SetCalledCallPreAttachedToMainTree(true);
1561 _Control::CallOnAttachedToMainTree(_Control& control)
1563 result r = E_SUCCESS;
1565 ControlList& children = control.GetChildList();
1566 _Control* pChild = null;
1568 int childrenCount = children.GetCount();
1570 for (int index = 0; index < childrenCount; index++)
1572 r = children.GetAt(index, pChild);
1575 SysAssert(r == E_OUT_OF_RANGE);
1576 SysTryReturn(NID_UI,
1577 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1578 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1581 if (!pChild->IsCalledCallAttachedToMainTree())
1583 r = CallOnAttachedToMainTree(*pChild);
1584 pChild->SetCalledCallAttachedToMainTree(true);
1588 if (!control.IsCalledCallAttachedToMainTree())
1590 r = control.GetControlDelegate().OnAttachedToMainTree();
1591 control.SetCalledCallAttachedToMainTree(true);
1598 _Control::CallOnDetachingFromMainTree(_Control& control)
1600 result r = E_SUCCESS;
1602 ControlList& children = control.GetChildList();
1603 _Control* pChild = null;
1605 _Window* pTop = control.GetRootWindow();
1608 _Control* pControl = pTop->GetFocusControl(this);
1609 if ((&control) == pControl)
1611 pTop->SetFocusControl(&control, false);
1613 _Control* pFocusTraversalControl = pTop->GetFocusTraversalControl(this);
1614 if ((&control) == pFocusTraversalControl)
1616 pTop->SetFocusTraversalControl(&control, false);
1620 if (!__isPostOrderTraversal)
1622 r = control.GetControlDelegate().OnDetachingFromMainTree();
1623 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1626 int childrenCount = children.GetCount();
1628 for (int index = 0; index < childrenCount; index++)
1630 r = children.GetAt(index, pChild);
1633 SysAssert(r == E_OUT_OF_RANGE);
1634 SysTryReturn(NID_UI,
1635 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1636 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1638 r = CallOnDetachingFromMainTree(*pChild);
1639 pChild->SetCalledCallAttachingToMainTree(false);
1640 pChild->SetCalledCallPreAttachedToMainTree(false);
1641 pChild->SetCalledCallAttachedToMainTree(false);
1642 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1645 if (__isPostOrderTraversal)
1647 r = control.GetControlDelegate().OnDetachingFromMainTree();
1648 control.SetCalledCallAttachingToMainTree(false);
1649 control.SetCalledCallPreAttachedToMainTree(false);
1650 control.SetCalledCallAttachedToMainTree(false);
1651 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1658 _Control::CallOnAncestorVisibleStateChanged(_Control& control)
1660 control.GetControlDelegate().OnAncestorVisibleStateChanged(*this);
1662 for (int i = 0; i < control.GetChildCount(); ++i)
1664 _Control* pChild = control.GetChild(i);
1667 CallOnAncestorVisibleStateChanged(*pChild);
1673 _Control::CallOnAncestorEnableStateChanged(_Control& control)
1675 control.GetControlDelegate().OnAncestorEnableStateChanged(*this);
1677 for (int i = 0; i < control.GetChildCount(); ++i)
1679 _Control* pChild = control.GetChild(i);
1682 CallOnAncestorEnableStateChanged(*pChild);
1688 _Control::CallOnAncestorInputEnableStateChanged(_Control& control)
1690 control.GetControlDelegate().OnAncestorInputEnableStateChanged(*this);
1692 for (int i = 0; i < control.GetChildCount(); ++i)
1694 _Control* pChild = control.GetChild(i);
1697 CallOnAncestorInputEnableStateChanged(*pChild);
1704 // [ToDo] Rollback is difficult.
1706 _Control::StartAttaching(_Control& child, _ControlArea area)
1708 result r = E_SUCCESS;
1710 _Control* pOldParent = child.GetParent();
1712 SysTryReturn(NID_UI,
1713 (pOldParent != this), E_INVALID_ARG,
1714 E_INVALID_ARG, "[E_INVALID_ARG] The child control is already attached to this container.");
1716 SysTryReturn(NID_UI,
1717 pOldParent == null, E_INVALID_ARG,
1718 E_INVALID_ARG, "[E_INVALID_ARG] Unable to add the child which already has another parent.");
1720 r = child.GetControlDelegate().OnAttaching(this);
1721 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1723 if (IsAttachedToMainTree())
1725 r = CallOnAttachingToMainTree(child);
1726 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1729 // [ToDo] Add control to layout
1730 // What should we do about non-layoutable controls?
1731 if (area == _CONTROL_AREA_CLIENT)
1733 _ControlManager* pMgr = _ControlManager::GetInstance();
1734 r = GetLastResult();
1735 SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r));
1737 r = __pLayoutContainer->AddItem(child.GetLayoutContainer());
1740 child.GetControlDelegate().OnAttachingFailed(*this);
1741 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Failed to apply layout.");
1746 if (IsAttachedToMainTree())
1748 if (!(IsOrientationRoot() && child.IsOrientationRoot()))
1750 child.ChangeLayout(_ControlManager::GetInstance()->GetOrientation());
1754 child.__area = area;
1756 if (area == _CONTROL_AREA_CLIENT)
1758 if (child.GetLayer() != _CONTROL_LAYER_CLIENT_TOP && child.GetLayer() != _CONTROL_LAYER_CLIENT_BOTTOM)
1760 child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE);
1765 child.SetLayer(_CONTROL_LAYER_SYSTEM);
1768 SysAssert(GetLastResult() == E_SUCCESS);
1773 _Control::EndAttaching(_Control& child)
1775 child.SetParent(this);
1776 InvalidateHierarchyRootWindow(child);
1777 InvalidateHierarchyAbsoluteBounds(child);
1779 FloatRectangle floatBounds(child.GetBoundsF().x, child.GetBoundsF().y, child.GetBoundsF().width, child.GetBoundsF().height);
1781 result r = E_SUCCESS;
1782 if (child.IsLayoutChangable() == false)
1784 r = child.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, floatBounds.width, floatBounds.height));
1788 r = child.UpdateBoundsOfVisualElement(floatBounds);
1790 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1792 r = child.GetControlDelegate().OnAttached();
1793 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1795 if (IsAttachedToMainTree())
1797 r = CallOnPreAttachedToMainTree(child);
1798 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1800 r = CallOnAttachedToMainTree(child);
1801 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1806 GetControlDelegate().OnChildAttached(child);
1816 _Control::AttachChild(_Control& child)
1819 result r = E_SUCCESS;
1821 SysTryReturn(NID_UI,
1822 IsChildAttachable(child), E_INVALID_ARG,
1823 E_INVALID_ARG, "[E_INVALID_ARG] %ls cannot be a child of %ls.",
1824 child.GetName().GetPointer(), GetName().GetPointer());
1826 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1832 ControlList& children = GetChildList();
1833 r = children.Add(&child);
1834 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1836 r = GetVisualElement()->AttachChild(*child.GetVisualElement());
1838 r = EndAttaching(child);
1839 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r));
1841 SysAssert(GetLastResult() == E_SUCCESS);
1847 _Control::UpdateFocusList(void)
1849 _Window* pTop = GetRootWindow();
1852 pTop->ResetFocusList();
1857 _Control::RemoveFocusRing(bool needToDelete)
1859 if (__pFocusVisualElement)
1863 __pFocusVisualElement.reset();
1867 __pFocusVisualElement->SetShowState(false);
1873 _Control::HasFocusRing(void)
1875 if (__pFocusVisualElement)
1884 _Control::SetFocusNavigateEnabled(bool enable)
1886 __isNavigatable = enable;
1890 _Control::IsFocusNavigateEnabled(void) const
1892 return __isNavigatable;
1896 _Control::IsFocusModeStateEnabled(void) const
1898 return _FocusManagerImpl::GetInstance()->IsFocusModeStateEnabled();
1905 _Control::InsertChildToBottom(_Control& child)
1908 result r = E_SUCCESS;
1910 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1916 ControlList& children = GetChildList();
1917 r = children.InsertAt(&child, 0);
1918 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1920 GetVisualElement()->InsertChild(*child.GetVisualElement(), null, false);
1921 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1923 r = EndAttaching(child);
1924 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r));
1926 SysAssert(GetLastResult() == E_SUCCESS);
1935 _Control::InsertChildAfter(const _Control& targetChild, _Control& child)
1938 result r = E_SUCCESS;
1940 SysTryReturn(NID_UI,
1941 targetChild.GetParent() == this, E_INVALID_ARG,
1942 E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child.");
1944 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1950 int targetIndex = GetChildIndex(targetChild);
1951 SysAssert(targetIndex != -1);
1953 ControlList& children = GetChildList();
1954 r = children.InsertAt(&child, targetIndex + 1);
1955 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1957 GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), true);
1958 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1960 r = EndAttaching(child);
1961 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r));
1963 SysAssert(GetLastResult() == E_SUCCESS);
1972 _Control::InsertChildBefore(const _Control& targetChild, _Control& child)
1975 result r = E_SUCCESS;
1977 SysTryReturn(NID_UI,
1978 targetChild.GetParent() == this, E_INVALID_ARG,
1979 E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child.");
1981 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1987 int targetIndex = GetChildIndex(targetChild);
1988 SysAssert(targetIndex != -1);
1990 ControlList& children = GetChildList();
1991 r = children.InsertAt(&child, targetIndex);
1992 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1994 GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), false);
1995 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1997 r = EndAttaching(child);
1998 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] propagated.", GetErrorMessage(r));
2000 SysAssert(GetLastResult() == E_SUCCESS);
2007 _Control::DetachChild(_Control& child)
2010 result r = E_SUCCESS;
2012 if (child.GetParent() != this)
2014 SetLastResult(E_INVALID_ARG);
2015 return E_INVALID_ARG;
2018 if (IsAttachedToMainTree())
2020 r = CallOnDetachingFromMainTree(child);
2021 SysTryReturn(NID_UI,
2022 r == E_SUCCESS, E_SYSTEM,
2023 E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent.");
2025 SysTryReturn(NID_UI,
2026 child.GetControlDelegate().OnDetaching() == E_SUCCESS, E_SYSTEM,
2027 E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent.");
2030 GetControlDelegate().OnChildDetaching(child);
2033 r = GetVisualElement()->DetachChild(*child.GetVisualElement());
2034 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2036 ControlList& children = GetChildList();
2037 r = children.Remove(&child);
2038 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2040 // Remove control to layout
2041 if (child.__area == _CONTROL_AREA_CLIENT)
2043 _ControlManager* pMgr = _ControlManager::GetInstance();
2044 r = GetLastResult();
2045 SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r));
2047 r = __pLayoutContainer->RemoveItem(child.GetLayoutContainer());
2048 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2051 child.SetParent(null);
2052 child.__area = _CONTROL_AREA_NONE;
2053 child.__layer = _CONTROL_LAYER_NONE;
2055 GetControlDelegate().OnChildDetached(child);
2058 SysAssert(GetLastResult() == E_SUCCESS);
2060 InvalidateHierarchyRootWindow(child);
2067 _Control::DetachAllChildren(bool detachSystemChild, bool recursive)
2070 result r = E_SUCCESS;
2072 int childCount = GetChildCount();
2077 while (childCount--)
2079 _Control* pChild = GetChild(itemIndex);
2085 if (!detachSystemChild && (pChild->GetArea() == _CONTROL_AREA_SYSTEM))
2091 int childCount = pChild->GetChildCount();
2092 if (childCount == 0)
2094 r = DetachChild(*pChild);
2097 SysLog(NID_UI, "child is not detached from this container.");
2102 r = DetachChild(*pChild);
2105 SysLog(NID_UI, "child is not detached from this container.");
2107 pChild->DetachAllChildren(detachSystemChild, true);
2113 int notDetachedChildCount = 0;
2114 while (childCount--)
2116 _Control* pChild = GetChild(itemIndex);
2122 if (!detachSystemChild && (pChild->GetArea() == _CONTROL_AREA_SYSTEM))
2127 r = DetachChild(*pChild);
2131 ++notDetachedChildCount;
2135 if (notDetachedChildCount > 0)
2137 SysLog(NID_UI, "%d children are not detached from this container.", notDetachedChildCount);
2146 _Control::MoveChildToTop(const _Control& child)
2149 result r = E_SUCCESS;
2151 SysTryReturn(NID_UI,
2152 child.GetParent() == this, E_INVALID_ARG,
2153 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2155 // If already on top,
2156 ControlList& children = GetChildList();
2157 if (GetChildIndex(child) == children.GetCount() - 1)
2159 SysAssert(GetLastResult() == E_SUCCESS);
2163 _Control* pChild = const_cast <_Control*>(&child);
2165 r = children.Remove(pChild);
2166 SysAssert(r == E_SUCCESS);
2168 r = children.Add(pChild);
2169 SysAssert(r == E_SUCCESS);
2171 r = child.GetVisualElement()->SetZOrder(null, true);
2172 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2174 SysAssert(GetLastResult() == E_SUCCESS);
2180 _Control::MoveChildToBottom(const _Control& child)
2183 result r = E_SUCCESS;
2185 SysTryReturn(NID_UI,
2186 child.GetParent() == this, E_INVALID_ARG,
2187 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2189 ControlList& children = GetChildList();
2191 if (GetChildIndex(child) == 0)
2193 SysAssert(GetLastResult() == E_SUCCESS);
2197 _Control* pChild = const_cast <_Control*>(&child);
2199 r = children.Remove(pChild);
2200 SysAssert(r == E_SUCCESS);
2202 r = children.InsertAt(pChild, 0);
2203 SysAssert(r == E_SUCCESS);
2205 r = child.GetVisualElement()->SetZOrder(null, false);
2206 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2208 SysAssert(GetLastResult() == E_SUCCESS);
2214 _Control::MoveChildAfter(const _Control& targetChild, const _Control& child)
2217 result r = E_SUCCESS;
2219 SysTryReturn(NID_UI,
2220 targetChild.GetParent() == this, E_INVALID_ARG,
2221 E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child.");
2223 SysTryReturn(NID_UI,
2224 child.GetParent() == this, E_INVALID_ARG,
2225 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2227 SysTryReturn(NID_UI,
2228 &targetChild != &child, E_INVALID_ARG,
2229 E_INVALID_ARG, "[E_INVALID_ARG] Cannot move after self.");
2231 ControlList& children = GetChildList();
2233 int targetIndex = GetChildIndex(targetChild);
2234 SysAssert(targetIndex != -1);
2236 if (targetIndex + 1 == GetChildIndex(child))
2238 SysAssert(GetLastResult() == E_SUCCESS);
2242 _Control* pChild = const_cast <_Control*>(&child);
2244 r = children.Remove(pChild);
2245 SysAssert(r == E_SUCCESS);
2247 r = children.InsertAt(pChild, targetIndex + 1);
2248 SysAssert(r == E_SUCCESS);
2250 r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), true);
2251 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2253 SysAssert(GetLastResult() == E_SUCCESS);
2259 _Control::MoveChildBefore(const _Control& targetChild, const _Control& child)
2262 result r = E_SUCCESS;
2264 SysTryReturn(NID_UI,
2265 targetChild.GetParent() == this, E_INVALID_ARG,
2266 E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child.");
2268 SysTryReturn(NID_UI,
2269 child.GetParent() == this, E_INVALID_ARG,
2270 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2272 SysTryReturn(NID_UI,
2273 &targetChild != &child, E_INVALID_ARG,
2274 E_INVALID_ARG, "[E_INVALID_ARG] Cannot move before self.");
2276 ControlList& children = GetChildList();
2278 int targetIndex = GetChildIndex(targetChild);
2279 SysAssert(targetIndex != -1);
2281 if (targetIndex - 1 == GetChildIndex(child))
2283 SysAssert(GetLastResult() == E_SUCCESS);
2287 _Control* pChild = const_cast <_Control*>(&child);
2289 r = children.Remove(pChild);
2290 SysAssert(r == E_SUCCESS);
2292 r = children.InsertAt(pChild, targetIndex);
2293 SysAssert(r == E_SUCCESS);
2295 r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), false);
2296 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2298 SysAssert(GetLastResult() == E_SUCCESS);
2305 _Control::GetChildIndex(const _Control& child) const
2308 result r = E_SUCCESS;
2310 SysTryReturn(NID_UI,
2311 child.GetParent() == this, -1,
2312 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2314 const ControlList& children = GetChildList();
2317 r = children.IndexOf(const_cast<_Control*>(&child), index);
2320 SysAssert(r == E_OBJ_NOT_FOUND);
2321 SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Unable to find the specified child.");
2325 SysAssert(GetLastResult() == E_SUCCESS);
2331 _Control::GetChild(int index) const
2334 result r = E_SUCCESS;
2336 const ControlList& children = GetChildList();
2338 _Control* pChild = null;
2339 r = children.GetAt(index, pChild);
2342 SysAssert(r == E_OUT_OF_RANGE);
2343 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
2347 SysAssert(GetLastResult() == E_SUCCESS);
2352 _Control::GetChildCount(void) const
2355 return GetChildList().GetCount();
2359 _Control::GetHandle(void) const
2361 return __controlHandle;
2365 _Control::GetUserData(void) const
2371 _Control::SetUserData(void* pUserData)
2373 __pUserData = pUserData;
2377 _Control::GetPropertyName(void) const
2380 return Tizen::Ui::Variant(__name);
2384 _Control::GetName(void) const
2386 Variant name = GetProperty("Name");
2388 return name.ToString();
2392 _Control::SetPropertyName(const Variant& name)
2395 __name = name.ToString();
2401 _Control::SetName(const String& name)
2403 SetProperty("Name", Variant(name));
2407 _Control::GetParent(void) const
2413 _Control::GetCanvasN(void) const
2415 return GetCanvasN(FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height));
2419 _Control::GetCanvasN(const Rectangle& bounds) const
2422 Canvas *pCanvas = GetControlDelegate().OnCanvasRequestedN(FloatRectangle(bounds.x, bounds.y, bounds.width, bounds.height));
2423 if (pCanvas == null)
2425 GetVisualElement()->SetFlushNeeded();
2426 pCanvas = GetVisualElement()->GetCanvasN(bounds);
2427 if (IsFailed(GetLastResult()))
2429 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
2432 if (pCanvas && !__isCalledGetCanvasN)
2434 pCanvas->SetBackgroundColor(GetBackgroundColor());
2436 const_cast <_Control*>(this)->__isCalledGetCanvasN = true;
2443 _Control::GetCanvasN(const FloatRectangle& bounds) const
2446 Canvas *pCanvas = GetControlDelegate().OnCanvasRequestedN(FloatRectangle(bounds));
2447 if (pCanvas == null)
2449 GetVisualElement()->SetFlushNeeded();
2450 pCanvas = GetVisualElement()->GetCanvasN(bounds);
2451 if (IsFailed(GetLastResult()))
2453 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
2456 if (pCanvas && !__isCalledGetCanvasN)
2458 pCanvas->SetBackgroundColor(GetBackgroundColor());
2460 const_cast <_Control*>(this)->__isCalledGetCanvasN = true;
2467 _Control::IsCalledGetCanvasN(void) const
2469 return __isCalledGetCanvasN;
2473 _Control::GetClientCanvasN(void) const
2475 return GetCanvasN(GetClientBounds());
2479 _Control::IsAncestorOf(const _Control& control) const
2482 return IsAncestorOf(control, *this);
2486 _Control::IsAncestorOf(const _Control& control, const _Control& ancestor) const
2488 const _Control* pParent = control.GetParent();
2491 if (pParent == &ancestor)
2495 return IsAncestorOf(*pParent, ancestor);
2502 _Control::GetRootWindow(void) const
2506 if (!__needRecalcRootWindow && __pRootWindow != this)
2508 return __pRootWindow;
2511 _Window* pRoot = null;
2512 _Control* pControl = const_cast<_Control*>(this);
2516 pRoot = dynamic_cast <_Window*>(pControl);
2521 pControl = pControl->GetParent();
2524 const_cast<_Control*>(this)->__pRootWindow = pRoot;
2525 const_cast<_Control*>(this)->__needRecalcRootWindow = false;
2531 _Control::IsAttachedToMainTree(void) const
2535 _ControlManager* pMgr = _ControlManager::GetInstance();
2541 _Window* pRootWindow = GetRootWindow();
2542 if (pRootWindow == null)
2547 return pRootWindow->IsAttached();
2551 _Control::IsFocusable(void) const
2558 _Control::SetFocusable(bool focusable)
2561 bool oldState = __focusable;
2562 __focusable = focusable;
2563 if (oldState != __focusable)
2565 GetControlDelegate().OnFocusableStateChanged(focusable);
2570 _Control::IsNativeObjectFocusable(void) const
2573 return __nativeObjectFocusable;
2577 _Control::SetNativeObjectFocusable(bool focusable)
2580 __nativeObjectFocusable = focusable;
2584 _Control::IsFocused(void) const
2588 _Window* pTop = GetRootWindow();
2594 if (this == pTop->GetFocusControl(const_cast<_Control*>(this)))
2603 _Control::SetFocusWindowActivationChecked(bool isChecked)
2605 __isFocusWindowActivationChecked = isChecked;
2609 _Control::IsFocusWindowActivationChecked(void) const
2611 return __isFocusWindowActivationChecked;
2615 _Control::SetFocused(bool on)
2619 SysTryReturn(NID_UI,
2620 IsAttachedToMainTree(), E_INVALID_OPERATION,
2621 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control should have a parent or be attached to the main tree.");
2623 SysTryReturn(NID_UI,
2624 IsFocusable(), E_INVALID_OPERATION,
2625 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This Control isn't focusable control.");
2627 _Window* pTop = GetRootWindow();
2631 pTop->SetFocusControl(this, true);
2635 pTop->SetFocusControl(this, false);
2638 bool isFocusControlListControl = _FocusManagerImpl::GetInstance()->IsFocusControlListControl(this);
2639 if (isFocusControlListControl)
2641 pTop->SetFocusTraversalControl(this, true);
2647 _Control::SetFont(const String& fontName)
2649 result r = E_SUCCESS;
2651 if (__fontName.Equals(fontName))
2656 __isControlFontChanged = true;
2657 __fontName = fontName;
2658 __fontFileName.Clear();
2660 Font* pFont = GetFallbackFont();
2664 r = GetLastResult();
2665 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2671 _Control::GetFallbackFont(void)
2673 unsigned long style = 0;
2675 float floatTextSize = 0.0f;
2676 result r = E_SUCCESS;
2677 _IControlDelegate& delegate = GetControlDelegate();
2678 delegate.OnFontInfoRequested(style, textSize);
2679 delegate.OnFontInfoRequested(style, floatTextSize);
2680 _ControlManager* pControlManager = _ControlManager::GetInstance();
2681 _FontImpl* pFontImpl = _FontImpl::GetInstance(*__pFont);
2682 if (!(__isControlFontChanged || pControlManager->IsDefaultFontChanged() || pControlManager->IsSystemFontChanged())
2684 && ((__pFont->GetSize() == textSize || __pFont->GetSizeF() == floatTextSize))
2685 && (pFontImpl->GetStyle() == static_cast<int>(style)))
2689 unique_ptr<Font>pTempFont(new(std::nothrow)Font());
2690 SysTryReturn(NID_UI , pTempFont , null , E_OUT_OF_MEMORY, "[%s] Fails to create a __pFont.", GetErrorMessage(r));
2692 if (!__fontName.IsEmpty())
2694 __isControlFontChanged = false;
2695 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2696 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2698 if (floatTextSize > 0.0f)
2700 r = pFontImpl->Construct(__fontName, style, floatTextSize, false);
2704 r = pFontImpl->Construct(__fontName, style, textSize, false);
2707 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2708 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2710 else if (!__fontFileName.IsEmpty())
2712 __isControlFontChanged = false;
2713 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2714 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2716 if (floatTextSize > 0.0f)
2718 r = pFontImpl->Construct(__fontFileName, style, floatTextSize);
2722 r = pFontImpl->Construct(__fontFileName, style, textSize);
2724 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2725 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2728 else if (!pControlManager->GetDefaultFont().IsEmpty())
2730 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2731 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2733 if (floatTextSize > 0.0f)
2735 r = pFontImpl->Construct(pControlManager->GetDefaultFont(), style, floatTextSize, false);
2739 r = pFontImpl->Construct(pControlManager->GetDefaultFont(), style, textSize, false);
2741 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2742 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2744 else if (!pControlManager->GetDefaultFontFile().IsEmpty())
2746 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2747 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2749 if (floatTextSize > 0.0f)
2751 r = pFontImpl->Construct(pControlManager->GetDefaultFontFile(), style, floatTextSize);
2755 r = pFontImpl->Construct(pControlManager->GetDefaultFontFile(), style, textSize);
2757 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2758 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2762 if (floatTextSize > 0.0f)
2764 r = pTempFont->Construct(style, floatTextSize);
2768 r = pTempFont->Construct(style, textSize);
2770 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2771 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2779 __pFont = pTempFont.release();
2780 delegate.OnFontChanged(__pFont);
2785 _Control::GetFont(void) const
2791 _Control::IsEnabled(void) const
2795 bool enabled = true;
2796 const _Control* pControl = this;
2800 if (!pControl->GetEnableState())
2805 pControl = pControl->GetParent();
2812 _Control::GetEnableState(void) const
2815 return __enabledState;
2819 _Control::SetEnableState(bool enabledState)
2822 const bool changed = (__enabledState != enabledState);
2825 __enabledState = enabledState;
2826 CallOnAncestorEnableStateChanged(*this);
2828 __pAccessibilityContainer->SetEnableState(enabledState);
2832 _Control::IsInputEventEnabled(void) const
2836 bool inputEnabled = true;
2837 const _Control* pControl = this;
2841 if (!pControl->GetInputEnableState())
2843 inputEnabled = false;
2846 pControl = pControl->GetParent();
2849 return inputEnabled;
2853 _Control::GetInputEnableState(void) const
2857 if (__inputLockRefCount != 0)
2868 _Control::LockInputEvent(void)
2870 __inputLockRefCount++;
2871 CallOnAncestorInputEnableStateChanged(*this);
2875 _Control::UnlockInputEvent(void)
2877 __inputLockRefCount--;
2878 if (__inputLockRefCount < 0)
2880 __inputLockRefCount = 0;
2885 _Control::IsVisible(void) const
2889 if (IsAttachedToMainTree() == false)
2891 SetLastResult(E_SYSTEM);
2895 bool visible = true;
2896 const _Control* pControl = this;
2900 if (!pControl->GetVisibleState())
2905 pControl = pControl->GetParent();
2912 _Control::GetVisibleState(void) const
2915 return __visibleState;
2919 _Control::SetVisibleState(bool visibleState)
2923 const bool changed = (__visibleState != visibleState) || !__initVisibleState;
2927 GetControlDelegate().OnVisibleStateChanging();
2930 __visibleState = visibleState;
2931 GetVisualElement()->SetShowState(visibleState);
2933 if (visibleState == false)
2935 int owneeCount = GetOwneeCount();
2936 for (int i = 0; i < owneeCount; ++i)
2938 _Window* pWindow = GetOwnee(i);
2941 pWindow->SetVisibleState(visibleState);
2948 GetControlDelegate().OnVisibleStateChanged();
2949 CallOnAncestorVisibleStateChanged(*this);
2950 _Control* pParent = GetParent();
2953 pParent->GetControlDelegate().OnChildVisibleStateChanged(*this);
2959 __initVisibleState = true;
2963 _Control::IsLayoutable(void) const
2970 _Control::IsClipToParent(void) const
2973 // SysAssert(GetVisualElement()->IsClipToParent() == __clipToParent);
2974 return __clipToParent;
2978 _Control::SetClipToParent(bool clipToParent)
2981 result r = E_SUCCESS;
2983 __clipToParent = clipToParent;
2984 r = GetVisualElement()->SetClipToParent(clipToParent);
2985 SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
2991 _Control::SetClipChildrenEnabled(bool clipChildren)
2994 //result r = E_SUCCESS;
2996 GetVisualElement()->SetClipChildrenEnabled(clipChildren);
2997 //SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
3003 _Control::GetBounds(void) const
3006 return _CoordinateSystemUtils::ConvertToInteger(__bounds);
3010 _Control::GetBoundsF(void) const
3017 _Control::GetPosition(void) const
3020 return Point(_CoordinateSystemUtils::ConvertToInteger(__bounds.x), _CoordinateSystemUtils::ConvertToInteger(__bounds.y));
3024 _Control::GetPositionF(void) const
3027 return FloatPoint(__bounds.x, __bounds.y);
3031 _Control::GetSize(void) const
3034 return Dimension(_CoordinateSystemUtils::ConvertToInteger(__bounds.width), _CoordinateSystemUtils::ConvertToInteger(__bounds.height));
3038 _Control::GetSizeF(void) const
3041 return FloatDimension(__bounds.width, __bounds.height);
3046 _Control::UpdateBoundsOfVisualElement(const FloatRectangle& controlBounds)
3048 FloatRectangle rect(controlBounds.x, controlBounds.y, controlBounds.width, controlBounds.height);
3050 _Control* pParent = GetParent();
3051 if (__area == _CONTROL_AREA_CLIENT && pParent)
3053 const FloatRectangle clientBounds = pParent->GetClientBoundsF();
3054 rect.x += clientBounds.x;
3055 rect.y += clientBounds.y;
3058 GetVisualElement()->SetBounds(rect);
3064 _Control::AdjustAbsoluteBounds(_Control& control, bool update)
3066 result r = E_SUCCESS;
3068 if (update && (&control != this))
3070 FloatRectangle fbounds = control.GetBoundsF();
3072 if (control.IsLayoutChangable() == false)
3074 r = control.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
3078 r = control.UpdateBoundsOfVisualElement(fbounds);
3082 for (int i = 0; i < control.GetChildCount(); ++i)
3084 _Control* pChild = control.GetChild(i);
3090 r = AdjustAbsoluteBounds(*pChild, false);
3094 r = AdjustAbsoluteBounds(*pChild);
3098 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
3107 _Control::IsInSizeRange(const Dimension& size) const
3109 return (__minSize.width <= size.width) && (size.width <= __maxSize.width) &&
3110 (__minSize.height <= size.height) && (size.height <= __maxSize.height);
3114 _Control::IsInSizeRange(const FloatDimension& size) const
3116 return (_FloatCompareLE(__minSize.width, size.width)) && (_FloatCompareLE(size.width, __maxSize.width)) &&
3117 (_FloatCompareLE(__minSize.height, size.height)) && (_FloatCompareLE(size.height, __maxSize.height));
3120 // Custom Exception: ex) Location::Map
3122 _Control::SetBoundsFinal(const FloatRectangle& newBounds, bool changeLayoutBaseRect, bool callBoundsChangeCallbacks)
3124 result r = E_SUCCESS;
3126 FloatRectangle bounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height);
3128 _IControlDelegate& delegate = GetControlDelegate();
3130 const bool moved = (__bounds.x != bounds.x) || (__bounds.y != bounds.y);
3131 const bool resized = (__bounds.width != bounds.width) || (__bounds.height != bounds.height);
3133 if ((moved || resized) && callBoundsChangeCallbacks)
3135 r = delegate.OnBoundsChanging(_CoordinateSystemUtils::ConvertToInteger(bounds));
3138 SysLogException(NID_UI, r, "[%s] Callback returns exception.", GetErrorMessage(r));
3139 return r; // Relay the result;
3141 r = delegate.OnBoundsChanging(bounds);
3144 SysLogException(NID_UI, r, "[%s] Callback returns exception.", GetErrorMessage(r));
3145 return r; // Relay the result;
3149 if (moved || resized)
3151 const FloatRectangle fbounds(bounds.x, bounds.y, bounds.width, bounds.height);
3152 if (IsLayoutChangable() == false)
3154 r = UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
3158 bool isAdjustPosition = false;
3160 _Window* pWindow = dynamic_cast<_Window*>(this);
3161 _Window* pRootWindow = null;
3164 _WindowType winType = pWindow->GetWindowType();
3165 if (winType == _WINDOW_TYPE_VE)
3167 _Control* pOwner = pWindow->GetOwner();
3170 pRootWindow = pOwner->GetRootWindow();
3173 if (pRootWindow->IsLayoutChangable() == false)
3175 isAdjustPosition = true;
3182 if (isAdjustPosition == true)
3184 FloatPoint ownerPosition = pRootWindow->GetPositionF();
3185 r = UpdateBoundsOfVisualElement(FloatRectangle(fbounds.x - ownerPosition.x, fbounds.y - ownerPosition.y, fbounds.width, fbounds.height));
3189 r = UpdateBoundsOfVisualElement(fbounds);
3194 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
3198 if (changeLayoutBaseRect)
3200 __pLayoutContainer->OnChangeBaseRect();
3203 if ((moved || resized) && callBoundsChangeCallbacks)
3205 if (IsMovable() && IsResizable())
3207 SetClientBounds(FloatRectangle(0.0f, 0.0f, GetSizeF().width, GetSizeF().height));
3209 if (__pFocusVisualElement)
3211 __pFocusVisualElement->SetBounds(FloatRectangle(0, 0, __bounds.width, __bounds.height));
3213 delegate.OnBoundsChanged();
3215 _Control* pParent = GetParent();
3218 pParent->GetControlDelegate().OnChildBoundsChanged(*this);
3221 ControlList& children = GetChildList();
3222 _Control* pChild = null;
3223 int childrenCount = children.GetCount();
3225 for (int index = 0; index < childrenCount; index++)
3227 r = children.GetAt(index, pChild);
3230 pChild->GetControlDelegate().OnParentBoundsChanged(*this);
3235 if (moved || resized)
3237 InvalidateHierarchyAbsoluteBounds(*this);
3244 // Custom Exception: ex) Location::Map
3246 _Control::AdjustSizeToRange(void)
3249 result r = E_SUCCESS;
3251 SysAssert(IsResizable());
3253 FloatDimension size = GetSizeF();
3254 bool changed = ::AdjustSizeToRange(size, __minSize, __maxSize);
3260 FloatRectangle newBounds(__bounds.x, __bounds.y, size.width, size.height);
3261 r = SetBoundsFinal(newBounds, true, true);
3270 // Custom Exception: ex) Location::Map
3273 _Control::SetBoundsInternal(const FloatRectangle& bounds, bool callBoundsChangeCallbacks)
3275 SysTryReturn(NID_UI,
3276 IsInSizeRange(FloatDimension(bounds.width, bounds.height)), E_INVALID_ARG,
3278 "[E_INVALID_ARG] The specified size(%f, %f) is out of range from min size(%f, %f) to max size(%f, %f).",
3279 bounds.width, bounds.height, __minSize.width, __minSize.height, __maxSize.width, __maxSize.height);
3281 SetUpdateLayoutState(true);
3283 return SetBoundsFinal(bounds, true, callBoundsChangeCallbacks);
3286 // Custom Exception: ex) Location::Map
3288 // E_UNSUPPORTED_OPERATION
3290 _Control::SetBounds(const Rectangle& bounds, bool callBoundsChangeCallbacks)
3294 __isChangedPositionByUser = true;
3296 if (callBoundsChangeCallbacks)
3298 SysTryReturn(NID_UI,
3299 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3300 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3302 FloatRectangle floatBounds(bounds.x, bounds.y, bounds.width, bounds.height);
3304 return SetBoundsInternal(floatBounds, callBoundsChangeCallbacks);
3307 // Custom Exception: ex) Location::Map
3309 // E_UNSUPPORTED_OPERATION
3311 _Control::SetBounds(const FloatRectangle& bounds, bool callBoundsChangeCallbacks)
3315 __isChangedPositionByUser = true;
3317 if (callBoundsChangeCallbacks)
3319 SysTryReturn(NID_UI,
3320 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3321 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3324 return SetBoundsInternal(bounds, callBoundsChangeCallbacks);
3327 // A custom Exception can occur. ex) Location::Map
3329 // E_UNSUPPORTED_OPERATION
3331 _Control::SetPosition(const Point& position)
3335 __isChangedPositionByUser = true;
3337 SysTryReturn(NID_UI,
3338 IsMovable(), E_UNSUPPORTED_OPERATION,
3339 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable.");
3341 return SetBoundsInternal(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height), true);
3345 _Control::SetPosition(const FloatPoint& position)
3349 __isChangedPositionByUser = true;
3351 SysTryReturn(NID_UI,
3352 IsMovable(), E_UNSUPPORTED_OPERATION,
3353 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable.");
3355 return SetBoundsInternal(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height), true);
3358 // Custom Exception: ex) Location::Map
3360 // E_UNSUPPORTED_OPERATION
3362 _Control::SetSize(const Dimension& size)
3366 SysTryReturn(NID_UI,
3367 IsResizable(), E_UNSUPPORTED_OPERATION,
3368 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3370 return SetBoundsInternal(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height), true);
3374 _Control::SetSize(const FloatDimension& size)
3378 SysTryReturn(NID_UI,
3379 IsResizable(), E_UNSUPPORTED_OPERATION,
3380 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3382 return SetBoundsInternal(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height), true);
3386 _Control::IsChangedPositionByUser(void) const
3388 return __isChangedPositionByUser;
3392 _Control::SetChangedPositionByUser(bool change)
3394 __isChangedPositionByUser = change;
3398 _Control::GetMinimumSize(void) const
3402 return _CoordinateSystemUtils::ConvertToInteger(__minSize);
3406 _Control::GetMinimumSizeF(void) const
3414 _Control::GetMaximumSize(void) const
3418 return _CoordinateSystemUtils::ConvertToInteger(__maxSize);
3422 _Control::GetMaximumSizeF(void) const
3429 // Custom Exception: ex) Location::Map
3430 // E_UNSUPPORTED_OPERATION
3433 _Control::SetMinimumSize(const Dimension& newMinSize)
3437 SysTryReturn(NID_UI,
3438 IsResizable(), E_UNSUPPORTED_OPERATION,
3439 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3441 SysTryReturn(NID_UI,
3442 (newMinSize.width >= 0 && newMinSize.height >= 0), E_INVALID_ARG,
3443 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3445 SysTryReturn(NID_UI,
3446 (newMinSize.width <= MAX_LENGTH && newMinSize.height <= MAX_LENGTH), E_INVALID_ARG,
3447 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3449 if (__maxSize.width < newMinSize.width)
3451 __maxSize.width = newMinSize.width;
3453 if (__maxSize.height < newMinSize.height)
3455 __maxSize.height = newMinSize.height;
3458 __minSize = _CoordinateSystemUtils::ConvertToFloat(newMinSize);
3459 return AdjustSizeToRange();
3463 _Control::SetMinimumSize(const FloatDimension& newMinSize)
3467 SysTryReturn(NID_UI,
3468 IsResizable(), E_UNSUPPORTED_OPERATION,
3469 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3471 SysTryReturn(NID_UI,
3472 (newMinSize.width >= 0 && newMinSize.height >= 0), E_INVALID_ARG,
3473 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3475 SysTryReturn(NID_UI,
3476 (newMinSize.width <= MAX_LENGTH && newMinSize.height <= MAX_LENGTH), E_INVALID_ARG,
3477 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3479 if (__maxSize.width < newMinSize.width)
3481 __maxSize.width = newMinSize.width;
3483 if (__maxSize.height < newMinSize.height)
3485 __maxSize.height = newMinSize.height;
3488 __minSize = newMinSize;
3489 return AdjustSizeToRange();
3492 // Custom Exception: ex) Location::Map
3493 // E_UNSUPPORTED_OPERATION
3496 _Control::SetMaximumSize(const Dimension& newMaxSize)
3500 SysTryReturn(NID_UI,
3501 IsResizable(), E_UNSUPPORTED_OPERATION,
3502 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3504 SysTryReturn(NID_UI,
3505 (newMaxSize.width >= 0 && newMaxSize.height >= 0), E_INVALID_ARG,
3506 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3508 SysTryReturn(NID_UI,
3509 (newMaxSize.width <= MAX_LENGTH && newMaxSize.height <= MAX_LENGTH), E_INVALID_ARG,
3510 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3512 if (newMaxSize.width < __minSize.width)
3514 __minSize.width = newMaxSize.width;
3516 if (newMaxSize.height < __minSize.height)
3518 __minSize.height = newMaxSize.height;
3521 __maxSize = _CoordinateSystemUtils::ConvertToFloat(newMaxSize);
3522 return AdjustSizeToRange();
3526 _Control::SetMaximumSize(const FloatDimension& newMaxSize)
3530 SysTryReturn(NID_UI,
3531 IsResizable(), E_UNSUPPORTED_OPERATION,
3532 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3534 SysTryReturn(NID_UI,
3535 (newMaxSize.width >= 0 && newMaxSize.height >= 0), E_INVALID_ARG,
3536 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3538 SysTryReturn(NID_UI,
3539 (newMaxSize.width <= MAX_LENGTH && newMaxSize.height <= MAX_LENGTH), E_INVALID_ARG,
3540 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3542 if (newMaxSize.width < __minSize.width)
3544 __minSize.width = newMaxSize.width;
3546 if (newMaxSize.height < __minSize.height)
3548 __minSize.height = newMaxSize.height;
3551 __maxSize = newMaxSize;
3552 return AdjustSizeToRange();
3557 _Control::ConvertToControlPosition(const Point& screenPosition) const
3559 Point controlPosition;
3560 Rectangle absoluteBounds = GetAbsoluteBounds();
3562 controlPosition.x = screenPosition.x - absoluteBounds.x;
3563 controlPosition.y = screenPosition.y - absoluteBounds.y;
3565 return controlPosition;
3569 _Control::ConvertToControlPosition(const FloatPoint& screenPosition) const
3571 FloatPoint controlPosition;
3572 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
3574 controlPosition.x = screenPosition.x - absoluteBounds.x;
3575 controlPosition.y = screenPosition.y - absoluteBounds.y;
3577 return controlPosition;
3581 _Control::ConvertToScreenPosition(const Point& controlPosition) const
3583 Point screenPosition;
3584 Rectangle absoluteBounds = GetAbsoluteBounds();
3586 screenPosition.x = controlPosition.x + absoluteBounds.x;
3587 screenPosition.y = controlPosition.y + absoluteBounds.y;
3589 return screenPosition;
3593 _Control::ConvertToScreenPosition(const FloatPoint& controlPosition) const
3595 FloatPoint screenPosition;
3596 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
3598 screenPosition.x = controlPosition.x + absoluteBounds.x;
3599 screenPosition.y = controlPosition.y + absoluteBounds.y;
3601 return screenPosition;
3605 _Control::GetClientBounds(void) const
3607 if (!__isSetClientBounds)
3609 return Rectangle(0, 0, __bounds.width, __bounds.height);
3612 return _CoordinateSystemUtils::ConvertToInteger(__clientBounds);
3616 _Control::GetClientBoundsF(void) const
3618 if (!__isSetClientBounds)
3620 return FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height);
3623 return __clientBounds;
3628 _Control::GetClientBounds(const Tizen::Graphics::Dimension& size) const
3630 if (!__isSetClientBounds)
3632 return Rectangle(0, 0, size.width, size.height);
3635 return _CoordinateSystemUtils::ConvertToInteger(__clientBounds);
3640 _Control::GetClientBoundsF(const Tizen::Graphics::FloatDimension& size) const
3642 if (!__isSetClientBounds)
3644 return FloatRectangle(0.0f, 0.0f, size.width, size.height);
3647 return __clientBounds;
3651 _Control::GetAbsoluteBounds(bool recalcAlways) const
3653 if (!recalcAlways && !__needRecalcAbsBounds)
3655 return __absoluteBounds;
3659 Rectangle absoluteBounds;
3660 Rectangle clientBounds;
3662 const _Control* pSelf = this;
3663 const _Control* pParent = GetParent();
3664 bool needRecalc = true;
3668 if (pParent->__needRecalcAbsBounds)
3670 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT))
3672 clientBounds = pParent->GetClientBounds();
3673 accumPoint += Point(clientBounds.x, clientBounds.y);
3674 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3675 accumPoint.y -= pParent->GetVerticalScrollPosition();
3678 accumPoint += pSelf->GetPosition();
3680 pParent = pParent->GetParent();
3684 Rectangle parentAbsoluteBounds = pParent->GetAbsoluteBounds(false);
3685 accumPoint += Point(parentAbsoluteBounds.x, parentAbsoluteBounds.y);
3687 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT))
3689 clientBounds = pParent->GetClientBounds();
3690 accumPoint += Point(clientBounds.x, clientBounds.y);
3691 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3692 accumPoint.y -= pParent->GetVerticalScrollPosition();
3695 accumPoint += pSelf->GetPosition();
3703 _Window* pWindow = GetRootWindow();
3706 Point winPoint = pWindow->GetPosition();
3707 accumPoint.x += winPoint.x;
3708 accumPoint.y += winPoint.y;
3712 absoluteBounds.x = accumPoint.x;
3713 absoluteBounds.y = accumPoint.y;
3714 absoluteBounds.width = __bounds.width;
3715 absoluteBounds.height = __bounds.height;
3717 const_cast<_Control*>(this)->__absoluteBounds = absoluteBounds;
3718 const_cast<_Control*>(this)->__needRecalcAbsBounds = false;
3720 return absoluteBounds;
3724 _Control::GetAbsoluteBoundsF(bool recalcAlways) const
3726 if (!recalcAlways && !__needRecalcAbsBoundsF)
3728 return __absoluteBoundsF;
3731 FloatPoint accumPoint;
3732 FloatRectangle absoluteBounds;
3733 FloatRectangle clientBounds;
3735 const _Control* pSelf = this;
3736 const _Control* pParent = GetParent();
3737 bool needRecalc = true;
3741 if (pParent->__needRecalcAbsBounds)
3743 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent)
3745 clientBounds = pParent->GetClientBoundsF();
3746 accumPoint += FloatPoint(clientBounds.x, clientBounds.y);
3747 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3748 accumPoint.y -= pParent->GetVerticalScrollPosition();
3751 accumPoint += pSelf->GetPositionF();
3753 pParent = pParent->GetParent();
3757 FloatRectangle parentAbsoluteBounds = pParent->GetAbsoluteBoundsF(false);
3758 accumPoint += FloatPoint(parentAbsoluteBounds.x, parentAbsoluteBounds.y);
3760 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent)
3762 clientBounds = pParent->GetClientBoundsF();
3763 accumPoint += FloatPoint(clientBounds.x, clientBounds.y);
3764 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3765 accumPoint.y -= pParent->GetVerticalScrollPosition();
3768 accumPoint += pSelf->GetPositionF();
3776 _Window* pWindow = GetRootWindow();
3779 FloatPoint winPoint = pWindow->GetPositionF();
3780 accumPoint.x += winPoint.x;
3781 accumPoint.y += winPoint.y;
3785 absoluteBounds.x = accumPoint.x;
3786 absoluteBounds.y = accumPoint.y;
3787 absoluteBounds.width = __bounds.width;
3788 absoluteBounds.height = __bounds.height;
3790 const_cast<_Control*>(this)->__absoluteBoundsF = absoluteBounds;
3791 const_cast<_Control*>(this)->__needRecalcAbsBoundsF = false;
3793 return absoluteBounds;
3797 _Control::SetClientBounds(const Rectangle& bounds)
3801 const bool moved = (__clientBounds.x != _CoordinateSystemUtils::ConvertToFloat(bounds).x) || (__clientBounds.y != _CoordinateSystemUtils::ConvertToFloat(bounds).y);
3802 const bool resized = (__clientBounds.width != _CoordinateSystemUtils::ConvertToFloat(bounds).width) || (__clientBounds.height != _CoordinateSystemUtils::ConvertToFloat(bounds).height);
3804 SysTryReturn(NID_UI,
3805 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3806 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3807 __clientBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
3808 __isSetClientBounds = true;
3810 if (moved || resized)
3812 result r = AdjustAbsoluteBounds(*this);
3813 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3815 SetUpdateLayoutState(true);
3816 InvalidateHierarchyAbsoluteBounds(*this);
3822 _Control::SetClientBounds(const FloatRectangle& bounds)
3826 const bool moved = (__clientBounds.x != bounds.x) || (__clientBounds.y != bounds.y);
3827 const bool resized = (__clientBounds.width != bounds.width) || (__clientBounds.height != bounds.height);
3829 SysTryReturn(NID_UI,
3830 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3831 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3832 __clientBounds = bounds;
3833 __isSetClientBounds = true;
3835 if (moved || resized)
3837 result r = AdjustAbsoluteBounds(*this);
3838 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3840 SetUpdateLayoutState(true);
3841 InvalidateHierarchyAbsoluteBounds(*this);
3848 _Control::IsCalledSetClientBounds(void) const
3850 return __isSetClientBounds;
3854 _Control::UpdateClientBounds(const FloatDimension& size, FloatRectangle& clientBounds)
3856 clientBounds.width = size.width;
3857 clientBounds.height = size.height;
3861 _Control::GetBackgroundColor(void) const
3864 return __backgroundColor;
3868 _Control::SetBackgroundColor(const Color& color)
3871 __backgroundColor = color;
3873 _ControlVisualElement* pCVE = dynamic_cast <_ControlVisualElement*>(GetVisualElement());
3876 pCVE->SetBackgroundColor(
3878 (float)color.GetRed() / 255.0f,
3879 (float)color.GetGreen() / 255.0f,
3880 (float)color.GetBlue() / 255.0f,
3881 (float)color.GetAlpha() / 255.0f
3886 GetControlDelegate().OnBackgroundColorChanged(const_cast<Color&>(color));
3890 _Control::~_Control(void)
3894 __destroying = true;
3897 DoBacktrace(__pDeleteBacktrace.get());
3899 DetachAllChildren();
3901 _ControlManager::GetInstance()->TakeFocusFromControl(*this);
3911 // Dangerous: it clears last result and log in catch block.
3912 // ClearLastResult();
3916 _Control::DisposeControl(void)
3918 __pControlDelegate = null;
3920 delete __pLayoutItemHandler;
3921 __pLayoutItemHandler = null;
3923 delete __pLayoutContainer;
3924 __pLayoutContainer = null;
3932 if (__pVisualElement)
3934 __pVisualElement->Destroy();
3936 __pVisualElement = null;
3938 delete __pVisualElementContentProvider;
3939 __pVisualElementContentProvider = null;
3941 delete __pVisualElementEventListener;
3942 __pVisualElementEventListener = null;
3944 delete __pCoreGestureDetectors;
3945 __pCoreGestureDetectors = null;
3947 delete __pDataBindingContext;
3948 __pDataBindingContext = null;
3950 ClearStartedGestureDetectorList();
3951 delete __pDetectStartedGestureMap;
3952 __pDetectStartedGestureMap = null;
3954 delete __pDelayedTouchInfoList;
3955 __pDelayedTouchInfoList = null;
3957 delete __pAccessibilityContainer;
3958 __pAccessibilityContainer = null;
3960 if (__pFocusVisualElement)
3962 __pFocusVisualElement.release();
3968 _Control::_Control(void)
3969 : __needRecalcRootWindow(true)
3970 , __needRecalcAbsBounds(true)
3971 , __needRecalcAbsBoundsF(true)
3972 , __pRootWindow(null)
3977 , __bounds(0.0f, 0.0f, 0.0f, 0.0f)
3978 , __contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f)
3979 , __clientBounds(0.0f, 0.0f, 0.0f, 0.0f)
3980 , __absoluteBounds(0, 0, 0, 0)
3981 , __absoluteBoundsF(0.0f, 0.0f, 0.0f, 0.0f)
3982 , __invalidatedBounds(0.0f, 0.0f, 0.0f, 0.0f)
3983 , __minSize(FloatDimension(0.0f, 0.0f))
3984 , __maxSize(FloatDimension(MAX_LENGTH, MAX_LENGTH))
3985 , __backgroundColor(Color::GetColor(COLOR_ID_BLACK))
3989 , __nativeObjectFocusable(true)
3990 , __enabledState(true)
3991 , __visibleState(true)
3992 , __initVisibleState(false)
3993 , __clipToParent(true)
3994 , __multiTouchEnabled(false)
3995 , __dragEnabled(false)
3996 , __dropEnabled(false)
3997 , __drawWhenVisible(true)
3998 , __isPostOrderTraversal(false)
3999 , __isCalledCallOnAttachingToMainTree(false)
4000 , __isCalledCallOnPreAttachedToMainTree(false)
4001 , __isCalledCallOnAttachedToMainTree(false)
4002 , __isSetClientBounds(false)
4003 , __isCalledGetCanvasN(false)
4004 , __isFocusMode(false)
4005 , __isNavigatable(true)
4006 , __isFocusWindowActivationChecked(false)
4007 , __isChangedPositionByUser(false)
4008 , __pVisualElementContentProvider(null)
4009 , __pVisualElement(null)
4010 , __pVisualElementEventListener(null)
4011 , __pLayoutItemHandler(null)
4012 , __pPortraitLayout(null)
4013 , __pLandscapeLayout(null)
4014 , __pLayoutContainer(null)
4015 , __area(_CONTROL_AREA_NONE)
4016 , __layer(_CONTROL_LAYER_NONE)
4017 , __orientation(_CONTROL_ORIENTATION_PORTRAIT)
4018 , __rotation(_CONTROL_ROTATION_0)
4019 , __pTouchEventPreviewer(null)
4020 , __pKeyEventPreviewer(null)
4021 , __pNotificationEventPreviewer(null)
4022 , __pKeyEventListener(null)
4023 , __pFocusEventListener(null)
4024 , __pNotificationEventListener(null)
4025 , __pCoreGestureDetectors(null)
4026 , __pDetectStartedGestureMap(null)
4027 , __pDelayedTouchInfoList(null)
4028 , __touchMoveAllowance(3)
4029 , __pressThresHold(0.0f)
4030 , __inputLockRefCount(0)
4032 , __isSentDelayedEvent(false)
4033 , __isSendingDelayedEvent(false)
4034 , __isChangingEventTarget(false)
4035 , __pDataBindingContext(null)
4036 , __pControlDelegate(null)
4038 , __destroying(false)
4039 , __isEventEnableState(true)
4040 , __isEffectSoundEnabled(true)
4041 , __isControlFontChanged(false)
4044 , __fontFileName(L"")
4045 , __pPreviousFocus(null)
4046 , __pNextFocus(null)
4047 , __pDragWindow(null)
4048 , __isDragAndDropSource(false)
4052 std::unique_ptr<Tizen::Base::Collection::ArrayListT<void*> > pNewBacktrace(new (std::nothrow) ArrayListT<void*>);
4053 SysTryReturnVoidResult(NID_SHELL, pNewBacktrace, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4055 result r = pNewBacktrace->Construct();
4056 SysTryReturnVoidResult(NID_SHELL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
4058 __pNewBacktrace = move(pNewBacktrace);
4060 // DoBacktrace(__pNewBacktrace.get());
4062 std::unique_ptr<Tizen::Base::Collection::ArrayListT<void*> > pDeleteBacktrace(new (std::nothrow) ArrayListT<void*>);
4063 SysTryReturnVoidResult(NID_SHELL, pDeleteBacktrace, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4065 r = pDeleteBacktrace->Construct();
4066 SysTryReturnVoidResult(NID_SHELL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
4068 __pDeleteBacktrace = move(pDeleteBacktrace);
4070 SetControlDelegate(*this);
4071 __pAccessibilityContainer = new (std::nothrow) _AccessibilityContainer(*this);
4072 __pAccessibilityContainer->Activate(true);
4074 __pLayoutItemHandler = new (std::nothrow) LayoutItemHandler(this);
4075 if (!__pLayoutItemHandler)
4080 __pLayoutContainer = CreateLayoutContainerN(__pLayoutItemHandler);
4081 if (!__pLayoutContainer)
4086 __pChildren = ::CreateControlListN();
4092 __pOwnees = ::CreateWindowListN();
4098 __pVisualElement = ::CreateVisualElementN();
4099 if (!__pVisualElement)
4104 __pVisualElement->SetUserData(this);
4105 __pVisualElement->SetClipChildrenEnabled(true);
4106 __pVisualElement->SetRedrawOnResizeEnabled(true);
4108 __pVisualElementContentProvider = new (std::nothrow) ControlVisualElementContentProvider(*this);
4109 SysTryCatch(NID_UI, __pVisualElementContentProvider, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4111 GetVisualElement()->SetContentProvider(__pVisualElementContentProvider);
4113 __pVisualElementEventListener = new (std::nothrow) ControlVisualElementEventListener(*this);
4114 SysTryCatch(NID_UI, __pVisualElementEventListener, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4116 GetVisualElement()->SetVisualElementEventListener(__pVisualElementEventListener);
4118 __pDetectStartedGestureMap = ::CreateGestureMapN();
4119 if (!__pDetectStartedGestureMap)
4124 __pCoreGestureDetectors = new (std::nothrow) LinkedListT<_TouchGestureDetector*>;
4125 if (!__pCoreGestureDetectors)
4130 __pDelayedTouchInfoList = new (std::nothrow) LinkedListT<_TouchInfo*>;
4131 if (!__pDelayedTouchInfoList)
4136 SetEventPreviewer<_UI_EVENT_TOUCH>(this);
4137 SetEventPreviewer<_UI_EVENT_KEY>(this);
4138 SetEventPreviewer<_UI_EVENT_NOTIFICAITON>(this);
4140 SetEventListener<_UI_EVENT_NOTIFICAITON>(this);
4141 SetEventListener<_UI_EVENT_FOCUS>(this);
4143 SetPropagatedTouchEventListener(this);
4144 SetPropagatedKeyEventListener(this);
4145 GET_COLOR_CONFIG(BASIC::background, __backgroundColor);
4147 if (IsFailed(GetLastResult()))
4149 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
4152 __screenDpi = _ControlManager::GetInstance()->GetScreenDpi();
4162 _Control::AcquireHandle(void)
4164 __controlHandle = _ControlManager::GetInstance()->Register(this); // [ToDo] exception?
4168 _Control::ReleaseHandle(void)
4170 _ControlManager::GetInstance()->Release(__controlHandle); // [ToDo] exception?
4174 _Control::SetDrawWhenVisible(bool draw)
4176 __drawWhenVisible = draw;
4180 _Control::IsDrawWhenVisible(void) const
4182 return __drawWhenVisible;
4186 _Control::SetTerminatingOrder(bool postOrderTraversal)
4188 __isPostOrderTraversal = postOrderTraversal;
4192 _Control::IsPostOrderTraversal(void) const
4194 return __isPostOrderTraversal;
4198 _Control::SetParent(_Control* pParent)
4201 __pParent = pParent;
4205 // Only called by _Window::SetOwner(pOwner)
4207 _Control::AttachOwnee(_Window& window)
4210 result r = E_SUCCESS;
4212 _Control* pOldOwner = window.GetOwner();
4215 pOldOwner->DetachOwnee(window);
4218 r = __pOwnees->Add(&window);
4221 SysLogException(NID_UI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4222 return E_OUT_OF_MEMORY;
4229 _Control::GetOwneeCount(void) const
4232 return __pOwnees->GetCount();
4237 _Control::GetOwnee(int index) const
4240 result r = E_SUCCESS;
4242 _Window* pOwnee = null;
4243 r = __pOwnees->GetAt(index, pOwnee);
4246 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
4253 // Called by _Window::SetOwner(null)
4255 _Control::DetachOwnee(_Window& ownee)
4258 result r = E_SUCCESS;
4260 _Control* pOwner = ownee.GetOwner();
4266 r = __pOwnees->Remove(&ownee);
4269 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
4274 _Control::DetachAllOwnees(void)
4278 int owneeCount = GetOwneeCount();
4279 while (owneeCount--)
4281 _Window* pOwnee = GetOwnee(0);
4287 pOwnee->SetOwner(null);
4291 _Layout::LayoutContainer&
4292 _Control::GetLayoutContainer() const
4294 return *__pLayoutContainer;
4298 _Control::SetMultiTouchEnabled(bool enabled)
4301 __multiTouchEnabled = enabled;
4305 _Control::IsMultiTouchEnabled(void) const
4308 return __multiTouchEnabled;
4312 _Control::SetMovable(bool movable)
4315 __movable = movable;
4319 _Control::SetResizable(bool resizable)
4325 __minSize = __maxSize = GetSizeF();
4328 if (!__resizable && resizable)
4330 __minSize = FloatDimension(0.0f, 0.0f);
4331 __maxSize = FloatDimension(MAX_LENGTH, MAX_LENGTH);
4334 __resizable = resizable;
4338 _Control::GetLayout(void) const
4341 _Layout::Layout* pLayout = __pLayoutContainer->GetLayout();
4343 SysAssert(GetLastResult() == E_SUCCESS);
4348 _Control::SetCurrentLayout(_Layout::Layout& layout)
4351 return __pLayoutContainer->SetCurrentLayout(layout);
4355 _Control::AddLayout(_Layout::Layout& layout)
4358 return __pLayoutContainer->AddLayout(layout);
4362 _Control::SetUpdateLayoutState(bool state)
4364 _Layout::Layout* pLayout = GetLayout();
4367 pLayout->SetUpdateState(state);
4372 _Control::SetEffectSoundEnabled(bool enable)
4374 __isEffectSoundEnabled = enable;
4378 _Control::IsEffectSoundEnabled(void) const
4380 return __isEffectSoundEnabled;
4383 _DataBindingContext*
4384 _Control::GetDataBindingContext(void)
4386 return __pDataBindingContext;
4388 _AccessibilityContainer*
4389 _Control::GetAccessibilityContainer(void)
4391 return __pAccessibilityContainer;
4394 _Control::SetDataBindingContext(_DataBindingContext* pDataBindingContext)
4396 __pDataBindingContext = pDataBindingContext;
4400 _Control::DoBacktrace(Tizen::Base::Collection::ArrayListT<void*>* pBacktraceList)
4402 SysTryReturnVoidResult(NID_SHELL, pBacktraceList, E_INVALID_ARG, "[E_INVALID_ARG].");
4404 const static int ADDR_SIZE = 100;
4406 void* pBuffer[ADDR_SIZE];
4408 retSize = backtrace(pBuffer, ADDR_SIZE);
4409 for (int i = 0; i < retSize; i++)
4413 pBacktraceList->Add(pBuffer[i]);
4419 _Control::SetDestroying(bool destroying)
4421 __destroying = destroying;
4425 _Control::IsDestroying(void) const
4427 return __destroying;
4431 _Control::GetDescription(void) const
4437 _Control::SetTouchCapture(bool allowOutOfBounds, bool allowOwnerBounds)
4439 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4440 SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null");
4442 pTouchManager->SetCapturedControl(this, allowOutOfBounds, allowOwnerBounds);
4446 _Control::ReleaseTouchCapture(void)
4448 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4449 SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null");
4451 pTouchManager->SetCapturedControl(null, false, false);
4455 _Control::GetTopmostChildAt(const Point& point) const
4457 _Control* pTouchedControl = null;
4458 FloatPoint ptf((float) point.x, (float) point.y);
4459 _ControlManager* pControlManager = _ControlManager::GetInstance();
4460 SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist.");
4462 _Window* pRootWindow = GetRootWindow();
4463 SysTryReturn(NID_UI, pRootWindow, null, E_SYSTEM, "[E_SYSTEM] GetRootWindow() is null, this control is detached from the main trree");
4465 _ControlVisualElement* pRootControlElement = dynamic_cast <_ControlVisualElement*>(pRootWindow->GetVisualElement());
4466 SysTryReturn(NID_UI, pRootControlElement, null, E_SYSTEM, "[E_SYSTEM] pRootControlElement is null.");
4468 _ControlVisualElement* pHitTestElm = pRootControlElement->GetControlChildAtPoint(ptf);
4469 if (pHitTestElm == null)
4471 SysSecureLog(NID_UI, "pHitTestElm is null, point(%f, %f)", ptf.x, ptf.y);
4475 pTouchedControl = static_cast <_Control*>(pHitTestElm->GetUserData());
4477 return pTouchedControl;
4481 _Control::SetContentAreaBounds(const Rectangle& rect)
4485 __contentAreaBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
4489 _Control::SetContentAreaBounds(const FloatRectangle& rect)
4493 __contentAreaBounds = rect;
4497 _Control::GetContentAreaBounds(void) const
4499 return _CoordinateSystemUtils::ConvertToInteger(__contentAreaBounds);
4503 _Control::GetContentAreaBoundsF(void) const
4505 if (__contentAreaBounds != FloatRectangle(0.0f, 0.0f, 0.0f, 0.0f))
4507 return __contentAreaBounds;
4511 _Layout::Layout* pLayout = GetLayout();
4514 _Layout::LayoutMatchMode widthMatchMode = _Layout::NONE_MODE;
4515 _Layout::LayoutMatchMode heightMatchMode = _Layout::NONE_MODE;
4517 _Layout::LayoutItem& layoutItem = GetLayoutContainer();
4519 pLayout->GetItemWidthMatchMode(layoutItem, widthMatchMode);
4520 pLayout->GetItemHeightMatchMode(layoutItem, heightMatchMode);
4522 bool widthWrapContent = widthMatchMode == _Layout::WRAP_CONTENT;
4523 bool heightWrapContent = heightMatchMode == _Layout::WRAP_CONTENT;
4525 if (widthWrapContent || heightWrapContent)
4527 FloatDimension contentSize = GetContentSizeF(widthWrapContent, heightWrapContent);
4528 return FloatRectangle(__bounds.x, __bounds.y, contentSize.width, contentSize.height);
4532 return __contentAreaBounds;
4539 _Control::GetCapturedBitmapN(bool includeChildren) const
4541 result r = E_SUCCESS;
4543 Canvas* pCanvas = null;
4544 Bitmap* pBitmap = null;
4546 pBitmap = GetControlDelegate().OnCapturedBitmapRequestedN();
4547 if (pBitmap == null)
4549 FloatRectangle rect;
4551 Rectangle boundsInCanvas = GetBounds();
4552 boundsInCanvas.x = boundsInCanvas.y = 0;
4554 pCanvas = new (std::nothrow) Canvas;
4555 SysTryReturn(NID_UI, pCanvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4557 r = pCanvas->Construct(boundsInCanvas);
4558 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
4560 GetVisualElement()->Draw();
4563 rect.SetBounds(boundsInCanvas.x, boundsInCanvas.y, boundsInCanvas.width, boundsInCanvas.height);
4565 r = GetVisualElement()->Capture(*pCanvas, rect, includeChildren);
4566 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
4568 pBitmap = new (std::nothrow) Bitmap;
4569 SysTryCatch(NID_UI, pBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4571 r = pBitmap->Construct(*pCanvas, boundsInCanvas);
4574 SysTryCatch(NID_UI, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4577 SysLog(NID_UI, "Bitmap (width:%d, height:%d)", pBitmap->GetWidth(), pBitmap->GetHeight());
4581 _BitmapImpl::ConvertToNonpremultiplied(*pBitmap, true);
4593 Tizen::Graphics::Rectangle
4594 _Control::GetInvalidatedBounds(void) const
4596 return _CoordinateSystemUtils::ConvertToInteger(__invalidatedBounds);
4599 Tizen::Graphics::FloatRectangle
4600 _Control::GetInvalidatedBoundsF(void) const
4602 return __invalidatedBounds;
4606 _Control::AddGestureDetector(const _TouchGestureDetector& gestureDetector)
4610 bool exist = __pCoreGestureDetectors->Contains(const_cast<_TouchGestureDetector*>(&gestureDetector));
4611 SysTryReturnResult(NID_UI, exist == false, E_OBJ_ALREADY_EXIST, "__pCoreGestureDetectors has gesture already");
4613 result r = __pCoreGestureDetectors->Add(const_cast<_TouchGestureDetector*>(&gestureDetector));
4614 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4616 r = const_cast<_TouchGestureDetector&>(gestureDetector).SetControl(*this);
4617 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "Control handle is not valid.");
4619 const_cast<_TouchGestureDetector&>(gestureDetector).OnTouchGestureDetectorAdded();
4625 _Control::RemoveGestureDetector(const _TouchGestureDetector& gestureDetector)
4629 result r = __pCoreGestureDetectors->Remove(&(const_cast<_TouchGestureDetector&>(gestureDetector)));
4635 const_cast<_TouchGestureDetector&>(gestureDetector).OnTouchGestureDetectorRemoved();
4640 IListT <_TouchGestureDetector*>*
4641 _Control::GetGestureDetectorList(void) const
4643 return __pCoreGestureDetectors;
4646 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>*
4647 _Control::GetStartedGestureDetectorEnumeratorN(void) const
4649 return __pDetectStartedGestureMap->GetMapEnumeratorN();
4652 IListT <_TouchGestureDetector*>*
4653 _Control::GetStartedGestureDetectorListN(void) const
4655 return __pDetectStartedGestureMap->GetKeysN();
4659 _Control::AddStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state)
4663 result r = E_SUCCESS;
4666 __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist);
4670 r = __pDetectStartedGestureMap->Add(const_cast<_TouchGestureDetector*>(&gestureDetector), state);
4677 _Control::SetStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state)
4681 result r = E_SUCCESS;
4684 __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist);
4688 r = __pDetectStartedGestureMap->SetValue(const_cast<_TouchGestureDetector*>(&gestureDetector), state);
4695 _Control::ClearStartedGestureDetectorList(void)
4699 result r = E_SUCCESS;
4701 IListT<_TouchGestureDetector*>* pList = __pDetectStartedGestureMap->GetKeysN();
4704 IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pList->GetEnumeratorN();
4707 while(pEnumerator->MoveNext() == E_SUCCESS)
4709 _TouchGestureDetector* pGestureDetector = null;
4710 pEnumerator->GetCurrent(pGestureDetector);
4712 if (pGestureDetector == null)
4717 __pDetectStartedGestureMap->Remove(pGestureDetector);
4724 IEnumeratorT<_TouchInfo*>* pEnumerator = __pDelayedTouchInfoList->GetEnumeratorN();
4727 while(pEnumerator->MoveNext() == E_SUCCESS)
4729 _TouchInfo* pTouchInfo = null;
4730 pEnumerator->GetCurrent(pTouchInfo);
4731 if (pTouchInfo == null)
4739 __pDelayedTouchInfoList->RemoveAll();
4743 __isSentDelayedEvent = false;
4744 __isSendingDelayedEvent = false;
4750 _Control::IsDelayedTouchEventEnabled(void) const
4752 bool existDelayTouchEventGesture = false;
4754 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4757 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4759 _TouchGestureDetector* pGestureDetector = null;
4760 pMapEnumerator->GetKey(pGestureDetector);
4762 if (pGestureDetector == null)
4767 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4768 pMapEnumerator->GetValue(state);
4770 if (pGestureDetector->IsDelayTouchEventEnabled())
4772 existDelayTouchEventGesture = true;
4775 delete pMapEnumerator;
4778 bool delayTouchEvent = false;
4779 if (existDelayTouchEventGesture)
4781 pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4784 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4786 _TouchGestureDetector* pGestureDetector = null;
4787 pMapEnumerator->GetKey(pGestureDetector);
4789 if (pGestureDetector == null)
4794 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4795 pMapEnumerator->GetValue(state);
4797 if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED)
4799 delayTouchEvent = true;
4803 delete pMapEnumerator;
4806 return delayTouchEvent;
4815 _Control::IsPossibleToSendDelayedTouchEvent(void) const
4817 bool existDelayTouchEventGesture = false;
4819 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4822 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4824 _TouchGestureDetector* pGestureDetector = null;
4825 pMapEnumerator->GetKey(pGestureDetector);
4827 if (pGestureDetector == null)
4832 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4833 pMapEnumerator->GetValue(state);
4835 if (pGestureDetector->IsDelayTouchEventEnabled())
4837 existDelayTouchEventGesture = true;
4840 delete pMapEnumerator;
4843 bool allFailed = true;
4844 if (existDelayTouchEventGesture)
4846 pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4849 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4851 _TouchGestureDetector* pGestureDetector = null;
4852 pMapEnumerator->GetKey(pGestureDetector);
4854 if (pGestureDetector == null)
4859 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4860 pMapEnumerator->GetValue(state);
4862 if (state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS)
4868 delete pMapEnumerator;
4880 _Control::IsCancelOnGestureSuccess(void) const
4882 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4883 SysAssert(pTouchManager != null);
4885 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4888 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4890 _TouchGestureDetector* pGestureDetector = null;
4891 pMapEnumerator->GetKey(pGestureDetector);
4893 if (pGestureDetector == null)
4898 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4899 pMapEnumerator->GetValue(state);
4901 if (pGestureDetector->IsCancelTouchEventOnSuccessEnabled() && state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS && !pTouchManager->IsTouchCanceledOnGestureSuccess())
4903 delete pMapEnumerator;
4907 delete pMapEnumerator;
4914 _Control::IsSentDelayedEvent(void) const
4916 return __isSentDelayedEvent;
4920 _Control::SetSentDelayedEvent(bool sent)
4922 __isSentDelayedEvent = sent;
4926 _Control::SetSendingDelayedEvent(bool sending)
4928 __isSendingDelayedEvent = sending;
4932 _Control::IsSendingDelayedEvent(void) const
4934 return __isSendingDelayedEvent;
4938 _Control::AddTouchInfo(const _TouchInfo& touchInfo)
4940 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4941 SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist.");
4943 _TouchInfo* pTouchInfo = new (std::nothrow) _TouchInfo;
4944 SysTryReturnVoidResult(NID_UI, pTouchInfo, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4946 FloatPoint screenPoint = pTouchManager->GetScreenPoint(touchInfo.GetPointId());
4947 pTouchInfo->SetTouchInfo(touchInfo.GetPointId(), touchInfo.GetTouchStatus(), screenPoint, false, 0);
4948 __pDelayedTouchInfoList->Add(pTouchInfo);
4951 IListT<_TouchInfo*>*
4952 _Control::GetTouchInfoList(void)
4954 return __pDelayedTouchInfoList;
4958 _Control::SetVisualElement(_ControlVisualElement* pVisualElement)
4960 __pVisualElement = pVisualElement;
4964 _Control::GetVisualElement(void) const
4966 return __pVisualElement;
4970 _Control::PrintDescription(bool printChildren, int level)
4972 int count = PrintDescription(printChildren, 0, level);
4974 SysSecureLog(NID_UI, "%d controls were printed.", count);
4978 _Control::PrintDescription(bool printChildren, int depth, int level)
4980 const int PRINT_CONTROL_VE = 1;
4981 const int PRINT_CONTROL_EVAS = 2;
4982 const int PRINT_CONTROL_VE_EVAS = 3;
4987 format.Format(LOG_LEN_MAX, L"%d", depth);
4989 for (int i = 0; i < depth; i++)
4991 indent.Append(L" ");
4994 indent.Append(format);
4996 String delimiter(L"-------------------------------------------------------------------------------------------");
4997 SysSecureLog(NID_UI, "%ls", delimiter.GetPointer());
5000 String publicDescription = GetControlDelegate().GetDescription();
5001 if (!publicDescription.IsEmpty())
5003 SysSecureLog(NID_UI, "%ls %ls", indent.GetPointer(), publicDescription.GetPointer());
5006 _ControlManager* pControlManager = _ControlManager::GetInstance();
5007 SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist.");
5009 bool focused = false;
5010 _Control* pFocusedControl = pControlManager->GetFocusControl();
5011 if (pFocusedControl && (pFocusedControl == this))
5017 SysSecureLog(NID_UI, "%ls 0x%x(%d %ls) enable(%d) enableState(%d) visible(%d) visibleState(%d) clip(%d) movable(%d) resizable(%d)",
5018 indent.GetPointer(), this, __controlHandle.ToInt(), GetName().GetPointer(), IsEnabled(), GetEnableState(), IsVisible(), GetVisibleState(),
5019 IsClipToParent(), IsMovable(), IsResizable());
5021 SysSecureLog(NID_UI, "%ls inputEnableState(%d) focusable(%d) focused(%d) prevFocus(0x%x) nextFocus(0x%x) font(0x%x) fontName(%ls) fontFileName(%ls)",
5022 indent.GetPointer(), GetInputEnableState(), IsFocusable(), focused, __pPreviousFocus, __pNextFocus, __pFont, __fontName.GetPointer(), __fontFileName.GetPointer());
5024 Rectangle bounds = GetBounds();
5025 Dimension min = GetMinimumSize();
5026 Dimension max = GetMaximumSize();
5027 Rectangle clientBounds = GetClientBounds();
5028 Rectangle absoluteBounds = GetAbsoluteBounds();
5030 SysSecureLog(NID_UI, "%ls bounds(%d %d %d %d) min(%d %d) max(%d %d) scrollPos(%.2f %.2f) cbounds(%d %d %d %d) abounds(%d %d %d %d)",
5031 indent.GetPointer(), bounds.x, bounds.y, bounds.width, bounds.height,
5032 min.width, min.height, max.width, max.height,
5033 GetVerticalScrollPosition(), GetHorizontalScrollPosition(),
5034 clientBounds.x, clientBounds.y, clientBounds.width, clientBounds.height,
5035 absoluteBounds.x, absoluteBounds.y, absoluteBounds.width, absoluteBounds.height);
5037 SysSecureLog(NID_UI, "%ls bgColor(0x%x) layoutable(%d) orientation(%d) drag(%d) drop(%d) area(%d) layer(%d)",
5038 indent.GetPointer(), __backgroundColor.GetRGB32(), IsLayoutable(), GetOrientation(), IsDragEnabled(), IsDropEnabled(), GetArea(), GetLayer());
5040 Canvas* pCanvas = GetCanvasN();
5043 Rectangle canvasBounds = pCanvas->GetBounds();
5044 Color canvasBackgroundColor = pCanvas->GetBackgroundColor();
5045 Color canvasForegroundColor = pCanvas->GetForegroundColor();
5047 SysSecureLog(NID_UI, "%ls canvas.bounds(%d %d %d %d) canvas.bgColor(0x%x) canvas.fgColor(0x%x)",
5048 indent.GetPointer(), canvasBounds.x, canvasBounds.y, canvasBounds.width, canvasBounds.height, canvasBackgroundColor.GetRGB32(), canvasForegroundColor.GetRGB32());
5053 SysSecureLog(NID_UI, "%ls DataBindingContext(0x%x) ControlDelegate(0x%x) UserData(0x%x) destroying(%d)",
5054 indent.GetPointer(), __pDataBindingContext, __pControlDelegate, __pUserData, __destroying);
5059 for (int i = 0; i < GetOwneeCount(); ++i)
5062 _Window* pOwnee = GetOwnee(i);
5065 ownee.Format(LOG_LEN_MAX, L"0x%x ", pOwnee);
5066 ownees.Append(ownee);
5070 if (!ownees.IsEmpty())
5072 SysSecureLog(NID_UI, "%ls Ownees(%ls)", indent.GetPointer(), ownees.GetPointer());
5075 _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*__pVisualElement);
5077 SysSecureLog(NID_UI, "%ls _VisualElement(0x%x) _VisualElementImpl(0x%x) VisualElementContentProvider(0x%x) VisualElementEventListener(0x%x)",
5078 indent.GetPointer(), __pVisualElement, pVisualElementImpl, __pVisualElementContentProvider, __pVisualElementEventListener);
5081 SysSecureLog(NID_UI, "%ls LayoutItemHandler(0x%x) PortraitLayout(0x%x) LandscapeLayout(0x%x) LayoutContainer(0x%x)",
5082 indent.GetPointer(), __pLayoutItemHandler, __pPortraitLayout, __pLandscapeLayout, __pLayoutContainer);
5085 String description = GetDescription();
5086 if (!description.IsEmpty())
5088 SysSecureLog(NID_UI, "%ls %ls", indent.GetPointer(), description.GetPointer());
5091 // Print Gesture List
5092 IListT<_TouchGestureDetector*>* pGestureList = GetGestureDetectorList();
5093 SysTryReturn(NID_UI, pGestureList, 0, E_SYSTEM, "[E_SYSTEM] System error occurred.");
5095 IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN();
5096 SysTryReturn(NID_UI, pEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
5098 while (pEnumerator->MoveNext() == E_SUCCESS)
5100 _TouchGestureDetector* pGestureDetector = null;
5101 pEnumerator->GetCurrent(pGestureDetector);
5102 if (pGestureDetector)
5104 SysSecureLog(NID_UI, "%ls AddedGesture : %ls", indent.GetPointer(), pGestureDetector->GetDescription().GetPointer());
5110 // Print Started Gesture List
5111 unique_ptr<IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState> > pStartedGestureEnumerator(GetStartedGestureDetectorEnumeratorN());
5112 SysTryReturn(NID_UI, pStartedGestureEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
5114 while (pStartedGestureEnumerator->MoveNext() == E_SUCCESS)
5116 _TouchGestureDetector* pStartedGestureDetector = null;
5117 pStartedGestureEnumerator->GetKey(pStartedGestureDetector);
5118 if (pStartedGestureDetector)
5120 SysSecureLog(NID_UI, "%ls StartedGesture : %ls", indent.GetPointer(), pStartedGestureDetector->GetDescription().GetPointer());
5125 unique_ptr<IEnumeratorT<void*> > pNewEnumerator(__pNewBacktrace->GetEnumeratorN());
5126 SysTryReturn(NID_SHELL, pNewEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5128 String newBacktrace;
5130 while (pNewEnumerator->MoveNext() == E_SUCCESS)
5133 pNewEnumerator->GetCurrent(pAddr);
5136 addr.Format(LOG_LEN_MAX, L"0x%x ", pAddr);
5137 newBacktrace.Append(addr);
5140 if (!newBacktrace.IsEmpty())
5142 SysSecureLog(NID_UI, "%ls new [%ls]", indent.GetPointer(), newBacktrace.GetPointer());
5146 unique_ptr<IEnumeratorT<void*> > pDeleteEnumerator(__pDeleteBacktrace->GetEnumeratorN());
5147 SysTryReturn(NID_SHELL, pDeleteEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5149 String deleteBacktrace;
5151 while (pDeleteEnumerator->MoveNext() == E_SUCCESS)
5154 pDeleteEnumerator->GetCurrent(pAddr);
5157 addr.Format(LOG_LEN_MAX, L"0x%x ", pAddr);
5158 deleteBacktrace.Append(addr);
5161 if (!deleteBacktrace.IsEmpty())
5163 SysSecureLog(NID_UI, "%ls delete [%ls]", indent.GetPointer(), deleteBacktrace.GetPointer());
5166 // Print VE and Evas
5169 case PRINT_CONTROL_VE:
5170 _VeDebug::DumpVeTree(pVisualElementImpl, 0);
5173 case PRINT_CONTROL_EVAS:
5174 _VeDebug::DumpEvasTree(pVisualElementImpl, 0);
5177 case PRINT_CONTROL_VE_EVAS:
5178 _VeDebug::DumpVeTree(pVisualElementImpl, 0);
5179 _VeDebug::DumpEvasTree(pVisualElementImpl, 0);
5186 static int totalCount = 0;
5197 int count = GetChildCount();
5198 totalCount += count;
5200 for (int i = count - 1; i >= 0; --i)
5202 _Control* pChild = GetChild(i);
5205 pChild->PrintDescription(printChildren, depth, level);
5214 _Control::PrintBacktrace(bool printChildren, bool newBacktrace)
5216 int count = PrintBacktrace(printChildren, 0, newBacktrace);
5218 SysSecureLog(NID_UI, "%d controls were printed.", count);
5222 _Control::PrintBacktrace(bool printChildren, int depth, bool newBacktrace)
5227 format.Format(LOG_LEN_MAX, L"%d", depth);
5229 for (int i = 0; i < depth; i++)
5231 indent.Append(L" ");
5234 indent.Append(format);
5236 String delimiter(L"-------------------------------------------------------------------------------------------");
5237 SysSecureLog(NID_UI, "%ls", delimiter.GetPointer());
5239 SysSecureLog(NID_UI, "%ls 0x%x(%d %ls)", indent.GetPointer(), this, __controlHandle.ToInt(), GetName().GetPointer());
5241 Tizen::Base::Collection::ArrayListT<void*>* pBacktraceList = null;
5245 pBacktraceList = __pNewBacktrace.get();
5249 pBacktraceList = __pDeleteBacktrace.get();
5252 SysTryReturn(NID_UI, pBacktraceList, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5254 int backtraceCount = pBacktraceList->GetCount();
5255 SysTryReturn(NID_UI, backtraceCount > 0, 0, E_INVALID_ARG, "[E_INVALID_ARG].");
5257 void** pBacktrace = new (std::nothrow) void*[backtraceCount];
5258 SysTryReturn(NID_UI, pBacktrace, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5260 unique_ptr<IEnumeratorT<void*> > pEnumerator(pBacktraceList->GetEnumeratorN());
5261 SysTryReturn(NID_UI, pEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5264 while (pEnumerator->MoveNext() == E_SUCCESS)
5267 pEnumerator->GetCurrent(pAddr);
5269 pBacktrace[i++] = pAddr;
5272 char** pSymbols = backtrace_symbols(pBacktrace, backtraceCount);
5273 SysTryReturn(NID_UI, pSymbols, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5275 for (int j = 0; j < backtraceCount; j++)
5277 SysSecureLog(NID_UI, "%ls [%s]", indent.GetPointer(), pSymbols[j]);
5281 delete [] pBacktrace;
5283 static int totalCount = 0;
5294 int count = GetChildCount();
5295 totalCount += count;
5297 for (int i = count - 1; i >= 0; --i)
5299 _Control* pChild = GetChild(i);
5302 pChild->PrintBacktrace(printChildren, depth, newBacktrace);
5311 _Control::DragAndDropBegin(const _DragAndDropItem& dragAndDropItem)
5313 _Window* pRootWindow = GetRootWindow();
5319 __isDragAndDropSource = true;
5321 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
5327 pEcoreEvas->SetDragAndDropState(true);
5328 pEcoreEvas->DragAndDropBegin(*pRootWindow, dragAndDropItem.GetData());
5330 __pDragWindow = GetControlDelegate().OnDragAndDropBeginning();
5334 _Control::DragAndDropDrop(void)
5336 _Window* pRootWindow = GetRootWindow();
5342 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
5343 pEcoreEvas->DragAndDropDrop(*pRootWindow);
5345 GetControlDelegate().OnDragAndDropDropping();
5348 Point dropPosition = pEcoreEvas->GetDropPosition();
5349 Rectangle bounds = GetRootWindow()->GetBounds();
5350 if (bounds.Contains(dropPosition))
5352 _Control* pDropControl = _ControlManager::GetInstance()->GetTopmostTouchedControl(dropPosition, true);
5355 // Send dnd events to Source.
5357 if (pDropControl->IsDragAndDropSource() == false)
5360 int pid = pEcoreEvas->GetProcessId(pRootWindow->GetNativeHandle());
5361 String dropData = pEcoreEvas->GetDropData();
5362 SysLog(NID_UI, "[DND][S:%d][0x%x] DROPPED(%ls)", pid, pDropControl, dropData.GetPointer());
5363 _DragAndDropItem* pDragAndDropItem = _DragAndDropItem::CreateInstanceN(_DRAG_AND_DROP_TYPE_TEXT, dropData);
5364 pDropControl->GetControlDelegate().OnDragAndDropDropped(*pDragAndDropItem);
5365 delete pDragAndDropItem;
5370 __isDragAndDropSource = false;
5374 _Control::GetDragWindow(void) const
5376 return __pDragWindow;
5380 _Control::IsDragAndDropSource(void) const
5382 return __isDragAndDropSource;
5386 _Control::OnDragAndDropBeginning(void)
5392 _Control::OnDragAndDropDropping(void)
5397 _Control::OnDragAndDropEntered(void)
5402 _Control::OnDragAndDropMoved(const FloatPoint& position)
5407 _Control::OnDragAndDropLeft(void)
5412 _Control::OnDragAndDropDropped(const _DragAndDropItem& dragAndDropItem)
5416 _ITouchEventPreviewer*
5417 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>) const
5419 return __pTouchEventPreviewer;
5422 _IKeyEventPreviewer*
5423 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_KEY>) const
5425 return __pKeyEventPreviewer;
5428 _INotificationEventPreviewer*
5429 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>) const
5431 return __pNotificationEventPreviewer;
5435 _Control::GetEventListener(_IntToType<_UI_EVENT_KEY>) const
5437 return __pKeyEventListener;
5440 _IFocusEventListener*
5441 _Control::GetEventListener(_IntToType<_UI_EVENT_FOCUS>) const
5443 return __pFocusEventListener;
5446 _INotificationEventListener*
5447 _Control::GetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>) const
5449 return __pNotificationEventListener;
5453 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>, _ITouchEventPreviewer* pPreviewer)
5455 __pTouchEventPreviewer = pPreviewer;
5459 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_KEY>, _IKeyEventPreviewer* pPreviewer)
5461 __pKeyEventPreviewer = pPreviewer;
5465 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventPreviewer* pPreviewer)
5467 __pNotificationEventPreviewer = pPreviewer;
5471 _Control::SetEventListener(_IntToType<_UI_EVENT_FOCUS>, _IFocusEventListener* pListener)
5473 __pFocusEventListener = pListener;
5477 _Control::SetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventListener* pListener)
5479 __pNotificationEventListener = pListener;
5483 _Control::IsDragEnabled(void) const
5485 return __dragEnabled;
5489 _Control::IsDropEnabled(void) const
5491 return __dropEnabled;
5495 _Control::SetDragEnabled(bool enabled)
5497 __dragEnabled = enabled;
5501 _Control::SetDropEnabled(bool enabled)
5503 __dropEnabled = enabled;
5507 _Control::SetTouchPressThreshold(float distance)
5509 __touchMoveAllowance = static_cast<int>(distance * __screenDpi);
5510 __pressThresHold = distance;
5514 _Control::GetTouchPressThreshold(void) const
5516 return __pressThresHold;
5520 _Control::GetTouchPressThresholdPixel(void) const
5522 return __touchMoveAllowance;
5526 _Control::SetChangingEventTarget(bool isChangingEventTarget)
5528 __isChangingEventTarget = isChangingEventTarget;
5532 _Control::GetChangingEventTarget(void) const
5534 return __isChangingEventTarget;
5538 _Control::SetEventEnableState(bool enableState)
5540 __isEventEnableState = enableState;
5544 _Control::IsEventEnabled(void) const
5546 return __isEventEnableState;
5550 _Control::SetPreviousFocus(_Control* pPreviousFocus)
5552 __pPreviousFocus = pPreviousFocus;
5556 _Control::SetNextFocus(_Control* pNextFocus)
5558 __pNextFocus = pNextFocus;
5561 _Control::GetPreviousFocus(void) const
5563 return __pPreviousFocus;
5566 _Control::GetNextFocus(void) const
5568 return __pNextFocus;
5572 _Control::OnDrawFocus(void)
5574 if (__pFocusVisualElement.get() == null)
5576 unique_ptr<VisualElement, _VisualElementDeleter> pFocusVisualElement (new (std::nothrow) VisualElement, _VisualElementDeleter());
5577 SysTryReturn(NID_UI, pFocusVisualElement, , E_SYSTEM, "[E_SYSTEM] System error");
5579 result r = pFocusVisualElement->Construct();
5580 SysTryReturn(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error");
5582 _VisualElementImpl* pImpl = _VisualElementImpl::GetInstance(*pFocusVisualElement);
5583 SysTryReturn(NID_UI, pImpl, , E_SYSTEM, "[E_SYSTEM] pImpl System error");
5584 pImpl->SetZOrderGroup(GetZOrderGroupOfVisualElement(_CONTROL_LAYER_SYSTEM));
5586 __pFocusVisualElement.reset(pFocusVisualElement.release());
5587 __pFocusVisualElement->SetImplicitAnimationEnabled(false);
5589 _VisualElement* pControVisualElement = this->GetVisualElement();
5590 pControVisualElement->AttachChild(*__pFocusVisualElement);
5593 if (__pFocusVisualElement)
5595 Rectangle rectangle = GetBounds();
5596 __pFocusVisualElement->SetBounds(FloatRectangle(0, 0, rectangle.width, rectangle.height));
5597 unique_ptr<Canvas>pCanvas(__pFocusVisualElement->GetCanvasN());
5600 pCanvas->SetBackgroundColor(0x55555555);
5603 Color contentHighlightedColor;
5604 GET_COLOR_CONFIG(FOCUSUI::CONTENT_BG_HIGHLIGHTED, contentHighlightedColor);
5605 Bitmap* pBitmap = null;
5606 Bitmap* pTempBitmap = null;
5607 result r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
5608 pBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentHighlightedColor);
5612 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
5616 r = pCanvas->DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, rectangle.width, rectangle.height), *pBitmap);
5623 r = pCanvas->DrawBitmap(FloatRectangle(0.0f, 0.0f, rectangle.width, rectangle.height), *pBitmap);
5630 __pFocusVisualElement->SetShowState(true);
5634 _Control::OnChildControlFocusMoved(const _Control& control)
5639 _Control::OnDescendantControlFocusMoved(const _Control& control)
5644 _Control::IsChildControlFocusManage(void) const
5650 _Control::SetFontFromFile(const String& fileName)
5652 result r = E_SUCCESS;
5654 if (__fontFileName.Equals(fileName))
5659 __isControlFontChanged = true;
5660 __fontFileName = fileName;
5663 Font* pFont = GetFallbackFont();
5667 r = GetLastResult();
5668 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5674 _Control::GetFontFile(void) const
5676 return __fontFileName;
5679 _Control::DrawFocus(void)
5681 _IControlDelegate& delegate = GetControlDelegate();
5682 delegate.OnDrawFocus();
5686 _Control::MakeFocusList(const _Control* pControl, IListT<_Control*>* pFocusControlList) const
5688 int childCount = pControl->GetChildCount();
5689 for(int i = 0; i < childCount; i++)
5691 _Control* pChildControl = pControl->GetChild(i);
5692 Rectangle rect = pChildControl->GetAbsoluteBounds();
5693 unique_ptr<IEnumeratorT<_Control*> > pEnum (pFocusControlList->GetEnumeratorN());
5695 while (pEnum->MoveNext() == E_SUCCESS)
5697 _Control* pEnumeratorControl = null;
5698 pEnum->GetCurrent(pEnumeratorControl);
5699 if (pEnumeratorControl != null)
5701 Rectangle enumeratorRect = pEnumeratorControl->GetAbsoluteBounds();
5702 if(enumeratorRect.y > rect.y)
5706 else if (enumeratorRect.y == rect.y)
5708 if(enumeratorRect.x > rect.x)
5717 pFocusControlList->InsertAt(pChildControl, index);
5722 _Control::MakeChildContainerFocusList(const _Control* pControl, int startIndex , IListT<_Control*>* pFocusControlList) const
5724 unique_ptr<IListT<_Control*> > pTempList (new (std::nothrow) ArrayListT<_Control*>);
5725 SysTryReturnVoidResult(NID_UI_CTRL, pTempList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
5726 MakeFocusList(pControl, pTempList.get());
5728 unique_ptr<IEnumeratorT<_Control*> > pTempEnum(pTempList->GetEnumeratorN());
5729 int index = ++startIndex;
5730 while (pTempEnum->MoveNext() == E_SUCCESS)
5732 _Control* pEnumeratorControl = null;
5733 pTempEnum->GetCurrent(pEnumeratorControl);
5734 pFocusControlList->InsertAt(pEnumeratorControl, index);
5739 Tizen::Base::Collection::IListT<_Control*>*
5740 _Control::GetFocusListN(void) const
5742 unique_ptr<IListT<_Control*> > pControlFocusList (new (std::nothrow) ArrayListT<_Control*>);
5743 SysTryReturn(NID_UI_CTRL, pControlFocusList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5744 MakeFocusList(this, pControlFocusList.get());
5746 unique_ptr<IEnumeratorT<_Control*> > pEnum(pControlFocusList->GetEnumeratorN());
5747 SysTryReturn(NID_UI_CTRL, pEnum, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
5749 int nextContainerIndex = -1;
5750 while (pEnum->MoveNext() == E_SUCCESS)
5752 _Control* pEnumeratorControl = null;
5753 pEnum->GetCurrent(pEnumeratorControl);
5755 if (nextContainerIndex < i)
5757 if (pEnumeratorControl->IsChildControlFocusManage() == false)
5759 MakeChildContainerFocusList(pEnumeratorControl, i, pControlFocusList.get());
5760 nextContainerIndex = i;
5761 pEnum.reset(pControlFocusList->GetEnumeratorN());
5767 return pControlFocusList.release();
5771 _Control::IsChildAttachable(_Control& child) const
5773 if (dynamic_cast <_Window*>(&child) != null)