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.
24 #include <unique_ptr.h>
25 #include <FBaseColLinkedListT.h>
26 #include <FBaseColArrayListT.h>
27 #include <FBaseColHashMapT.h>
28 #include <FBaseSysLog.h>
29 #include <FGrpFloatRectangle.h>
30 #include <FUiAnimVisualElementContentProvider.h>
31 #include <FBase_Log.h>
32 #include <FGrp_BitmapImpl.h>
33 #include <FSys_SystemInfoImpl.h>
34 #include "FUi_Control.h"
35 #include "FUi_ControlManager.h"
36 #include "FUi_FocusManagerImpl.h"
37 #include "FUi_CoordinateSystemUtils.h"
38 #include "FUi_Window.h"
39 #include "FUi_EcoreEvasMgr.h"
40 #include "FUi_EcoreEvas.h"
41 #include "FUi_LayoutLayoutContainer.h"
42 #include "FUi_LayoutAbsoluteLayout.h"
43 #include "FUi_LayoutILayoutItemHandler.h"
44 #include "FUi_TouchManager.h"
45 #include "FUi_DataBindingContext.h"
46 #include "FUi_TouchLongPressGestureDetector.h"
47 #include "FUi_TouchTapGestureDetector.h"
48 #include "FUi_AccessibilityContainer.h"
49 #include "FUi_ResourceManager.h"
50 #include "FUiAnim_ControlVisualElement.h"
51 #include "FUiAnim_Debug.h"
52 #include "FUiAnim_VisualElement.h"
53 #include "FUiAnim_VisualElementImpl.h"
54 #include "FUiCtrl_Form.h"
55 #include "FUiCtrl_Frame.h"
56 #include "FUi_ContainerImpl.h"
59 using namespace Tizen::Base;
60 using namespace Tizen::Base::Collection;
61 using namespace Tizen::Base::Runtime;
62 using namespace Tizen::Graphics;
63 using namespace Tizen::Ui;
64 using namespace Tizen::Ui::Animations;
65 using namespace Tizen::Ui::Controls;
70 GetZOrderGroupOfVisualElement(_ControlLayer layer)
74 case _CONTROL_LAYER_OVERLAY:
75 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL - 1;
76 case _CONTROL_LAYER_CLIENT_BOTTOM:
77 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL;
78 case _CONTROL_LAYER_NONE:
80 case _CONTROL_LAYER_CLIENT_MIDDLE:
81 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 1;
82 case _CONTROL_LAYER_CLIENT_TOP:
83 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 2;
84 case _CONTROL_LAYER_SYSTEM:
85 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 3;
88 return _ControlVisualElement::Z_ORDER_GROUP_CONTROL + 1;
93 AdjustSizeToRange(float& width, float& height, const FloatDimension& minDim, const FloatDimension& maxDim)
96 if (width < minDim.width)
101 if (height < minDim.height)
103 height = minDim.height;
107 if (width > maxDim.width)
109 width = maxDim.width;
112 if (height > maxDim.height)
114 height = maxDim.height;
122 AdjustSizeToRange(FloatDimension& dim, const FloatDimension& minDim, const FloatDimension& maxDim)
124 return AdjustSizeToRange(dim.width, dim.height, minDim, maxDim);
129 _ControlVisualElement*
130 CreateVisualElementN(void)
134 _ControlVisualElement* pVisualElement = new (std::nothrow) _ControlVisualElement;
135 SysTryReturn(NID_UI, pVisualElement, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
138 pVisualElement->ConstructControlVisualElement() == E_SUCCESS, ,
139 E_SYSTEM, "[E_SYSTEM] System error occurred.");
141 pVisualElement->SetImplicitAnimationEnabled(false);
142 pVisualElement->SetShowState(true);
143 pVisualElement->SetBackBufferEnabled(true);
144 pVisualElement->SetRedrawOnResizeEnabled(true);
145 pVisualElement->SetSurfaceOpaque(false);
147 return pVisualElement;
150 //delete pVisualElement;
151 pVisualElement->Destroy();
155 _Control::GestureMap*
156 CreateGestureMapN(void)
160 _Control::GestureMap* pGestureMap = new (std::nothrow) _Control::GestureMap;
161 SysTryReturn(NID_UI, pGestureMap, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
164 pGestureMap->Construct() == E_SUCCESS, ,
165 E_SYSTEM, "[E_SYSTEM] System error occurred.");
175 _Control::ControlList*
176 CreateControlListN(void)
180 _Control::ControlList* pControlList = new (std::nothrow) _Control::ControlList;
181 SysTryReturn(NID_UI, pControlList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
187 _Control::WindowList*
188 CreateWindowListN(void)
192 _Control::WindowList* pWindowList = new (std::nothrow) _Control::WindowList;
193 SysTryReturn(NID_UI, pWindowList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
200 _Layout::LayoutContainer*
201 CreateLayoutContainerN(_Layout::ILayoutItemHandler* pLayoutItemHandler)
204 result r = E_SUCCESS;
206 _Layout::LayoutContainer* pLayoutContainer = null;
207 _Layout::AbsoluteLayout* pAbsLayout = null;
209 pLayoutContainer = new (std::nothrow) _Layout::LayoutContainer();
210 SysTryReturn(NID_UI, pLayoutContainer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage");
211 if (IsFailed(GetLastResult()))
216 pAbsLayout = new (std::nothrow) _Layout::AbsoluteLayout();
217 SysTryCatch(NID_UI, pAbsLayout, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
218 if (IsFailed(GetLastResult()))
223 pLayoutContainer->SetItemHandler(pLayoutItemHandler);
225 r = pLayoutContainer->SetDefaultLayout(*pAbsLayout);
226 SysTryCatch(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error occurred.");
228 return pLayoutContainer;
232 delete pLayoutContainer;
237 } // Anonymous namespace
239 namespace Tizen { namespace Ui
242 IMPLEMENT_PROPERTY(_Control);
244 class _Control::ControlVisualElementContentProvider
245 : public VisualElementContentProvider
252 ControlVisualElementContentProvider(_Control& control)
257 virtual ~ControlVisualElementContentProvider(void)
261 virtual bool PrepareDraw(VisualElement& target)
263 _ControlVisualElement* pCVE = dynamic_cast <_ControlVisualElement*>(&target);
269 Color bgColor = __control.GetBackgroundColor();
271 pCVE->SetBackgroundColor(
273 (float) bgColor.GetRed() / 255.0f,
274 (float) bgColor.GetGreen() / 255.0f,
275 (float) bgColor.GetBlue() / 255.0f,
276 (float) bgColor.GetAlpha() / 255.0f
280 __control.GetControlDelegate().OnDraw();
282 target.SetFlushNeeded();
287 virtual HitTestResult HitTest(VisualElement& target, const FloatPoint& point)
289 return __control.GetControlDelegate().HitTest(point);
293 ControlVisualElementContentProvider(const ControlVisualElementContentProvider& rhs);
294 ControlVisualElementContentProvider& operator =(const ControlVisualElementContentProvider& rhs);
297 class _Control::ControlVisualElementEventListener
298 : public IVisualElementEventListener
301 ControlVisualElementEventListener(_Control& control)
306 virtual ~ControlVisualElementEventListener(void)
311 virtual void OnChildAttached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& child)
315 virtual void OnChildDetached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& child)
319 virtual void OnAttached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& parent)
323 virtual void OnDetached(Tizen::Ui::Animations::VisualElement& source, Tizen::Ui::Animations::VisualElement& parent)
327 virtual result OnTransformChanging(Tizen::Ui::Animations::VisualElement& source, FloatMatrix4& newTransform)
332 virtual void OnTransformChanged(Tizen::Ui::Animations::VisualElement& source, const FloatMatrix4& previousTransform)
336 virtual result OnChildrenTransformChanging(Tizen::Ui::Animations::VisualElement& source, FloatMatrix4& newTransform)
338 for (int i = 0; i < __control.GetChildCount(); ++i)
340 _Control* pChild = __control.GetChild(i);
346 if (pChild->GetArea() == _CONTROL_AREA_SYSTEM)
348 _VisualElement* pVisualElement = pChild->GetVisualElement();
351 FloatMatrix4 inverseMatrix(newTransform);
352 inverseMatrix.Invert();
354 result r = pVisualElement->SetTransformMatrix(inverseMatrix);
366 virtual void OnChildrenTransformChanged(Tizen::Ui::Animations::VisualElement& source, const FloatMatrix4& previousTransform)
370 virtual result OnBoundsChanging(Tizen::Ui::Animations::VisualElement& source, FloatRectangle& newBounds)
375 virtual void OnBoundsChanged(Tizen::Ui::Animations::VisualElement& source, const FloatRectangle& previousBounds)
379 virtual void OnShowStateChanged(Tizen::Ui::Animations::VisualElement& source, bool previousShowState)
384 ControlVisualElementEventListener(const ControlVisualElementEventListener& rhs);
385 ControlVisualElementEventListener& operator =(const ControlVisualElementEventListener& rhs);
389 }; // ControlVisualElementEventListener
391 // Layout Item Handler
392 class _Control::LayoutItemHandler
393 : public _Layout::ILayoutItemHandler
396 LayoutItemHandler(_Control* pControl)
397 : __pControl(pControl)
399 SysAssert(__pControl);
402 void SetItemVisibleState(bool visible)
404 __pControl->SetVisibleState(visible);
407 result SetItemBounds(const FloatRectangle& rect)
409 SysAssert(__pControl->IsInSizeRange(FloatDimension(rect.width, rect.height)));
410 return __pControl->SetBoundsFinal(rect, false, true);
413 FloatRectangle GetItemBounds(void) const
415 return __pControl->GetBoundsF();
418 FloatRectangle GetItemClientBoundsFromSize(const FloatDimension& size) const
420 FloatRectangle clientBounds(0.0f, 0.0f, 0.0f, 0.0f);
421 __pControl->UpdateClientBounds(size, clientBounds);
425 FloatDimension GetItemContentSize(bool horizontalMode, bool verticalMode) const
427 return __pControl->GetControlDelegate().GetContentSizeF(horizontalMode, verticalMode);
430 FloatDimension GetItemMinimumSize(void) const
432 return __pControl->GetMinimumSizeF();
435 FloatDimension GetItemMaximumSize(void) const
437 return __pControl->GetMaximumSizeF();
440 result OnItemMeasure(float& width, float& height)
442 Dimension evaluatedSize(_CoordinateSystemUtils::ConvertToInteger(width), _CoordinateSystemUtils::ConvertToInteger(height));
443 FloatDimension evaluatedSizeF(width, height);
445 bool changed = __pControl->GetControlDelegate().OnEvaluateSize(evaluatedSizeF);
448 width = evaluatedSizeF.width;
449 height = evaluatedSizeF.height;
453 __pControl->GetControlDelegate().OnEvaluateSize(evaluatedSize);
455 if (evaluatedSize.width != (_CoordinateSystemUtils::ConvertToInteger(width)))
457 width = evaluatedSize.width;
459 if (evaluatedSize.height != (_CoordinateSystemUtils::ConvertToInteger(height)))
461 height = evaluatedSize.height;
469 LayoutItemHandler(const LayoutItemHandler& rhs);
470 LayoutItemHandler& operator =(const LayoutItemHandler& rhs);
473 _Control* __pControl;
474 }; // LayoutItemHandler
479 _Control::CreateControlN(void)
481 _Control* pControl = new (std::nothrow) _Control;
482 SysTryReturn(NID_UI, pControl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
483 if (IsFailed(GetLastResult()))
488 pControl->AcquireHandle();
490 SysAssert(GetLastResult() == E_SUCCESS);
499 _Control::ResetEventListeners(void)
501 __pFocusEventListener = this;
502 __pNotificationEventListener = this;
506 _Control::SetControlDelegate(_IControlDelegate& delegate)
508 __pControlDelegate = &delegate;
512 _Control::ResetControlDelegate(void)
514 __pControlDelegate = this;
518 _Control::GetControlDelegate(void) const
522 return const_cast<_Control&>(*this);
525 SysAssert(__pControlDelegate);
526 return *__pControlDelegate;
530 _Control::SetPropagatedTouchEventListener(_IPropagatedTouchEventListener* pListener)
532 __pPropagatedTouchEventListener = pListener;
535 _IPropagatedTouchEventListener*
536 _Control::GetPropagatedTouchEventListener(void) const
540 return const_cast<_Control*>(this);
543 SysAssert(__pPropagatedTouchEventListener);
544 return __pPropagatedTouchEventListener;
548 _Control::SetPropagatedKeyEventListener(_IPropagatedKeyEventListener* pListener)
550 __pPropagatedKeyEventListener = pListener;
553 _IPropagatedKeyEventListener*
554 _Control::GetPropagatedKeyEventListener(void) const
558 return const_cast<_Control*>(this);
561 SysAssert(__pPropagatedKeyEventListener);
562 return __pPropagatedKeyEventListener;
566 _Control::OnPreviewKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
572 _Control::OnPreviewKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
578 _Control::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
580 //SysLog(NID_UI, ">>> [core] OnKeyPressed(%d, %d)", keyInfo.GetKeyCode(), keyInfo.GetKeyModifier());
585 _Control::OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo)
587 //SysLog(NID_UI, ">>> [core] OnKeyReleased(%d, %d)", keyInfo.GetKeyCode(), keyInfo.GetKeyModifier());
592 _Control::TranslateKeyEventInfo(const _Control& source, _KeyInfo& keyInfo)
597 _UiTouchEventDelivery
598 _Control::OnPreviewTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
600 return _UI_TOUCH_EVENT_DELIVERY_YES;
603 _UiTouchEventDelivery
604 _Control::OnPreviewTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
606 return _UI_TOUCH_EVENT_DELIVERY_YES;
609 _UiTouchEventDelivery
610 _Control::OnPreviewTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
612 return _UI_TOUCH_EVENT_DELIVERY_YES;
615 _UiTouchEventDelivery
616 _Control::OnPreviewTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
618 return _UI_TOUCH_EVENT_DELIVERY_YES;
622 _Control::OnTouchPressed(const _Control& source, const _TouchInfo& touchinfo)
628 _Control::OnTouchReleased(const _Control& source, const _TouchInfo& touchinfo)
634 _Control::OnTouchMoved(const _Control& source, const _TouchInfo& touchinfo)
640 _Control::OnTouchCanceled(const _Control& source, const _TouchInfo& touchinfo)
645 _UiTouchEventDelivery
646 _Control::OnPreviewMousePressed(const _Control& source, const _MouseInfo& mouseinfo)
648 return _UI_TOUCH_EVENT_DELIVERY_YES;
651 _UiTouchEventDelivery
652 _Control::OnPreviewMouseReleased(const _Control& source, const _MouseInfo& mouseinfo)
654 return _UI_TOUCH_EVENT_DELIVERY_YES;
657 _UiTouchEventDelivery
658 _Control::OnPreviewMouseMoved(const _Control& source, const _MouseInfo& mouseinfo)
660 return _UI_TOUCH_EVENT_DELIVERY_YES;
663 _UiTouchEventDelivery
664 _Control::OnPreviewMouseWheeled(const _Control& source, const _MouseInfo& mouseinfo)
666 return _UI_TOUCH_EVENT_DELIVERY_YES;
670 _Control::OnMousePressed(const _Control& source, const _MouseInfo& mouseinfo)
676 _Control::OnMouseReleased(const _Control& source, const _MouseInfo& mouseinfo)
682 _Control::OnMouseMoved(const _Control& source, const _MouseInfo& mouseinfo)
688 _Control::OnMouseWheeled(const _Control& source, const _MouseInfo& mouseinfo)
694 _Control::OnFocusGained(const _Control& source)
696 bool isfocusMode = _FocusManagerImpl::GetInstance()->IsFocusModeStateEnabled();
705 _Control::OnFocusLost(const _Control& source)
707 if (__pFocusVisualElement)
709 __pFocusVisualElement.reset();
715 _Control::OnPreviewNotifiedN(const _Control& source, IList* pArgs)
721 _Control::OnNotifiedN(const _Control& source, IList* pArgs)
727 _Control::IsMovable(void) const
734 _Control::IsResizable(void) const
741 _Control::GetContentSize(void) const
744 return Dimension(0, 0);
748 _Control::GetContentSizeF(bool horizontalMode, bool verticalMode) const
751 return FloatDimension(0.0f, 0.0f);
755 _Control::HitTest(const FloatPoint& point)
757 _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*__pVisualElement);
759 if (pVisualElementImpl)
761 if (pVisualElementImpl->HitTestI(point) == _VisualElementImpl::HITTEST_MATCH)
763 return HIT_TEST_MATCH;
767 return HIT_TEST_NOWHERE;
771 _Control::GetVerticalScrollPosition(void) const
777 _Control::GetHorizontalScrollPosition(void) const
783 _Control::GetOrientation(void) const
786 return __orientation;
790 _Control::OnDraw(void)
795 _Control::OnCanvasRequestedN(const FloatRectangle& bounds)
802 _Control::OnCapturedBitmapRequestedN(void)
809 _Control::OnAttaching(const _Control* pParent)
815 _Control::OnAttached(void)
821 _Control::OnAttachingToMainTree(const _Control* pParent)
827 _Control::OnPreAttachedToMainTree(void)
833 _Control::OnAttachedToMainTree(void)
839 _Control::OnDetachingFromMainTree(void)
845 _Control::OnAttachingFailed(const _Control& parent)
850 _Control::OnDetaching(void)
856 _Control::OnBoundsChanging(const Rectangle& bounds)
862 _Control::OnBoundsChanging(const FloatRectangle& bounds)
868 _Control::OnBoundsChanged(void)
874 _Control::OnEvaluateSize(Dimension& evaluatedSize)
880 _Control::OnEvaluateSize(FloatDimension& evaluatedSize)
886 _Control::OnParentBoundsChanged(const _Control& parent)
891 _Control::OnChildAttached(const _Control& child)
896 _Control::OnChildDetaching(const _Control& child)
901 _Control::OnChildDetached(const _Control& child)
906 _Control::OnChildBoundsChanged(const _Control& child)
911 _Control::OnChildVisibleStateChanged(const _Control& child)
916 _Control::OnChangeLayout(_ControlOrientation orientation)
921 _Control::OnChangeLayout(_ControlRotation rotation)
926 _Control::OnZOrderChanging(_ControlZOrderUpdate zOrderUpdate)
931 _Control::OnVisibleStateChanging(void)
936 _Control::OnVisibleStateChanged(void)
941 _Control::OnAncestorVisibleStateChanged(const _Control& control)
943 _TouchManager* pTouchManager = _TouchManager::GetInstance();
944 if (pTouchManager && IsVisible() == false && IsAttachedToMainTree() == true)
946 if(pTouchManager->GetTouchControlSource() == this)
948 SysLog(NID_UI, "VisibleState changed false, Call SetTouchCanceled");
949 pTouchManager->SetTouchCanceled(null);
955 _Control::OnAncestorEnableStateChanged(const _Control& control)
960 _Control::OnAncestorInputEnableStateChanged(const _Control& control)
965 _Control::OnTouchPressHandled(const _Control& control)
970 _Control::OnTouchReleaseHandled(const _Control& control)
975 _Control::OnTouchMoveHandled(const _Control& control)
980 _Control::OnFontChanged(Tizen::Graphics::Font* pFont)
982 SetUpdateLayoutState(true);
986 _Control::OnFontInfoRequested(unsigned long& style, int& size)
991 _Control::OnFontInfoRequested(unsigned long& style, float& size)
996 _Control::OnBackgroundColorChanged(Color& backgroundColor)
1001 _Control::OnFocusableStateChanged(bool focusalbeState)
1006 _Control::OnFocusModeStateChanged(void)
1011 _Control::OnTouchCancelHandled(const _Control& control)
1016 _Control::Accept(Visitor& visitor)
1020 VisitType visitType = visitor.Visit(*this);
1027 case VISIT_DOWNWARD:
1028 for (int i = 0; i < GetChildCount(); ++i) // [Postpone] Keep handle list before iternation.
1030 _Control* pChild = GetChild(i);
1033 pChild->Accept(visitor);
1040 _Control* pParent = GetParent();
1043 pParent->Accept(visitor);
1054 _Control::Accept(Visitor& visitor) const
1056 const_cast <_Control*>(this)->Accept(visitor);
1060 _Control::InvalidateHierarchyRootWindow(void)
1065 virtual VisitType Visit(_Control& control)
1067 control.__needRecalcRootWindow = true;
1068 control.__pRootWindow = null;
1070 return VISIT_DOWNWARD;
1079 _Control::Draw(bool recursive)
1083 Invalidate(recursive);
1084 GetVisualElement()->Draw();
1088 _Control::Show(void)
1090 GetVisualElement()->Flush();
1093 SysAssert(GetLastResult() == E_SUCCESS);
1097 _Control::ChangeLayout(_ControlOrientation orientation, bool callRotation)
1104 _Visitor(_ControlOrientation orientation)
1105 : __orientation(orientation){}
1107 virtual VisitType Visit(_Control& control)
1109 if (control.__orientation != __orientation)
1111 control.__orientation = __orientation;
1112 control.GetControlDelegate().OnChangeLayout(__orientation);
1116 return VISIT_DOWNWARD;
1120 _ControlOrientation __orientation;
1123 _Visitor visitor(orientation);
1126 SysAssert(GetLastResult() == E_SUCCESS);
1128 if (callRotation == true)
1130 _ControlManager* pMgr = _ControlManager::GetInstance();
1133 _ControlRotation rotation = pMgr->GetOrientationStatus();
1134 ChangeLayout(rotation);
1140 _Control::ChangeLayout(_ControlRotation rotation)
1147 _Visitor(_ControlRotation rotation)
1148 : __rotation(rotation){}
1150 virtual VisitType Visit(_Control& control)
1152 if (control.__rotation != __rotation)
1154 control.__rotation = __rotation;
1155 control.GetControlDelegate().OnChangeLayout(__rotation);
1159 return VISIT_DOWNWARD;
1163 _ControlRotation __rotation;
1166 _Visitor visitor(rotation);
1169 SysAssert(GetLastResult() == E_SUCCESS);
1173 _Control::IsLayoutChangable(void) const
1179 _Control::IsOrientationRoot(void) const
1185 _Control::Invalidate(void)
1188 GetVisualElement()->InvalidateRectangle(null);
1192 _Control::Invalidate(bool recursive)
1199 virtual VisitType Visit(_Control& control)
1201 if (control.GetVisibleState() == false)
1206 control.Invalidate();
1209 int owneeCount = control.GetOwneeCount();
1210 for (int i = 0; i < owneeCount; ++i)
1212 _Window* pOwnee = control.GetOwnee(i);
1215 pOwnee->Invalidate(true);
1219 return VISIT_DOWNWARD;
1224 _Layout::Layout* pLayout = GetLayout();
1227 pLayout->UpdateLayout();
1230 if (recursive == false)
1242 _Control::Invalidate(const Rectangle& rect)
1245 FloatRectangle rectf(rect.x, rect.y, rect.width, rect.height);
1246 GetVisualElement()->InvalidateRectangle(&rectf);
1248 __invalidatedBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
1252 _Control::Invalidate(const FloatRectangle& rect)
1255 FloatRectangle rectf(rect.x, rect.y, rect.width, rect.height);
1256 GetVisualElement()->InvalidateRectangle(&rectf);
1258 __invalidatedBounds = rect;
1262 _Control::Contains(const Point& point) const
1266 Rectangle bounds = GetBounds();
1267 bounds.x = bounds.y = 0;
1268 return bounds.Contains(point);
1272 _Control::Contains(const FloatPoint& point) const
1276 FloatRectangle bounds = GetBoundsF();
1277 bounds.x = bounds.y = 0;
1278 return bounds.Contains(point);
1283 _Control::PartialUpdateLayout(void)
1287 _Layout::Layout* pLayout = GetLayout();
1290 pLayout->PartialUpdateLayout();
1295 _Control::UpdateLayout(void)
1299 _Layout::Layout* pLayout = GetLayout();
1302 pLayout->UpdateLayout();
1307 _Control::SetChildAlwaysOnTop(_Control& child)
1311 SysTryReturn(NID_UI,
1312 child.GetParent() == this, E_INVALID_ARG,
1313 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1315 SysTryReturn(NID_UI,
1316 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1317 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1319 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_TOP)
1324 child.SetLayer(_CONTROL_LAYER_CLIENT_TOP);
1330 _Control::SetChildAlwaysAtBottom(_Control& child)
1334 SysTryReturn(NID_UI,
1335 child.GetParent() == this, E_INVALID_ARG,
1336 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1338 SysTryReturn(NID_UI,
1339 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1340 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1342 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_BOTTOM)
1347 child.SetLayer(_CONTROL_LAYER_CLIENT_BOTTOM);
1353 _Control::ResetChildLayer(_Control& child)
1357 SysTryReturn(NID_UI,
1358 child.GetParent() == this, E_INVALID_ARG,
1359 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1361 SysTryReturn(NID_UI,
1362 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1363 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1365 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_MIDDLE)
1370 child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE);
1377 _Control::AttachSystemChild(_Control& child)
1380 result r = E_SUCCESS;
1382 r = StartAttaching(child, _CONTROL_AREA_SYSTEM);
1388 ControlList& children = GetChildList();
1389 r = children.Add(&child);
1390 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1392 r = GetVisualElement()->AttachChild(*child.GetVisualElement());
1393 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1395 r = EndAttaching(child);
1401 SysAssert(GetLastResult() == E_SUCCESS);
1407 _Control::DetachSystemChild(_Control& child)
1409 return DetachChild(child);
1413 _Control::HasParent(void) const
1415 return __pParent != null;
1419 _Control::GetArea(void) const
1426 _Control::GetLayer(void) const
1433 _Control::SetLayer(_ControlLayer layer)
1436 _VisualElementImpl* pImpl = _VisualElementImpl::GetInstance(*GetVisualElement());
1438 result r = pImpl->SetZOrderGroup(::GetZOrderGroupOfVisualElement(layer));
1441 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1444 const _Control::ControlList&
1445 _Control::GetChildList() const
1447 return const_cast <_Control*>(this)->GetChildList();
1450 _Control::ControlList&
1451 _Control::GetChildList()
1453 return *__pChildren;
1457 _Control::IsCalledCallAttachingToMainTree(void)
1459 return __isCalledCallOnAttachingToMainTree;
1463 _Control::SetCalledCallAttachingToMainTree(bool isAttaching)
1465 __isCalledCallOnAttachingToMainTree = isAttaching;
1469 _Control::IsCalledCallPreAttachedToMainTree(void)
1471 return __isCalledCallOnPreAttachedToMainTree;
1475 _Control::IsCalledCallAttachedToMainTree(void)
1477 return __isCalledCallOnAttachedToMainTree;
1481 _Control::SetCalledCallPreAttachedToMainTree(bool isAttached)
1483 __isCalledCallOnPreAttachedToMainTree = isAttached;
1487 _Control::SetCalledCallAttachedToMainTree(bool isAttached)
1489 __isCalledCallOnAttachedToMainTree = isAttached;
1493 _Control::CallOnAttachingToMainTree(_Control& control)
1495 result r = E_SUCCESS;
1497 ControlList& children = control.GetChildList();
1498 _Control* pChild = null;
1500 int childrenCount = children.GetCount();
1502 for (int index = 0; index < childrenCount; index++)
1504 r = children.GetAt(index, pChild);
1507 SysAssert(r == E_OUT_OF_RANGE);
1508 SysTryReturn(NID_UI,
1509 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1510 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1512 if (!pChild->IsCalledCallAttachingToMainTree())
1514 r = CallOnAttachingToMainTree(*pChild);
1515 pChild->SetCalledCallAttachingToMainTree(true);
1516 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1520 if (!control.IsCalledCallAttachingToMainTree())
1522 r = control.GetControlDelegate().OnAttachingToMainTree(this);
1523 control.SetCalledCallAttachingToMainTree(true);
1524 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1531 _Control::CallOnPreAttachedToMainTree(_Control& control)
1533 result r = E_SUCCESS;
1535 ControlList& children = control.GetChildList();
1536 _Control* pChild = null;
1538 int childrenCount = children.GetCount();
1540 for (int index = 0; index < childrenCount; index++)
1542 r = children.GetAt(index, pChild);
1545 SysAssert(r == E_OUT_OF_RANGE);
1546 SysTryReturn(NID_UI,
1547 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1548 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1551 if (!pChild->IsCalledCallPreAttachedToMainTree())
1553 r = CallOnPreAttachedToMainTree(*pChild);
1554 pChild->SetCalledCallPreAttachedToMainTree(true);
1558 if (!control.IsCalledCallPreAttachedToMainTree())
1560 r = control.GetControlDelegate().OnPreAttachedToMainTree();
1561 control.SetCalledCallPreAttachedToMainTree(true);
1568 _Control::CallOnAttachedToMainTree(_Control& control)
1570 result r = E_SUCCESS;
1572 ControlList& children = control.GetChildList();
1573 _Control* pChild = null;
1575 int childrenCount = children.GetCount();
1577 for (int index = 0; index < childrenCount; index++)
1579 r = children.GetAt(index, pChild);
1582 SysAssert(r == E_OUT_OF_RANGE);
1583 SysTryReturn(NID_UI,
1584 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1585 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1588 if (!pChild->IsCalledCallAttachedToMainTree())
1590 r = CallOnAttachedToMainTree(*pChild);
1591 pChild->SetCalledCallAttachedToMainTree(true);
1595 if (!control.IsCalledCallAttachedToMainTree())
1597 r = control.GetControlDelegate().OnAttachedToMainTree();
1598 control.SetCalledCallAttachedToMainTree(true);
1605 _Control::CallOnDetachingFromMainTree(_Control& control)
1607 result r = E_SUCCESS;
1609 ControlList& children = control.GetChildList();
1610 _Control* pChild = null;
1612 _Window* pTop = control.GetRootWindow();
1615 _Control* pControl = pTop->GetFocusControl(this);
1616 if ((&control) == pControl)
1618 pTop->SetFocusControl(&control, false);
1620 _Control* pFocusTraversalControl = pTop->GetFocusTraversalControl(this);
1621 if ((&control) == pFocusTraversalControl)
1623 pTop->SetFocusTraversalControl(&control, false);
1627 if (!__isPostOrderTraversal)
1629 r = control.GetControlDelegate().OnDetachingFromMainTree();
1630 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1633 int childrenCount = children.GetCount();
1635 for (int index = 0; index < childrenCount; index++)
1637 r = children.GetAt(index, pChild);
1640 SysAssert(r == E_OUT_OF_RANGE);
1641 SysTryReturn(NID_UI,
1642 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1643 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1645 r = CallOnDetachingFromMainTree(*pChild);
1646 pChild->SetCalledCallAttachingToMainTree(false);
1647 pChild->SetCalledCallPreAttachedToMainTree(false);
1648 pChild->SetCalledCallAttachedToMainTree(false);
1649 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1652 if (__isPostOrderTraversal)
1654 r = control.GetControlDelegate().OnDetachingFromMainTree();
1655 control.SetCalledCallAttachingToMainTree(false);
1656 control.SetCalledCallPreAttachedToMainTree(false);
1657 control.SetCalledCallAttachedToMainTree(false);
1658 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1665 _Control::CallOnAncestorVisibleStateChanged(void)
1670 _Visitor(_Control& parent)
1671 : __parent(parent){}
1673 virtual VisitType Visit(_Control& control)
1675 control.GetControlDelegate().OnAncestorVisibleStateChanged(__parent);
1676 return VISIT_DOWNWARD;
1682 _Visitor visitor(*this);
1687 _Control::CallOnAncestorEnableStateChanged(void)
1692 _Visitor(_Control& parent)
1693 : __parent(parent){}
1695 virtual VisitType Visit(_Control& control)
1697 control.GetControlDelegate().OnAncestorEnableStateChanged(__parent);
1698 return VISIT_DOWNWARD;
1704 _Visitor visitor(*this);
1709 _Control::CallOnAncestorInputEnableStateChanged(void)
1714 _Visitor(_Control& parent)
1715 : __parent(parent){}
1717 virtual VisitType Visit(_Control& control)
1719 control.GetControlDelegate().OnAncestorInputEnableStateChanged(__parent);
1720 return VISIT_DOWNWARD;
1726 _Visitor visitor(*this);
1732 // [ToDo] Rollback is difficult.
1734 _Control::StartAttaching(_Control& child, _ControlArea area)
1736 result r = E_SUCCESS;
1738 _Control* pOldParent = child.GetParent();
1740 SysTryReturn(NID_UI,
1741 (pOldParent != this), E_INVALID_ARG,
1742 E_INVALID_ARG, "[E_INVALID_ARG] The child control is already attached to this container.");
1744 SysTryReturn(NID_UI,
1745 pOldParent == null, E_INVALID_ARG,
1746 E_INVALID_ARG, "[E_INVALID_ARG] Unable to add the child which already has another parent.");
1748 r = child.GetControlDelegate().OnAttaching(this);
1749 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1751 if (IsAttachedToMainTree())
1753 r = CallOnAttachingToMainTree(child);
1754 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1757 // [ToDo] Add control to layout
1758 // What should we do about non-layoutable controls?
1759 if (area == _CONTROL_AREA_CLIENT)
1761 _ControlManager* pMgr = _ControlManager::GetInstance();
1762 r = GetLastResult();
1763 SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r));
1765 r = __pLayoutContainer->AddItem(child.GetLayoutContainer());
1768 child.GetControlDelegate().OnAttachingFailed(*this);
1769 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Failed to apply layout.");
1774 if (IsAttachedToMainTree())
1776 if (!(IsOrientationRoot() && child.IsOrientationRoot()))
1778 child.ChangeLayout(_ControlManager::GetInstance()->GetOrientation());
1782 child.__area = area;
1784 if (area == _CONTROL_AREA_CLIENT)
1786 if (child.GetLayer() != _CONTROL_LAYER_CLIENT_TOP && child.GetLayer() != _CONTROL_LAYER_CLIENT_BOTTOM)
1788 child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE);
1793 child.SetLayer(_CONTROL_LAYER_SYSTEM);
1796 SysAssert(GetLastResult() == E_SUCCESS);
1801 _Control::EndAttaching(_Control& child)
1803 child.SetParent(this);
1804 child.InvalidateHierarchyRootWindow();
1806 FloatRectangle floatBounds(child.GetBoundsF().x, child.GetBoundsF().y, child.GetBoundsF().width, child.GetBoundsF().height);
1808 result r = E_SUCCESS;
1809 if (child.IsLayoutChangable() == false)
1811 r = child.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, floatBounds.width, floatBounds.height));
1815 r = child.UpdateBoundsOfVisualElement(floatBounds);
1817 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1819 r = child.GetControlDelegate().OnAttached();
1820 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1822 if (IsAttachedToMainTree())
1824 r = CallOnPreAttachedToMainTree(child);
1825 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1827 r = CallOnAttachedToMainTree(child);
1828 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1833 GetControlDelegate().OnChildAttached(child);
1843 _Control::AttachChild(_Control& child)
1846 result r = E_SUCCESS;
1848 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1854 ControlList& children = GetChildList();
1855 r = children.Add(&child);
1856 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1858 r = GetVisualElement()->AttachChild(*child.GetVisualElement());
1860 r = EndAttaching(child);
1866 SysAssert(GetLastResult() == E_SUCCESS);
1872 _Control::UpdateFocusList(void)
1874 _Window* pTop = GetRootWindow();
1877 pTop->ResetFocusList();
1882 _Control::RemoveFocusRing(void)
1884 if (__pFocusVisualElement)
1886 __pFocusVisualElement.reset();
1891 _Control::HasFocusRing(void)
1893 if (__pFocusVisualElement)
1902 _Control::SetFocusNavigateEnabled(bool enable)
1904 __isNavigatable = enable;
1908 _Control::IsFocusNavigateEnabled(void) const
1910 return __isNavigatable;
1914 _Control::IsFocusModeStateEnabled(void) const
1916 return _FocusManagerImpl::GetInstance()->IsFocusModeStateEnabled();
1923 _Control::InsertChildToBottom(_Control& child)
1926 result r = E_SUCCESS;
1928 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1934 ControlList& children = GetChildList();
1935 r = children.InsertAt(&child, 0);
1936 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1938 GetVisualElement()->InsertChild(*child.GetVisualElement(), null, false);
1939 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1941 r = EndAttaching(child);
1947 SysAssert(GetLastResult() == E_SUCCESS);
1955 _Control::InsertChildAfter(const _Control& targetChild, _Control& child)
1958 result r = E_SUCCESS;
1960 SysTryReturn(NID_UI,
1961 targetChild.GetParent() == this, E_INVALID_ARG,
1962 E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child.");
1964 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1970 int targetIndex = GetChildIndex(targetChild);
1971 SysAssert(targetIndex != -1);
1973 ControlList& children = GetChildList();
1974 r = children.InsertAt(&child, targetIndex + 1);
1975 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1977 GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), true);
1978 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1980 r = EndAttaching(child);
1986 SysAssert(GetLastResult() == E_SUCCESS);
1994 _Control::InsertChildBefore(const _Control& targetChild, _Control& child)
1997 result r = E_SUCCESS;
1999 SysTryReturn(NID_UI,
2000 targetChild.GetParent() == this, E_INVALID_ARG,
2001 E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child.");
2003 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
2009 int targetIndex = GetChildIndex(targetChild);
2010 SysAssert(targetIndex != -1);
2012 ControlList& children = GetChildList();
2013 r = children.InsertAt(&child, targetIndex);
2014 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2016 GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), false);
2017 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2019 r = EndAttaching(child);
2025 SysAssert(GetLastResult() == E_SUCCESS);
2031 _Control::DetachChild(_Control& child)
2034 result r = E_SUCCESS;
2036 SysTryReturn(NID_UI,
2037 child.GetParent() == this, E_INVALID_ARG,
2038 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2040 if (IsAttachedToMainTree())
2042 r = CallOnDetachingFromMainTree(child);
2043 SysTryReturn(NID_UI,
2044 r == E_SUCCESS, E_SYSTEM,
2045 E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent.");
2047 SysTryReturn(NID_UI,
2048 child.GetControlDelegate().OnDetaching() == E_SUCCESS, E_SYSTEM,
2049 E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent.");
2052 GetControlDelegate().OnChildDetaching(child);
2055 r = GetVisualElement()->DetachChild(*child.GetVisualElement());
2056 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2058 ControlList& children = GetChildList();
2059 r = children.Remove(&child);
2060 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2062 // Remove control to layout
2063 if (child.__area == _CONTROL_AREA_CLIENT)
2065 _ControlManager* pMgr = _ControlManager::GetInstance();
2066 r = GetLastResult();
2067 SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r));
2069 r = __pLayoutContainer->RemoveItem(child.GetLayoutContainer());
2070 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2073 child.SetParent(null);
2074 child.__area = _CONTROL_AREA_NONE;
2075 child.__layer = _CONTROL_LAYER_NONE;
2077 GetControlDelegate().OnChildDetached(child);
2080 SysAssert(GetLastResult() == E_SUCCESS);
2082 child.InvalidateHierarchyRootWindow();
2089 _Control::DetachAllChildren(bool detachSystemChild, bool recursive)
2092 result r = E_SUCCESS;
2094 int childCount = GetChildCount();
2099 while (childCount--)
2101 _Control* pChild = GetChild(itemIndex);
2107 if (!detachSystemChild && (pChild->GetArea() == _CONTROL_AREA_SYSTEM))
2113 int childCount = pChild->GetChildCount();
2114 if (childCount == 0)
2116 r = DetachChild(*pChild);
2119 SysLog(NID_UI, "child is not detached from this container.");
2124 r = DetachChild(*pChild);
2127 SysLog(NID_UI, "child is not detached from this container.");
2129 pChild->DetachAllChildren(detachSystemChild, true);
2135 int notDetachedChildCount = 0;
2136 while (childCount--)
2138 _Control* pChild = GetChild(itemIndex);
2144 if (!detachSystemChild && (pChild->GetArea() == _CONTROL_AREA_SYSTEM))
2149 r = DetachChild(*pChild);
2153 ++notDetachedChildCount;
2157 SysLog(NID_UI, "%d children are not detached from this container.", notDetachedChildCount);
2165 _Control::MoveChildToTop(const _Control& child)
2168 result r = E_SUCCESS;
2170 SysTryReturn(NID_UI,
2171 child.GetParent() == this, E_INVALID_ARG,
2172 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2174 // If already on top,
2175 ControlList& children = GetChildList();
2176 if (GetChildIndex(child) == children.GetCount() - 1)
2178 SysAssert(GetLastResult() == E_SUCCESS);
2182 _Control* pChild = const_cast <_Control*>(&child);
2184 r = children.Remove(pChild);
2185 SysAssert(r == E_SUCCESS);
2187 r = children.Add(pChild);
2188 SysAssert(r == E_SUCCESS);
2190 r = child.GetVisualElement()->SetZOrder(null, true);
2191 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2193 SysAssert(GetLastResult() == E_SUCCESS);
2199 _Control::MoveChildToBottom(const _Control& child)
2202 result r = E_SUCCESS;
2204 SysTryReturn(NID_UI,
2205 child.GetParent() == this, E_INVALID_ARG,
2206 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2208 ControlList& children = GetChildList();
2210 if (GetChildIndex(child) == 0)
2212 SysAssert(GetLastResult() == E_SUCCESS);
2216 _Control* pChild = const_cast <_Control*>(&child);
2218 r = children.Remove(pChild);
2219 SysAssert(r == E_SUCCESS);
2221 r = children.InsertAt(pChild, 0);
2222 SysAssert(r == E_SUCCESS);
2224 r = child.GetVisualElement()->SetZOrder(null, false);
2225 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2227 SysAssert(GetLastResult() == E_SUCCESS);
2233 _Control::MoveChildAfter(const _Control& targetChild, const _Control& child)
2236 result r = E_SUCCESS;
2238 SysTryReturn(NID_UI,
2239 targetChild.GetParent() == this, E_INVALID_ARG,
2240 E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child.");
2242 SysTryReturn(NID_UI,
2243 child.GetParent() == this, E_INVALID_ARG,
2244 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2246 SysTryReturn(NID_UI,
2247 &targetChild != &child, E_INVALID_ARG,
2248 E_INVALID_ARG, "[E_INVALID_ARG] Cannot move after self.");
2250 ControlList& children = GetChildList();
2252 int targetIndex = GetChildIndex(targetChild);
2253 SysAssert(targetIndex != -1);
2255 if (targetIndex + 1 == GetChildIndex(child))
2257 SysAssert(GetLastResult() == E_SUCCESS);
2261 _Control* pChild = const_cast <_Control*>(&child);
2263 r = children.Remove(pChild);
2264 SysAssert(r == E_SUCCESS);
2266 r = children.InsertAt(pChild, targetIndex + 1);
2267 SysAssert(r == E_SUCCESS);
2269 r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), true);
2270 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2272 SysAssert(GetLastResult() == E_SUCCESS);
2278 _Control::MoveChildBefore(const _Control& targetChild, const _Control& child)
2281 result r = E_SUCCESS;
2283 SysTryReturn(NID_UI,
2284 targetChild.GetParent() == this, E_INVALID_ARG,
2285 E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child.");
2287 SysTryReturn(NID_UI,
2288 child.GetParent() == this, E_INVALID_ARG,
2289 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2291 SysTryReturn(NID_UI,
2292 &targetChild != &child, E_INVALID_ARG,
2293 E_INVALID_ARG, "[E_INVALID_ARG] Cannot move before self.");
2295 ControlList& children = GetChildList();
2297 int targetIndex = GetChildIndex(targetChild);
2298 SysAssert(targetIndex != -1);
2300 if (targetIndex - 1 == GetChildIndex(child))
2302 SysAssert(GetLastResult() == E_SUCCESS);
2306 _Control* pChild = const_cast <_Control*>(&child);
2308 r = children.Remove(pChild);
2309 SysAssert(r == E_SUCCESS);
2311 r = children.InsertAt(pChild, targetIndex);
2312 SysAssert(r == E_SUCCESS);
2314 r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), false);
2315 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2317 SysAssert(GetLastResult() == E_SUCCESS);
2324 _Control::GetChildIndex(const _Control& child) const
2327 result r = E_SUCCESS;
2329 SysTryReturn(NID_UI,
2330 child.GetParent() == this, -1,
2331 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2333 const ControlList& children = GetChildList();
2336 r = children.IndexOf(const_cast<_Control*>(&child), index);
2339 SysAssert(r == E_OBJ_NOT_FOUND);
2340 SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Unable to find the specified child.");
2344 SysAssert(GetLastResult() == E_SUCCESS);
2350 _Control::GetChild(int index) const
2353 result r = E_SUCCESS;
2355 const ControlList& children = GetChildList();
2357 _Control* pChild = null;
2358 r = children.GetAt(index, pChild);
2361 SysAssert(r == E_OUT_OF_RANGE);
2362 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
2366 SysAssert(GetLastResult() == E_SUCCESS);
2371 _Control::GetChildCount(void) const
2374 return GetChildList().GetCount();
2378 _Control::GetHandle(void) const
2380 return __controlHandle;
2384 _Control::GetUserData(void) const
2390 _Control::SetUserData(void* pUserData)
2392 __pUserData = pUserData;
2396 _Control::GetPropertyName(void) const
2399 return Tizen::Ui::Variant(__name);
2403 _Control::GetName(void) const
2405 Variant name = GetProperty("Name");
2407 return name.ToString();
2411 _Control::SetPropertyName(const Variant& name)
2414 __name = name.ToString();
2420 _Control::SetName(const String& name)
2422 SetProperty("Name", Variant(name));
2426 _Control::GetParent(void) const
2432 _Control::GetCanvasN(void) const
2434 return GetCanvasN(FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height));
2438 _Control::GetCanvasN(const Rectangle& bounds) const
2441 Canvas *pCanvas = GetControlDelegate().OnCanvasRequestedN(FloatRectangle(bounds.x, bounds.y, bounds.width, bounds.height));
2442 if (pCanvas == null)
2444 GetVisualElement()->SetFlushNeeded();
2445 pCanvas = GetVisualElement()->GetCanvasN(bounds);
2446 if (IsFailed(GetLastResult()))
2448 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
2451 if (pCanvas && !__isCalledGetCanvasN)
2453 pCanvas->SetBackgroundColor(GetBackgroundColor());
2455 const_cast <_Control*>(this)->__isCalledGetCanvasN = true;
2462 _Control::GetCanvasN(const FloatRectangle& bounds) const
2465 Canvas *pCanvas = GetControlDelegate().OnCanvasRequestedN(FloatRectangle(bounds));
2466 if (pCanvas == null)
2468 GetVisualElement()->SetFlushNeeded();
2469 pCanvas = GetVisualElement()->GetCanvasN(bounds);
2470 if (IsFailed(GetLastResult()))
2472 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
2475 if (pCanvas && !__isCalledGetCanvasN)
2477 pCanvas->SetBackgroundColor(GetBackgroundColor());
2479 const_cast <_Control*>(this)->__isCalledGetCanvasN = true;
2486 _Control::IsCalledGetCanvasN(void) const
2488 return __isCalledGetCanvasN;
2492 _Control::GetClientCanvasN(void) const
2494 return GetCanvasN(GetClientBounds());
2498 _Control::IsAncestorOf(const _Control& control) const
2502 const _Control* pParent = control.GetParent();
2512 const _Control& __ancestor;
2517 _Visitor(const _Control& ancestor)
2518 : __ancestor(ancestor)
2521 virtual VisitType Visit(_Control& control)
2523 if (&__ancestor == &control)
2530 return VISIT_UPWARD;
2535 _Visitor visitor(*this);
2536 pParent->Accept(visitor);
2538 SysAssert(GetLastResult() == E_SUCCESS);
2543 _Control::GetRootWindow(void) const
2547 if (!__needRecalcRootWindow && __pRootWindow != this)
2549 return __pRootWindow;
2560 virtual VisitType Visit(_Control& control)
2562 pRoot = dynamic_cast <_Window*>(&control);
2568 return VISIT_UPWARD;
2575 SysAssert(GetLastResult() == E_SUCCESS);
2577 const_cast<_Control*>(this)->__pRootWindow = visitor.pRoot;
2578 const_cast<_Control*>(this)->__needRecalcRootWindow = false;
2580 return visitor.pRoot;
2584 _Control::IsAttachedToMainTree(void) const
2588 _ControlManager* pMgr = _ControlManager::GetInstance();
2594 _Window* pRootWindow = GetRootWindow();
2595 if (pRootWindow == null)
2600 return pRootWindow->IsAttached();
2604 _Control::IsFocusable(void) const
2611 _Control::SetFocusable(bool focusable)
2614 bool oldState = __focusable;
2615 __focusable = focusable;
2616 if (oldState != __focusable)
2618 GetControlDelegate().OnFocusableStateChanged(focusable);
2623 _Control::IsNativeObjectFocusable(void) const
2626 return __nativeObjectFocusable;
2630 _Control::SetNativeObjectFocusable(bool focusable)
2633 __nativeObjectFocusable = focusable;
2637 _Control::IsFocused(void) const
2641 _Window* pTop = GetRootWindow();
2647 if (this == pTop->GetFocusControl(const_cast<_Control*>(this)))
2656 _Control::SetFocused(bool on)
2660 SysTryReturn(NID_UI,
2661 IsAttachedToMainTree(), E_INVALID_OPERATION,
2662 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control should have a parent or be attached to the main tree.");
2664 SysTryReturn(NID_UI,
2665 IsFocusable(), E_INVALID_OPERATION,
2666 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This Control isn't focusable control.");
2668 _Window* pTop = GetRootWindow();
2672 pTop->SetFocusControl(this, true);
2676 pTop->SetFocusControl(this, false);
2683 _Control::SetFont(const String& fontName)
2685 result r = E_SUCCESS;
2687 if (__fontName.Equals(fontName))
2692 __isControlFontChanged = true;
2693 __fontName = fontName;
2694 __fontFileName.Clear();
2696 Font* pFont = GetFallbackFont();
2700 r = GetLastResult();
2701 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2707 _Control::GetFallbackFont(void)
2709 unsigned long style = 0;
2711 float floatTextSize = 0.0f;
2712 result r = E_SUCCESS;
2713 _IControlDelegate& delegate = GetControlDelegate();
2714 delegate.OnFontInfoRequested(style, textSize);
2715 delegate.OnFontInfoRequested(style, floatTextSize);
2716 _ControlManager* pControlManager = _ControlManager::GetInstance();
2717 _FontImpl* pFontImpl = _FontImpl::GetInstance(*__pFont);
2718 if (!(__isControlFontChanged || pControlManager->IsDefaultFontChanged() || pControlManager->IsSystemFontChanged())
2720 && ((__pFont->GetSize() == textSize || __pFont->GetSizeF() == floatTextSize))
2721 && (pFontImpl->GetStyle() == static_cast<int>(style)))
2725 unique_ptr<Font>pTempFont(new(std::nothrow)Font());
2726 SysTryReturn(NID_UI , pTempFont , null , E_OUT_OF_MEMORY, "[%s] Fails to create a __pFont.", GetErrorMessage(r));
2728 if (!__fontName.IsEmpty())
2730 __isControlFontChanged = false;
2731 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2732 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2734 if (floatTextSize > 0.0f)
2736 r = pFontImpl->Construct(__fontName, style, floatTextSize, false);
2740 r = pFontImpl->Construct(__fontName, style, textSize, false);
2743 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2744 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2746 else if (!__fontFileName.IsEmpty())
2748 __isControlFontChanged = false;
2749 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2750 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2752 if (floatTextSize > 0.0f)
2754 r = pFontImpl->Construct(__fontFileName, style, floatTextSize);
2758 r = pFontImpl->Construct(__fontFileName, style, textSize);
2760 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2761 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2764 else if (!pControlManager->GetDefaultFont().IsEmpty())
2766 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2767 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2769 if (floatTextSize > 0.0f)
2771 r = pFontImpl->Construct(pControlManager->GetDefaultFont(), style, floatTextSize, false);
2775 r = pFontImpl->Construct(pControlManager->GetDefaultFont(), style, textSize, false);
2777 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2778 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2780 else if (!pControlManager->GetDefaultFontFile().IsEmpty())
2782 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2783 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2785 if (floatTextSize > 0.0f)
2787 r = pFontImpl->Construct(pControlManager->GetDefaultFontFile(), style, floatTextSize);
2791 r = pFontImpl->Construct(pControlManager->GetDefaultFontFile(), style, textSize);
2793 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2794 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2798 if (floatTextSize > 0.0f)
2800 r = pTempFont->Construct(style, floatTextSize);
2804 r = pTempFont->Construct(style, textSize);
2806 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2807 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2815 __pFont = pTempFont.release();
2816 delegate.OnFontChanged(__pFont);
2821 _Control::GetFont(void) const
2827 _Control::IsEnabled(void) const
2839 virtual VisitType Visit(_Control& control)
2841 if (!control.GetEnableState())
2847 return VISIT_UPWARD;
2853 return visitor.enabled;
2857 _Control::GetEnableState(void) const
2860 return __enabledState;
2864 _Control::SetEnableState(bool enabledState)
2867 const bool changed = (__enabledState != enabledState);
2870 __enabledState = enabledState;
2871 CallOnAncestorEnableStateChanged();
2873 __pAccessibilityContainer->SetEnableState(enabledState);
2877 _Control::IsInputEventEnabled(void) const
2887 : inputEnabled(true){}
2889 virtual VisitType Visit(_Control& control)
2891 if (!control.GetInputEnableState())
2893 inputEnabled = false;
2897 return VISIT_UPWARD;
2903 return visitor.inputEnabled;
2907 _Control::GetInputEnableState(void) const
2911 if (__inputLockRefCount != 0)
2922 _Control::LockInputEvent(void)
2924 __inputLockRefCount++;
2925 CallOnAncestorInputEnableStateChanged();
2929 _Control::UnlockInputEvent(void)
2931 __inputLockRefCount--;
2932 if (__inputLockRefCount < 0)
2934 __inputLockRefCount = 0;
2939 _Control::IsVisible(void) const
2943 SysTryReturn(NID_UI, IsAttachedToMainTree(), false, E_SYSTEM, "[E_SYSTEM] This control should be attached to the main tree.");
2953 virtual VisitType Visit(_Control& control)
2955 if (!control.GetVisibleState())
2961 return VISIT_UPWARD;
2968 SysAssert(GetLastResult() == E_SUCCESS);
2969 return visitor.visible;
2973 _Control::GetVisibleState(void) const
2976 return __visibleState;
2980 _Control::SetVisibleState(bool visibleState)
2984 const bool changed = (__visibleState != visibleState) || !__initVisibleState;
2988 GetControlDelegate().OnVisibleStateChanging();
2991 __visibleState = visibleState;
2992 GetVisualElement()->SetShowState(visibleState);
2994 if (visibleState == false)
2996 int owneeCount = GetOwneeCount();
2997 for (int i = 0; i < owneeCount; ++i)
2999 _Window* pWindow = GetOwnee(i);
3002 pWindow->SetVisibleState(visibleState);
3009 GetControlDelegate().OnVisibleStateChanged();
3010 CallOnAncestorVisibleStateChanged();
3011 _Control* pParent = GetParent();
3014 pParent->GetControlDelegate().OnChildVisibleStateChanged(*this);
3020 __initVisibleState = true;
3024 _Control::IsLayoutable(void) const
3031 _Control::IsClipToParent(void) const
3034 // SysAssert(GetVisualElement()->IsClipToParent() == __clipToParent);
3035 return __clipToParent;
3039 _Control::SetClipToParent(bool clipToParent)
3042 result r = E_SUCCESS;
3044 __clipToParent = clipToParent;
3045 r = GetVisualElement()->SetClipToParent(clipToParent);
3046 SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
3052 _Control::SetClipChildrenEnabled(bool clipChildren)
3055 //result r = E_SUCCESS;
3057 GetVisualElement()->SetClipChildrenEnabled(clipChildren);
3058 //SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
3064 _Control::GetBounds(void) const
3067 return _CoordinateSystemUtils::ConvertToInteger(__bounds);
3071 _Control::GetBoundsF(void) const
3078 _Control::GetPosition(void) const
3081 return Point(_CoordinateSystemUtils::ConvertToInteger(__bounds.x), _CoordinateSystemUtils::ConvertToInteger(__bounds.y));
3085 _Control::GetPositionF(void) const
3088 return FloatPoint(__bounds.x, __bounds.y);
3092 _Control::GetSize(void) const
3095 return Dimension(_CoordinateSystemUtils::ConvertToInteger(__bounds.width), _CoordinateSystemUtils::ConvertToInteger(__bounds.height));
3099 _Control::GetSizeF(void) const
3102 return FloatDimension(__bounds.width, __bounds.height);
3107 _Control::UpdateBoundsOfVisualElement(const FloatRectangle& controlBounds)
3109 FloatRectangle rect(controlBounds.x, controlBounds.y, controlBounds.width, controlBounds.height);
3111 _Control* pParent = GetParent();
3112 if (__area == _CONTROL_AREA_CLIENT && pParent)
3114 const FloatRectangle clientBounds = pParent->GetClientBoundsF();
3115 rect.x += clientBounds.x;
3116 rect.y += clientBounds.y;
3119 GetVisualElement()->SetBounds(rect);
3125 _Control::AdjustAbsoluteBounds(void)
3130 _Visitor(_Control* pControl)
3131 : __pControl(pControl){}
3133 virtual VisitType Visit(_Control& control)
3135 result r = E_SUCCESS;
3137 if (__pControl == &control)
3139 return VISIT_DOWNWARD;
3141 FloatRectangle fbounds = control.GetBoundsF();
3142 if (control.IsLayoutChangable() == false)
3144 r = control.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
3148 r = control.UpdateBoundsOfVisualElement(fbounds);
3151 ControlList& children = control.GetChildList();
3153 int childrenCount = children.GetCount();
3154 if (childrenCount <= 0)
3160 return VISIT_DOWNWARD;
3164 _Control* __pControl;
3167 _Visitor visitor(this);
3174 _Control::IsInSizeRange(const Dimension& size) const
3176 return (__minSize.width <= size.width) && (size.width <= __maxSize.width) &&
3177 (__minSize.height <= size.height) && (size.height <= __maxSize.height);
3181 _Control::IsInSizeRange(const FloatDimension& size) const
3183 return (__minSize.width <= size.width) && (size.width <= __maxSize.width) &&
3184 (__minSize.height <= size.height) && (size.height <= __maxSize.height);
3187 // Custom Exception: ex) Location::Map
3189 _Control::SetBoundsFinal(const FloatRectangle& newBounds, bool changeLayoutBaseRect, bool callBoundsChangeCallbacks)
3191 result r = E_SUCCESS;
3193 FloatRectangle bounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height);
3195 _IControlDelegate& delegate = GetControlDelegate();
3197 const bool moved = (__bounds.x != bounds.x) || (__bounds.y != bounds.y);
3198 const bool resized = (__bounds.width != bounds.width) || (__bounds.height != bounds.height);
3200 if ((moved || resized) && callBoundsChangeCallbacks)
3202 r = delegate.OnBoundsChanging(_CoordinateSystemUtils::ConvertToInteger(bounds));
3205 SysLogException(NID_UI, r, "[%s] Callback returns exception.", GetErrorMessage(r));
3206 return r; // Relay the result;
3208 r = delegate.OnBoundsChanging(bounds);
3211 SysLogException(NID_UI, r, "[%s] Callback returns exception.", GetErrorMessage(r));
3212 return r; // Relay the result;
3216 if (moved || resized)
3218 const FloatRectangle fbounds(bounds.x, bounds.y, bounds.width, bounds.height);
3219 if (IsLayoutChangable() == false)
3221 r = UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
3225 r = UpdateBoundsOfVisualElement(fbounds);
3229 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
3233 if (changeLayoutBaseRect)
3235 __pLayoutContainer->OnChangeBaseRect();
3238 if ((moved || resized) && callBoundsChangeCallbacks)
3240 if (IsMovable() && IsResizable())
3242 SetClientBounds(FloatRectangle(0.0f, 0.0f, GetSizeF().width, GetSizeF().height));
3244 if (__pFocusVisualElement)
3246 __pFocusVisualElement->SetBounds(FloatRectangle(0, 0, __bounds.width, __bounds.height));
3248 delegate.OnBoundsChanged();
3250 _Control* pParent = GetParent();
3253 pParent->GetControlDelegate().OnChildBoundsChanged(*this);
3256 ControlList& children = GetChildList();
3257 _Control* pChild = null;
3258 int childrenCount = children.GetCount();
3260 for (int index = 0; index < childrenCount; index++)
3262 r = children.GetAt(index, pChild);
3265 pChild->GetControlDelegate().OnParentBoundsChanged(*this);
3274 // Custom Exception: ex) Location::Map
3276 _Control::AdjustSizeToRange(void)
3279 result r = E_SUCCESS;
3281 SysAssert(IsResizable());
3283 FloatDimension size = GetSizeF();
3284 bool changed = ::AdjustSizeToRange(size, __minSize, __maxSize);
3290 FloatRectangle newBounds(__bounds.x, __bounds.y, size.width, size.height);
3291 r = SetBoundsFinal(newBounds, true, true);
3300 // Custom Exception: ex) Location::Map
3303 _Control::SetBoundsInternal(const FloatRectangle& bounds, bool callBoundsChangeCallbacks)
3305 SysTryReturn(NID_UI,
3306 IsInSizeRange(Dimension(bounds.width, bounds.height)), E_INVALID_ARG,
3308 "[E_INVALID_ARG] The specified size(%f, %f) is out of range from min size(%d, %d) to max size(%d, %d).",
3309 bounds.width, bounds.height, __minSize.width, __minSize.height, __maxSize.width, __maxSize.height);
3311 SetUpdateLayoutState(true);
3313 return SetBoundsFinal(bounds, true, callBoundsChangeCallbacks);
3316 // Custom Exception: ex) Location::Map
3318 // E_UNSUPPORTED_OPERATION
3320 _Control::SetBounds(const Rectangle& bounds, bool callBoundsChangeCallbacks)
3324 if (callBoundsChangeCallbacks)
3326 SysTryReturn(NID_UI,
3327 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3328 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3330 FloatRectangle floatBounds(bounds.x, bounds.y, bounds.width, bounds.height);
3332 return SetBoundsInternal(floatBounds, callBoundsChangeCallbacks);
3335 // Custom Exception: ex) Location::Map
3337 // E_UNSUPPORTED_OPERATION
3339 _Control::SetBounds(const FloatRectangle& bounds, bool callBoundsChangeCallbacks)
3343 if (callBoundsChangeCallbacks)
3345 SysTryReturn(NID_UI,
3346 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3347 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3350 return SetBoundsInternal(bounds, callBoundsChangeCallbacks);
3353 // A custom Exception can occur. ex) Location::Map
3355 // E_UNSUPPORTED_OPERATION
3357 _Control::SetPosition(const Point& position)
3361 SysTryReturn(NID_UI,
3362 IsMovable(), E_UNSUPPORTED_OPERATION,
3363 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable.");
3365 return SetBoundsInternal(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height), true);
3369 _Control::SetPosition(const FloatPoint& position)
3373 SysTryReturn(NID_UI,
3374 IsMovable(), E_UNSUPPORTED_OPERATION,
3375 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable.");
3377 return SetBoundsInternal(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height), true);
3380 // Custom Exception: ex) Location::Map
3382 // E_UNSUPPORTED_OPERATION
3384 _Control::SetSize(const Dimension& size)
3388 SysTryReturn(NID_UI,
3389 IsResizable(), E_UNSUPPORTED_OPERATION,
3390 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3392 return SetBoundsInternal(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height), true);
3396 _Control::SetSize(const FloatDimension& size)
3400 SysTryReturn(NID_UI,
3401 IsResizable(), E_UNSUPPORTED_OPERATION,
3402 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3404 return SetBoundsInternal(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height), true);
3408 _Control::GetMinimumSize(void) const
3412 return _CoordinateSystemUtils::ConvertToInteger(__minSize);
3416 _Control::GetMinimumSizeF(void) const
3424 _Control::GetMaximumSize(void) const
3428 return _CoordinateSystemUtils::ConvertToInteger(__maxSize);
3432 _Control::GetMaximumSizeF(void) const
3439 // Custom Exception: ex) Location::Map
3440 // E_UNSUPPORTED_OPERATION
3443 _Control::SetMinimumSize(const Dimension& newMinSize)
3447 SysTryReturn(NID_UI,
3448 IsResizable(), E_UNSUPPORTED_OPERATION,
3449 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3451 SysTryReturn(NID_UI,
3452 (newMinSize.width >= 0 && newMinSize.height >= 0), E_INVALID_ARG,
3453 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3455 SysTryReturn(NID_UI,
3456 (newMinSize.width <= MAX_LENGTH && newMinSize.height <= MAX_LENGTH), E_INVALID_ARG,
3457 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3459 if (__maxSize.width < newMinSize.width)
3461 __maxSize.width = newMinSize.width;
3463 if (__maxSize.height < newMinSize.height)
3465 __maxSize.height = newMinSize.height;
3468 __minSize = _CoordinateSystemUtils::ConvertToFloat(newMinSize);
3469 return AdjustSizeToRange();
3473 _Control::SetMinimumSize(const FloatDimension& newMinSize)
3477 SysTryReturn(NID_UI,
3478 IsResizable(), E_UNSUPPORTED_OPERATION,
3479 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3481 SysTryReturn(NID_UI,
3482 (newMinSize.width >= 0 && newMinSize.height >= 0), E_INVALID_ARG,
3483 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3485 SysTryReturn(NID_UI,
3486 (newMinSize.width <= MAX_LENGTH && newMinSize.height <= MAX_LENGTH), E_INVALID_ARG,
3487 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3489 if (__maxSize.width < newMinSize.width)
3491 __maxSize.width = newMinSize.width;
3493 if (__maxSize.height < newMinSize.height)
3495 __maxSize.height = newMinSize.height;
3498 __minSize = newMinSize;
3499 return AdjustSizeToRange();
3502 // Custom Exception: ex) Location::Map
3503 // E_UNSUPPORTED_OPERATION
3506 _Control::SetMaximumSize(const Dimension& newMaxSize)
3510 SysTryReturn(NID_UI,
3511 IsResizable(), E_UNSUPPORTED_OPERATION,
3512 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3514 SysTryReturn(NID_UI,
3515 (newMaxSize.width >= 0 && newMaxSize.height >= 0), E_INVALID_ARG,
3516 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3518 SysTryReturn(NID_UI,
3519 (newMaxSize.width <= MAX_LENGTH && newMaxSize.height <= MAX_LENGTH), E_INVALID_ARG,
3520 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3522 if (newMaxSize.width < __minSize.width)
3524 __minSize.width = newMaxSize.width;
3526 if (newMaxSize.height < __minSize.height)
3528 __minSize.height = newMaxSize.height;
3531 __maxSize = _CoordinateSystemUtils::ConvertToFloat(newMaxSize);
3532 return AdjustSizeToRange();
3536 _Control::SetMaximumSize(const FloatDimension& newMaxSize)
3540 SysTryReturn(NID_UI,
3541 IsResizable(), E_UNSUPPORTED_OPERATION,
3542 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3544 SysTryReturn(NID_UI,
3545 (newMaxSize.width >= 0 && newMaxSize.height >= 0), E_INVALID_ARG,
3546 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3548 SysTryReturn(NID_UI,
3549 (newMaxSize.width <= MAX_LENGTH && newMaxSize.height <= MAX_LENGTH), E_INVALID_ARG,
3550 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3552 if (newMaxSize.width < __minSize.width)
3554 __minSize.width = newMaxSize.width;
3556 if (newMaxSize.height < __minSize.height)
3558 __minSize.height = newMaxSize.height;
3561 __maxSize = newMaxSize;
3562 return AdjustSizeToRange();
3567 _Control::ConvertToControlPosition(const Point& screenPosition) const
3569 Point controlPosition;
3570 Rectangle absoluteBounds = GetAbsoluteBounds();
3572 controlPosition.x = screenPosition.x - absoluteBounds.x;
3573 controlPosition.y = screenPosition.y - absoluteBounds.y;
3575 return controlPosition;
3579 _Control::ConvertToControlPosition(const FloatPoint& screenPosition) const
3581 FloatPoint controlPosition;
3582 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
3584 controlPosition.x = screenPosition.x - absoluteBounds.x;
3585 controlPosition.y = screenPosition.y - absoluteBounds.y;
3587 return controlPosition;
3591 _Control::ConvertToScreenPosition(const Point& controlPosition) const
3593 Point screenPosition;
3594 Rectangle absoluteBounds = GetAbsoluteBounds();
3596 screenPosition.x = controlPosition.x + absoluteBounds.x;
3597 screenPosition.y = controlPosition.y + absoluteBounds.y;
3599 return screenPosition;
3603 _Control::ConvertToScreenPosition(const FloatPoint& controlPosition) const
3605 FloatPoint screenPosition;
3606 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
3608 screenPosition.x = controlPosition.x + absoluteBounds.x;
3609 screenPosition.y = controlPosition.y + absoluteBounds.y;
3611 return screenPosition;
3615 _Control::GetClientBounds(void) const
3617 if (!__isSetClientBounds)
3619 return Rectangle(0, 0, __bounds.width, __bounds.height);
3622 return _CoordinateSystemUtils::ConvertToInteger(__clientBounds);
3626 _Control::GetClientBoundsF(void) const
3628 if (!__isSetClientBounds)
3630 return FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height);
3633 return __clientBounds;
3638 _Control::GetClientBounds(const Tizen::Graphics::Dimension& size) const
3640 if (!__isSetClientBounds)
3642 return Rectangle(0, 0, size.width, size.height);
3645 return _CoordinateSystemUtils::ConvertToInteger(__clientBounds);
3650 _Control::GetClientBoundsF(const Tizen::Graphics::FloatDimension& size) const
3652 if (!__isSetClientBounds)
3654 return FloatRectangle(0.0f, 0.0f, size.width, size.height);
3657 return __clientBounds;
3661 _Control::GetAbsoluteBounds(void) const
3664 Rectangle absoluteBounds;
3665 Rectangle clientBounds;
3667 const _Control* pSelf = this;
3668 const _Control* pParent = GetParent();
3672 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent)
3674 clientBounds = pParent->GetClientBounds();
3675 accumPoint += Point(clientBounds.x, clientBounds.y);
3676 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3677 accumPoint.y -= pParent->GetVerticalScrollPosition();
3680 accumPoint += pSelf->GetPosition();
3682 pParent = pParent->GetParent();
3685 _Window* pWindow = GetRootWindow();
3689 Point winPoint = pWindow->GetPosition();
3691 accumPoint.x += winPoint.x;
3692 accumPoint.y += winPoint.y;
3695 absoluteBounds.x = accumPoint.x;
3696 absoluteBounds.y = accumPoint.y;
3697 absoluteBounds.width = __bounds.width;
3698 absoluteBounds.height = __bounds.height;
3700 return absoluteBounds;
3704 _Control::GetAbsoluteBoundsF(void) const
3706 FloatPoint accumPoint;
3707 FloatRectangle absoluteBounds;
3708 FloatRectangle clientBounds;
3710 const _Control* pSelf = this;
3711 const _Control* pParent = GetParent();
3715 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent)
3717 clientBounds = pParent->GetClientBoundsF();
3718 accumPoint += FloatPoint(clientBounds.x, clientBounds.y);
3719 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3720 accumPoint.y -= pParent->GetVerticalScrollPosition();
3723 accumPoint += pSelf->GetPositionF();
3725 pParent = pParent->GetParent();
3728 _Window* pWindow = GetRootWindow();
3732 FloatPoint winPoint = pWindow->GetPositionF();
3734 accumPoint.x += winPoint.x;
3735 accumPoint.y += winPoint.y;
3738 absoluteBounds.x = accumPoint.x;
3739 absoluteBounds.y = accumPoint.y;
3740 absoluteBounds.width = __bounds.width;
3741 absoluteBounds.height = __bounds.height;
3743 return absoluteBounds;
3747 _Control::SetClientBounds(const Rectangle& bounds)
3751 const bool moved = (__clientBounds.x != _CoordinateSystemUtils::ConvertToFloat(bounds).x) || (__clientBounds.y != _CoordinateSystemUtils::ConvertToFloat(bounds).y);
3752 const bool resized = (__clientBounds.width != _CoordinateSystemUtils::ConvertToFloat(bounds).width) || (__clientBounds.height != _CoordinateSystemUtils::ConvertToFloat(bounds).height);
3754 SysTryReturn(NID_UI,
3755 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3756 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3757 __clientBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
3758 __isSetClientBounds = true;
3760 if (moved || resized)
3762 result r = AdjustAbsoluteBounds();
3763 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3765 SetUpdateLayoutState(true);
3771 _Control::SetClientBounds(const FloatRectangle& bounds)
3775 const bool moved = (__clientBounds.x != bounds.x) || (__clientBounds.y != bounds.y);
3776 const bool resized = (__clientBounds.width != bounds.width) || (__clientBounds.height != bounds.height);
3778 SysTryReturn(NID_UI,
3779 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3780 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3781 __clientBounds = bounds;
3782 __isSetClientBounds = true;
3784 if (moved || resized)
3786 result r = AdjustAbsoluteBounds();
3787 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3789 SetUpdateLayoutState(true);
3796 _Control::IsCalledSetClientBounds(void)
3798 return __isSetClientBounds;
3802 _Control::UpdateClientBounds(const FloatDimension& size, FloatRectangle& clientBounds)
3804 clientBounds.width = size.width;
3805 clientBounds.height = size.height;
3809 _Control::GetBackgroundColor(void) const
3812 return __backgroundColor;
3816 _Control::SetBackgroundColor(const Color& color)
3819 __backgroundColor = color;
3821 _ControlVisualElement* pCVE = dynamic_cast <_ControlVisualElement*>(GetVisualElement());
3824 pCVE->SetBackgroundColor(
3826 (float)color.GetRed() / 255.0f,
3827 (float)color.GetGreen() / 255.0f,
3828 (float)color.GetBlue() / 255.0f,
3829 (float)color.GetAlpha() / 255.0f
3834 GetControlDelegate().OnBackgroundColorChanged(const_cast<Color&>(color));
3838 _Control::~_Control(void)
3840 __destroying = true;
3842 DetachAllChildren();
3844 _ControlManager::GetInstance()->TakeFocusFromControl(*this);
3854 // Dangerous: it clears last result and log in catch block.
3855 // ClearLastResult();
3859 _Control::DisposeControl(void)
3861 __pControlDelegate = null;
3863 delete __pLayoutItemHandler;
3864 __pLayoutItemHandler = null;
3866 delete __pLayoutContainer;
3867 __pLayoutContainer = null;
3875 if (__pVisualElement)
3877 __pVisualElement->Destroy();
3879 __pVisualElement = null;
3881 delete __pVisualElementContentProvider;
3882 __pVisualElementContentProvider = null;
3884 delete __pVisualElementEventListener;
3885 __pVisualElementEventListener = null;
3887 delete __pCoreGestureDetectors;
3888 __pCoreGestureDetectors = null;
3890 delete __pDataBindingContext;
3891 __pDataBindingContext = null;
3893 ClearStartedGestureDetectorList();
3894 delete __pDetectStartedGestureMap;
3895 __pDetectStartedGestureMap = null;
3897 delete __pDelayedTouchInfoList;
3898 __pDelayedTouchInfoList = null;
3900 delete __pAccessibilityContainer;
3901 __pAccessibilityContainer = null;
3903 if (__pFocusVisualElement)
3905 __pFocusVisualElement.release();
3911 _Control::_Control(void)
3912 : __needRecalcRootWindow(true)
3913 , __pRootWindow(null)
3918 , __bounds(0.0f, 0.0f, 0.0f, 0.0f)
3919 , __contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f)
3920 , __clientBounds(0.0f, 0.0f, 0.0f, 0.0f)
3921 , __absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f)
3922 , __invalidatedBounds(0.0f, 0.0f, 0.0f, 0.0f)
3923 , __minSize(FloatDimension(0.0f, 0.0f))
3924 , __maxSize(FloatDimension(MAX_LENGTH, MAX_LENGTH))
3925 , __backgroundColor(Color::GetColor(COLOR_ID_BLACK))
3929 , __nativeObjectFocusable(true)
3930 , __enabledState(true)
3931 , __visibleState(true)
3932 , __initVisibleState(false)
3933 , __clipToParent(true)
3934 , __multiTouchEnabled(false)
3935 , __dragEnabled(false)
3936 , __dropEnabled(false)
3937 , __drawWhenVisible(true)
3938 , __isPostOrderTraversal(false)
3939 , __isCalledCallOnAttachingToMainTree(false)
3940 , __isCalledCallOnPreAttachedToMainTree(false)
3941 , __isCalledCallOnAttachedToMainTree(false)
3942 , __isSetClientBounds(false)
3943 , __isCalledGetCanvasN(false)
3944 , __isFocusMode(false)
3945 , __isNavigatable(true)
3946 , __pVisualElementContentProvider(null)
3947 , __pVisualElement(null)
3948 , __pVisualElementEventListener(null)
3949 , __pLayoutItemHandler(null)
3950 , __pPortraitLayout(null)
3951 , __pLandscapeLayout(null)
3952 , __pLayoutContainer(null)
3953 , __area(_CONTROL_AREA_NONE)
3954 , __layer(_CONTROL_LAYER_NONE)
3955 , __orientation(_CONTROL_ORIENTATION_PORTRAIT)
3956 , __rotation(_CONTROL_ROTATION_0)
3957 , __pTouchEventPreviewer(null)
3958 , __pKeyEventPreviewer(null)
3959 , __pNotificationEventPreviewer(null)
3960 , __pKeyEventListener(null)
3961 , __pFocusEventListener(null)
3962 , __pNotificationEventListener(null)
3963 , __pCoreGestureDetectors(null)
3964 , __pDetectStartedGestureMap(null)
3965 , __pDelayedTouchInfoList(null)
3966 , __touchMoveAllowance(3)
3967 , __pressThresHold(0.0f)
3968 , __inputLockRefCount(0)
3970 , __isSentDelayedEvent(false)
3971 , __isSendingDelayedEvent(false)
3972 , __isChangingEventTarget(false)
3973 , __pDataBindingContext(null)
3974 , __pControlDelegate(null)
3976 , __destroying(false)
3977 , __isEventEnableState(true)
3978 , __isEffectSoundEnabled(true)
3979 , __isControlFontChanged(false)
3982 , __fontFileName(L"")
3983 , __pPreviousFocus(null)
3984 , __pNextFocus(null)
3988 SetControlDelegate(*this);
3989 __pAccessibilityContainer = new (std::nothrow) _AccessibilityContainer(*this);
3990 __pAccessibilityContainer->Activate(true);
3992 __pLayoutItemHandler = new (std::nothrow) LayoutItemHandler(this);
3993 if (!__pLayoutItemHandler)
3998 __pLayoutContainer = CreateLayoutContainerN(__pLayoutItemHandler);
3999 if (!__pLayoutContainer)
4004 __pChildren = ::CreateControlListN();
4010 __pOwnees = ::CreateWindowListN();
4016 __pVisualElement = ::CreateVisualElementN();
4017 if (!__pVisualElement)
4022 __pVisualElement->SetUserData(this);
4023 __pVisualElement->SetClipChildrenEnabled(true);
4024 __pVisualElement->SetRedrawOnResizeEnabled(true);
4026 __pVisualElementContentProvider = new (std::nothrow) ControlVisualElementContentProvider(*this);
4027 SysTryCatch(NID_UI, __pVisualElementContentProvider, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4029 GetVisualElement()->SetContentProvider(__pVisualElementContentProvider);
4031 __pVisualElementEventListener = new (std::nothrow) ControlVisualElementEventListener(*this);
4032 SysTryCatch(NID_UI, __pVisualElementEventListener, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4034 GetVisualElement()->SetVisualElementEventListener(__pVisualElementEventListener);
4036 __pDetectStartedGestureMap = ::CreateGestureMapN();
4037 if (!__pDetectStartedGestureMap)
4042 __pCoreGestureDetectors = new (std::nothrow) LinkedListT<_TouchGestureDetector*>;
4043 if (!__pCoreGestureDetectors)
4048 __pDelayedTouchInfoList = new (std::nothrow) LinkedListT<_TouchInfo*>;
4049 if (!__pDelayedTouchInfoList)
4054 SetEventPreviewer<_UI_EVENT_TOUCH>(this);
4055 SetEventPreviewer<_UI_EVENT_KEY>(this);
4056 SetEventPreviewer<_UI_EVENT_NOTIFICAITON>(this);
4058 SetEventListener<_UI_EVENT_NOTIFICAITON>(this);
4059 SetEventListener<_UI_EVENT_FOCUS>(this);
4061 SetPropagatedTouchEventListener(this);
4062 SetPropagatedKeyEventListener(this);
4063 GET_COLOR_CONFIG(BASIC::background, __backgroundColor);
4065 if (IsFailed(GetLastResult()))
4067 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
4070 __screenDpi = _ControlManager::GetInstance()->GetScreenDpi();
4080 _Control::AcquireHandle(void)
4082 __controlHandle = _ControlManager::GetInstance()->Register(this); // [ToDo] exception?
4086 _Control::ReleaseHandle(void)
4088 _ControlManager::GetInstance()->Release(__controlHandle); // [ToDo] exception?
4092 _Control::SetDrawWhenVisible(bool draw)
4094 __drawWhenVisible = draw;
4098 _Control::IsDrawWhenVisible(void)
4100 return __drawWhenVisible;
4104 _Control::SetTerminatingOrder(bool postOrderTraversal)
4106 __isPostOrderTraversal = postOrderTraversal;
4110 _Control::IsPostOrderTraversal(void)
4112 return __isPostOrderTraversal;
4116 _Control::SetParent(_Control* pParent)
4119 __pParent = pParent;
4123 // Only called by _Window::SetOwner(pOwner)
4125 _Control::AttachOwnee(_Window& window)
4128 result r = E_SUCCESS;
4130 _Control* pOldOwner = window.GetOwner();
4133 pOldOwner->DetachOwnee(window);
4136 r = __pOwnees->Add(&window);
4139 SysLogException(NID_UI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4140 return E_OUT_OF_MEMORY;
4147 _Control::GetOwneeCount(void) const
4150 return __pOwnees->GetCount();
4155 _Control::GetOwnee(int index) const
4158 result r = E_SUCCESS;
4160 _Window* pOwnee = null;
4161 r = __pOwnees->GetAt(index, pOwnee);
4164 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
4171 // Called by _Window::SetOwner(null)
4173 _Control::DetachOwnee(_Window& ownee)
4176 result r = E_SUCCESS;
4178 _Control* pOwner = ownee.GetOwner();
4184 r = __pOwnees->Remove(&ownee);
4187 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
4192 _Control::DetachAllOwnees(void)
4196 int owneeCount = GetOwneeCount();
4197 while (owneeCount--)
4199 _Window* pOwnee = GetOwnee(0);
4205 pOwnee->SetOwner(null);
4209 _Layout::LayoutContainer&
4210 _Control::GetLayoutContainer() const
4212 return *__pLayoutContainer;
4216 _Control::SetMultiTouchEnabled(bool enabled)
4219 __multiTouchEnabled = enabled;
4223 _Control::IsMultiTouchEnabled(void) const
4226 return __multiTouchEnabled;
4230 _Control::SetMovable(bool movable)
4233 __movable = movable;
4237 _Control::SetResizable(bool resizable)
4243 __minSize = __maxSize = GetSizeF();
4246 if (!__resizable && resizable)
4248 __minSize = FloatDimension(0.0f, 0.0f);
4249 __maxSize = FloatDimension(MAX_LENGTH, MAX_LENGTH);
4252 __resizable = resizable;
4256 _Control::GetLayout(void) const
4259 _Layout::Layout* pLayout = __pLayoutContainer->GetLayout();
4261 SysAssert(GetLastResult() == E_SUCCESS);
4266 _Control::SetCurrentLayout(_Layout::Layout& layout)
4269 return __pLayoutContainer->SetCurrentLayout(layout);
4273 _Control::AddLayout(_Layout::Layout& layout)
4276 return __pLayoutContainer->AddLayout(layout);
4280 _Control::SetUpdateLayoutState(bool state)
4282 _Layout::Layout* pLayout = GetLayout();
4285 pLayout->SetUpdateState(state);
4290 _Control::SetEffectSoundEnabled(bool enable)
4292 __isEffectSoundEnabled = enable;
4296 _Control::IsEffectSoundEnabled(void) const
4298 return __isEffectSoundEnabled;
4301 _DataBindingContext*
4302 _Control::GetDataBindingContext(void)
4304 return __pDataBindingContext;
4306 _AccessibilityContainer*
4307 _Control::GetAccessibilityContainer(void)
4309 return __pAccessibilityContainer;
4312 _Control::SetDataBindingContext(_DataBindingContext* pDataBindingContext)
4314 __pDataBindingContext = pDataBindingContext;
4318 _Control::GetDescription(void) const
4324 _Control::SetTouchCapture(bool allowOutOfBounds, bool allowOwnerBounds)
4326 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4327 SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null");
4329 pTouchManager->SetCapturedControl(this, allowOutOfBounds, allowOwnerBounds);
4333 _Control::ReleaseTouchCapture(void)
4335 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4336 SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null");
4338 pTouchManager->SetCapturedControl(null, false, false);
4342 _Control::GetTopmostChildAt(const Point& point) const
4344 _Control* pTouchedControl = null;
4345 FloatPoint ptf((float) point.x, (float) point.y);
4346 _ControlManager* pControlManager = _ControlManager::GetInstance();
4347 SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist.");
4349 _Window* pRootWindow = GetRootWindow();
4350 SysTryReturn(NID_UI, pRootWindow, null, E_SYSTEM, "[E_SYSTEM] GetRootWindow() is null, this control is detached from the main trree");
4352 _ControlVisualElement* pRootControlElement = dynamic_cast <_ControlVisualElement*>(pRootWindow->GetVisualElement());
4353 SysTryReturn(NID_UI, pRootControlElement, null, E_SYSTEM, "[E_SYSTEM] pRootControlElement is null.");
4355 _ControlVisualElement* pHitTestElm = pRootControlElement->GetControlChildAtPoint(ptf);
4356 if (pHitTestElm == null)
4358 SysSecureLog(NID_UI, "pHitTestElm is null, point(%f, %f)", ptf.x, ptf.y);
4362 pTouchedControl = static_cast <_Control*>(pHitTestElm->GetUserData());
4364 return pTouchedControl;
4368 _Control::SetContentAreaBounds(const Rectangle& rect)
4372 __contentAreaBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
4376 _Control::SetContentAreaBounds(const FloatRectangle& rect)
4380 __contentAreaBounds = rect;
4384 _Control::GetContentAreaBounds(void) const
4386 return _CoordinateSystemUtils::ConvertToInteger(__contentAreaBounds);
4390 _Control::GetContentAreaBoundsF(void) const
4392 return __contentAreaBounds;
4396 _Control::GetCapturedBitmapN(bool includeChildren) const
4398 result r = E_SUCCESS;
4400 Canvas* pCanvas = null;
4401 Bitmap* pBitmap = null;
4403 pBitmap = GetControlDelegate().OnCapturedBitmapRequestedN();
4404 if (pBitmap == null)
4406 FloatRectangle rect;
4408 Rectangle boundsInCanvas = GetBounds();
4409 boundsInCanvas.x = boundsInCanvas.y = 0;
4411 pCanvas = new (std::nothrow) Canvas;
4412 SysTryReturn(NID_UI, pCanvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4414 r = pCanvas->Construct(boundsInCanvas);
4415 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
4417 GetVisualElement()->Draw();
4418 ClearLastResult(); // [ToDo] Temp.
4420 rect.SetBounds(boundsInCanvas.x, boundsInCanvas.y, boundsInCanvas.width, boundsInCanvas.height);
4422 r = GetVisualElement()->Capture(*pCanvas, rect, includeChildren);
4423 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
4425 pBitmap = new (std::nothrow) Bitmap;
4426 SysTryCatch(NID_UI, pBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4428 r = pBitmap->Construct(*pCanvas, boundsInCanvas);
4431 SysAssert(r == E_OUT_OF_MEMORY);
4432 SysTryCatch(NID_UI, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4435 SysLog(NID_UI, "Bitmap (width:%d, height:%d)", pBitmap->GetWidth(), pBitmap->GetHeight());
4439 _BitmapImpl::ConvertToNonpremultiplied(*pBitmap, true);
4451 Tizen::Graphics::Rectangle
4452 _Control::GetInvalidatedBounds(void) const
4454 return _CoordinateSystemUtils::ConvertToInteger(__invalidatedBounds);
4457 Tizen::Graphics::FloatRectangle
4458 _Control::GetInvalidatedBoundsF(void) const
4460 return __invalidatedBounds;
4464 _Control::AddGestureDetector(const _TouchGestureDetector& gestureDetector)
4468 bool exist = __pCoreGestureDetectors->Contains(const_cast<_TouchGestureDetector*>(&gestureDetector));
4469 SysTryReturnResult(NID_UI, exist == false, E_OBJ_ALREADY_EXIST, "[E_OBJ_ALREADY_EXIST]__pCoreGestureDetectors has gesture already");
4471 result r = __pCoreGestureDetectors->Add(const_cast<_TouchGestureDetector*>(&gestureDetector));
4472 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4474 r = const_cast<_TouchGestureDetector&>(gestureDetector).SetControl(*this);
4475 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "Control handle is not valid.");
4477 const_cast<_TouchGestureDetector&>(gestureDetector).OnTouchGestureDetectorAdded();
4483 _Control::RemoveGestureDetector(const _TouchGestureDetector& gestureDetector)
4487 result r = __pCoreGestureDetectors->Remove(&(const_cast<_TouchGestureDetector&>(gestureDetector)));
4493 const_cast<_TouchGestureDetector&>(gestureDetector).OnTouchGestureDetectorRemoved();
4498 IListT <_TouchGestureDetector*>*
4499 _Control::GetGestureDetectorList(void) const
4501 return __pCoreGestureDetectors;
4504 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>*
4505 _Control::GetStartedGestureDetectorEnumeratorN(void) const
4507 return __pDetectStartedGestureMap->GetMapEnumeratorN();
4510 IListT <_TouchGestureDetector*>*
4511 _Control::GetStartedGestureDetectorListN(void) const
4513 return __pDetectStartedGestureMap->GetKeysN();
4517 _Control::AddStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state)
4521 result r = E_SUCCESS;
4524 __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist);
4528 r = __pDetectStartedGestureMap->Add(const_cast<_TouchGestureDetector*>(&gestureDetector), state);
4535 _Control::SetStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state)
4539 result r = E_SUCCESS;
4542 __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist);
4546 r = __pDetectStartedGestureMap->SetValue(const_cast<_TouchGestureDetector*>(&gestureDetector), state);
4553 _Control::ClearStartedGestureDetectorList(void)
4557 result r = E_SUCCESS;
4559 IListT<_TouchGestureDetector*>* pList = __pDetectStartedGestureMap->GetKeysN();
4562 IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pList->GetEnumeratorN();
4565 while(pEnumerator->MoveNext() == E_SUCCESS)
4567 _TouchGestureDetector* pGestureDetector = null;
4568 pEnumerator->GetCurrent(pGestureDetector);
4570 if (pGestureDetector == null)
4575 __pDetectStartedGestureMap->Remove(pGestureDetector);
4582 IEnumeratorT<_TouchInfo*>* pEnumerator = __pDelayedTouchInfoList->GetEnumeratorN();
4585 while(pEnumerator->MoveNext() == E_SUCCESS)
4587 _TouchInfo* pTouchInfo = null;
4588 pEnumerator->GetCurrent(pTouchInfo);
4589 if (pTouchInfo == null)
4597 __pDelayedTouchInfoList->RemoveAll();
4601 __isSentDelayedEvent = false;
4602 __isSendingDelayedEvent = false;
4608 _Control::IsDelayedTouchEventEnabled(void) const
4610 bool existDelayTouchEventGesture = false;
4612 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4615 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4617 _TouchGestureDetector* pGestureDetector = null;
4618 pMapEnumerator->GetKey(pGestureDetector);
4620 if (pGestureDetector == null)
4625 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4626 pMapEnumerator->GetValue(state);
4628 if (pGestureDetector->IsDelayTouchEventEnabled())
4630 existDelayTouchEventGesture = true;
4633 delete pMapEnumerator;
4636 bool delayTouchEvent = false;
4637 if (existDelayTouchEventGesture)
4639 pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4642 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4644 _TouchGestureDetector* pGestureDetector = null;
4645 pMapEnumerator->GetKey(pGestureDetector);
4647 if (pGestureDetector == null)
4652 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4653 pMapEnumerator->GetValue(state);
4655 if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED)
4657 delayTouchEvent = true;
4661 delete pMapEnumerator;
4664 return delayTouchEvent;
4673 _Control::IsPossibleToSendDelayedTouchEvent(void) const
4675 bool existDelayTouchEventGesture = false;
4677 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4680 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4682 _TouchGestureDetector* pGestureDetector = null;
4683 pMapEnumerator->GetKey(pGestureDetector);
4685 if (pGestureDetector == null)
4690 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4691 pMapEnumerator->GetValue(state);
4693 if (pGestureDetector->IsDelayTouchEventEnabled())
4695 existDelayTouchEventGesture = true;
4698 delete pMapEnumerator;
4701 bool allFailed = true;
4702 if (existDelayTouchEventGesture)
4704 pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4707 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4709 _TouchGestureDetector* pGestureDetector = null;
4710 pMapEnumerator->GetKey(pGestureDetector);
4712 if (pGestureDetector == null)
4717 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4718 pMapEnumerator->GetValue(state);
4720 if (state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS)
4726 delete pMapEnumerator;
4738 _Control::IsCancelOnGestureSuccess(void) const
4740 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4741 SysAssert(pTouchManager != null);
4743 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4746 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4748 _TouchGestureDetector* pGestureDetector = null;
4749 pMapEnumerator->GetKey(pGestureDetector);
4751 if (pGestureDetector == null)
4756 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4757 pMapEnumerator->GetValue(state);
4759 if (pGestureDetector->IsCancelTouchEventOnSuccessEnabled() && state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS && !pTouchManager->IsTouchCanceledOnGestureSuccess())
4761 delete pMapEnumerator;
4765 delete pMapEnumerator;
4772 _Control::IsSentDelayedEvent(void) const
4774 return __isSentDelayedEvent;
4778 _Control::SetSentDelayedEvent(bool sent)
4780 __isSentDelayedEvent = sent;
4784 _Control::SetSendingDelayedEvent(bool sending)
4786 __isSendingDelayedEvent = sending;
4790 _Control::IsSendingDelayedEvent(void) const
4792 return __isSendingDelayedEvent;
4796 _Control::AddTouchInfo(const _TouchInfo& touchInfo)
4798 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4799 SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist.");
4801 _TouchInfo* pTouchInfo = new (std::nothrow) _TouchInfo;
4802 SysTryReturnVoidResult(NID_UI, pTouchInfo, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4804 FloatPoint screenPoint = pTouchManager->GetScreenPoint(touchInfo.GetPointId());
4805 pTouchInfo->SetTouchInfo(touchInfo.GetPointId(), touchInfo.GetTouchStatus(), screenPoint, false, 0);
4806 __pDelayedTouchInfoList->Add(pTouchInfo);
4809 IListT<_TouchInfo*>*
4810 _Control::GetTouchInfoList(void)
4812 return __pDelayedTouchInfoList;
4816 _Control::SetVisualElement(_ControlVisualElement* pVisualElement)
4818 __pVisualElement = pVisualElement;
4822 _Control::GetVisualElement(void) const
4824 return __pVisualElement;
4828 _Control::PrintDescription(bool printChildren, int level)
4830 int count = PrintDescription(printChildren, 0, level);
4832 SysSecureLog(NID_UI, "%d controls were printed.", count);
4836 _Control::PrintDescription(bool printChildren, int depth, int level)
4838 const int PRINT_CONTROL_VE = 1;
4839 const int PRINT_CONTROL_EVAS = 2;
4840 const int PRINT_CONTROL_VE_EVAS = 3;
4845 format.Format(LOG_LEN_MAX, L"%d", depth);
4847 for (int i = 0; i < depth; i++)
4849 indent.Append(L" ");
4852 indent.Append(format);
4854 String delimiter(L"-------------------------------------------------------------------------------------------");
4855 SysSecureLog(NID_UI, "%ls", delimiter.GetPointer());
4858 String publicDescription = GetControlDelegate().GetDescription();
4859 if (!publicDescription.IsEmpty())
4861 SysSecureLog(NID_UI, "%ls %ls", indent.GetPointer(), publicDescription.GetPointer());
4864 _ControlManager* pControlManager = _ControlManager::GetInstance();
4865 SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist.");
4867 bool focused = false;
4868 _Control* pFocusedControl = pControlManager->GetFocusControl();
4869 if (pFocusedControl && (pFocusedControl == this))
4875 SysSecureLog(NID_UI, "%ls 0x%x(%d %ls) enable(%d) enableState(%d) visible(%d) visibleState(%d) focusable(%d) focused(%d) clip(%d) movable(%d) resizable(%d) inputEnableState(%d)",
4876 indent.GetPointer(), this, __controlHandle.ToInt(), GetName().GetPointer(), IsEnabled(), GetEnableState(), IsVisible(), GetVisibleState(),
4877 IsFocusable(), focused, IsClipToParent(), IsMovable(), IsResizable(), GetInputEnableState());
4879 Rectangle bounds = GetBounds();
4880 Dimension min = GetMinimumSize();
4881 Dimension max = GetMaximumSize();
4882 Rectangle clientBounds = GetClientBounds();
4883 Rectangle absoluteBounds = GetAbsoluteBounds();
4885 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)",
4886 indent.GetPointer(), bounds.x, bounds.y, bounds.width, bounds.height,
4887 min.width, min.height, max.width, max.height,
4888 GetVerticalScrollPosition(), GetHorizontalScrollPosition(),
4889 clientBounds.x, clientBounds.y, clientBounds.width, clientBounds.height,
4890 absoluteBounds.x, absoluteBounds.y, absoluteBounds.width, absoluteBounds.height);
4892 SysSecureLog(NID_UI, "%ls bgColor(0x%x) layoutable(%d) orientation(%d) drag(%d) drop(%d) area(%d) layer(%d)",
4893 indent.GetPointer(), __backgroundColor.GetRGB32(), IsLayoutable(), GetOrientation(), IsDragEnabled(), IsDropEnabled(), GetArea(), GetLayer());
4895 Canvas* pCanvas = GetCanvasN();
4898 Rectangle canvasBounds = pCanvas->GetBounds();
4899 Color canvasBackgroundColor = pCanvas->GetBackgroundColor();
4900 Color canvasForegroundColor = pCanvas->GetForegroundColor();
4902 SysSecureLog(NID_UI, "%ls canvas.bounds(%d %d %d %d) canvas.bgColor(0x%x) canvas.fgColor(0x%x)",
4903 indent.GetPointer(), canvasBounds.x, canvasBounds.y, canvasBounds.width, canvasBounds.height, canvasBackgroundColor.GetRGB32(), canvasForegroundColor.GetRGB32());
4908 SysSecureLog(NID_UI, "%ls DataBindingContext(0x%x) ControlDelegate(0x%x) UserData(0x%x) destroying(%d)",
4909 indent.GetPointer(), __pDataBindingContext, __pControlDelegate, __pUserData, __destroying);
4914 for (int i = 0; i < GetOwneeCount(); ++i)
4917 _Window* pOwnee = GetOwnee(i);
4920 ownee.Format(LOG_LEN_MAX, L"0x%x ", pOwnee);
4921 ownees.Append(ownee);
4925 if (!ownees.IsEmpty())
4927 SysSecureLog(NID_UI, "%ls Ownees(%ls)", indent.GetPointer(), ownees.GetPointer());
4930 _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*__pVisualElement);
4932 SysSecureLog(NID_UI, "%ls _VisualElement(0x%x) _VisualElementImpl(0x%x) VisualElementContentProvider(0x%x) VisualElementEventListener(0x%x)",
4933 indent.GetPointer(), __pVisualElement, pVisualElementImpl, __pVisualElementContentProvider, __pVisualElementEventListener);
4936 SysSecureLog(NID_UI, "%ls LayoutItemHandler(0x%x) PortraitLayout(0x%x) LandscapeLayout(0x%x) LayoutContainer(0x%x)",
4937 indent.GetPointer(), __pLayoutItemHandler, __pPortraitLayout, __pLandscapeLayout, __pLayoutContainer);
4940 String description = GetDescription();
4941 if (!description.IsEmpty())
4943 SysSecureLog(NID_UI, "%ls %ls", indent.GetPointer(), description.GetPointer());
4946 // Print Gesture List
4947 IListT<_TouchGestureDetector*>* pGestureList = GetGestureDetectorList();
4948 SysTryReturn(NID_UI, pGestureList, 0, E_SYSTEM, "[E_SYSTEM] System error occurred.");
4950 IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN();
4951 SysTryReturn(NID_UI, pEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4953 while (pEnumerator->MoveNext() == E_SUCCESS)
4955 _TouchGestureDetector* pGestureDetector = null;
4956 pEnumerator->GetCurrent(pGestureDetector);
4957 if (pGestureDetector)
4959 SysSecureLog(NID_UI, "%ls AddedGesture : %ls", indent.GetPointer(), pGestureDetector->GetDescription().GetPointer());
4965 // Print Started Gesture List
4966 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pStartedGestureEnumerator = GetStartedGestureDetectorEnumeratorN();
4967 SysTryReturn(NID_UI, pStartedGestureEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4969 while (pStartedGestureEnumerator->MoveNext() == E_SUCCESS)
4971 _TouchGestureDetector* pStartedGestureDetector = null;
4972 pStartedGestureEnumerator->GetKey(pStartedGestureDetector);
4973 if (pStartedGestureDetector)
4975 SysSecureLog(NID_UI, "%ls StartedGesture : %ls", indent.GetPointer(), pStartedGestureDetector->GetDescription().GetPointer());
4979 delete pStartedGestureEnumerator;
4981 // Print VE and Evas
4984 case PRINT_CONTROL_VE:
4985 _VeDebug::DumpVeTree(pVisualElementImpl, 0);
4988 case PRINT_CONTROL_EVAS:
4989 _VeDebug::DumpEvasTree(pVisualElementImpl, 0);
4992 case PRINT_CONTROL_VE_EVAS:
4993 _VeDebug::DumpVeTree(pVisualElementImpl, 0);
4994 _VeDebug::DumpEvasTree(pVisualElementImpl, 0);
5001 static int totalCount = 0;
5012 int count = GetChildCount();
5013 totalCount += count;
5015 for (int i = count - 1; i >= 0; --i)
5017 _Control* pChild = GetChild(i);
5020 pChild->PrintDescription(printChildren, depth, level);
5028 _ITouchEventPreviewer*
5029 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>) const
5031 return __pTouchEventPreviewer;
5034 _IKeyEventPreviewer*
5035 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_KEY>) const
5037 return __pKeyEventPreviewer;
5040 _INotificationEventPreviewer*
5041 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>) const
5043 return __pNotificationEventPreviewer;
5047 _Control::GetEventListener(_IntToType<_UI_EVENT_KEY>) const
5049 return __pKeyEventListener;
5052 _IFocusEventListener*
5053 _Control::GetEventListener(_IntToType<_UI_EVENT_FOCUS>) const
5055 return __pFocusEventListener;
5058 _INotificationEventListener*
5059 _Control::GetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>) const
5061 return __pNotificationEventListener;
5065 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>, _ITouchEventPreviewer* pPreviewer)
5067 __pTouchEventPreviewer = pPreviewer;
5071 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_KEY>, _IKeyEventPreviewer* pPreviewer)
5073 __pKeyEventPreviewer = pPreviewer;
5077 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventPreviewer* pPreviewer)
5079 __pNotificationEventPreviewer = pPreviewer;
5083 _Control::SetEventListener(_IntToType<_UI_EVENT_FOCUS>, _IFocusEventListener* pListener)
5085 __pFocusEventListener = pListener;
5089 _Control::SetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventListener* pListener)
5091 __pNotificationEventListener = pListener;
5095 _Control::IsDragEnabled(void) const
5097 return __dragEnabled;
5101 _Control::IsDropEnabled(void) const
5103 return __dropEnabled;
5107 _Control::SetDragEnabled(bool enabled)
5109 __dragEnabled = enabled;
5113 _Control::SetDropEnabled(bool enabled)
5115 __dropEnabled = enabled;
5119 _Control::SetTouchPressThreshold(float distance)
5121 __touchMoveAllowance = static_cast<int>(distance * __screenDpi);
5122 __pressThresHold = distance;
5126 _Control::GetTouchPressThreshold(void) const
5128 return __pressThresHold;
5132 _Control::GetTouchPressThresholdPixel(void) const
5134 return __touchMoveAllowance;
5138 _Control::SetChangingEventTarget(bool isChangingEventTarget)
5140 __isChangingEventTarget = isChangingEventTarget;
5144 _Control::GetChangingEventTarget(void) const
5146 return __isChangingEventTarget;
5150 _Control::SetEventEnableState(bool enableState)
5152 __isEventEnableState = enableState;
5156 _Control::IsEventEnabled(void) const
5158 return __isEventEnableState;
5162 _Control::SetPreviousFocus(_Control* pPreviousFocus)
5164 __pPreviousFocus = pPreviousFocus;
5168 _Control::SetNextFocus(_Control* pNextFocus)
5170 __pNextFocus = pNextFocus;
5173 _Control::GetPreviousFocus(void) const
5175 return __pPreviousFocus;
5178 _Control::GetNextFocus(void) const
5180 return __pNextFocus;
5184 _Control::OnDrawFocus(void)
5186 unique_ptr<VisualElement, _VisualElementDeleter> pFocusVisualElement (new (std::nothrow) VisualElement, _VisualElementDeleter());
5187 SysTryReturn(NID_UI, pFocusVisualElement, , E_SYSTEM, "[E_SYSTEM] System error");
5189 result r = pFocusVisualElement->Construct();
5190 SysTryReturn(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error");
5192 __pFocusVisualElement.reset(pFocusVisualElement.release());
5193 __pFocusVisualElement->SetImplicitAnimationEnabled(false);
5194 __pFocusVisualElement->SetShowState(true);
5196 _VisualElement* pControVisualElement = this->GetVisualElement();
5197 pControVisualElement->AttachChild(*__pFocusVisualElement);
5199 if (__pFocusVisualElement)
5201 Rectangle rectangle = GetBounds();
5202 __pFocusVisualElement->SetBounds(FloatRectangle(0, 0, rectangle.width, rectangle.height));
5203 unique_ptr<Canvas>pCanvas(__pFocusVisualElement->GetCanvasN());
5206 pCanvas->SetBackgroundColor(0x55555555);
5209 Color contentHighlightedColor;
5210 GET_COLOR_CONFIG(FOCUSUI::CONTENT_BG_HIGHLIGHTED, contentHighlightedColor);
5211 Bitmap* pBitmap = null;
5212 Bitmap* pTempBitmap = null;
5213 result r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
5214 pBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentHighlightedColor);
5218 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
5222 r = pCanvas->DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, rectangle.width, rectangle.height), *pBitmap);
5229 r = pCanvas->DrawBitmap(FloatRectangle(0.0f, 0.0f, rectangle.width, rectangle.height), *pBitmap);
5233 __pFocusVisualElement->SetShowState(true);
5238 _Control::OnChildControlFocusMoved(const _Control& control)
5243 _Control::OnDescendantControlFocusMoved(const _Control& control)
5248 _Control::IsChildControlFocusManage(void) const
5254 _Control::SetFontFromFile(const String& fileName)
5256 result r = E_SUCCESS;
5258 if (__fontFileName.Equals(fileName))
5263 __isControlFontChanged = true;
5264 __fontFileName = fileName;
5267 Font* pFont = GetFallbackFont();
5271 r = GetLastResult();
5272 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5278 _Control::GetFontFile(void) const
5280 return __fontFileName;
5283 _Control::DrawFocus(void)
5285 _IControlDelegate& delegate = GetControlDelegate();
5286 delegate.OnDrawFocus();
5290 _Control::MakeFocusList(const _Control* pControl, IListT<_Control*>* pFocusControlList) const
5292 int childCount = pControl->GetChildCount();
5293 for(int i = 0; i < childCount; i++)
5295 _Control* pChildControl = pControl->GetChild(i);
5296 Rectangle rect = pChildControl->GetAbsoluteBounds();
5297 unique_ptr<IEnumeratorT<_Control*> > pEnum (pFocusControlList->GetEnumeratorN());
5299 while (pEnum->MoveNext() == E_SUCCESS)
5301 _Control* pEnumeratorControl = null;
5302 pEnum->GetCurrent(pEnumeratorControl);
5303 if (pEnumeratorControl != null)
5305 Rectangle enumeratorRect = pEnumeratorControl->GetAbsoluteBounds();
5306 if(enumeratorRect.y > rect.y)
5310 else if (enumeratorRect.y == rect.y)
5312 if(enumeratorRect.x > rect.x)
5321 pFocusControlList->InsertAt(pChildControl, index);
5326 _Control::MakeChildContainerFocusList(const _Control* pControl, int startIndex , IListT<_Control*>* pFocusControlList) const
5328 unique_ptr<IListT<_Control*> > pTempList (new (std::nothrow) ArrayListT<_Control*>);
5329 SysTryReturnVoidResult(NID_UI_CTRL, pTempList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
5330 MakeFocusList(pControl, pTempList.get());
5332 unique_ptr<IEnumeratorT<_Control*> > pTempEnum(pTempList->GetEnumeratorN());
5333 int index = ++startIndex;
5334 while (pTempEnum->MoveNext() == E_SUCCESS)
5336 _Control* pEnumeratorControl = null;
5337 pTempEnum->GetCurrent(pEnumeratorControl);
5338 pFocusControlList->InsertAt(pEnumeratorControl, index);
5343 Tizen::Base::Collection::IListT<_Control*>*
5344 _Control::GetFocusListN(void) const
5346 unique_ptr<IListT<_Control*> > pControlFocusList (new (std::nothrow) ArrayListT<_Control*>);
5347 SysTryReturn(NID_UI_CTRL, pControlFocusList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
5348 MakeFocusList(this, pControlFocusList.get());
5350 unique_ptr<IEnumeratorT<_Control*> > pEnum(pControlFocusList->GetEnumeratorN());
5351 SysTryReturn(NID_UI_CTRL, pEnum, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
5353 int nextContainerIndex = -1;
5354 while (pEnum->MoveNext() == E_SUCCESS)
5356 _Control* pEnumeratorControl = null;
5357 pEnum->GetCurrent(pEnumeratorControl);
5359 if (nextContainerIndex < i)
5361 if (pEnumeratorControl->IsChildControlFocusManage() == false)
5363 MakeChildContainerFocusList(pEnumeratorControl, i, pControlFocusList.get());
5364 nextContainerIndex = i;
5365 pEnum.reset(pControlFocusList->GetEnumeratorN());
5371 return pControlFocusList.release();