2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
18 * @file FUi_Control.cpp
19 * @brief This is the implementation file for the _Control class.
23 #include <unique_ptr.h>
24 #include <FBaseColLinkedListT.h>
25 #include <FBaseColArrayListT.h>
26 #include <FBaseColHashMapT.h>
27 #include <FBaseSysLog.h>
28 #include <FGrpFloatRectangle.h>
29 #include <FUiAnimVisualElementContentProvider.h>
30 #include <FBase_Log.h>
31 #include "FUi_Control.h"
32 #include "FUi_ControlManager.h"
33 #include "FUi_Window.h"
34 #include "FUi_EcoreEvasMgr.h"
35 #include "FUi_EcoreEvas.h"
36 #include "FUi_LayoutLayoutContainer.h"
37 #include "FUi_LayoutAbsoluteLayout.h"
38 #include "FUi_LayoutILayoutItemHandler.h"
39 #include "FUi_TouchManager.h"
40 #include "FUi_DataBindingContext.h"
41 #include "FUi_TouchLongPressGestureDetector.h"
42 #include "FUi_TouchTapGestureDetector.h"
43 #include "FUi_AccessibilityContainer.h"
44 #include "FUi_ResourceManager.h"
45 #include "FUiAnim_VisualElement.h"
46 #include "FUiAnim_ControlVisualElement.h"
47 #include "FUiAnim_VisualElementImpl.h"
48 #include "FUiCtrl_Form.h"
49 #include "FUiCtrl_Frame.h"
52 using namespace Tizen::Base;
53 using namespace Tizen::Base::Collection;
54 using namespace Tizen::Base::Runtime;
55 using namespace Tizen::Graphics;
56 using namespace Tizen::Ui;
57 using namespace Tizen::Ui::Animations;
62 GetZOrderGroupOfVisualElement(_ControlLayer layer)
66 case _CONTROL_LAYER_OVERLAY:
67 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL - 1;
68 case _CONTROL_LAYER_CLIENT_BOTTOM:
69 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL;
70 case _CONTROL_LAYER_NONE:
72 case _CONTROL_LAYER_CLIENT_MIDDLE:
73 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 1;
74 case _CONTROL_LAYER_CLIENT_TOP:
75 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 2;
76 case _CONTROL_LAYER_SYSTEM:
77 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 3;
80 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 1;
85 AdjustSizeToRange(int& width, int& height, const Dimension& minDim, const Dimension& maxDim)
88 if (width < minDim.width)
93 if (height < minDim.height)
95 height = minDim.height;
99 if (width > maxDim.width)
101 width = maxDim.width;
104 if (height > maxDim.height)
106 height = maxDim.height;
114 AdjustSizeToRange(Dimension& dim, const Dimension& minDim, const Dimension& maxDim)
116 return AdjustSizeToRange(dim.width, dim.height, minDim, maxDim);
121 _ControlVisualElement*
122 CreateVisualElementN(void)
126 _ControlVisualElement* pVisualElement = new (std::nothrow) _ControlVisualElement;
127 SysTryReturn(NID_UI, pVisualElement, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
130 pVisualElement->ConstructControlVisualElement() == E_SUCCESS, ,
131 E_SYSTEM, "[E_SYSTEM] System error occurred.");
133 pVisualElement->SetImplicitAnimationEnabled(false);
134 pVisualElement->SetShowState(true);
135 pVisualElement->SetBackBufferEnabled(true);
136 pVisualElement->SetRedrawOnResizeEnabled(true);
137 pVisualElement->SetSurfaceOpaque(false);
139 return pVisualElement;
142 //delete pVisualElement;
143 pVisualElement->Destroy();
147 _Control::GestureMap*
148 CreateGestureMapN(void)
152 _Control::GestureMap* pGestureMap = new (std::nothrow) _Control::GestureMap;
153 SysTryReturn(NID_UI, pGestureMap, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
156 pGestureMap->Construct() == E_SUCCESS, ,
157 E_SYSTEM, "[E_SYSTEM] System error occurred.");
167 _Control::ControlList*
168 CreateControlListN(void)
172 _Control::ControlList* pControlList = new (std::nothrow) _Control::ControlList;
173 SysTryReturn(NID_UI, pControlList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
179 _Control::WindowList*
180 CreateWindowListN(void)
184 _Control::WindowList* pWindowList = new (std::nothrow) _Control::WindowList;
185 SysTryReturn(NID_UI, pWindowList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
192 _Layout::LayoutContainer*
193 CreateLayoutContainerN(_Layout::ILayoutItemHandler* pLayoutItemHandler)
196 result r = E_SUCCESS;
198 _Layout::LayoutContainer* pLayoutContainer = null;
199 _Layout::AbsoluteLayout* pAbsLayout = null;
201 pLayoutContainer = new (std::nothrow) _Layout::LayoutContainer();
202 SysTryReturn(NID_UI, pLayoutContainer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage");
203 if (IsFailed(GetLastResult()))
208 pAbsLayout = new (std::nothrow) _Layout::AbsoluteLayout();
209 SysTryCatch(NID_UI, pAbsLayout, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
210 if (IsFailed(GetLastResult()))
215 pLayoutContainer->SetItemHandler(pLayoutItemHandler);
217 r = pLayoutContainer->SetDefaultLayout(*pAbsLayout);
218 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error occurred.");
220 return pLayoutContainer;
224 delete pLayoutContainer;
229 } // Anonymous namespace
231 namespace Tizen { namespace Ui
234 IMPLEMENT_PROPERTY(_Control);
236 class _Control::ControlVisualElementContentProvider
237 : public VisualElementContentProvider
244 ControlVisualElementContentProvider(_Control& control)
249 virtual ~ControlVisualElementContentProvider(void)
253 virtual bool PrepareDraw(VisualElement& target)
255 _ControlVisualElement* pCVE = dynamic_cast <_ControlVisualElement*>(&target);
261 Color bgColor = __control.GetBackgroundColor();
263 pCVE->SetBackgroundColor(
265 (float) bgColor.GetRed() / 255.0f,
266 (float) bgColor.GetGreen() / 255.0f,
267 (float) bgColor.GetBlue() / 255.0f,
268 (float) bgColor.GetAlpha() / 255.0f
272 __control.GetControlDelegate().OnDraw();
274 target.SetFlushNeeded();
279 virtual HitTestResult HitTest(VisualElement& target, const FloatPoint& point)
281 return __control.GetControlDelegate().HitTest(point);
285 ControlVisualElementContentProvider(const ControlVisualElementContentProvider& rhs);
286 ControlVisualElementContentProvider& operator =(const ControlVisualElementContentProvider& rhs);
289 class _Control::ControlVisualElementEventListener
290 : public IVisualElementEventListener
293 ControlVisualElementEventListener(_Control& control)
298 virtual ~ControlVisualElementEventListener(void)
303 virtual void OnChildAttached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& child)
307 virtual void OnChildDetached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& child)
311 virtual void OnAttached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& parent)
315 virtual void OnDetached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& parent)
319 virtual result OnTransformChanging(Tizen::Ui::Animations::VisualElement& source, FloatMatrix4& newTransform)
324 virtual void OnTransformChanged(Tizen::Ui::Animations::VisualElement& source, const FloatMatrix4& previousTransform)
328 virtual result OnChildrenTransformChanging(Tizen::Ui::Animations::VisualElement& source, FloatMatrix4& newTransform)
330 for (int i = 0; i < __control.GetChildCount(); ++i)
332 _Control* pChild = __control.GetChild(i);
338 if (pChild->GetArea() == _CONTROL_AREA_SYSTEM)
340 _VisualElement* pVisualElement = pChild->GetVisualElement();
343 FloatMatrix4 inverseMatrix(newTransform);
344 inverseMatrix.Invert();
346 result r = pVisualElement->SetTransformMatrix(inverseMatrix);
358 virtual void OnChildrenTransformChanged(Tizen::Ui::Animations::VisualElement& source, const FloatMatrix4& previousTransform)
362 virtual result OnBoundsChanging(Tizen::Ui::Animations::VisualElement& source, FloatRectangle& newBounds)
367 virtual void OnBoundsChanged(Tizen::Ui::Animations::VisualElement& source, const FloatRectangle& previousBounds)
371 virtual void OnShowStateChanged(Tizen::Ui::Animations::VisualElement& source, bool previousShowState)
376 ControlVisualElementEventListener(const ControlVisualElementEventListener& rhs);
377 ControlVisualElementEventListener& operator =(const ControlVisualElementEventListener& rhs);
381 }; // ControlVisualElementEventListener
383 // Layout Item Handler
384 class _Control::LayoutItemHandler
385 : public _Layout::ILayoutItemHandler
388 LayoutItemHandler(_Control* pControl)
389 : __pControl(pControl)
391 SysAssert(__pControl);
394 void SetItemVisibleState(bool visible)
396 __pControl->SetVisibleState(visible);
399 result SetItemBounds(const Rectangle& rect)
401 SysAssert(__pControl->IsInSizeRange(Dimension(rect.width, rect.height)));
402 FloatRectangle floatBounds(rect.x, rect.y, rect.width, rect.height);
403 return __pControl->SetBoundsFinal(floatBounds, false, true);
406 Rectangle GetItemBounds(void) const
408 return __pControl->GetBounds();
411 Rectangle GetItemClientBoundsFromSize(const Dimension& size) const
413 return __pControl->GetClientBounds(size);
416 Dimension GetItemContentSize(void) const
418 return __pControl->GetControlDelegate().GetContentSize();
421 Dimension GetItemMinimumSize(void) const
423 return __pControl->GetMinimumSize();
426 Dimension GetItemMaximumSize(void) const
428 return __pControl->GetMaximumSize();
431 result OnItemMeasure(int& width, int& height)
433 Dimension evaluatedSize(width, height);
434 __pControl->GetControlDelegate().OnEvaluateSize(evaluatedSize);
436 width = evaluatedSize.width;
437 height = evaluatedSize.height;
443 LayoutItemHandler(const LayoutItemHandler& rhs);
444 LayoutItemHandler& operator =(const LayoutItemHandler& rhs);
447 _Control* __pControl;
448 }; // LayoutItemHandler
453 _Control::CreateControlN(void)
455 _Control* pControl = new (std::nothrow) _Control;
456 SysTryReturn(NID_UI, pControl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
457 if (IsFailed(GetLastResult()))
462 pControl->AcquireHandle();
464 SysAssert(GetLastResult() == E_SUCCESS);
473 _Control::ResetEventListeners(void)
475 __pFocusEventListener = this;
476 __pNotificationEventListener = this;
480 _Control::SetControlDelegate(_IControlDelegate& delegate)
482 __pControlDelegate = &delegate;
486 _Control::ResetControlDelegate(void)
488 __pControlDelegate = this;
492 _Control::GetControlDelegate(void) const
496 return const_cast<_Control&>(*this);
499 SysAssert(__pControlDelegate);
500 return *__pControlDelegate;
504 _Control::SetPropagatedTouchEventListener(_IPropagatedTouchEventListener* pListener)
506 __pPropagatedTouchEventListener = pListener;
509 _IPropagatedTouchEventListener*
510 _Control::GetPropagatedTouchEventListener(void) const
514 return const_cast<_Control*>(this);
517 SysAssert(__pPropagatedTouchEventListener);
518 return __pPropagatedTouchEventListener;
522 _Control::SetPropagatedKeyEventListener(_IPropagatedKeyEventListener* pListener)
524 __pPropagatedKeyEventListener = pListener;
527 _IPropagatedKeyEventListener*
528 _Control::GetPropagatedKeyEventListener(void) const
532 return const_cast<_Control*>(this);
535 SysAssert(__pPropagatedKeyEventListener);
536 return __pPropagatedKeyEventListener;
540 _Control::OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
546 _Control::OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
552 _Control::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
554 //SysLog(NID_UI, ">>> [core] OnKeyPressed(%d, %d)", keyInfo.GetKeyCode(), keyInfo.GetKeyModifier());
559 _Control::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
561 //SysLog(NID_UI, ">>> [core] OnKeyReleased(%d, %d)", keyInfo.GetKeyCode(), keyInfo.GetKeyModifier());
566 _Control::TranslateKeyEventInfo(const _Control& source, _KeyInfo& keyInfo)
571 _UiTouchEventDelivery
572 _Control::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
574 return _UI_TOUCH_EVENT_DELIVERY_YES;
577 _UiTouchEventDelivery
578 _Control::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
580 return _UI_TOUCH_EVENT_DELIVERY_YES;
583 _UiTouchEventDelivery
584 _Control::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
586 return _UI_TOUCH_EVENT_DELIVERY_YES;
589 _UiTouchEventDelivery
590 _Control::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
592 return _UI_TOUCH_EVENT_DELIVERY_YES;
596 _Control::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
602 _Control::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
608 _Control::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
614 _Control::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
620 _Control::OnFocusGained(const _Control& source)
626 _Control::OnFocusLost(const _Control& source)
632 _Control::OnPreviewNotifiedN(const _Control& source, IList* pArgs)
638 _Control::OnNotifiedN(const _Control& source, IList* pArgs)
644 _Control::IsMovable(void) const
651 _Control::IsResizable(void) const
658 _Control::GetContentSize(void) const
665 _Control::HitTest(const FloatPoint& point)
667 _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*__pVisualElement);
669 if (pVisualElementImpl)
671 if (pVisualElementImpl->HitTestI(point) == _VisualElementImpl::HITTEST_MATCH)
673 return HIT_TEST_MATCH;
677 return HIT_TEST_NOWHERE;
681 _Control::GetVerticalScrollPosition(void) const
687 _Control::GetHorizontalScrollPosition(void) const
693 _Control::GetOrientation(void) const
696 return __orientation;
700 _Control::OnDraw(void)
705 _Control::OnCanvasRequestedN(const Dimension& size)
712 _Control::OnCapturedBitmapRequestedN(void)
719 _Control::OnAttaching(const _Control* pParent)
725 _Control::OnAttached(void)
731 _Control::OnAttachingToMainTree(const _Control* pParent)
737 _Control::OnAttachedToMainTree(void)
743 _Control::OnDetachingFromMainTree(void)
749 _Control::OnAttachingFailed(const _Control& parent)
754 _Control::OnDetaching(void)
760 _Control::OnBoundsChanging(const Rectangle& bounds)
766 _Control::OnBoundsChanged(void)
772 _Control::OnEvaluateSize(Dimension& evaluatedSize)
777 _Control::OnParentBoundsChanged(const _Control& parent)
783 _Control::OnChildAttached(const _Control& child)
788 _Control::OnChildDetaching(const _Control& child)
793 _Control::OnChildDetached(const _Control& child)
798 _Control::OnChildBoundsChanged(const _Control& child)
803 _Control::OnChildVisibleStateChanged(const _Control& child)
808 _Control::OnChangeLayout(_ControlOrientation orientation)
813 _Control::OnZOrderChanging(_ControlZOrderUpdate zOrderUpdate)
818 _Control::OnVisibleStateChanging(void)
823 _Control::OnVisibleStateChanged(void)
828 _Control::OnAncestorVisibleStateChanged(const _Control& control)
833 _Control::OnAncestorEnableStateChanged(const _Control& control)
838 _Control::OnTouchPressHandled(const _Control& control)
843 _Control::OnTouchReleaseHandled(const _Control& control)
848 _Control::OnTouchMoveHandled(const _Control& control)
853 _Control::OnFontChanged(Tizen::Graphics::Font* pFont)
858 _Control::OnFontInfoRequested(unsigned long& style, int& size)
863 _Control::OnTouchCancelHandled(const _Control& control)
868 _Control::Accept(Visitor& visitor)
872 VisitType visitType = visitor.Visit(*this);
880 for (int i = 0; i < GetChildCount(); ++i) // [Postpone] Keep handle list before iternation.
882 _Control* pChild = GetChild(i);
885 pChild->Accept(visitor);
892 _Control* pParent = GetParent();
895 pParent->Accept(visitor);
906 _Control::Accept(Visitor& visitor) const
908 const_cast <_Control*>(this)->Accept(visitor);
912 _Control::Draw(bool recursive)
916 Invalidate(recursive);
917 GetVisualElement()->Draw();
923 GetVisualElement()->Flush();
926 SysAssert(GetLastResult() == E_SUCCESS);
930 _Control::ChangeLayout(_ControlOrientation orientation)
937 _Visitor(_ControlOrientation orientation)
938 : __orientation(orientation){}
940 virtual VisitType Visit(_Control& control)
942 if (control.__orientation != __orientation)
944 control.__orientation = __orientation;
945 control.GetControlDelegate().OnChangeLayout(__orientation);
949 return VISIT_DOWNWARD;
953 _ControlOrientation __orientation;
956 _Visitor visitor(orientation);
959 SysAssert(GetLastResult() == E_SUCCESS);
963 _Control::IsLayoutChangable(void) const
969 _Control::IsOrientationRoot(void) const
975 _Control::Invalidate(void)
978 GetVisualElement()->InvalidateRectangle(null);
982 _Control::Invalidate(bool recursive)
989 virtual VisitType Visit(_Control& control)
991 if (control.GetVisibleState() == false)
996 control.Invalidate();
999 int owneeCount = control.GetOwneeCount();
1000 for (int i = 0; i < owneeCount; ++i)
1002 _Window* pOwnee = control.GetOwnee(i);
1005 pOwnee->Invalidate(true);
1009 return VISIT_DOWNWARD;
1014 _Layout::Layout* pLayout = GetLayout();
1017 pLayout->UpdateLayout();
1020 if (recursive == false)
1032 _Control::Invalidate(const Rectangle& rect)
1035 FloatRectangle rectf(rect.x, rect.y, rect.width, rect.height);
1036 GetVisualElement()->InvalidateRectangle(&rectf);
1038 __invalidatedBounds = rect;
1042 _Control::Contains(const Point& point) const
1046 Rectangle bounds = GetBounds();
1047 bounds.x = bounds.y = 0;
1048 return bounds.Contains(point);
1052 _Control::PartialUpdateLayout(void)
1056 _Layout::Layout* pLayout = GetLayout();
1059 pLayout->PartialUpdateLayout();
1064 _Control::UpdateLayout(void)
1068 _Layout::Layout* pLayout = GetLayout();
1071 pLayout->UpdateLayout();
1076 _Control::SetChildAlwaysOnTop(_Control& child)
1080 SysTryReturn(NID_UI,
1081 child.GetParent() == this, E_INVALID_ARG,
1082 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1084 SysTryReturn(NID_UI,
1085 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1086 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1088 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_TOP)
1093 child.SetLayer(_CONTROL_LAYER_CLIENT_TOP);
1095 SysAssert(GetLastResult() == E_SUCCESS);
1100 _Control::SetChildAlwaysAtBottom(_Control& child)
1104 SysTryReturn(NID_UI,
1105 child.GetParent() == this, E_INVALID_ARG,
1106 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1108 SysTryReturn(NID_UI,
1109 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1110 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1112 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_BOTTOM)
1117 child.SetLayer(_CONTROL_LAYER_CLIENT_BOTTOM);
1119 SysAssert(GetLastResult() == E_SUCCESS);
1124 _Control::ResetChildLayer(_Control& child)
1128 SysTryReturn(NID_UI,
1129 child.GetParent() == this, E_INVALID_ARG,
1130 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1132 SysTryReturn(NID_UI,
1133 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1134 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1136 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_MIDDLE)
1141 child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE);
1143 SysAssert(GetLastResult() == E_SUCCESS);
1149 _Control::AttachSystemChild(_Control& child)
1152 result r = E_SUCCESS;
1154 r = StartAttaching(child, _CONTROL_AREA_SYSTEM);
1160 ControlList& children = GetChildList();
1161 r = children.Add(&child);
1162 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1164 r = GetVisualElement()->AttachChild(*child.GetVisualElement());
1165 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1167 r = EndAttaching(child);
1173 SysAssert(GetLastResult() == E_SUCCESS);
1179 _Control::DetachSystemChild(_Control& child)
1181 return DetachChild(child);
1185 _Control::HasParent(void) const
1187 return __pParent != null;
1191 _Control::GetArea(void) const
1198 _Control::GetLayer(void) const
1205 _Control::SetLayer(_ControlLayer layer)
1208 _VisualElementImpl* pImpl = _VisualElementImpl::GetInstance(*GetVisualElement());
1210 result r = pImpl->SetZOrderGroup(::GetZOrderGroupOfVisualElement(layer));
1213 SysAssert(r == E_SUCCESS);
1214 ClearLastResult(); // [Temp] Will be removed.
1216 SysAssert(r == E_SUCCESS);
1219 const _Control::ControlList&
1220 _Control::GetChildList() const
1222 return const_cast <_Control*>(this)->GetChildList();
1225 _Control::ControlList&
1226 _Control::GetChildList()
1228 return *__pChildren;
1232 _Control::IsCalledCallAttachingToMainTree(void)
1234 return __isCalledCallOnAttachingToMainTree;
1238 _Control::SetCalledCallAttachingToMainTree(bool isAttaching)
1240 __isCalledCallOnAttachingToMainTree = isAttaching;
1244 _Control::IsCalledCallAttachedToMainTree(void)
1246 return __isCalledCallOnAttachedToMainTree;
1250 _Control::SetCalledCallAttachedToMainTree(bool isAttached)
1252 __isCalledCallOnAttachedToMainTree = isAttached;
1256 _Control::CallOnAttachingToMainTree(_Control& control)
1258 result r = E_SUCCESS;
1260 ControlList& children = control.GetChildList();
1261 _Control* pChild = null;
1263 int childrenCount = children.GetCount();
1265 for (int index = 0; index < childrenCount; index++)
1267 r = children.GetAt(index, pChild);
1270 SysAssert(r == E_OUT_OF_RANGE);
1271 SysTryReturn(NID_UI,
1272 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1273 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1275 if (!pChild->IsCalledCallAttachingToMainTree())
1277 r = CallOnAttachingToMainTree(*pChild);
1278 pChild->SetCalledCallAttachingToMainTree(true);
1279 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1283 if (!control.IsCalledCallAttachingToMainTree())
1285 r = control.GetControlDelegate().OnAttachingToMainTree(this);
1286 control.SetCalledCallAttachingToMainTree(true);
1287 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1294 _Control::CallOnAttachedToMainTree(_Control& control)
1296 result r = E_SUCCESS;
1298 ControlList& children = control.GetChildList();
1299 _Control* pChild = null;
1301 int childrenCount = children.GetCount();
1303 for (int index = 0; index < childrenCount; index++)
1305 r = children.GetAt(index, pChild);
1308 SysAssert(r == E_OUT_OF_RANGE);
1309 SysTryReturn(NID_UI,
1310 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1311 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1314 if (!pChild->IsCalledCallAttachedToMainTree())
1316 r = CallOnAttachedToMainTree(*pChild);
1317 pChild->SetCalledCallAttachedToMainTree(true);
1321 if (!control.IsCalledCallAttachedToMainTree())
1323 r = control.GetControlDelegate().OnAttachedToMainTree();
1324 control.SetCalledCallAttachedToMainTree(true);
1330 _Control::CallOnDetachingFromMainTree(_Control& control)
1332 result r = E_SUCCESS;
1334 ControlList& children = control.GetChildList();
1335 _Control* pChild = null;
1337 if (!__isPostOrderTraversal)
1339 r = control.GetControlDelegate().OnDetachingFromMainTree();
1340 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1343 int childrenCount = children.GetCount();
1345 for (int index = 0; index < childrenCount; index++)
1347 r = children.GetAt(index, pChild);
1350 SysAssert(r == E_OUT_OF_RANGE);
1351 SysTryReturn(NID_UI,
1352 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1353 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1355 r = CallOnDetachingFromMainTree(*pChild);
1356 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1359 if (__isPostOrderTraversal)
1361 r = control.GetControlDelegate().OnDetachingFromMainTree();
1362 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1369 _Control::CallOnAncestorVisibleStateChanged(void)
1374 _Visitor(_Control& parent)
1375 : __parent(parent){}
1377 virtual VisitType Visit(_Control& control)
1379 control.GetControlDelegate().OnAncestorVisibleStateChanged(__parent);
1380 return VISIT_DOWNWARD;
1386 _Visitor visitor(*this);
1391 _Control::CallOnAncestorEnableStateChanged(void)
1396 _Visitor(_Control& parent)
1397 : __parent(parent){}
1399 virtual VisitType Visit(_Control& control)
1401 control.GetControlDelegate().OnAncestorEnableStateChanged(__parent);
1402 return VISIT_DOWNWARD;
1408 _Visitor visitor(*this);
1414 // [ToDo] Rollback is difficult.
1416 _Control::StartAttaching(_Control& child, _ControlArea area)
1418 result r = E_SUCCESS;
1420 _Control* pOldParent = child.GetParent();
1422 SysTryReturn(NID_UI,
1423 (pOldParent != this), E_INVALID_ARG,
1424 E_INVALID_ARG, "[E_INVALID_ARG] The child control is already attached to this container.");
1426 SysTryReturn(NID_UI,
1427 pOldParent == null, E_INVALID_ARG,
1428 E_INVALID_ARG, "[E_INVALID_ARG] Unable to add the child which already has another parent.");
1430 r = child.GetControlDelegate().OnAttaching(this);
1431 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1433 if (IsAttachedToMainTree())
1435 r = CallOnAttachingToMainTree(child);
1436 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1439 // [ToDo] Add control to layout
1440 // What should we do about non-layoutable controls?
1441 if (area == _CONTROL_AREA_CLIENT)
1443 _ControlManager* pMgr = _ControlManager::GetInstance();
1444 r = GetLastResult();
1445 SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r));
1447 #if !defined(MULTI_WINDOW)
1448 if (this != &(pMgr->GetRoot()))
1451 r = __pLayoutContainer->AddItem(child.GetLayoutContainer());
1456 child.GetControlDelegate().OnAttachingFailed(*this);
1457 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Failed to apply layout.");
1462 if (IsAttachedToMainTree())
1464 #if defined(MULTI_WINDOW)
1465 if (!(IsOrientationRoot() && child.IsOrientationRoot()))
1467 if (IsLayoutChangable() && child.IsLayoutChangable())
1470 child.ChangeLayout(_ControlManager::GetInstance()->GetOrientation());
1474 child.__area = area;
1476 if (area == _CONTROL_AREA_CLIENT)
1478 if (child.GetLayer() != _CONTROL_LAYER_CLIENT_TOP && child.GetLayer() != _CONTROL_LAYER_CLIENT_BOTTOM)
1480 child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE);
1485 child.SetLayer(_CONTROL_LAYER_SYSTEM);
1488 SysAssert(GetLastResult() == E_SUCCESS);
1493 _Control::EndAttaching(_Control& child)
1495 child.SetParent(this);
1497 FloatRectangle floatBounds(child.GetBounds().x, child.GetBounds().y, child.GetBounds().width, child.GetBounds().height);
1499 result r = E_SUCCESS;
1500 if (child.IsLayoutChangable() == false)
1502 r = child.UpdateBoundsOfVisualElement(FloatRectangle(0, 0, floatBounds.width, floatBounds.height));
1506 r = child.UpdateBoundsOfVisualElement(floatBounds);
1508 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1510 r = child.GetControlDelegate().OnAttached();
1511 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1513 if (IsAttachedToMainTree())
1515 r = CallOnAttachedToMainTree(child);
1516 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1521 GetControlDelegate().OnChildAttached(child);
1531 _Control::AttachChild(_Control& child)
1534 result r = E_SUCCESS;
1536 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1542 ControlList& children = GetChildList();
1543 r = children.Add(&child);
1544 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1546 r = GetVisualElement()->AttachChild(*child.GetVisualElement());
1548 r = EndAttaching(child);
1554 SysAssert(GetLastResult() == E_SUCCESS);
1562 _Control::InsertChildToBottom(_Control& child)
1565 result r = E_SUCCESS;
1567 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1573 ControlList& children = GetChildList();
1574 r = children.InsertAt(&child, 0);
1575 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1577 GetVisualElement()->InsertChild(*child.GetVisualElement(), null, false);
1578 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1580 r = EndAttaching(child);
1586 SysAssert(GetLastResult() == E_SUCCESS);
1594 _Control::InsertChildAfter(const _Control& targetChild, _Control& child)
1597 result r = E_SUCCESS;
1599 SysTryReturn(NID_UI,
1600 targetChild.GetParent() == this, E_INVALID_ARG,
1601 E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child.");
1603 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1609 int targetIndex = GetChildIndex(targetChild);
1610 SysAssert(targetIndex != -1);
1612 ControlList& children = GetChildList();
1613 r = children.InsertAt(&child, targetIndex + 1);
1614 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1616 GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), true);
1617 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1619 r = EndAttaching(child);
1625 SysAssert(GetLastResult() == E_SUCCESS);
1633 _Control::InsertChildBefore(const _Control& targetChild, _Control& child)
1636 result r = E_SUCCESS;
1638 SysTryReturn(NID_UI,
1639 targetChild.GetParent() == this, E_INVALID_ARG,
1640 E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child.");
1642 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1648 int targetIndex = GetChildIndex(targetChild);
1649 SysAssert(targetIndex != -1);
1651 ControlList& children = GetChildList();
1652 r = children.InsertAt(&child, targetIndex);
1653 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1655 GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), false);
1656 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1658 r = EndAttaching(child);
1664 SysAssert(GetLastResult() == E_SUCCESS);
1670 _Control::DetachChild(_Control& child)
1673 result r = E_SUCCESS;
1675 SysTryReturn(NID_UI,
1676 child.GetParent() == this, E_INVALID_ARG,
1677 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1679 if (IsAttachedToMainTree())
1681 r = CallOnDetachingFromMainTree(child);
1682 SysTryReturn(NID_UI,
1683 r == E_SUCCESS, E_SYSTEM,
1684 E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent.");
1686 SysTryReturn(NID_UI,
1687 child.GetControlDelegate().OnDetaching() == E_SUCCESS, E_SYSTEM,
1688 E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent.");
1691 GetControlDelegate().OnChildDetaching(child);
1694 r = GetVisualElement()->DetachChild(*child.GetVisualElement());
1695 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1697 ControlList& children = GetChildList();
1698 r = children.Remove(&child);
1699 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1701 // Remove control to layout
1702 if (child.__area == _CONTROL_AREA_CLIENT)
1704 _ControlManager* pMgr = _ControlManager::GetInstance();
1705 r = GetLastResult();
1706 SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r));
1708 #if !defined(MULTI_WINDOW)
1709 if (this != &(pMgr->GetRoot()))
1712 r = __pLayoutContainer->RemoveItem(child.GetLayoutContainer());
1713 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1717 child.SetParent(null);
1718 child.__area = _CONTROL_AREA_NONE;
1719 child.__layer = _CONTROL_LAYER_NONE;
1721 GetControlDelegate().OnChildDetached(child);
1724 SysAssert(GetLastResult() == E_SUCCESS);
1730 _Control::DetachAllChildren(bool detachSystemChild)
1733 result r = E_SUCCESS;
1735 int notDetachedChildCount = 0;
1737 int childCount = GetChildCount();
1740 while (childCount--)
1742 _Control* pChild = GetChild(itemIndex);
1748 if (!detachSystemChild && (pChild->GetArea() == _CONTROL_AREA_SYSTEM))
1753 r = DetachChild(*pChild);
1757 ++notDetachedChildCount;
1761 SysLog(NID_UI, "%d children are not detached from this container.", notDetachedChildCount);
1767 _Control::MoveChildToTop(const _Control& child)
1770 result r = E_SUCCESS;
1772 SysTryReturn(NID_UI,
1773 child.GetParent() == this, E_INVALID_ARG,
1774 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1776 // If already on top,
1777 ControlList& children = GetChildList();
1778 if (GetChildIndex(child) == children.GetCount() - 1)
1780 SysAssert(GetLastResult() == E_SUCCESS);
1784 _Control* pChild = const_cast <_Control*>(&child);
1786 r = children.Remove(pChild);
1787 SysAssert(r == E_SUCCESS);
1789 r = children.Add(pChild);
1790 SysAssert(r == E_SUCCESS);
1792 r = child.GetVisualElement()->SetZOrder(null, true);
1793 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1795 SysAssert(GetLastResult() == E_SUCCESS);
1801 _Control::MoveChildToBottom(const _Control& child)
1804 result r = E_SUCCESS;
1806 SysTryReturn(NID_UI,
1807 child.GetParent() == this, E_INVALID_ARG,
1808 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1810 ControlList& children = GetChildList();
1812 if (GetChildIndex(child) == 0)
1814 SysAssert(GetLastResult() == E_SUCCESS);
1818 _Control* pChild = const_cast <_Control*>(&child);
1820 r = children.Remove(pChild);
1821 SysAssert(r == E_SUCCESS);
1823 r = children.InsertAt(pChild, 0);
1824 SysAssert(r == E_SUCCESS);
1826 r = child.GetVisualElement()->SetZOrder(null, false);
1827 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1829 SysAssert(GetLastResult() == E_SUCCESS);
1835 _Control::MoveChildAfter(const _Control& targetChild, const _Control& child)
1838 result r = E_SUCCESS;
1840 SysTryReturn(NID_UI,
1841 targetChild.GetParent() == this, E_INVALID_ARG,
1842 E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child.");
1844 SysTryReturn(NID_UI,
1845 child.GetParent() == this, E_INVALID_ARG,
1846 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1848 SysTryReturn(NID_UI,
1849 &targetChild != &child, E_INVALID_ARG,
1850 E_INVALID_ARG, "[E_INVALID_ARG] Cannot move after self.");
1852 ControlList& children = GetChildList();
1854 int targetIndex = GetChildIndex(targetChild);
1855 SysAssert(targetIndex != -1);
1857 if (targetIndex + 1 == GetChildIndex(child))
1859 SysAssert(GetLastResult() == E_SUCCESS);
1863 _Control* pChild = const_cast <_Control*>(&child);
1865 r = children.Remove(pChild);
1866 SysAssert(r == E_SUCCESS);
1868 r = children.InsertAt(pChild, targetIndex + 1);
1869 SysAssert(r == E_SUCCESS);
1871 r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), true);
1872 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1874 SysAssert(GetLastResult() == E_SUCCESS);
1880 _Control::MoveChildBefore(const _Control& targetChild, const _Control& child)
1883 result r = E_SUCCESS;
1885 SysTryReturn(NID_UI,
1886 targetChild.GetParent() == this, E_INVALID_ARG,
1887 E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child.");
1889 SysTryReturn(NID_UI,
1890 child.GetParent() == this, E_INVALID_ARG,
1891 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1893 SysTryReturn(NID_UI,
1894 &targetChild != &child, E_INVALID_ARG,
1895 E_INVALID_ARG, "[E_INVALID_ARG] Cannot move before self.");
1897 ControlList& children = GetChildList();
1899 int targetIndex = GetChildIndex(targetChild);
1900 SysAssert(targetIndex != -1);
1902 if (targetIndex - 1 == GetChildIndex(child))
1904 SysAssert(GetLastResult() == E_SUCCESS);
1908 _Control* pChild = const_cast <_Control*>(&child);
1910 r = children.Remove(pChild);
1911 SysAssert(r == E_SUCCESS);
1913 r = children.InsertAt(pChild, targetIndex);
1914 SysAssert(r == E_SUCCESS);
1916 r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), false);
1917 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1919 SysAssert(GetLastResult() == E_SUCCESS);
1926 _Control::GetChildIndex(const _Control& child) const
1929 result r = E_SUCCESS;
1931 SysTryReturn(NID_UI,
1932 child.GetParent() == this, -1,
1933 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1935 const ControlList& children = GetChildList();
1938 r = children.IndexOf(const_cast<_Control*>(&child), index);
1941 SysAssert(r == E_OBJ_NOT_FOUND);
1942 SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Unable to find the specified child.");
1946 SysAssert(GetLastResult() == E_SUCCESS);
1952 _Control::GetChild(int index) const
1955 result r = E_SUCCESS;
1957 const ControlList& children = GetChildList();
1959 _Control* pChild = null;
1960 r = children.GetAt(index, pChild);
1963 SysAssert(r == E_OUT_OF_RANGE);
1964 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1968 SysAssert(GetLastResult() == E_SUCCESS);
1973 _Control::GetChildCount(void) const
1976 return GetChildList().GetCount();
1980 _Control::GetHandle(void) const
1982 return __controlHandle;
1986 _Control::GetUserData(void) const
1992 _Control::SetUserData(void* pUserData)
1994 __pUserData = pUserData;
1998 _Control::GetPropertyName(void) const
2001 return Tizen::Ui::Variant(__name);
2005 _Control::GetName(void) const
2007 Variant name = GetProperty("Name");
2009 return name.ToString();
2013 _Control::SetPropertyName(const Variant& name)
2016 __name = name.ToString();
2022 _Control::SetName(const String& name)
2024 SetProperty("Name", Variant(name));
2028 _Control::GetParent(void) const
2034 _Control::GetCanvasN(void) const
2036 return GetCanvasN(Rectangle(0, 0, __bounds.width, __bounds.height));
2040 _Control::GetCanvasN(const Rectangle& bounds) const
2043 Canvas *pCanvas = GetControlDelegate().OnCanvasRequestedN(Dimension(bounds.width, bounds.height));
2044 if (pCanvas == null)
2046 GetVisualElement()->SetFlushNeeded();
2047 pCanvas = GetVisualElement()->GetCanvasN(bounds);
2048 if (IsFailed(GetLastResult()))
2050 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
2053 if (pCanvas && !__isCalledGetCanvasN)
2055 pCanvas->SetBackgroundColor(GetBackgroundColor());
2057 const_cast <_Control*>(this)->__isCalledGetCanvasN = true;
2064 _Control::IsCalledGetCanvasN(void) const
2066 return __isCalledGetCanvasN;
2070 _Control::GetClientCanvasN(void) const
2072 return GetCanvasN(GetClientBounds());
2076 _Control::IsAncestorOf(const _Control& control) const
2080 const _Control* pParent = control.GetParent();
2090 const _Control& __ancestor;
2095 _Visitor(const _Control& ancestor)
2096 : __ancestor(ancestor)
2099 virtual VisitType Visit(_Control& control)
2101 if (&__ancestor == &control)
2108 return VISIT_UPWARD;
2113 _Visitor visitor(*this);
2114 pParent->Accept(visitor);
2116 SysAssert(GetLastResult() == E_SUCCESS);
2121 _Control::GetRootWindow(void) const
2133 virtual VisitType Visit(_Control& control)
2135 pRoot = dynamic_cast <_Window*>(&control);
2141 return VISIT_UPWARD;
2148 SysAssert(GetLastResult() == E_SUCCESS);
2149 return visitor.pRoot;
2153 _Control::IsAttachedToMainTree(void) const
2157 _ControlManager* pMgr = _ControlManager::GetInstance();
2163 #if !defined(MULTI_WINDOW)
2164 if (this == &(pMgr->GetRoot()))
2170 _Window* pRootWindow = GetRootWindow();
2171 if (pRootWindow == null)
2176 return pRootWindow->IsAttached();
2180 _Control::IsFocusable(void) const
2187 _Control::SetFocusable(bool focusable)
2190 __focusable = focusable;
2194 _Control::IsNativeObjectFocusable(void) const
2197 return __nativeObjectFocusable;
2201 _Control::SetNativeObjectFocusable(bool focusable)
2204 __nativeObjectFocusable = focusable;
2208 _Control::IsFocused(void) const
2217 for (int i = 0; i < GetChildCount(); ++i)
2219 _Control* pChild = GetChild(i);
2227 if (pChild->__focusSet)
2237 _Control::GetFocused(void) const
2239 for (int i = GetChildCount() - 1; i >= 0; --i)
2241 _Control* pChild = GetChild(i);
2249 if (pChild->__focusSet == true)
2251 return pChild->GetFocused();
2255 if (__focusSet == true)
2257 return const_cast <_Control*>(this);
2267 _Control::SetFocused(void)
2271 SysTryReturn(NID_UI,
2272 IsAttachedToMainTree(), E_INVALID_OPERATION,
2273 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control should have a parent or be attached to the main tree.");
2275 SysTryReturn(NID_UI,
2276 IsFocusable(), E_INVALID_OPERATION,
2277 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This Control isn't focusable control.");
2279 _Window* pTop = GetRootWindow();
2282 pTop->SetFocusOff(this);
2285 _ControlManager* pControlMgr = _ControlManager::GetInstance();
2286 SysAssert(pControlMgr);
2288 if (pTop->IsActivated() && pTop->IsFocusableDescendant(this))
2290 pControlMgr->SetFocusedControl(*this); // Dangerous if _Control::Manager::SetFocusedControl() is called by User.
2293 if (IsFailed(GetLastResult()))
2295 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
2302 // [ToDo] Assume the control is attached to the main tree.
2304 _Control::SetFocusOn(void)
2309 _Control* pParent = GetParent();
2312 pParent->SetFocusOn();
2316 // [ToDo] Find the focused descendent and clear flags upwards.
2318 _Control::SetFocusOff(_Control* pFocus)
2323 for (int i = 0; i < GetChildCount(); ++i)
2325 _Control* pChild = GetChild(i);
2333 if (pChild->__focusSet == true)
2335 pChild->SetFocusOff(pFocus);
2342 _Control::SetFont(const String& fontName)
2344 result r = E_SUCCESS;
2346 if (__fontName.Equals(fontName))
2351 __isControlFontChanged = true;
2352 __fontName = fontName;
2354 Font* pFont = GetFallbackFont();
2358 r = GetLastResult();
2359 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2365 _Control::GetFallbackFont(void)
2367 unsigned long style;
2369 result r = E_SUCCESS;
2370 _IControlDelegate& delegate = GetControlDelegate();
2371 delegate.OnFontInfoRequested(style, textSize);
2372 _ControlManager* pControlManager = _ControlManager::GetInstance();
2374 if (!(__isControlFontChanged || pControlManager->IsDefaultFontChanged()) && __pFont != null && __pFont->GetSize() == textSize)
2378 unique_ptr<Font>pTempFont(new(std::nothrow)Font());
2379 SysTryReturn(NID_UI , pTempFont , null , E_OUT_OF_MEMORY, "[%s] Fails to create a __pFont.", GetErrorMessage(r));
2381 if (!__fontName.IsEmpty())
2383 __isControlFontChanged = false;
2384 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2385 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2387 r = pFontImpl->Construct(__fontName, style, textSize, false);
2388 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2389 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2391 else if (!pControlManager->GetDefaultFont().IsEmpty())
2393 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2394 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2396 r = pFontImpl->Construct(pControlManager->GetDefaultFont(), style, textSize, false);
2397 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2398 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2402 r = pTempFont->Construct(style, textSize);
2403 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2404 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2412 __pFont = pTempFont.release();
2413 delegate.OnFontChanged(__pFont);
2418 _Control::GetFont(void) const
2424 _Control::IsEnabled(void) const
2436 virtual VisitType Visit(_Control& control)
2438 if (!control.GetEnableState())
2444 return VISIT_UPWARD;
2450 return visitor.enabled;
2454 _Control::GetEnableState(void) const
2457 return __enabledState;
2461 _Control::SetEnableState(bool enabledState)
2464 const bool changed = (__enabledState != enabledState);
2465 __enabledState = enabledState;
2468 CallOnAncestorEnableStateChanged();
2470 __pAccessibilityContainer->SetEnableState(enabledState);
2474 _Control::IsInputEnabled(void) const
2484 : inputEnabled(true){}
2486 virtual VisitType Visit(_Control& control)
2488 if (!control.GetInputEnableState())
2490 inputEnabled = false;
2494 return VISIT_UPWARD;
2500 return visitor.inputEnabled;
2504 _Control::GetInputEnableState(void) const
2507 return __inputEnabledState;
2511 _Control::SetInputEnableState(bool inputEnabledState)
2514 __inputEnabledState = inputEnabledState;
2518 _Control::IsVisible(void) const
2522 SysTryReturn(NID_UI, IsAttachedToMainTree(), false, E_SYSTEM, "[E_SYSTEM] This control should be attached to the main tree.");
2532 virtual VisitType Visit(_Control& control)
2534 if (!control.GetVisibleState())
2540 return VISIT_UPWARD;
2547 SysAssert(GetLastResult() == E_SUCCESS);
2548 return visitor.visible;
2552 _Control::GetVisibleState(void) const
2555 return __visibleState;
2559 _Control::SetVisibleState(bool visibleState)
2563 const bool changed = (__visibleState != visibleState) || !__initVisibleState;
2567 GetControlDelegate().OnVisibleStateChanging();
2570 __visibleState = visibleState;
2571 GetVisualElement()->SetShowState(visibleState);
2573 if (visibleState == false)
2575 int owneeCount = GetOwneeCount();
2576 for (int i = 0; i < owneeCount; ++i)
2578 _Window* pWindow = GetOwnee(i);
2581 pWindow->SetVisibleState(visibleState);
2588 GetControlDelegate().OnVisibleStateChanged();
2589 CallOnAncestorVisibleStateChanged();
2591 _Control* pParent = GetParent();
2594 pParent->GetControlDelegate().OnChildVisibleStateChanged(*this);
2600 __initVisibleState = true;
2604 _Control::IsLayoutable(void) const
2611 _Control::IsClipToParent(void) const
2614 // SysAssert(GetVisualElement()->IsClipToParent() == __clipToParent);
2615 return __clipToParent;
2619 _Control::SetClipToParent(bool clipToParent)
2622 result r = E_SUCCESS;
2624 __clipToParent = clipToParent;
2625 r = GetVisualElement()->SetClipToParent(clipToParent);
2626 SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
2632 _Control::SetClipChildrenEnabled(bool clipChildren)
2635 //result r = E_SUCCESS;
2637 GetVisualElement()->SetClipChildrenEnabled(clipChildren);
2638 //SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
2644 _Control::GetBounds(void) const
2651 _Control::GetPosition(void) const
2654 return Point(__bounds.x, __bounds.y);
2658 _Control::GetSize(void) const
2661 return Dimension(__bounds.width, __bounds.height);
2666 _Control::UpdateBoundsOfVisualElement(const FloatRectangle& controlBounds)
2668 FloatRectangle rect(controlBounds.x, controlBounds.y, controlBounds.width, controlBounds.height);
2670 _Control* pParent = GetParent();
2671 if (__area == _CONTROL_AREA_CLIENT && pParent)
2673 const Rectangle clientBounds = pParent->GetClientBounds();
2674 rect.x += (float)clientBounds.x;
2675 rect.y += (float)clientBounds.y;
2678 GetVisualElement()->SetBounds(rect);
2684 _Control::IsInSizeRange(const Dimension& size)
2686 return (__minSize.width <= size.width) && (size.width <= __maxSize.width) &&
2687 (__minSize.height <= size.height) && (size.height <= __maxSize.height);
2690 // Custom Exception: ex) Location::Map
2692 _Control::SetBoundsFinal(const FloatRectangle& newBounds, bool changeLayoutBaseRect, bool callBoundsChangeCallbacks)
2694 result r = E_SUCCESS;
2696 Rectangle bounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height);
2698 _IControlDelegate& delegate = GetControlDelegate();
2700 const bool moved = (__bounds.x != bounds.x) || (__bounds.y != bounds.y);
2701 const bool resized = (__bounds.width != bounds.width) || (__bounds.height != bounds.height);
2703 if ((moved || resized) && callBoundsChangeCallbacks)
2705 r = delegate.OnBoundsChanging(bounds);
2708 SysLogException(NID_UI, r, "[%s] Callback returns exception.", GetErrorMessage(r));
2709 return r; // Relay the result;
2713 if (moved || resized)
2715 const FloatRectangle fbounds(bounds.x, bounds.y, bounds.width, bounds.height);
2716 if (IsLayoutChangable() == false)
2718 r = UpdateBoundsOfVisualElement(FloatRectangle(0, 0, fbounds.width, fbounds.height));
2722 r = UpdateBoundsOfVisualElement(fbounds);
2726 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2730 if (changeLayoutBaseRect)
2732 __pLayoutContainer->OnChangeBaseRect();
2735 if ((moved || resized) && callBoundsChangeCallbacks)
2737 if (IsMovable() && IsResizable())
2739 SetClientBounds(Rectangle(0, 0, GetSize().width, GetSize().height));
2741 delegate.OnBoundsChanged();
2743 _Control* pParent = GetParent();
2746 pParent->GetControlDelegate().OnChildBoundsChanged(*this);
2749 ControlList& children = GetChildList();
2750 _Control* pChild = null;
2751 int childrenCount = children.GetCount();
2753 for (int index = 0; index < childrenCount; index++)
2755 r = children.GetAt(index, pChild);
2758 pChild->GetControlDelegate().OnParentBoundsChanged(*this);
2767 // Custom Exception: ex) Location::Map
2769 _Control::AdjustSizeToRange(void)
2772 result r = E_SUCCESS;
2774 SysAssert(IsResizable());
2776 Dimension size = GetSize();
2777 bool changed = ::AdjustSizeToRange(size, __minSize, __maxSize);
2783 FloatRectangle newBounds(__bounds.x, __bounds.y, size.width, size.height);
2784 r = SetBoundsFinal(newBounds, true, true);
2793 // Custom Exception: ex) Location::Map
2796 _Control::SetBoundsInternal(const FloatRectangle& bounds, bool callBoundsChangeCallbacks)
2798 SysTryReturn(NID_UI,
2799 IsInSizeRange(Dimension(bounds.width, bounds.height)), E_INVALID_ARG,
2801 "[E_INVALID_ARG] The specified size(%f, %f) is out of range from min size(%d, %d) to max size(%d, %d).",
2802 bounds.width, bounds.height, __minSize.width, __minSize.height, __maxSize.width, __maxSize.height);
2804 SetUpdateLayoutState(true);
2806 return SetBoundsFinal(bounds, true, callBoundsChangeCallbacks);
2809 // Custom Exception: ex) Location::Map
2811 // E_UNSUPPORTED_OPERATION
2813 _Control::SetBounds(const Rectangle& bounds, bool callBoundsChangeCallbacks)
2817 if (callBoundsChangeCallbacks)
2819 SysTryReturn(NID_UI,
2820 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
2821 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
2823 FloatRectangle floatBounds(bounds.x, bounds.y, bounds.width, bounds.height);
2825 return SetBoundsInternal(floatBounds, callBoundsChangeCallbacks);
2828 // Custom Exception: ex) Location::Map
2830 // E_UNSUPPORTED_OPERATION
2832 _Control::SetBounds(const FloatRectangle& bounds, bool callBoundsChangeCallbacks)
2836 if (callBoundsChangeCallbacks)
2838 SysTryReturn(NID_UI,
2839 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
2840 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
2843 return SetBoundsInternal(bounds, callBoundsChangeCallbacks);
2846 // A custom Exception can occur. ex) Location::Map
2848 // E_UNSUPPORTED_OPERATION
2850 _Control::SetPosition(const Point& position)
2854 SysTryReturn(NID_UI,
2855 IsMovable(), E_UNSUPPORTED_OPERATION,
2856 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable.");
2858 return SetBoundsInternal(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height), true);
2861 // Custom Exception: ex) Location::Map
2863 // E_UNSUPPORTED_OPERATION
2865 _Control::SetSize(const Dimension& size)
2869 SysTryReturn(NID_UI,
2870 IsResizable(), E_UNSUPPORTED_OPERATION,
2871 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
2873 return SetBoundsInternal(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height), true);
2877 _Control::GetMinimumSize(void) const
2885 _Control::GetMaximumSize(void) const
2892 // Custom Exception: ex) Location::Map
2893 // E_UNSUPPORTED_OPERATION
2896 _Control::SetMinimumSize(const Dimension& newMinSize)
2900 SysTryReturn(NID_UI,
2901 IsResizable(), E_UNSUPPORTED_OPERATION,
2902 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
2904 SysTryReturn(NID_UI,
2905 (newMinSize.width >= 0 && newMinSize.height >= 0), E_INVALID_ARG,
2906 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
2908 SysTryReturn(NID_UI,
2909 (newMinSize.width <= MAX_LENGTH && newMinSize.height <= MAX_LENGTH), E_INVALID_ARG,
2910 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
2912 if (__maxSize.width < newMinSize.width)
2914 __maxSize.width = newMinSize.width;
2916 if (__maxSize.height < newMinSize.height)
2918 __maxSize.height = newMinSize.height;
2921 __minSize = newMinSize;
2922 return AdjustSizeToRange();
2925 // Custom Exception: ex) Location::Map
2926 // E_UNSUPPORTED_OPERATION
2929 _Control::SetMaximumSize(const Dimension& newMaxSize)
2933 SysTryReturn(NID_UI,
2934 IsResizable(), E_UNSUPPORTED_OPERATION,
2935 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
2937 SysTryReturn(NID_UI,
2938 (newMaxSize.width >= 0 && newMaxSize.height >= 0), E_INVALID_ARG,
2939 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
2941 SysTryReturn(NID_UI,
2942 (newMaxSize.width <= MAX_LENGTH && newMaxSize.height <= MAX_LENGTH), E_INVALID_ARG,
2943 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
2945 if (newMaxSize.width < __minSize.width)
2947 __minSize.width = newMaxSize.width;
2949 if (newMaxSize.height < __minSize.height)
2951 __minSize.height = newMaxSize.height;
2954 __maxSize = newMaxSize;
2955 return AdjustSizeToRange();
2959 _Control::ConvertToControlPosition(const Point& screenPosition) const
2961 Point controlPosition;
2962 Rectangle absoluteBounds = GetAbsoluteBounds();
2964 controlPosition.x = screenPosition.x - absoluteBounds.x;
2965 controlPosition.y = screenPosition.y - absoluteBounds.y;
2967 return controlPosition;
2971 _Control::ConvertToScreenPosition(const Point& controlPosition) const
2973 Point screenPosition;
2974 Rectangle absoluteBounds = GetAbsoluteBounds();
2976 screenPosition.x = controlPosition.x + absoluteBounds.x;
2977 screenPosition.y = controlPosition.y + absoluteBounds.y;
2979 return screenPosition;
2983 _Control::GetClientBounds(void) const
2985 if (!__isSetClientBounds)
2987 return Rectangle(0, 0, __bounds.width, __bounds.height);
2990 return __clientBounds;
2994 _Control::GetClientBounds(const Dimension& size) const
2996 if (!__isSetClientBounds)
2998 return Rectangle(0, 0, size.width, size.height);
3001 return __clientBounds;
3005 _Control::GetAbsoluteBounds(void) const
3007 #if !defined(MULTI_WINDOW)
3009 Rectangle absoluteBounds;
3010 Rectangle clientBounds;
3012 const _Control* pSelf = this;
3013 const _Control* pParent = GetParent();
3016 accumPoint += pSelf->GetPosition();
3021 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent)
3023 clientBounds = pParent->GetClientBounds();
3024 accumPoint += Point(clientBounds.x, clientBounds.y);
3025 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3026 accumPoint.y -= pParent->GetVerticalScrollPosition();
3029 accumPoint += pSelf->GetPosition();
3031 pParent = pParent->GetParent();
3034 absoluteBounds.x = accumPoint.x;
3035 absoluteBounds.y = accumPoint.y;
3036 absoluteBounds.width = __bounds.width;
3037 absoluteBounds.height = __bounds.height;
3039 return absoluteBounds;
3042 Rectangle absoluteBounds;
3043 Rectangle clientBounds;
3045 const _Control* pSelf = this;
3046 const _Control* pParent = GetParent();
3050 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent)
3052 clientBounds = pParent->GetClientBounds();
3053 accumPoint += Point(clientBounds.x, clientBounds.y);
3054 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3055 accumPoint.y -= pParent->GetVerticalScrollPosition();
3058 accumPoint += pSelf->GetPosition();
3060 pParent = pParent->GetParent();
3063 _Window* pWindow = GetRootWindow();
3067 Point winPoint = pWindow->GetPosition();
3069 accumPoint.x += winPoint.x;
3070 accumPoint.y += winPoint.y;
3073 absoluteBounds.x = accumPoint.x;
3074 absoluteBounds.y = accumPoint.y;
3075 absoluteBounds.width = __bounds.width;
3076 absoluteBounds.height = __bounds.height;
3078 return absoluteBounds;
3083 _Control::SetClientBounds(const Rectangle& bounds)
3087 SysTryReturn(NID_UI,
3088 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3089 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3090 __clientBounds = bounds;
3091 __isSetClientBounds = true;
3093 SetUpdateLayoutState(true);
3099 _Control::IsCalledSetClientBounds(void)
3101 return __isSetClientBounds;
3105 _Control::GetBackgroundColor(void) const
3108 return __backgroundColor;
3112 _Control::SetBackgroundColor(const Color& color)
3115 __backgroundColor = color;
3117 _ControlVisualElement* pCVE = dynamic_cast <_ControlVisualElement*>(GetVisualElement());
3120 pCVE->SetBackgroundColor(
3122 (float)color.GetRed() / 255.0f,
3123 (float)color.GetGreen() / 255.0f,
3124 (float)color.GetBlue() / 255.0f,
3125 (float)color.GetAlpha() / 255.0f
3131 _Control::~_Control(void)
3133 __destroying = true;
3135 DetachAllChildren();
3137 _ControlManager::GetInstance()->TakeFocusFromControl(*this);
3147 // Dangerous: it clears last result and log in catch block.
3148 // ClearLastResult();
3152 _Control::DisposeControl(void)
3154 __pControlDelegate = null;
3156 delete __pLayoutItemHandler;
3157 __pLayoutItemHandler = null;
3159 delete __pLayoutContainer;
3160 __pLayoutContainer = null;
3168 if (__pVisualElement)
3170 __pVisualElement->Destroy();
3172 __pVisualElement = null;
3174 delete __pVisualElementContentProvider;
3175 __pVisualElementContentProvider = null;
3177 delete __pVisualElementEventListener;
3178 __pVisualElementEventListener = null;
3180 delete __pCoreGestureDetectors;
3181 __pCoreGestureDetectors = null;
3183 delete __pDataBindingContext;
3184 __pDataBindingContext = null;
3186 ClearStartedGestureDetectorList();
3187 delete __pDetectStartedGestureMap;
3188 __pDetectStartedGestureMap = null;
3190 delete __pDelayedTouchInfoList;
3191 __pDelayedTouchInfoList = null;
3193 delete __pAccessibilityContainer;
3194 __pAccessibilityContainer = null;
3199 _Control::_Control(void)
3204 , __bounds(0, 0, 0, 0)
3205 , __clientBounds(0, 0, 0, 0)
3206 , __absoluteBounds(0, 0, 0, 0)
3207 , __invalidatedBounds(0, 0, 0, 0)
3208 , __minSize(Dimension(0, 0))
3209 , __maxSize(Dimension(MAX_LENGTH, MAX_LENGTH))
3210 , __backgroundColor(Color::GetColor(COLOR_ID_BLACK))
3214 , __nativeObjectFocusable(true)
3215 , __enabledState(true)
3216 , __inputEnabledState(true)
3217 , __visibleState(true)
3218 , __initVisibleState(false)
3219 , __clipToParent(true)
3221 , __multiTouchEnabled(false)
3222 , __dragEnabled(false)
3223 , __dropEnabled(false)
3224 , __drawWhenVisible(true)
3225 , __isPostOrderTraversal(false)
3226 , __isCalledCallOnAttachingToMainTree(false)
3227 , __isCalledCallOnAttachedToMainTree(false)
3228 , __isSetClientBounds(false)
3229 , __isCalledGetCanvasN(false)
3230 , __pVisualElementContentProvider(null)
3231 , __pVisualElement(null)
3232 , __pVisualElementEventListener(null)
3233 , __pLayoutItemHandler(null)
3234 , __pPortraitLayout(null)
3235 , __pLandscapeLayout(null)
3236 , __pLayoutContainer(null)
3237 , __area(_CONTROL_AREA_NONE)
3238 , __layer(_CONTROL_LAYER_NONE)
3239 , __orientation(_CONTROL_ORIENTATION_PORTRAIT)
3240 , __pTouchEventPreviewer(null)
3241 , __pKeyEventPreviewer(null)
3242 , __pNotificationEventPreviewer(null)
3243 , __pKeyEventListener(null)
3244 , __pFocusEventListener(null)
3245 , __pNotificationEventListener(null)
3246 , __pCoreGestureDetectors(null)
3247 , __pDetectStartedGestureMap(null)
3248 , __pDelayedTouchInfoList(null)
3249 ,__touchMoveAllowance(TOUCH_MOVE_ALLOWANCE_SENSITIVE)
3250 , __isSentDelayedEvent(false)
3251 , __isSendingDelayedEvent(false)
3252 , __isChangingEventTarget(false)
3253 , __pDataBindingContext(null)
3254 , __pControlDelegate(null)
3256 , __destroying(false)
3257 , __isEventReceivable(true)
3258 , __isControlFontChanged(false)
3264 SetControlDelegate(*this);
3265 __pAccessibilityContainer = new (std::nothrow) _AccessibilityContainer(*this);
3267 __pLayoutItemHandler = new (std::nothrow) LayoutItemHandler(this);
3268 if (!__pLayoutItemHandler)
3273 __pLayoutContainer = CreateLayoutContainerN(__pLayoutItemHandler);
3274 if (!__pLayoutContainer)
3279 __pChildren = ::CreateControlListN();
3285 __pOwnees = ::CreateWindowListN();
3291 __pVisualElement = ::CreateVisualElementN();
3292 if (!__pVisualElement)
3297 __pVisualElement->SetUserData(this);
3298 __pVisualElement->SetClipChildrenEnabled(true);
3299 __pVisualElement->SetRedrawOnResizeEnabled(true);
3301 __pVisualElementContentProvider = new (std::nothrow) ControlVisualElementContentProvider(*this);
3302 SysTryCatch(NID_UI, __pVisualElementContentProvider, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
3304 GetVisualElement()->SetContentProvider(__pVisualElementContentProvider);
3306 __pVisualElementEventListener = new (std::nothrow) ControlVisualElementEventListener(*this);
3307 SysTryCatch(NID_UI, __pVisualElementEventListener, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
3309 GetVisualElement()->SetVisualElementEventListener(__pVisualElementEventListener);
3311 __pDetectStartedGestureMap = ::CreateGestureMapN();
3312 if (!__pDetectStartedGestureMap)
3317 __pCoreGestureDetectors = new (std::nothrow) LinkedListT<_TouchGestureDetector*>;
3318 if (!__pCoreGestureDetectors)
3323 __pDelayedTouchInfoList = new (std::nothrow) LinkedListT<_TouchInfo*>;
3324 if (!__pDelayedTouchInfoList)
3329 SetEventPreviewer<_UI_EVENT_TOUCH>(this);
3330 SetEventPreviewer<_UI_EVENT_KEY>(this);
3331 SetEventPreviewer<_UI_EVENT_NOTIFICAITON>(this);
3333 SetEventListener<_UI_EVENT_NOTIFICAITON>(this);
3334 SetEventListener<_UI_EVENT_FOCUS>(this);
3336 SetPropagatedTouchEventListener(this);
3337 SetPropagatedKeyEventListener(this);
3338 _ResourceManager::GetInstance()->GetColor(L"DEFAULTCOLORTABLE::background", __backgroundColor);
3340 if (IsFailed(GetLastResult()))
3342 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
3353 _Control::AcquireHandle(void)
3355 __controlHandle = _ControlManager::GetInstance()->Register(this); // [ToDo] exception?
3359 _Control::ReleaseHandle(void)
3361 _ControlManager::GetInstance()->Release(__controlHandle); // [ToDo] exception?
3365 _Control::SetDrawWhenVisible(bool draw)
3367 __drawWhenVisible = draw;
3371 _Control::IsDrawWhenVisible(void)
3373 return __drawWhenVisible;
3377 _Control::SetTerminatingOrder(bool postOrderTraversal)
3379 __isPostOrderTraversal = postOrderTraversal;
3383 _Control::SetParent(_Control* pParent)
3386 __pParent = pParent;
3390 // Only called by _Window::SetOwner(pOwner)
3392 _Control::AttachOwnee(_Window& window)
3395 result r = E_SUCCESS;
3397 _Control* pOldOwner = window.GetOwner();
3400 pOldOwner->DetachOwnee(window);
3403 r = __pOwnees->Add(&window);
3406 SysAssert(r == E_OUT_OF_MEMORY);
3407 SysLogException(NID_UI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
3408 return E_OUT_OF_MEMORY;
3415 _Control::GetOwneeCount(void) const
3418 return __pOwnees->GetCount();
3423 _Control::GetOwnee(int index) const
3426 result r = E_SUCCESS;
3428 _Window* pOwnee = null;
3429 r = __pOwnees->GetAt(index, pOwnee);
3432 SysAssert(r == E_OUT_OF_RANGE);
3433 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
3440 // Called by _Window::SetOwner(null)
3442 _Control::DetachOwnee(_Window& ownee)
3445 result r = E_SUCCESS;
3447 _Control* pOwner = ownee.GetOwner();
3453 r = __pOwnees->Remove(&ownee);
3454 SysAssert(r == E_SUCCESS);
3458 _Control::DetachAllOwnees(void)
3462 int owneeCount = GetOwneeCount();
3463 while (owneeCount--)
3465 _Window* pOwnee = GetOwnee(0);
3473 pOwnee->SetOwner(null);
3477 _Layout::LayoutContainer&
3478 _Control::GetLayoutContainer() const
3480 return *__pLayoutContainer;
3484 _Control::SetMultiTouchEnabled(bool enabled)
3487 __multiTouchEnabled = enabled;
3491 _Control::IsMultiTouchEnabled(void) const
3494 return __multiTouchEnabled;
3498 _Control::SetMovable(bool movable)
3501 __movable = movable;
3505 _Control::SetResizable(bool resizable)
3511 __minSize = __maxSize = GetSize();
3514 if (!__resizable && resizable)
3516 __minSize = Dimension(0, 0);
3517 __maxSize = Dimension(MAX_LENGTH, MAX_LENGTH);
3520 __resizable = resizable;
3524 _Control::GetLayout(void) const
3527 _Layout::Layout* pLayout = __pLayoutContainer->GetLayout();
3529 SysAssert(GetLastResult() == E_SUCCESS);
3534 _Control::SetCurrentLayout(_Layout::Layout& layout)
3537 return __pLayoutContainer->SetCurrentLayout(layout);
3541 _Control::AddLayout(_Layout::Layout& layout)
3544 return __pLayoutContainer->AddLayout(layout);
3548 _Control::SetUpdateLayoutState(bool state)
3550 _Layout::Layout* pLayout = GetLayout();
3553 pLayout->SetUpdateState(state);
3557 _DataBindingContext*
3558 _Control::GetDataBindingContext(void)
3560 return __pDataBindingContext;
3562 _AccessibilityContainer*
3563 _Control::GetAccessibilityContainer(void)
3565 return __pAccessibilityContainer;
3568 _Control::SetDataBindingContext(_DataBindingContext* pDataBindingContext)
3570 __pDataBindingContext = pDataBindingContext;
3574 _Control::GetDescription(void) const
3580 _Control::SetTouchCapture(bool allowOutOfBounds)
3582 _TouchManager* pTouchManager = _TouchManager::GetInstance();
3583 SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null");
3585 pTouchManager->SetCapturedControl(this, allowOutOfBounds);
3589 _Control::ReleaseTouchCapture(void)
3591 _TouchManager* pTouchManager = _TouchManager::GetInstance();
3592 SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null");
3594 pTouchManager->SetCapturedControl(null, false);
3598 _Control::GetTopmostChildAt(const Point& point) const
3600 _Control* pTouchedControl = null;
3601 FloatPoint ptf((float) point.x, (float) point.y);
3602 _ControlManager* pControlManager = _ControlManager::GetInstance();
3603 SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist.");
3605 #if !defined(MULTI_WINDOW)
3606 _ControlVisualElement* pRootControlElement =
3607 dynamic_cast <_ControlVisualElement*>(pControlManager->GetRoot().GetVisualElement());
3609 _Window* pRootWindow = GetRootWindow();
3610 SysTryReturn(NID_UI, pRootWindow, null, E_SYSTEM, "[E_SYSTEM] GetRootWindow() is null, this control is detached from the main trree");
3612 _ControlVisualElement* pRootControlElement =
3613 dynamic_cast <_ControlVisualElement*>(pRootWindow->GetVisualElement());
3616 SysTryReturn(NID_UI, pRootControlElement, null, E_SYSTEM, "[E_SYSTEM] pRootControlElement is null.");
3618 _ControlVisualElement* pHitTestElm = pRootControlElement->GetControlChildAtPoint(ptf);
3619 SysTryReturn(NID_UI, pHitTestElm, null, E_SYSTEM, "[E_SYSTEM] pHitTestElm is null.");
3621 pTouchedControl = static_cast <_Control*>(pHitTestElm->GetUserData());
3623 return pTouchedControl;
3627 _Control::GetCapturedBitmapN(bool includeChildren) const
3629 result r = E_SUCCESS;
3631 Canvas* pCanvas = null;
3632 Bitmap* pBitmap = null;
3634 pBitmap = GetControlDelegate().OnCapturedBitmapRequestedN();
3635 if (pBitmap == null)
3637 FloatRectangle rect;
3639 Rectangle boundsInCanvas = GetBounds();
3640 boundsInCanvas.x = boundsInCanvas.y = 0;
3642 pCanvas = new (std::nothrow) Canvas;
3643 SysTryReturn(NID_UI, pCanvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
3645 r = pCanvas->Construct(boundsInCanvas);
3646 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
3648 GetVisualElement()->Draw();
3649 ClearLastResult(); // [ToDo] Temp.
3651 rect.SetBounds(boundsInCanvas.x, boundsInCanvas.y, boundsInCanvas.width, boundsInCanvas.height);
3653 r = GetVisualElement()->Capture(*pCanvas, rect, includeChildren);
3654 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
3656 pBitmap = new (std::nothrow) Bitmap;
3657 SysTryCatch(NID_UI, pBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
3659 r = pBitmap->Construct(*pCanvas, boundsInCanvas);
3662 SysAssert(r == E_OUT_OF_MEMORY);
3663 SysTryCatch(NID_UI, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
3666 SysLog(NID_UI, "Bitmap (width:%d, height:%d)", pBitmap->GetWidth(), pBitmap->GetHeight());
3681 Tizen::Graphics::Rectangle
3682 _Control::GetInvalidatedBounds(void) const
3684 return __invalidatedBounds;
3688 _Control::AddGestureDetector(const _TouchGestureDetector& gestureDetector)
3692 bool exist = __pCoreGestureDetectors->Contains(const_cast<_TouchGestureDetector*>(&gestureDetector));
3693 SysTryReturnResult(NID_UI, exist == false, E_OBJ_ALREADY_EXIST, "[E_OBJ_ALREADY_EXIST]__pCoreGestureDetectors has gesture already");
3695 result r = __pCoreGestureDetectors->Add(const_cast<_TouchGestureDetector*>(&gestureDetector));
3696 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3698 r = const_cast<_TouchGestureDetector&>(gestureDetector).SetControl(*this);
3699 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "Control handle is not valid.");
3705 _Control::RemoveGestureDetector(const _TouchGestureDetector& gestureDetector)
3709 result r = __pCoreGestureDetectors->Remove(&(const_cast<_TouchGestureDetector&>(gestureDetector)));
3710 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3715 IListT <_TouchGestureDetector*>*
3716 _Control::GetGestureDetectorList(void) const
3718 return __pCoreGestureDetectors;
3721 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>*
3722 _Control::GetStartedGestureDetectorEnumeratorN(void) const
3724 return __pDetectStartedGestureMap->GetMapEnumeratorN();
3728 _Control::AddStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state)
3732 result r = E_SUCCESS;
3735 __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist);
3739 r = __pDetectStartedGestureMap->Add(const_cast<_TouchGestureDetector*>(&gestureDetector), state);
3746 _Control::SetStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state)
3750 result r = E_SUCCESS;
3753 __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist);
3757 r = __pDetectStartedGestureMap->SetValue(const_cast<_TouchGestureDetector*>(&gestureDetector), state);
3764 _Control::ClearStartedGestureDetectorList(void)
3768 result r = E_SUCCESS;
3770 IListT<_TouchGestureDetector*>* pList = __pDetectStartedGestureMap->GetKeysN();
3773 IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pList->GetEnumeratorN();
3776 while(pEnumerator->MoveNext() == E_SUCCESS)
3778 _TouchGestureDetector* pGestureDetector = null;
3779 pEnumerator->GetCurrent(pGestureDetector);
3781 if (pGestureDetector == null)
3786 __pDetectStartedGestureMap->Remove(pGestureDetector);
3793 IEnumeratorT<_TouchInfo*>* pEnumerator = __pDelayedTouchInfoList->GetEnumeratorN();
3796 while(pEnumerator->MoveNext() == E_SUCCESS)
3798 _TouchInfo* pTouchInfo = null;
3799 pEnumerator->GetCurrent(pTouchInfo);
3800 if (pTouchInfo == null)
3808 __pDelayedTouchInfoList->RemoveAll();
3812 __isSentDelayedEvent = false;
3813 __isSendingDelayedEvent = false;
3819 _Control::IsDelayedTouchEventEnabled(void) const
3821 bool existDelayTouchEventGesture = false;
3823 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
3826 while(pMapEnumerator->MoveNext() == E_SUCCESS)
3828 _TouchGestureDetector* pGestureDetector = null;
3829 pMapEnumerator->GetKey(pGestureDetector);
3831 if (pGestureDetector == null)
3836 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
3837 pMapEnumerator->GetValue(state);
3839 if (pGestureDetector->IsDelayTouchEventEnabled())
3841 existDelayTouchEventGesture = true;
3844 delete pMapEnumerator;
3847 bool delayTouchEvent = false;
3848 if (existDelayTouchEventGesture)
3850 pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
3853 while(pMapEnumerator->MoveNext() == E_SUCCESS)
3855 _TouchGestureDetector* pGestureDetector = null;
3856 pMapEnumerator->GetKey(pGestureDetector);
3858 if (pGestureDetector == null)
3863 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
3864 pMapEnumerator->GetValue(state);
3866 if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED)
3868 delayTouchEvent = true;
3872 delete pMapEnumerator;
3875 return delayTouchEvent;
3884 _Control::IsPossibleToSendDelayedTouchEvent(void) const
3886 bool existDelayTouchEventGesture = false;
3888 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
3891 while(pMapEnumerator->MoveNext() == E_SUCCESS)
3893 _TouchGestureDetector* pGestureDetector = null;
3894 pMapEnumerator->GetKey(pGestureDetector);
3896 if (pGestureDetector == null)
3901 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
3902 pMapEnumerator->GetValue(state);
3904 if (pGestureDetector->IsDelayTouchEventEnabled())
3906 existDelayTouchEventGesture = true;
3909 delete pMapEnumerator;
3912 bool allFailed = true;
3913 if (existDelayTouchEventGesture)
3915 pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
3918 while(pMapEnumerator->MoveNext() == E_SUCCESS)
3920 _TouchGestureDetector* pGestureDetector = null;
3921 pMapEnumerator->GetKey(pGestureDetector);
3923 if (pGestureDetector == null)
3928 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
3929 pMapEnumerator->GetValue(state);
3931 if (state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS)
3937 delete pMapEnumerator;
3949 _Control::IsCancelOnGestureSuccess(void) const
3951 _TouchManager* pTouchManager = _TouchManager::GetInstance();
3952 SysAssert(pTouchManager != null);
3954 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
3957 while(pMapEnumerator->MoveNext() == E_SUCCESS)
3959 _TouchGestureDetector* pGestureDetector = null;
3960 pMapEnumerator->GetKey(pGestureDetector);
3962 if (pGestureDetector == null)
3967 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
3968 pMapEnumerator->GetValue(state);
3970 if (pGestureDetector->IsCancelTouchEventOnSuccessEnabled() && state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS && !pTouchManager->IsTouchCanceledOnGestureSuccess())
3972 delete pMapEnumerator;
3976 delete pMapEnumerator;
3983 _Control::IsSentDelayedEvent(void) const
3985 return __isSentDelayedEvent;
3989 _Control::SetSentDelayedEvent(bool sent)
3991 __isSentDelayedEvent = sent;
3995 _Control::SetSendingDelayedEvent(bool sending)
3997 __isSendingDelayedEvent = sending;
4001 _Control::IsSendingDelayedEvent(void) const
4003 return __isSendingDelayedEvent;
4007 _Control::AddTouchInfo(const _TouchInfo& touchInfo)
4009 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4010 SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist.");
4012 _TouchInfo* pTouchInfo = new (std::nothrow) _TouchInfo;
4013 SysTryReturnVoidResult(NID_UI, pTouchInfo, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4015 Point screenPoint = pTouchManager->GetScreenPoint(touchInfo.GetPointId());
4016 pTouchInfo->SetTouchInfo(touchInfo.GetPointId(), touchInfo.GetTouchStatus(), screenPoint, false, 0);
4017 __pDelayedTouchInfoList->Add(pTouchInfo);
4020 IListT<_TouchInfo*>*
4021 _Control::GetTouchInfoList(void)
4023 return __pDelayedTouchInfoList;
4027 _Control::GetVisualElement(void) const
4029 SysAssert(__pVisualElement);
4030 return __pVisualElement;
4034 _Control::PrintDescription(bool printChildren)
4036 int count = PrintDescription(printChildren, 0);
4038 SysLog(NID_UI, "%d controls were printed.", count);
4042 _Control::PrintDescription(bool printChildren, int depth)
4047 format.Format(LOG_LEN_MAX, L"%d", depth);
4049 for (int i = 0; i < depth; i++)
4051 indent.Append(L" ");
4054 indent.Append(format);
4056 String delimiter(L"-------------------------------------------------------------------------------------------");
4057 SysLog(NID_UI, "%ls", delimiter.GetPointer());
4060 String publicDescription = GetControlDelegate().GetDescription();
4061 if (!publicDescription.IsEmpty())
4063 SysLog(NID_UI, "%ls %ls", indent.GetPointer(), publicDescription.GetPointer());
4067 SysLog(NID_UI, "%ls 0x%x(%d %ls) enable(%d) enableState(%d) visible(%d) visibleState(%d) focusable(%d) clip(%d) movable(%d) resizable(%d)",
4068 indent.GetPointer(), this, __controlHandle.ToInt(), GetName().GetPointer(), IsEnabled(), GetEnableState(), IsVisible(), GetVisibleState(),
4069 IsFocusable(), IsClipToParent(), IsMovable(), IsResizable());
4071 Rectangle bounds = GetBounds();
4072 Dimension min = GetMinimumSize();
4073 Dimension max = GetMaximumSize();
4074 Rectangle clientBounds = GetClientBounds();
4075 Rectangle absoluteBounds = GetAbsoluteBounds();
4077 SysLog(NID_UI, "%ls bounds(%d %d %d %d) min(%d %d) max(%d %d) scrollPos(%d %d) cbounds(%d %d %d %d) abounds(%d %d %d %d)",
4078 indent.GetPointer(), bounds.x, bounds.y, bounds.width, bounds.height,
4079 min.width, min.height, max.width, max.height,
4080 GetVerticalScrollPosition(), GetHorizontalScrollPosition(),
4081 clientBounds.x, clientBounds.y, clientBounds.width, clientBounds.height,
4082 absoluteBounds.x, absoluteBounds.y, absoluteBounds.width, absoluteBounds.height);
4084 SysLog(NID_UI, "%ls bgColor(0x%x) layoutable(%d) orientation(%d) drag(%d) drop(%d) area(%d) layer(%d)",
4085 indent.GetPointer(), __backgroundColor.GetRGB32(), IsLayoutable(), GetOrientation(), IsDragEnabled(), IsDropEnabled(), GetArea(), GetLayer());
4087 Canvas* pCanvas = GetCanvasN();
4090 Rectangle canvasBounds = pCanvas->GetBounds();
4091 Color canvasBackgroundColor = pCanvas->GetBackgroundColor();
4092 Color canvasForegroundColor = pCanvas->GetForegroundColor();
4094 SysLog(NID_UI, "%ls canvas.bounds(%d %d %d %d) canvas.bgColor(0x%x) canvas.fgColor(0x%x)",
4095 indent.GetPointer(), canvasBounds.x, canvasBounds.y, canvasBounds.width, canvasBounds.height, canvasBackgroundColor.GetRGB32(), canvasForegroundColor.GetRGB32());
4100 SysLog(NID_UI, "%ls DataBindingContext(0x%x) ControlDelegate(0x%x) UserData(0x%x) destroying(%d)",
4101 indent.GetPointer(), __pDataBindingContext, __pControlDelegate, __pUserData, __destroying);
4106 for (int i = 0; i < GetOwneeCount(); ++i)
4109 _Window* pOwnee = GetOwnee(i);
4112 ownee.Format(LOG_LEN_MAX, L"0x%x ", pOwnee);
4113 ownees.Append(ownee);
4117 if (!ownees.IsEmpty())
4119 SysLog(NID_UI, "%ls Ownees(%ls)", indent.GetPointer(), ownees.GetPointer());
4122 SysLog(NID_UI, "%ls VisualElement(0x%x) VisualElementContentProvider(0x%x) VisualElementEventListener(0x%x)",
4123 indent.GetPointer(), GetVisualElement(), __pVisualElementContentProvider, __pVisualElementEventListener);
4126 SysLog(NID_UI, "%ls LayoutItemHandler(0x%x) PortraitLayout(0x%x) LandscapeLayout(0x%x) LayoutContainer(0x%x)",
4127 indent.GetPointer(), __pLayoutItemHandler, __pPortraitLayout, __pLandscapeLayout, __pLayoutContainer);
4130 String description = GetDescription();
4131 if (!description.IsEmpty())
4133 SysLog(NID_UI, "%ls %ls", indent.GetPointer(), description.GetPointer());
4136 // Print Gesture List
4137 IListT<_TouchGestureDetector*>* pGestureList = GetGestureDetectorList();
4138 SysTryReturn(NID_UI, pGestureList, 0, E_SYSTEM, "[E_SYSTEM] System error occurred.");
4140 IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN();
4141 SysTryReturn(NID_UI, pEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4143 while (pEnumerator->MoveNext() == E_SUCCESS)
4145 _TouchGestureDetector* pGestureDetector = null;
4146 pEnumerator->GetCurrent(pGestureDetector);
4147 if (pGestureDetector)
4149 SysLog(NID_UI, "%ls %ls", indent.GetPointer(), pGestureDetector->GetDescription().GetPointer());
4156 static int totalCount = 0;
4167 int count = GetChildCount();
4168 totalCount += count;
4170 for (int i = count - 1; i >= 0; --i)
4172 _Control* pChild = GetChild(i);
4175 pChild->PrintDescription(printChildren, depth);
4183 _ITouchEventPreviewer*
4184 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>) const
4186 return __pTouchEventPreviewer;
4189 _IKeyEventPreviewer*
4190 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_KEY>) const
4192 return __pKeyEventPreviewer;
4195 _INotificationEventPreviewer*
4196 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>) const
4198 return __pNotificationEventPreviewer;
4202 _Control::GetEventListener(_IntToType<_UI_EVENT_KEY>) const
4204 return __pKeyEventListener;
4207 _IFocusEventListener*
4208 _Control::GetEventListener(_IntToType<_UI_EVENT_FOCUS>) const
4210 return __pFocusEventListener;
4213 _INotificationEventListener*
4214 _Control::GetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>) const
4216 return __pNotificationEventListener;
4220 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>, _ITouchEventPreviewer* pPreviewer)
4222 __pTouchEventPreviewer = pPreviewer;
4226 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_KEY>, _IKeyEventPreviewer* pPreviewer)
4228 __pKeyEventPreviewer = pPreviewer;
4232 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventPreviewer* pPreviewer)
4234 __pNotificationEventPreviewer = pPreviewer;
4238 _Control::SetEventListener(_IntToType<_UI_EVENT_FOCUS>, _IFocusEventListener* pListener)
4240 __pFocusEventListener = pListener;
4244 _Control::SetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventListener* pListener)
4246 __pNotificationEventListener = pListener;
4250 _Control::IsDragEnabled(void) const
4252 return __dragEnabled;
4256 _Control::IsDropEnabled(void) const
4258 return __dropEnabled;
4262 _Control::SetDragEnabled(bool enabled)
4264 __dragEnabled = enabled;
4268 _Control::SetDropEnabled(bool enabled)
4270 __dropEnabled = enabled;
4274 _Control::SetTouchMoveAllowance(_TouchMoveAllowance touchMoveAllowanceType)
4276 __touchMoveAllowance = touchMoveAllowanceType;
4280 _Control::GetTouchMoveAllowance(void) const
4282 return __touchMoveAllowance;
4286 _Control::SetChangingEventTarget(bool isChangingEventTarget)
4288 __isChangingEventTarget = isChangingEventTarget;
4292 _Control::GetChangingEventTarget(void) const
4294 return __isChangingEventTarget;
4298 _Control::SetEventReceivable(bool receivable)
4300 __isEventReceivable = receivable;
4304 _Control::IsEventReceivable(void) const
4306 return __isEventReceivable;