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)
700 _Control::OnFocusLost(const _Control& source)
702 if (__pFocusVisualElement)
704 __pFocusVisualElement.reset();
710 _Control::OnPreviewNotifiedN(const _Control& source, IList* pArgs)
716 _Control::OnNotifiedN(const _Control& source, IList* pArgs)
722 _Control::IsMovable(void) const
729 _Control::IsResizable(void) const
736 _Control::GetContentSize(void) const
739 return Dimension(0, 0);
743 _Control::GetContentSizeF(bool horizontalMode, bool verticalMode) const
746 return FloatDimension(0.0f, 0.0f);
750 _Control::HitTest(const FloatPoint& point)
752 _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*__pVisualElement);
754 if (pVisualElementImpl)
756 if (pVisualElementImpl->HitTestI(point) == _VisualElementImpl::HITTEST_MATCH)
758 return HIT_TEST_MATCH;
762 return HIT_TEST_NOWHERE;
766 _Control::GetVerticalScrollPosition(void) const
772 _Control::GetHorizontalScrollPosition(void) const
778 _Control::GetOrientation(void) const
781 return __orientation;
785 _Control::OnDraw(void)
790 _Control::OnCanvasRequestedN(const FloatRectangle& bounds)
797 _Control::OnCapturedBitmapRequestedN(void)
804 _Control::OnAttaching(const _Control* pParent)
810 _Control::OnAttached(void)
816 _Control::OnAttachingToMainTree(const _Control* pParent)
822 _Control::OnPreAttachedToMainTree(void)
828 _Control::OnAttachedToMainTree(void)
834 _Control::OnDetachingFromMainTree(void)
840 _Control::OnAttachingFailed(const _Control& parent)
845 _Control::OnDetaching(void)
851 _Control::OnBoundsChanging(const Rectangle& bounds)
857 _Control::OnBoundsChanging(const FloatRectangle& bounds)
863 _Control::OnBoundsChanged(void)
869 _Control::OnEvaluateSize(Dimension& evaluatedSize)
875 _Control::OnEvaluateSize(FloatDimension& evaluatedSize)
881 _Control::OnParentBoundsChanged(const _Control& parent)
886 _Control::OnChildAttached(const _Control& child)
891 _Control::OnChildDetaching(const _Control& child)
896 _Control::OnChildDetached(const _Control& child)
901 _Control::OnChildBoundsChanged(const _Control& child)
906 _Control::OnChildVisibleStateChanged(const _Control& child)
911 _Control::OnChangeLayout(_ControlOrientation orientation)
916 _Control::OnChangeLayout(_ControlRotation rotation)
921 _Control::OnZOrderChanging(_ControlZOrderUpdate zOrderUpdate)
926 _Control::OnVisibleStateChanging(void)
931 _Control::OnVisibleStateChanged(void)
936 _Control::OnAncestorVisibleStateChanged(const _Control& control)
938 _TouchManager* pTouchManager = _TouchManager::GetInstance();
939 if (pTouchManager && IsVisible() == false)
941 if(pTouchManager->GetTouchControlSource() == this)
943 SysLog(NID_UI, "VisibleState changed false, Call SetTouchCanceled");
944 pTouchManager->SetTouchCanceled(null);
950 _Control::OnAncestorEnableStateChanged(const _Control& control)
955 _Control::OnAncestorInputEnableStateChanged(const _Control& control)
960 _Control::OnTouchPressHandled(const _Control& control)
965 _Control::OnTouchReleaseHandled(const _Control& control)
970 _Control::OnTouchMoveHandled(const _Control& control)
975 _Control::OnFontChanged(Tizen::Graphics::Font* pFont)
977 SetUpdateLayoutState(true);
981 _Control::OnFontInfoRequested(unsigned long& style, int& size)
986 _Control::OnFontInfoRequested(unsigned long& style, float& size)
991 _Control::OnBackgroundColorChanged(Color& backgroundColor)
996 _Control::OnFocusableStateChanged(bool focusalbeState)
1001 _Control::OnFocusModeStateChanged(void)
1006 _Control::OnTouchCancelHandled(const _Control& control)
1011 _Control::Accept(Visitor& visitor)
1015 VisitType visitType = visitor.Visit(*this);
1022 case VISIT_DOWNWARD:
1023 for (int i = 0; i < GetChildCount(); ++i) // [Postpone] Keep handle list before iternation.
1025 _Control* pChild = GetChild(i);
1028 pChild->Accept(visitor);
1035 _Control* pParent = GetParent();
1038 pParent->Accept(visitor);
1049 _Control::Accept(Visitor& visitor) const
1051 const_cast <_Control*>(this)->Accept(visitor);
1055 _Control::InvalidateHierarchyRootWindow(void)
1060 virtual VisitType Visit(_Control& control)
1062 control.__needRecalcRootWindow = true;
1063 control.__pRootWindow = null;
1065 return VISIT_DOWNWARD;
1074 _Control::Draw(bool recursive)
1078 Invalidate(recursive);
1079 GetVisualElement()->Draw();
1083 _Control::Show(void)
1085 GetVisualElement()->Flush();
1088 SysAssert(GetLastResult() == E_SUCCESS);
1092 _Control::ChangeLayout(_ControlOrientation orientation, bool callRotation)
1099 _Visitor(_ControlOrientation orientation)
1100 : __orientation(orientation){}
1102 virtual VisitType Visit(_Control& control)
1104 if (control.__orientation != __orientation)
1106 control.__orientation = __orientation;
1107 control.GetControlDelegate().OnChangeLayout(__orientation);
1111 return VISIT_DOWNWARD;
1115 _ControlOrientation __orientation;
1118 _Visitor visitor(orientation);
1121 SysAssert(GetLastResult() == E_SUCCESS);
1123 if (callRotation == true)
1125 _ControlManager* pMgr = _ControlManager::GetInstance();
1128 _ControlRotation rotation = pMgr->GetOrientationStatus();
1129 ChangeLayout(rotation);
1135 _Control::ChangeLayout(_ControlRotation rotation)
1142 _Visitor(_ControlRotation rotation)
1143 : __rotation(rotation){}
1145 virtual VisitType Visit(_Control& control)
1147 if (control.__rotation != __rotation)
1149 control.__rotation = __rotation;
1150 control.GetControlDelegate().OnChangeLayout(__rotation);
1154 return VISIT_DOWNWARD;
1158 _ControlRotation __rotation;
1161 _Visitor visitor(rotation);
1164 SysAssert(GetLastResult() == E_SUCCESS);
1168 _Control::IsLayoutChangable(void) const
1174 _Control::IsOrientationRoot(void) const
1180 _Control::Invalidate(void)
1183 GetVisualElement()->InvalidateRectangle(null);
1187 _Control::Invalidate(bool recursive)
1194 virtual VisitType Visit(_Control& control)
1196 if (control.GetVisibleState() == false)
1201 control.Invalidate();
1204 int owneeCount = control.GetOwneeCount();
1205 for (int i = 0; i < owneeCount; ++i)
1207 _Window* pOwnee = control.GetOwnee(i);
1210 pOwnee->Invalidate(true);
1214 return VISIT_DOWNWARD;
1219 _Layout::Layout* pLayout = GetLayout();
1222 pLayout->UpdateLayout();
1225 if (recursive == false)
1237 _Control::Invalidate(const Rectangle& rect)
1240 FloatRectangle rectf(rect.x, rect.y, rect.width, rect.height);
1241 GetVisualElement()->InvalidateRectangle(&rectf);
1243 __invalidatedBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
1247 _Control::Invalidate(const FloatRectangle& rect)
1250 FloatRectangle rectf(rect.x, rect.y, rect.width, rect.height);
1251 GetVisualElement()->InvalidateRectangle(&rectf);
1253 __invalidatedBounds = rect;
1257 _Control::Contains(const Point& point) const
1261 Rectangle bounds = GetBounds();
1262 bounds.x = bounds.y = 0;
1263 return bounds.Contains(point);
1267 _Control::Contains(const FloatPoint& point) const
1271 FloatRectangle bounds = GetBoundsF();
1272 bounds.x = bounds.y = 0;
1273 return bounds.Contains(point);
1278 _Control::PartialUpdateLayout(void)
1282 _Layout::Layout* pLayout = GetLayout();
1285 pLayout->PartialUpdateLayout();
1290 _Control::UpdateLayout(void)
1294 _Layout::Layout* pLayout = GetLayout();
1297 pLayout->UpdateLayout();
1302 _Control::SetChildAlwaysOnTop(_Control& child)
1306 SysTryReturn(NID_UI,
1307 child.GetParent() == this, E_INVALID_ARG,
1308 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1310 SysTryReturn(NID_UI,
1311 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1312 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1314 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_TOP)
1319 child.SetLayer(_CONTROL_LAYER_CLIENT_TOP);
1325 _Control::SetChildAlwaysAtBottom(_Control& child)
1329 SysTryReturn(NID_UI,
1330 child.GetParent() == this, E_INVALID_ARG,
1331 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1333 SysTryReturn(NID_UI,
1334 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1335 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1337 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_BOTTOM)
1342 child.SetLayer(_CONTROL_LAYER_CLIENT_BOTTOM);
1348 _Control::ResetChildLayer(_Control& child)
1352 SysTryReturn(NID_UI,
1353 child.GetParent() == this, E_INVALID_ARG,
1354 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1356 SysTryReturn(NID_UI,
1357 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1358 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1360 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_MIDDLE)
1365 child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE);
1372 _Control::AttachSystemChild(_Control& child)
1375 result r = E_SUCCESS;
1377 r = StartAttaching(child, _CONTROL_AREA_SYSTEM);
1383 ControlList& children = GetChildList();
1384 r = children.Add(&child);
1385 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1387 r = GetVisualElement()->AttachChild(*child.GetVisualElement());
1388 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1390 r = EndAttaching(child);
1396 SysAssert(GetLastResult() == E_SUCCESS);
1402 _Control::DetachSystemChild(_Control& child)
1404 return DetachChild(child);
1408 _Control::HasParent(void) const
1410 return __pParent != null;
1414 _Control::GetArea(void) const
1421 _Control::GetLayer(void) const
1428 _Control::SetLayer(_ControlLayer layer)
1431 _VisualElementImpl* pImpl = _VisualElementImpl::GetInstance(*GetVisualElement());
1433 result r = pImpl->SetZOrderGroup(::GetZOrderGroupOfVisualElement(layer));
1436 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1439 const _Control::ControlList&
1440 _Control::GetChildList() const
1442 return const_cast <_Control*>(this)->GetChildList();
1445 _Control::ControlList&
1446 _Control::GetChildList()
1448 return *__pChildren;
1452 _Control::IsCalledCallAttachingToMainTree(void)
1454 return __isCalledCallOnAttachingToMainTree;
1458 _Control::SetCalledCallAttachingToMainTree(bool isAttaching)
1460 __isCalledCallOnAttachingToMainTree = isAttaching;
1464 _Control::IsCalledCallPreAttachedToMainTree(void)
1466 return __isCalledCallOnPreAttachedToMainTree;
1470 _Control::IsCalledCallAttachedToMainTree(void)
1472 return __isCalledCallOnAttachedToMainTree;
1476 _Control::SetCalledCallPreAttachedToMainTree(bool isAttached)
1478 __isCalledCallOnPreAttachedToMainTree = isAttached;
1482 _Control::SetCalledCallAttachedToMainTree(bool isAttached)
1484 __isCalledCallOnAttachedToMainTree = isAttached;
1488 _Control::CallOnAttachingToMainTree(_Control& control)
1490 result r = E_SUCCESS;
1492 ControlList& children = control.GetChildList();
1493 _Control* pChild = null;
1495 int childrenCount = children.GetCount();
1497 for (int index = 0; index < childrenCount; index++)
1499 r = children.GetAt(index, pChild);
1502 SysAssert(r == E_OUT_OF_RANGE);
1503 SysTryReturn(NID_UI,
1504 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1505 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1507 if (!pChild->IsCalledCallAttachingToMainTree())
1509 r = CallOnAttachingToMainTree(*pChild);
1510 pChild->SetCalledCallAttachingToMainTree(true);
1511 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1515 if (!control.IsCalledCallAttachingToMainTree())
1517 r = control.GetControlDelegate().OnAttachingToMainTree(this);
1518 control.SetCalledCallAttachingToMainTree(true);
1519 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1526 _Control::CallOnPreAttachedToMainTree(_Control& control)
1528 result r = E_SUCCESS;
1530 ControlList& children = control.GetChildList();
1531 _Control* pChild = null;
1533 int childrenCount = children.GetCount();
1535 for (int index = 0; index < childrenCount; index++)
1537 r = children.GetAt(index, pChild);
1540 SysAssert(r == E_OUT_OF_RANGE);
1541 SysTryReturn(NID_UI,
1542 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1543 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1546 if (!pChild->IsCalledCallPreAttachedToMainTree())
1548 r = CallOnPreAttachedToMainTree(*pChild);
1549 pChild->SetCalledCallPreAttachedToMainTree(true);
1553 if (!control.IsCalledCallPreAttachedToMainTree())
1555 r = control.GetControlDelegate().OnPreAttachedToMainTree();
1556 control.SetCalledCallPreAttachedToMainTree(true);
1563 _Control::CallOnAttachedToMainTree(_Control& control)
1565 result r = E_SUCCESS;
1567 ControlList& children = control.GetChildList();
1568 _Control* pChild = null;
1570 int childrenCount = children.GetCount();
1572 for (int index = 0; index < childrenCount; index++)
1574 r = children.GetAt(index, pChild);
1577 SysAssert(r == E_OUT_OF_RANGE);
1578 SysTryReturn(NID_UI,
1579 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1580 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1583 if (!pChild->IsCalledCallAttachedToMainTree())
1585 r = CallOnAttachedToMainTree(*pChild);
1586 pChild->SetCalledCallAttachedToMainTree(true);
1590 if (!control.IsCalledCallAttachedToMainTree())
1592 r = control.GetControlDelegate().OnAttachedToMainTree();
1593 control.SetCalledCallAttachedToMainTree(true);
1600 _Control::CallOnDetachingFromMainTree(_Control& control)
1602 result r = E_SUCCESS;
1604 ControlList& children = control.GetChildList();
1605 _Control* pChild = null;
1607 _Window* pTop = control.GetRootWindow();
1610 _Control* pControl = pTop->GetFocusControl(this);
1611 if ((&control) == pControl)
1613 pTop->SetFocusControl(&control, false);
1615 _Control* pFocusTraversalControl = pTop->GetFocusTraversalControl(this);
1616 if ((&control) == pFocusTraversalControl)
1618 pTop->SetFocusTraversalControl(this);
1622 if (!__isPostOrderTraversal)
1624 r = control.GetControlDelegate().OnDetachingFromMainTree();
1625 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1628 int childrenCount = children.GetCount();
1630 for (int index = 0; index < childrenCount; index++)
1632 r = children.GetAt(index, pChild);
1635 SysAssert(r == E_OUT_OF_RANGE);
1636 SysTryReturn(NID_UI,
1637 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1638 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1640 r = CallOnDetachingFromMainTree(*pChild);
1641 pChild->SetCalledCallAttachingToMainTree(false);
1642 pChild->SetCalledCallPreAttachedToMainTree(false);
1643 pChild->SetCalledCallAttachedToMainTree(false);
1644 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1647 if (__isPostOrderTraversal)
1649 r = control.GetControlDelegate().OnDetachingFromMainTree();
1650 control.SetCalledCallAttachingToMainTree(false);
1651 control.SetCalledCallPreAttachedToMainTree(false);
1652 control.SetCalledCallAttachedToMainTree(false);
1653 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1660 _Control::CallOnAncestorVisibleStateChanged(void)
1665 _Visitor(_Control& parent)
1666 : __parent(parent){}
1668 virtual VisitType Visit(_Control& control)
1670 control.GetControlDelegate().OnAncestorVisibleStateChanged(__parent);
1671 return VISIT_DOWNWARD;
1677 _Visitor visitor(*this);
1682 _Control::CallOnAncestorEnableStateChanged(void)
1687 _Visitor(_Control& parent)
1688 : __parent(parent){}
1690 virtual VisitType Visit(_Control& control)
1692 control.GetControlDelegate().OnAncestorEnableStateChanged(__parent);
1693 return VISIT_DOWNWARD;
1699 _Visitor visitor(*this);
1704 _Control::CallOnAncestorInputEnableStateChanged(void)
1709 _Visitor(_Control& parent)
1710 : __parent(parent){}
1712 virtual VisitType Visit(_Control& control)
1714 control.GetControlDelegate().OnAncestorInputEnableStateChanged(__parent);
1715 return VISIT_DOWNWARD;
1721 _Visitor visitor(*this);
1727 // [ToDo] Rollback is difficult.
1729 _Control::StartAttaching(_Control& child, _ControlArea area)
1731 result r = E_SUCCESS;
1733 _Control* pOldParent = child.GetParent();
1735 SysTryReturn(NID_UI,
1736 (pOldParent != this), E_INVALID_ARG,
1737 E_INVALID_ARG, "[E_INVALID_ARG] The child control is already attached to this container.");
1739 SysTryReturn(NID_UI,
1740 pOldParent == null, E_INVALID_ARG,
1741 E_INVALID_ARG, "[E_INVALID_ARG] Unable to add the child which already has another parent.");
1743 r = child.GetControlDelegate().OnAttaching(this);
1744 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1746 if (IsAttachedToMainTree())
1748 r = CallOnAttachingToMainTree(child);
1749 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1752 // [ToDo] Add control to layout
1753 // What should we do about non-layoutable controls?
1754 if (area == _CONTROL_AREA_CLIENT)
1756 _ControlManager* pMgr = _ControlManager::GetInstance();
1757 r = GetLastResult();
1758 SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r));
1760 r = __pLayoutContainer->AddItem(child.GetLayoutContainer());
1763 child.GetControlDelegate().OnAttachingFailed(*this);
1764 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Failed to apply layout.");
1769 if (IsAttachedToMainTree())
1771 if (!(IsOrientationRoot() && child.IsOrientationRoot()))
1773 child.ChangeLayout(_ControlManager::GetInstance()->GetOrientation());
1777 child.__area = area;
1779 if (area == _CONTROL_AREA_CLIENT)
1781 if (child.GetLayer() != _CONTROL_LAYER_CLIENT_TOP && child.GetLayer() != _CONTROL_LAYER_CLIENT_BOTTOM)
1783 child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE);
1788 child.SetLayer(_CONTROL_LAYER_SYSTEM);
1791 SysAssert(GetLastResult() == E_SUCCESS);
1796 _Control::EndAttaching(_Control& child)
1798 child.SetParent(this);
1799 child.InvalidateHierarchyRootWindow();
1801 FloatRectangle floatBounds(child.GetBoundsF().x, child.GetBoundsF().y, child.GetBoundsF().width, child.GetBoundsF().height);
1803 result r = E_SUCCESS;
1804 if (child.IsLayoutChangable() == false)
1806 r = child.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, floatBounds.width, floatBounds.height));
1810 r = child.UpdateBoundsOfVisualElement(floatBounds);
1812 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1814 r = child.GetControlDelegate().OnAttached();
1815 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1817 if (IsAttachedToMainTree())
1819 r = CallOnPreAttachedToMainTree(child);
1820 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1822 r = CallOnAttachedToMainTree(child);
1823 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1828 GetControlDelegate().OnChildAttached(child);
1838 _Control::AttachChild(_Control& child)
1841 result r = E_SUCCESS;
1843 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1849 ControlList& children = GetChildList();
1850 r = children.Add(&child);
1851 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1853 r = GetVisualElement()->AttachChild(*child.GetVisualElement());
1855 r = EndAttaching(child);
1861 SysAssert(GetLastResult() == E_SUCCESS);
1867 _Control::UpdateFocusList(void)
1869 _Window* pTop = GetRootWindow();
1872 pTop->ResetFocusList();
1877 _Control::RemoveFocusRing(void)
1879 if (__pFocusVisualElement)
1881 __pFocusVisualElement.reset();
1886 _Control::HasFocusRing(void)
1888 if (__pFocusVisualElement)
1897 _Control::SetFocusNavigateEnabled(bool enable)
1899 __isNavigatable = enable;
1903 _Control::IsFocusNavigateEnabled(void) const
1905 return __isNavigatable;
1909 _Control::IsFocusModeStateEnabled(void) const
1911 return _FocusManagerImpl::GetInstance()->IsFocusModeStateEnabled();
1918 _Control::InsertChildToBottom(_Control& child)
1921 result r = E_SUCCESS;
1923 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1929 ControlList& children = GetChildList();
1930 r = children.InsertAt(&child, 0);
1931 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1933 GetVisualElement()->InsertChild(*child.GetVisualElement(), null, false);
1934 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1936 r = EndAttaching(child);
1942 SysAssert(GetLastResult() == E_SUCCESS);
1950 _Control::InsertChildAfter(const _Control& targetChild, _Control& child)
1953 result r = E_SUCCESS;
1955 SysTryReturn(NID_UI,
1956 targetChild.GetParent() == this, E_INVALID_ARG,
1957 E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child.");
1959 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1965 int targetIndex = GetChildIndex(targetChild);
1966 SysAssert(targetIndex != -1);
1968 ControlList& children = GetChildList();
1969 r = children.InsertAt(&child, targetIndex + 1);
1970 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1972 GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), true);
1973 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1975 r = EndAttaching(child);
1981 SysAssert(GetLastResult() == E_SUCCESS);
1989 _Control::InsertChildBefore(const _Control& targetChild, _Control& child)
1992 result r = E_SUCCESS;
1994 SysTryReturn(NID_UI,
1995 targetChild.GetParent() == this, E_INVALID_ARG,
1996 E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child.");
1998 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
2004 int targetIndex = GetChildIndex(targetChild);
2005 SysAssert(targetIndex != -1);
2007 ControlList& children = GetChildList();
2008 r = children.InsertAt(&child, targetIndex);
2009 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2011 GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), false);
2012 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2014 r = EndAttaching(child);
2020 SysAssert(GetLastResult() == E_SUCCESS);
2026 _Control::DetachChild(_Control& child)
2029 result r = E_SUCCESS;
2031 SysTryReturn(NID_UI,
2032 child.GetParent() == this, E_INVALID_ARG,
2033 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2035 if (IsAttachedToMainTree())
2037 r = CallOnDetachingFromMainTree(child);
2038 SysTryReturn(NID_UI,
2039 r == E_SUCCESS, E_SYSTEM,
2040 E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent.");
2042 SysTryReturn(NID_UI,
2043 child.GetControlDelegate().OnDetaching() == E_SUCCESS, E_SYSTEM,
2044 E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent.");
2047 GetControlDelegate().OnChildDetaching(child);
2050 r = GetVisualElement()->DetachChild(*child.GetVisualElement());
2051 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2053 ControlList& children = GetChildList();
2054 r = children.Remove(&child);
2055 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2057 // Remove control to layout
2058 if (child.__area == _CONTROL_AREA_CLIENT)
2060 _ControlManager* pMgr = _ControlManager::GetInstance();
2061 r = GetLastResult();
2062 SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r));
2064 r = __pLayoutContainer->RemoveItem(child.GetLayoutContainer());
2065 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2068 child.SetParent(null);
2069 child.__area = _CONTROL_AREA_NONE;
2070 child.__layer = _CONTROL_LAYER_NONE;
2072 GetControlDelegate().OnChildDetached(child);
2075 SysAssert(GetLastResult() == E_SUCCESS);
2077 child.InvalidateHierarchyRootWindow();
2084 _Control::DetachAllChildren(bool detachSystemChild, bool recursive)
2087 result r = E_SUCCESS;
2089 int childCount = GetChildCount();
2094 while (childCount--)
2096 _Control* pChild = GetChild(itemIndex);
2102 if (!detachSystemChild && (pChild->GetArea() == _CONTROL_AREA_SYSTEM))
2108 int childCount = pChild->GetChildCount();
2109 if (childCount == 0)
2111 r = DetachChild(*pChild);
2114 SysLog(NID_UI, "child is not detached from this container.");
2119 r = DetachChild(*pChild);
2122 SysLog(NID_UI, "child is not detached from this container.");
2124 pChild->DetachAllChildren(detachSystemChild, true);
2130 int notDetachedChildCount = 0;
2131 while (childCount--)
2133 _Control* pChild = GetChild(itemIndex);
2139 if (!detachSystemChild && (pChild->GetArea() == _CONTROL_AREA_SYSTEM))
2144 r = DetachChild(*pChild);
2148 ++notDetachedChildCount;
2152 SysLog(NID_UI, "%d children are not detached from this container.", notDetachedChildCount);
2160 _Control::MoveChildToTop(const _Control& child)
2163 result r = E_SUCCESS;
2165 SysTryReturn(NID_UI,
2166 child.GetParent() == this, E_INVALID_ARG,
2167 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2169 // If already on top,
2170 ControlList& children = GetChildList();
2171 if (GetChildIndex(child) == children.GetCount() - 1)
2173 SysAssert(GetLastResult() == E_SUCCESS);
2177 _Control* pChild = const_cast <_Control*>(&child);
2179 r = children.Remove(pChild);
2180 SysAssert(r == E_SUCCESS);
2182 r = children.Add(pChild);
2183 SysAssert(r == E_SUCCESS);
2185 r = child.GetVisualElement()->SetZOrder(null, true);
2186 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2188 SysAssert(GetLastResult() == E_SUCCESS);
2194 _Control::MoveChildToBottom(const _Control& child)
2197 result r = E_SUCCESS;
2199 SysTryReturn(NID_UI,
2200 child.GetParent() == this, E_INVALID_ARG,
2201 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2203 ControlList& children = GetChildList();
2205 if (GetChildIndex(child) == 0)
2207 SysAssert(GetLastResult() == E_SUCCESS);
2211 _Control* pChild = const_cast <_Control*>(&child);
2213 r = children.Remove(pChild);
2214 SysAssert(r == E_SUCCESS);
2216 r = children.InsertAt(pChild, 0);
2217 SysAssert(r == E_SUCCESS);
2219 r = child.GetVisualElement()->SetZOrder(null, false);
2220 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2222 SysAssert(GetLastResult() == E_SUCCESS);
2228 _Control::MoveChildAfter(const _Control& targetChild, const _Control& child)
2231 result r = E_SUCCESS;
2233 SysTryReturn(NID_UI,
2234 targetChild.GetParent() == this, E_INVALID_ARG,
2235 E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child.");
2237 SysTryReturn(NID_UI,
2238 child.GetParent() == this, E_INVALID_ARG,
2239 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2241 SysTryReturn(NID_UI,
2242 &targetChild != &child, E_INVALID_ARG,
2243 E_INVALID_ARG, "[E_INVALID_ARG] Cannot move after self.");
2245 ControlList& children = GetChildList();
2247 int targetIndex = GetChildIndex(targetChild);
2248 SysAssert(targetIndex != -1);
2250 if (targetIndex + 1 == GetChildIndex(child))
2252 SysAssert(GetLastResult() == E_SUCCESS);
2256 _Control* pChild = const_cast <_Control*>(&child);
2258 r = children.Remove(pChild);
2259 SysAssert(r == E_SUCCESS);
2261 r = children.InsertAt(pChild, targetIndex + 1);
2262 SysAssert(r == E_SUCCESS);
2264 r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), true);
2265 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2267 SysAssert(GetLastResult() == E_SUCCESS);
2273 _Control::MoveChildBefore(const _Control& targetChild, const _Control& child)
2276 result r = E_SUCCESS;
2278 SysTryReturn(NID_UI,
2279 targetChild.GetParent() == this, E_INVALID_ARG,
2280 E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child.");
2282 SysTryReturn(NID_UI,
2283 child.GetParent() == this, E_INVALID_ARG,
2284 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2286 SysTryReturn(NID_UI,
2287 &targetChild != &child, E_INVALID_ARG,
2288 E_INVALID_ARG, "[E_INVALID_ARG] Cannot move before self.");
2290 ControlList& children = GetChildList();
2292 int targetIndex = GetChildIndex(targetChild);
2293 SysAssert(targetIndex != -1);
2295 if (targetIndex - 1 == GetChildIndex(child))
2297 SysAssert(GetLastResult() == E_SUCCESS);
2301 _Control* pChild = const_cast <_Control*>(&child);
2303 r = children.Remove(pChild);
2304 SysAssert(r == E_SUCCESS);
2306 r = children.InsertAt(pChild, targetIndex);
2307 SysAssert(r == E_SUCCESS);
2309 r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), false);
2310 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2312 SysAssert(GetLastResult() == E_SUCCESS);
2319 _Control::GetChildIndex(const _Control& child) const
2322 result r = E_SUCCESS;
2324 SysTryReturn(NID_UI,
2325 child.GetParent() == this, -1,
2326 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2328 const ControlList& children = GetChildList();
2331 r = children.IndexOf(const_cast<_Control*>(&child), index);
2334 SysAssert(r == E_OBJ_NOT_FOUND);
2335 SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Unable to find the specified child.");
2339 SysAssert(GetLastResult() == E_SUCCESS);
2345 _Control::GetChild(int index) const
2348 result r = E_SUCCESS;
2350 const ControlList& children = GetChildList();
2352 _Control* pChild = null;
2353 r = children.GetAt(index, pChild);
2356 SysAssert(r == E_OUT_OF_RANGE);
2357 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
2361 SysAssert(GetLastResult() == E_SUCCESS);
2366 _Control::GetChildCount(void) const
2369 return GetChildList().GetCount();
2373 _Control::GetHandle(void) const
2375 return __controlHandle;
2379 _Control::GetUserData(void) const
2385 _Control::SetUserData(void* pUserData)
2387 __pUserData = pUserData;
2391 _Control::GetPropertyName(void) const
2394 return Tizen::Ui::Variant(__name);
2398 _Control::GetName(void) const
2400 Variant name = GetProperty("Name");
2402 return name.ToString();
2406 _Control::SetPropertyName(const Variant& name)
2409 __name = name.ToString();
2415 _Control::SetName(const String& name)
2417 SetProperty("Name", Variant(name));
2421 _Control::GetParent(void) const
2427 _Control::GetCanvasN(void) const
2429 return GetCanvasN(FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height));
2433 _Control::GetCanvasN(const Rectangle& bounds) const
2436 Canvas *pCanvas = GetControlDelegate().OnCanvasRequestedN(FloatRectangle(bounds.x, bounds.y, bounds.width, bounds.height));
2437 if (pCanvas == null)
2439 GetVisualElement()->SetFlushNeeded();
2440 pCanvas = GetVisualElement()->GetCanvasN(bounds);
2441 if (IsFailed(GetLastResult()))
2443 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
2446 if (pCanvas && !__isCalledGetCanvasN)
2448 pCanvas->SetBackgroundColor(GetBackgroundColor());
2450 const_cast <_Control*>(this)->__isCalledGetCanvasN = true;
2457 _Control::GetCanvasN(const FloatRectangle& bounds) const
2460 Canvas *pCanvas = GetControlDelegate().OnCanvasRequestedN(FloatRectangle(bounds));
2461 if (pCanvas == null)
2463 GetVisualElement()->SetFlushNeeded();
2464 pCanvas = GetVisualElement()->GetCanvasN(bounds);
2465 if (IsFailed(GetLastResult()))
2467 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
2470 if (pCanvas && !__isCalledGetCanvasN)
2472 pCanvas->SetBackgroundColor(GetBackgroundColor());
2474 const_cast <_Control*>(this)->__isCalledGetCanvasN = true;
2481 _Control::IsCalledGetCanvasN(void) const
2483 return __isCalledGetCanvasN;
2487 _Control::GetClientCanvasN(void) const
2489 return GetCanvasN(GetClientBounds());
2493 _Control::IsAncestorOf(const _Control& control) const
2497 const _Control* pParent = control.GetParent();
2507 const _Control& __ancestor;
2512 _Visitor(const _Control& ancestor)
2513 : __ancestor(ancestor)
2516 virtual VisitType Visit(_Control& control)
2518 if (&__ancestor == &control)
2525 return VISIT_UPWARD;
2530 _Visitor visitor(*this);
2531 pParent->Accept(visitor);
2533 SysAssert(GetLastResult() == E_SUCCESS);
2538 _Control::GetRootWindow(void) const
2542 if (!__needRecalcRootWindow && __pRootWindow != this)
2544 return __pRootWindow;
2555 virtual VisitType Visit(_Control& control)
2557 pRoot = dynamic_cast <_Window*>(&control);
2563 return VISIT_UPWARD;
2570 SysAssert(GetLastResult() == E_SUCCESS);
2572 const_cast<_Control*>(this)->__pRootWindow = visitor.pRoot;
2573 const_cast<_Control*>(this)->__needRecalcRootWindow = false;
2575 return visitor.pRoot;
2579 _Control::IsAttachedToMainTree(void) const
2583 _ControlManager* pMgr = _ControlManager::GetInstance();
2589 _Window* pRootWindow = GetRootWindow();
2590 if (pRootWindow == null)
2595 return pRootWindow->IsAttached();
2599 _Control::IsFocusable(void) const
2606 _Control::SetFocusable(bool focusable)
2609 bool oldState = __focusable;
2610 __focusable = focusable;
2611 if (oldState != __focusable)
2613 GetControlDelegate().OnFocusableStateChanged(focusable);
2618 _Control::IsNativeObjectFocusable(void) const
2621 return __nativeObjectFocusable;
2625 _Control::SetNativeObjectFocusable(bool focusable)
2628 __nativeObjectFocusable = focusable;
2632 _Control::IsFocused(void) const
2636 _Window* pTop = GetRootWindow();
2642 if (this == pTop->GetFocusControl(const_cast<_Control*>(this)))
2651 _Control::SetFocused(bool on)
2655 SysTryReturn(NID_UI,
2656 IsAttachedToMainTree(), E_INVALID_OPERATION,
2657 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control should have a parent or be attached to the main tree.");
2659 SysTryReturn(NID_UI,
2660 IsFocusable(), E_INVALID_OPERATION,
2661 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This Control isn't focusable control.");
2663 _Window* pTop = GetRootWindow();
2667 pTop->SetFocusControl(this, true);
2671 pTop->SetFocusControl(this, false);
2678 _Control::SetFont(const String& fontName)
2680 result r = E_SUCCESS;
2682 if (__fontName.Equals(fontName))
2687 __isControlFontChanged = true;
2688 __fontName = fontName;
2689 __fontFileName.Clear();
2691 Font* pFont = GetFallbackFont();
2695 r = GetLastResult();
2696 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2702 _Control::GetFallbackFont(void)
2704 unsigned long style = 0;
2706 float floatTextSize = 0.0f;
2707 result r = E_SUCCESS;
2708 _IControlDelegate& delegate = GetControlDelegate();
2709 delegate.OnFontInfoRequested(style, textSize);
2710 delegate.OnFontInfoRequested(style, floatTextSize);
2711 _ControlManager* pControlManager = _ControlManager::GetInstance();
2712 _FontImpl* pFontImpl = _FontImpl::GetInstance(*__pFont);
2713 if (!(__isControlFontChanged || pControlManager->IsDefaultFontChanged() || pControlManager->IsSystemFontChanged())
2715 && ((__pFont->GetSize() == textSize || __pFont->GetSizeF() == floatTextSize))
2716 && (pFontImpl->GetStyle() == static_cast<int>(style)))
2720 unique_ptr<Font>pTempFont(new(std::nothrow)Font());
2721 SysTryReturn(NID_UI , pTempFont , null , E_OUT_OF_MEMORY, "[%s] Fails to create a __pFont.", GetErrorMessage(r));
2723 if (!__fontName.IsEmpty())
2725 __isControlFontChanged = false;
2726 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2727 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2729 if (floatTextSize > 0.0f)
2731 r = pFontImpl->Construct(__fontName, style, floatTextSize, false);
2735 r = pFontImpl->Construct(__fontName, style, textSize, false);
2738 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2739 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2741 else if (!__fontFileName.IsEmpty())
2743 __isControlFontChanged = false;
2744 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2745 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2747 if (floatTextSize > 0.0f)
2749 r = pFontImpl->Construct(__fontFileName, style, floatTextSize);
2753 r = pFontImpl->Construct(__fontFileName, style, textSize);
2755 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2756 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2759 else if (!pControlManager->GetDefaultFont().IsEmpty())
2761 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2762 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2764 if (floatTextSize > 0.0f)
2766 r = pFontImpl->Construct(pControlManager->GetDefaultFont(), style, floatTextSize, false);
2770 r = pFontImpl->Construct(pControlManager->GetDefaultFont(), style, textSize, false);
2772 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2773 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2775 else if (!pControlManager->GetDefaultFontFile().IsEmpty())
2777 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2778 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2780 if (floatTextSize > 0.0f)
2782 r = pFontImpl->Construct(pControlManager->GetDefaultFontFile(), style, floatTextSize);
2786 r = pFontImpl->Construct(pControlManager->GetDefaultFontFile(), style, textSize);
2788 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2789 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2793 if (floatTextSize > 0.0f)
2795 r = pTempFont->Construct(style, floatTextSize);
2799 r = pTempFont->Construct(style, textSize);
2801 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2802 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2810 __pFont = pTempFont.release();
2811 delegate.OnFontChanged(__pFont);
2816 _Control::GetFont(void) const
2822 _Control::IsEnabled(void) const
2834 virtual VisitType Visit(_Control& control)
2836 if (!control.GetEnableState())
2842 return VISIT_UPWARD;
2848 return visitor.enabled;
2852 _Control::GetEnableState(void) const
2855 return __enabledState;
2859 _Control::SetEnableState(bool enabledState)
2862 const bool changed = (__enabledState != enabledState);
2865 __enabledState = enabledState;
2866 CallOnAncestorEnableStateChanged();
2868 __pAccessibilityContainer->SetEnableState(enabledState);
2872 _Control::IsInputEventEnabled(void) const
2882 : inputEnabled(true){}
2884 virtual VisitType Visit(_Control& control)
2886 if (!control.GetInputEnableState())
2888 inputEnabled = false;
2892 return VISIT_UPWARD;
2898 return visitor.inputEnabled;
2902 _Control::GetInputEnableState(void) const
2906 if (__inputLockRefCount != 0)
2917 _Control::LockInputEvent(void)
2919 __inputLockRefCount++;
2920 CallOnAncestorInputEnableStateChanged();
2924 _Control::UnlockInputEvent(void)
2926 __inputLockRefCount--;
2927 if (__inputLockRefCount < 0)
2929 __inputLockRefCount = 0;
2934 _Control::IsVisible(void) const
2938 SysTryReturn(NID_UI, IsAttachedToMainTree(), false, E_SYSTEM, "[E_SYSTEM] This control should be attached to the main tree.");
2948 virtual VisitType Visit(_Control& control)
2950 if (!control.GetVisibleState())
2956 return VISIT_UPWARD;
2963 SysAssert(GetLastResult() == E_SUCCESS);
2964 return visitor.visible;
2968 _Control::GetVisibleState(void) const
2971 return __visibleState;
2975 _Control::SetVisibleState(bool visibleState)
2979 const bool changed = (__visibleState != visibleState) || !__initVisibleState;
2983 GetControlDelegate().OnVisibleStateChanging();
2986 __visibleState = visibleState;
2987 GetVisualElement()->SetShowState(visibleState);
2989 if (visibleState == false)
2991 int owneeCount = GetOwneeCount();
2992 for (int i = 0; i < owneeCount; ++i)
2994 _Window* pWindow = GetOwnee(i);
2997 pWindow->SetVisibleState(visibleState);
3004 GetControlDelegate().OnVisibleStateChanged();
3005 CallOnAncestorVisibleStateChanged();
3006 _Control* pParent = GetParent();
3009 pParent->GetControlDelegate().OnChildVisibleStateChanged(*this);
3015 __initVisibleState = true;
3019 _Control::IsLayoutable(void) const
3026 _Control::IsClipToParent(void) const
3029 // SysAssert(GetVisualElement()->IsClipToParent() == __clipToParent);
3030 return __clipToParent;
3034 _Control::SetClipToParent(bool clipToParent)
3037 result r = E_SUCCESS;
3039 __clipToParent = clipToParent;
3040 r = GetVisualElement()->SetClipToParent(clipToParent);
3041 SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
3047 _Control::SetClipChildrenEnabled(bool clipChildren)
3050 //result r = E_SUCCESS;
3052 GetVisualElement()->SetClipChildrenEnabled(clipChildren);
3053 //SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
3059 _Control::GetBounds(void) const
3062 return _CoordinateSystemUtils::ConvertToInteger(__bounds);
3066 _Control::GetBoundsF(void) const
3073 _Control::GetPosition(void) const
3076 return Point(_CoordinateSystemUtils::ConvertToInteger(__bounds.x), _CoordinateSystemUtils::ConvertToInteger(__bounds.y));
3080 _Control::GetPositionF(void) const
3083 return FloatPoint(__bounds.x, __bounds.y);
3087 _Control::GetSize(void) const
3090 return Dimension(_CoordinateSystemUtils::ConvertToInteger(__bounds.width), _CoordinateSystemUtils::ConvertToInteger(__bounds.height));
3094 _Control::GetSizeF(void) const
3097 return FloatDimension(__bounds.width, __bounds.height);
3102 _Control::UpdateBoundsOfVisualElement(const FloatRectangle& controlBounds)
3104 FloatRectangle rect(controlBounds.x, controlBounds.y, controlBounds.width, controlBounds.height);
3106 _Control* pParent = GetParent();
3107 if (__area == _CONTROL_AREA_CLIENT && pParent)
3109 const FloatRectangle clientBounds = pParent->GetClientBoundsF();
3110 rect.x += clientBounds.x;
3111 rect.y += clientBounds.y;
3114 GetVisualElement()->SetBounds(rect);
3120 _Control::AdjustAbsoluteBounds(void)
3125 _Visitor(_Control* pControl)
3126 : __pControl(pControl){}
3128 virtual VisitType Visit(_Control& control)
3130 result r = E_SUCCESS;
3132 if (__pControl == &control)
3134 return VISIT_DOWNWARD;
3136 FloatRectangle fbounds = control.GetBoundsF();
3137 if (control.IsLayoutChangable() == false)
3139 r = control.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
3143 r = control.UpdateBoundsOfVisualElement(fbounds);
3146 ControlList& children = control.GetChildList();
3148 int childrenCount = children.GetCount();
3149 if (childrenCount <= 0)
3155 return VISIT_DOWNWARD;
3159 _Control* __pControl;
3162 _Visitor visitor(this);
3169 _Control::IsInSizeRange(const Dimension& size) const
3171 return (__minSize.width <= size.width) && (size.width <= __maxSize.width) &&
3172 (__minSize.height <= size.height) && (size.height <= __maxSize.height);
3176 _Control::IsInSizeRange(const FloatDimension& size) const
3178 return (__minSize.width <= size.width) && (size.width <= __maxSize.width) &&
3179 (__minSize.height <= size.height) && (size.height <= __maxSize.height);
3182 // Custom Exception: ex) Location::Map
3184 _Control::SetBoundsFinal(const FloatRectangle& newBounds, bool changeLayoutBaseRect, bool callBoundsChangeCallbacks)
3186 result r = E_SUCCESS;
3188 FloatRectangle bounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height);
3190 _IControlDelegate& delegate = GetControlDelegate();
3192 const bool moved = (__bounds.x != bounds.x) || (__bounds.y != bounds.y);
3193 const bool resized = (__bounds.width != bounds.width) || (__bounds.height != bounds.height);
3195 if ((moved || resized) && callBoundsChangeCallbacks)
3197 r = delegate.OnBoundsChanging(_CoordinateSystemUtils::ConvertToInteger(bounds));
3200 SysLogException(NID_UI, r, "[%s] Callback returns exception.", GetErrorMessage(r));
3201 return r; // Relay the result;
3203 r = delegate.OnBoundsChanging(bounds);
3206 SysLogException(NID_UI, r, "[%s] Callback returns exception.", GetErrorMessage(r));
3207 return r; // Relay the result;
3211 if (moved || resized)
3213 const FloatRectangle fbounds(bounds.x, bounds.y, bounds.width, bounds.height);
3214 if (IsLayoutChangable() == false)
3216 r = UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
3220 r = UpdateBoundsOfVisualElement(fbounds);
3224 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
3228 if (changeLayoutBaseRect)
3230 __pLayoutContainer->OnChangeBaseRect();
3233 if ((moved || resized) && callBoundsChangeCallbacks)
3235 if (IsMovable() && IsResizable())
3237 SetClientBounds(FloatRectangle(0.0f, 0.0f, GetSizeF().width, GetSizeF().height));
3239 if (__pFocusVisualElement)
3241 __pFocusVisualElement->SetBounds(FloatRectangle(0, 0, __bounds.width, __bounds.height));
3243 delegate.OnBoundsChanged();
3245 _Control* pParent = GetParent();
3248 pParent->GetControlDelegate().OnChildBoundsChanged(*this);
3251 ControlList& children = GetChildList();
3252 _Control* pChild = null;
3253 int childrenCount = children.GetCount();
3255 for (int index = 0; index < childrenCount; index++)
3257 r = children.GetAt(index, pChild);
3260 pChild->GetControlDelegate().OnParentBoundsChanged(*this);
3269 // Custom Exception: ex) Location::Map
3271 _Control::AdjustSizeToRange(void)
3274 result r = E_SUCCESS;
3276 SysAssert(IsResizable());
3278 FloatDimension size = GetSizeF();
3279 bool changed = ::AdjustSizeToRange(size, __minSize, __maxSize);
3285 FloatRectangle newBounds(__bounds.x, __bounds.y, size.width, size.height);
3286 r = SetBoundsFinal(newBounds, true, true);
3295 // Custom Exception: ex) Location::Map
3298 _Control::SetBoundsInternal(const FloatRectangle& bounds, bool callBoundsChangeCallbacks)
3300 SysTryReturn(NID_UI,
3301 IsInSizeRange(Dimension(bounds.width, bounds.height)), E_INVALID_ARG,
3303 "[E_INVALID_ARG] The specified size(%f, %f) is out of range from min size(%d, %d) to max size(%d, %d).",
3304 bounds.width, bounds.height, __minSize.width, __minSize.height, __maxSize.width, __maxSize.height);
3306 SetUpdateLayoutState(true);
3308 return SetBoundsFinal(bounds, true, callBoundsChangeCallbacks);
3311 // Custom Exception: ex) Location::Map
3313 // E_UNSUPPORTED_OPERATION
3315 _Control::SetBounds(const Rectangle& bounds, bool callBoundsChangeCallbacks)
3319 if (callBoundsChangeCallbacks)
3321 SysTryReturn(NID_UI,
3322 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3323 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3325 FloatRectangle floatBounds(bounds.x, bounds.y, bounds.width, bounds.height);
3327 return SetBoundsInternal(floatBounds, callBoundsChangeCallbacks);
3330 // Custom Exception: ex) Location::Map
3332 // E_UNSUPPORTED_OPERATION
3334 _Control::SetBounds(const FloatRectangle& bounds, bool callBoundsChangeCallbacks)
3338 if (callBoundsChangeCallbacks)
3340 SysTryReturn(NID_UI,
3341 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3342 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3345 return SetBoundsInternal(bounds, callBoundsChangeCallbacks);
3348 // A custom Exception can occur. ex) Location::Map
3350 // E_UNSUPPORTED_OPERATION
3352 _Control::SetPosition(const Point& position)
3356 SysTryReturn(NID_UI,
3357 IsMovable(), E_UNSUPPORTED_OPERATION,
3358 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable.");
3360 return SetBoundsInternal(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height), true);
3364 _Control::SetPosition(const FloatPoint& position)
3368 SysTryReturn(NID_UI,
3369 IsMovable(), E_UNSUPPORTED_OPERATION,
3370 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable.");
3372 return SetBoundsInternal(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height), true);
3375 // Custom Exception: ex) Location::Map
3377 // E_UNSUPPORTED_OPERATION
3379 _Control::SetSize(const Dimension& size)
3383 SysTryReturn(NID_UI,
3384 IsResizable(), E_UNSUPPORTED_OPERATION,
3385 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3387 return SetBoundsInternal(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height), true);
3391 _Control::SetSize(const FloatDimension& size)
3395 SysTryReturn(NID_UI,
3396 IsResizable(), E_UNSUPPORTED_OPERATION,
3397 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3399 return SetBoundsInternal(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height), true);
3403 _Control::GetMinimumSize(void) const
3407 return _CoordinateSystemUtils::ConvertToInteger(__minSize);
3411 _Control::GetMinimumSizeF(void) const
3419 _Control::GetMaximumSize(void) const
3423 return _CoordinateSystemUtils::ConvertToInteger(__maxSize);
3427 _Control::GetMaximumSizeF(void) const
3434 // Custom Exception: ex) Location::Map
3435 // E_UNSUPPORTED_OPERATION
3438 _Control::SetMinimumSize(const Dimension& newMinSize)
3442 SysTryReturn(NID_UI,
3443 IsResizable(), E_UNSUPPORTED_OPERATION,
3444 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3446 SysTryReturn(NID_UI,
3447 (newMinSize.width >= 0 && newMinSize.height >= 0), E_INVALID_ARG,
3448 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3450 SysTryReturn(NID_UI,
3451 (newMinSize.width <= MAX_LENGTH && newMinSize.height <= MAX_LENGTH), E_INVALID_ARG,
3452 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3454 if (__maxSize.width < newMinSize.width)
3456 __maxSize.width = newMinSize.width;
3458 if (__maxSize.height < newMinSize.height)
3460 __maxSize.height = newMinSize.height;
3463 __minSize = _CoordinateSystemUtils::ConvertToFloat(newMinSize);
3464 return AdjustSizeToRange();
3468 _Control::SetMinimumSize(const FloatDimension& newMinSize)
3472 SysTryReturn(NID_UI,
3473 IsResizable(), E_UNSUPPORTED_OPERATION,
3474 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3476 SysTryReturn(NID_UI,
3477 (newMinSize.width >= 0 && newMinSize.height >= 0), E_INVALID_ARG,
3478 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3480 SysTryReturn(NID_UI,
3481 (newMinSize.width <= MAX_LENGTH && newMinSize.height <= MAX_LENGTH), E_INVALID_ARG,
3482 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3484 if (__maxSize.width < newMinSize.width)
3486 __maxSize.width = newMinSize.width;
3488 if (__maxSize.height < newMinSize.height)
3490 __maxSize.height = newMinSize.height;
3493 __minSize = newMinSize;
3494 return AdjustSizeToRange();
3497 // Custom Exception: ex) Location::Map
3498 // E_UNSUPPORTED_OPERATION
3501 _Control::SetMaximumSize(const Dimension& newMaxSize)
3505 SysTryReturn(NID_UI,
3506 IsResizable(), E_UNSUPPORTED_OPERATION,
3507 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3509 SysTryReturn(NID_UI,
3510 (newMaxSize.width >= 0 && newMaxSize.height >= 0), E_INVALID_ARG,
3511 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3513 SysTryReturn(NID_UI,
3514 (newMaxSize.width <= MAX_LENGTH && newMaxSize.height <= MAX_LENGTH), E_INVALID_ARG,
3515 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3517 if (newMaxSize.width < __minSize.width)
3519 __minSize.width = newMaxSize.width;
3521 if (newMaxSize.height < __minSize.height)
3523 __minSize.height = newMaxSize.height;
3526 __maxSize = _CoordinateSystemUtils::ConvertToFloat(newMaxSize);
3527 return AdjustSizeToRange();
3531 _Control::SetMaximumSize(const FloatDimension& newMaxSize)
3535 SysTryReturn(NID_UI,
3536 IsResizable(), E_UNSUPPORTED_OPERATION,
3537 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3539 SysTryReturn(NID_UI,
3540 (newMaxSize.width >= 0 && newMaxSize.height >= 0), E_INVALID_ARG,
3541 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3543 SysTryReturn(NID_UI,
3544 (newMaxSize.width <= MAX_LENGTH && newMaxSize.height <= MAX_LENGTH), E_INVALID_ARG,
3545 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3547 if (newMaxSize.width < __minSize.width)
3549 __minSize.width = newMaxSize.width;
3551 if (newMaxSize.height < __minSize.height)
3553 __minSize.height = newMaxSize.height;
3556 __maxSize = newMaxSize;
3557 return AdjustSizeToRange();
3562 _Control::ConvertToControlPosition(const Point& screenPosition) const
3564 Point controlPosition;
3565 Rectangle absoluteBounds = GetAbsoluteBounds();
3567 controlPosition.x = screenPosition.x - absoluteBounds.x;
3568 controlPosition.y = screenPosition.y - absoluteBounds.y;
3570 return controlPosition;
3574 _Control::ConvertToControlPosition(const FloatPoint& screenPosition) const
3576 FloatPoint controlPosition;
3577 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
3579 controlPosition.x = screenPosition.x - absoluteBounds.x;
3580 controlPosition.y = screenPosition.y - absoluteBounds.y;
3582 return controlPosition;
3586 _Control::ConvertToScreenPosition(const Point& controlPosition) const
3588 Point screenPosition;
3589 Rectangle absoluteBounds = GetAbsoluteBounds();
3591 screenPosition.x = controlPosition.x + absoluteBounds.x;
3592 screenPosition.y = controlPosition.y + absoluteBounds.y;
3594 return screenPosition;
3598 _Control::ConvertToScreenPosition(const FloatPoint& controlPosition) const
3600 FloatPoint screenPosition;
3601 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
3603 screenPosition.x = controlPosition.x + absoluteBounds.x;
3604 screenPosition.y = controlPosition.y + absoluteBounds.y;
3606 return screenPosition;
3610 _Control::GetClientBounds(void) const
3612 if (!__isSetClientBounds)
3614 return Rectangle(0, 0, __bounds.width, __bounds.height);
3617 return _CoordinateSystemUtils::ConvertToInteger(__clientBounds);
3621 _Control::GetClientBoundsF(void) const
3623 if (!__isSetClientBounds)
3625 return FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height);
3628 return __clientBounds;
3633 _Control::GetClientBounds(const Tizen::Graphics::Dimension& size) const
3635 if (!__isSetClientBounds)
3637 return Rectangle(0, 0, size.width, size.height);
3640 return _CoordinateSystemUtils::ConvertToInteger(__clientBounds);
3645 _Control::GetClientBoundsF(const Tizen::Graphics::FloatDimension& size) const
3647 if (!__isSetClientBounds)
3649 return FloatRectangle(0.0f, 0.0f, size.width, size.height);
3652 return __clientBounds;
3656 _Control::GetAbsoluteBounds(void) const
3659 Rectangle absoluteBounds;
3660 Rectangle clientBounds;
3662 const _Control* pSelf = this;
3663 const _Control* pParent = GetParent();
3667 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent)
3669 clientBounds = pParent->GetClientBounds();
3670 accumPoint += Point(clientBounds.x, clientBounds.y);
3671 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3672 accumPoint.y -= pParent->GetVerticalScrollPosition();
3675 accumPoint += pSelf->GetPosition();
3677 pParent = pParent->GetParent();
3680 _Window* pWindow = GetRootWindow();
3684 Point winPoint = pWindow->GetPosition();
3686 accumPoint.x += winPoint.x;
3687 accumPoint.y += winPoint.y;
3690 absoluteBounds.x = accumPoint.x;
3691 absoluteBounds.y = accumPoint.y;
3692 absoluteBounds.width = __bounds.width;
3693 absoluteBounds.height = __bounds.height;
3695 return absoluteBounds;
3699 _Control::GetAbsoluteBoundsF(void) const
3701 FloatPoint accumPoint;
3702 FloatRectangle absoluteBounds;
3703 FloatRectangle clientBounds;
3705 const _Control* pSelf = this;
3706 const _Control* pParent = GetParent();
3710 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent)
3712 clientBounds = pParent->GetClientBoundsF();
3713 accumPoint += FloatPoint(clientBounds.x, clientBounds.y);
3714 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3715 accumPoint.y -= pParent->GetVerticalScrollPosition();
3718 accumPoint += pSelf->GetPositionF();
3720 pParent = pParent->GetParent();
3723 _Window* pWindow = GetRootWindow();
3727 FloatPoint winPoint = pWindow->GetPositionF();
3729 accumPoint.x += winPoint.x;
3730 accumPoint.y += winPoint.y;
3733 absoluteBounds.x = accumPoint.x;
3734 absoluteBounds.y = accumPoint.y;
3735 absoluteBounds.width = __bounds.width;
3736 absoluteBounds.height = __bounds.height;
3738 return absoluteBounds;
3742 _Control::SetClientBounds(const Rectangle& bounds)
3746 const bool moved = (__clientBounds.x != _CoordinateSystemUtils::ConvertToFloat(bounds).x) || (__clientBounds.y != _CoordinateSystemUtils::ConvertToFloat(bounds).y);
3747 const bool resized = (__clientBounds.width != _CoordinateSystemUtils::ConvertToFloat(bounds).width) || (__clientBounds.height != _CoordinateSystemUtils::ConvertToFloat(bounds).height);
3749 SysTryReturn(NID_UI,
3750 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3751 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3752 __clientBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
3753 __isSetClientBounds = true;
3755 if (moved || resized)
3757 result r = AdjustAbsoluteBounds();
3758 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3760 SetUpdateLayoutState(true);
3766 _Control::SetClientBounds(const FloatRectangle& bounds)
3770 const bool moved = (__clientBounds.x != bounds.x) || (__clientBounds.y != bounds.y);
3771 const bool resized = (__clientBounds.width != bounds.width) || (__clientBounds.height != bounds.height);
3773 SysTryReturn(NID_UI,
3774 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3775 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3776 __clientBounds = bounds;
3777 __isSetClientBounds = true;
3779 if (moved || resized)
3781 result r = AdjustAbsoluteBounds();
3782 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3784 SetUpdateLayoutState(true);
3791 _Control::IsCalledSetClientBounds(void)
3793 return __isSetClientBounds;
3797 _Control::UpdateClientBounds(const FloatDimension& size, FloatRectangle& clientBounds)
3799 clientBounds.width = size.width;
3800 clientBounds.height = size.height;
3804 _Control::GetBackgroundColor(void) const
3807 return __backgroundColor;
3811 _Control::SetBackgroundColor(const Color& color)
3814 __backgroundColor = color;
3816 _ControlVisualElement* pCVE = dynamic_cast <_ControlVisualElement*>(GetVisualElement());
3819 pCVE->SetBackgroundColor(
3821 (float)color.GetRed() / 255.0f,
3822 (float)color.GetGreen() / 255.0f,
3823 (float)color.GetBlue() / 255.0f,
3824 (float)color.GetAlpha() / 255.0f
3829 GetControlDelegate().OnBackgroundColorChanged(const_cast<Color&>(color));
3833 _Control::~_Control(void)
3835 __destroying = true;
3837 DetachAllChildren();
3839 _ControlManager::GetInstance()->TakeFocusFromControl(*this);
3849 // Dangerous: it clears last result and log in catch block.
3850 // ClearLastResult();
3854 _Control::DisposeControl(void)
3856 __pControlDelegate = null;
3858 delete __pLayoutItemHandler;
3859 __pLayoutItemHandler = null;
3861 delete __pLayoutContainer;
3862 __pLayoutContainer = null;
3870 if (__pVisualElement)
3872 __pVisualElement->Destroy();
3874 __pVisualElement = null;
3876 delete __pVisualElementContentProvider;
3877 __pVisualElementContentProvider = null;
3879 delete __pVisualElementEventListener;
3880 __pVisualElementEventListener = null;
3882 delete __pCoreGestureDetectors;
3883 __pCoreGestureDetectors = null;
3885 delete __pDataBindingContext;
3886 __pDataBindingContext = null;
3888 ClearStartedGestureDetectorList();
3889 delete __pDetectStartedGestureMap;
3890 __pDetectStartedGestureMap = null;
3892 delete __pDelayedTouchInfoList;
3893 __pDelayedTouchInfoList = null;
3895 delete __pAccessibilityContainer;
3896 __pAccessibilityContainer = null;
3898 if (__pFocusVisualElement)
3900 __pFocusVisualElement.release();
3906 _Control::_Control(void)
3907 : __needRecalcRootWindow(true)
3908 , __pRootWindow(null)
3913 , __bounds(0.0f, 0.0f, 0.0f, 0.0f)
3914 , __contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f)
3915 , __clientBounds(0.0f, 0.0f, 0.0f, 0.0f)
3916 , __absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f)
3917 , __invalidatedBounds(0.0f, 0.0f, 0.0f, 0.0f)
3918 , __minSize(FloatDimension(0.0f, 0.0f))
3919 , __maxSize(FloatDimension(MAX_LENGTH, MAX_LENGTH))
3920 , __backgroundColor(Color::GetColor(COLOR_ID_BLACK))
3924 , __nativeObjectFocusable(true)
3925 , __enabledState(true)
3926 , __visibleState(true)
3927 , __initVisibleState(false)
3928 , __clipToParent(true)
3929 , __multiTouchEnabled(false)
3930 , __dragEnabled(false)
3931 , __dropEnabled(false)
3932 , __drawWhenVisible(true)
3933 , __isPostOrderTraversal(false)
3934 , __isCalledCallOnAttachingToMainTree(false)
3935 , __isCalledCallOnPreAttachedToMainTree(false)
3936 , __isCalledCallOnAttachedToMainTree(false)
3937 , __isSetClientBounds(false)
3938 , __isCalledGetCanvasN(false)
3939 , __isFocusMode(false)
3940 , __isNavigatable(true)
3941 , __pVisualElementContentProvider(null)
3942 , __pVisualElement(null)
3943 , __pVisualElementEventListener(null)
3944 , __pLayoutItemHandler(null)
3945 , __pPortraitLayout(null)
3946 , __pLandscapeLayout(null)
3947 , __pLayoutContainer(null)
3948 , __area(_CONTROL_AREA_NONE)
3949 , __layer(_CONTROL_LAYER_NONE)
3950 , __orientation(_CONTROL_ORIENTATION_PORTRAIT)
3951 , __rotation(_CONTROL_ROTATION_0)
3952 , __pTouchEventPreviewer(null)
3953 , __pKeyEventPreviewer(null)
3954 , __pNotificationEventPreviewer(null)
3955 , __pKeyEventListener(null)
3956 , __pFocusEventListener(null)
3957 , __pNotificationEventListener(null)
3958 , __pCoreGestureDetectors(null)
3959 , __pDetectStartedGestureMap(null)
3960 , __pDelayedTouchInfoList(null)
3961 , __touchMoveAllowance(3)
3962 , __pressThresHold(0.0f)
3963 , __inputLockRefCount(0)
3965 , __isSentDelayedEvent(false)
3966 , __isSendingDelayedEvent(false)
3967 , __isChangingEventTarget(false)
3968 , __pDataBindingContext(null)
3969 , __pControlDelegate(null)
3971 , __destroying(false)
3972 , __isEventEnableState(true)
3973 , __isEffectSoundEnabled(true)
3974 , __isControlFontChanged(false)
3977 , __fontFileName(L"")
3978 , __pPreviousFocus(null)
3979 , __pNextFocus(null)
3983 SetControlDelegate(*this);
3984 __pAccessibilityContainer = new (std::nothrow) _AccessibilityContainer(*this);
3985 __pAccessibilityContainer->Activate(true);
3987 __pLayoutItemHandler = new (std::nothrow) LayoutItemHandler(this);
3988 if (!__pLayoutItemHandler)
3993 __pLayoutContainer = CreateLayoutContainerN(__pLayoutItemHandler);
3994 if (!__pLayoutContainer)
3999 __pChildren = ::CreateControlListN();
4005 __pOwnees = ::CreateWindowListN();
4011 __pVisualElement = ::CreateVisualElementN();
4012 if (!__pVisualElement)
4017 __pVisualElement->SetUserData(this);
4018 __pVisualElement->SetClipChildrenEnabled(true);
4019 __pVisualElement->SetRedrawOnResizeEnabled(true);
4021 __pVisualElementContentProvider = new (std::nothrow) ControlVisualElementContentProvider(*this);
4022 SysTryCatch(NID_UI, __pVisualElementContentProvider, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4024 GetVisualElement()->SetContentProvider(__pVisualElementContentProvider);
4026 __pVisualElementEventListener = new (std::nothrow) ControlVisualElementEventListener(*this);
4027 SysTryCatch(NID_UI, __pVisualElementEventListener, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4029 GetVisualElement()->SetVisualElementEventListener(__pVisualElementEventListener);
4031 __pDetectStartedGestureMap = ::CreateGestureMapN();
4032 if (!__pDetectStartedGestureMap)
4037 __pCoreGestureDetectors = new (std::nothrow) LinkedListT<_TouchGestureDetector*>;
4038 if (!__pCoreGestureDetectors)
4043 __pDelayedTouchInfoList = new (std::nothrow) LinkedListT<_TouchInfo*>;
4044 if (!__pDelayedTouchInfoList)
4049 SetEventPreviewer<_UI_EVENT_TOUCH>(this);
4050 SetEventPreviewer<_UI_EVENT_KEY>(this);
4051 SetEventPreviewer<_UI_EVENT_NOTIFICAITON>(this);
4053 SetEventListener<_UI_EVENT_NOTIFICAITON>(this);
4054 SetEventListener<_UI_EVENT_FOCUS>(this);
4056 SetPropagatedTouchEventListener(this);
4057 SetPropagatedKeyEventListener(this);
4058 GET_COLOR_CONFIG(BASIC::background, __backgroundColor);
4060 if (IsFailed(GetLastResult()))
4062 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
4065 __screenDpi = _ControlManager::GetInstance()->GetScreenDpi();
4075 _Control::AcquireHandle(void)
4077 __controlHandle = _ControlManager::GetInstance()->Register(this); // [ToDo] exception?
4081 _Control::ReleaseHandle(void)
4083 _ControlManager::GetInstance()->Release(__controlHandle); // [ToDo] exception?
4087 _Control::SetDrawWhenVisible(bool draw)
4089 __drawWhenVisible = draw;
4093 _Control::IsDrawWhenVisible(void)
4095 return __drawWhenVisible;
4099 _Control::SetTerminatingOrder(bool postOrderTraversal)
4101 __isPostOrderTraversal = postOrderTraversal;
4105 _Control::IsPostOrderTraversal(void)
4107 return __isPostOrderTraversal;
4111 _Control::SetParent(_Control* pParent)
4114 __pParent = pParent;
4118 // Only called by _Window::SetOwner(pOwner)
4120 _Control::AttachOwnee(_Window& window)
4123 result r = E_SUCCESS;
4125 _Control* pOldOwner = window.GetOwner();
4128 pOldOwner->DetachOwnee(window);
4131 r = __pOwnees->Add(&window);
4134 SysLogException(NID_UI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4135 return E_OUT_OF_MEMORY;
4142 _Control::GetOwneeCount(void) const
4145 return __pOwnees->GetCount();
4150 _Control::GetOwnee(int index) const
4153 result r = E_SUCCESS;
4155 _Window* pOwnee = null;
4156 r = __pOwnees->GetAt(index, pOwnee);
4159 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
4166 // Called by _Window::SetOwner(null)
4168 _Control::DetachOwnee(_Window& ownee)
4171 result r = E_SUCCESS;
4173 _Control* pOwner = ownee.GetOwner();
4179 r = __pOwnees->Remove(&ownee);
4182 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
4187 _Control::DetachAllOwnees(void)
4191 int owneeCount = GetOwneeCount();
4192 while (owneeCount--)
4194 _Window* pOwnee = GetOwnee(0);
4200 pOwnee->SetOwner(null);
4204 _Layout::LayoutContainer&
4205 _Control::GetLayoutContainer() const
4207 return *__pLayoutContainer;
4211 _Control::SetMultiTouchEnabled(bool enabled)
4214 __multiTouchEnabled = enabled;
4218 _Control::IsMultiTouchEnabled(void) const
4221 return __multiTouchEnabled;
4225 _Control::SetMovable(bool movable)
4228 __movable = movable;
4232 _Control::SetResizable(bool resizable)
4238 __minSize = __maxSize = GetSizeF();
4241 if (!__resizable && resizable)
4243 __minSize = FloatDimension(0.0f, 0.0f);
4244 __maxSize = FloatDimension(MAX_LENGTH, MAX_LENGTH);
4247 __resizable = resizable;
4251 _Control::GetLayout(void) const
4254 _Layout::Layout* pLayout = __pLayoutContainer->GetLayout();
4256 SysAssert(GetLastResult() == E_SUCCESS);
4261 _Control::SetCurrentLayout(_Layout::Layout& layout)
4264 return __pLayoutContainer->SetCurrentLayout(layout);
4268 _Control::AddLayout(_Layout::Layout& layout)
4271 return __pLayoutContainer->AddLayout(layout);
4275 _Control::SetUpdateLayoutState(bool state)
4277 _Layout::Layout* pLayout = GetLayout();
4280 pLayout->SetUpdateState(state);
4285 _Control::SetEffectSoundEnabled(bool enable)
4287 __isEffectSoundEnabled = enable;
4291 _Control::IsEffectSoundEnabled(void) const
4293 return __isEffectSoundEnabled;
4296 _DataBindingContext*
4297 _Control::GetDataBindingContext(void)
4299 return __pDataBindingContext;
4301 _AccessibilityContainer*
4302 _Control::GetAccessibilityContainer(void)
4304 return __pAccessibilityContainer;
4307 _Control::SetDataBindingContext(_DataBindingContext* pDataBindingContext)
4309 __pDataBindingContext = pDataBindingContext;
4313 _Control::GetDescription(void) const
4319 _Control::SetTouchCapture(bool allowOutOfBounds, bool allowOwnerBounds)
4321 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4322 SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null");
4324 pTouchManager->SetCapturedControl(this, allowOutOfBounds, allowOwnerBounds);
4328 _Control::ReleaseTouchCapture(void)
4330 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4331 SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null");
4333 pTouchManager->SetCapturedControl(null, false, false);
4337 _Control::GetTopmostChildAt(const Point& point) const
4339 _Control* pTouchedControl = null;
4340 FloatPoint ptf((float) point.x, (float) point.y);
4341 _ControlManager* pControlManager = _ControlManager::GetInstance();
4342 SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist.");
4344 _Window* pRootWindow = GetRootWindow();
4345 SysTryReturn(NID_UI, pRootWindow, null, E_SYSTEM, "[E_SYSTEM] GetRootWindow() is null, this control is detached from the main trree");
4347 _ControlVisualElement* pRootControlElement = dynamic_cast <_ControlVisualElement*>(pRootWindow->GetVisualElement());
4348 SysTryReturn(NID_UI, pRootControlElement, null, E_SYSTEM, "[E_SYSTEM] pRootControlElement is null.");
4350 _ControlVisualElement* pHitTestElm = pRootControlElement->GetControlChildAtPoint(ptf);
4351 SysTryReturn(NID_UI, pHitTestElm, null, E_SYSTEM, "[E_SYSTEM] pHitTestElm is null.");
4353 pTouchedControl = static_cast <_Control*>(pHitTestElm->GetUserData());
4355 return pTouchedControl;
4359 _Control::SetContentAreaBounds(const Rectangle& rect)
4363 __contentAreaBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
4367 _Control::SetContentAreaBounds(const FloatRectangle& rect)
4371 __contentAreaBounds = rect;
4375 _Control::GetContentAreaBounds(void) const
4377 return _CoordinateSystemUtils::ConvertToInteger(__contentAreaBounds);
4381 _Control::GetContentAreaBoundsF(void) const
4383 return __contentAreaBounds;
4387 _Control::GetCapturedBitmapN(bool includeChildren) const
4389 result r = E_SUCCESS;
4391 Canvas* pCanvas = null;
4392 Bitmap* pBitmap = null;
4394 pBitmap = GetControlDelegate().OnCapturedBitmapRequestedN();
4395 if (pBitmap == null)
4397 FloatRectangle rect;
4399 Rectangle boundsInCanvas = GetBounds();
4400 boundsInCanvas.x = boundsInCanvas.y = 0;
4402 pCanvas = new (std::nothrow) Canvas;
4403 SysTryReturn(NID_UI, pCanvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4405 r = pCanvas->Construct(boundsInCanvas);
4406 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
4408 GetVisualElement()->Draw();
4409 ClearLastResult(); // [ToDo] Temp.
4411 rect.SetBounds(boundsInCanvas.x, boundsInCanvas.y, boundsInCanvas.width, boundsInCanvas.height);
4413 r = GetVisualElement()->Capture(*pCanvas, rect, includeChildren);
4414 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
4416 pBitmap = new (std::nothrow) Bitmap;
4417 SysTryCatch(NID_UI, pBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4419 r = pBitmap->Construct(*pCanvas, boundsInCanvas);
4422 SysAssert(r == E_OUT_OF_MEMORY);
4423 SysTryCatch(NID_UI, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4426 SysLog(NID_UI, "Bitmap (width:%d, height:%d)", pBitmap->GetWidth(), pBitmap->GetHeight());
4430 _BitmapImpl::ConvertToNonpremultiplied(*pBitmap, true);
4442 Tizen::Graphics::Rectangle
4443 _Control::GetInvalidatedBounds(void) const
4445 return _CoordinateSystemUtils::ConvertToInteger(__invalidatedBounds);
4448 Tizen::Graphics::FloatRectangle
4449 _Control::GetInvalidatedBoundsF(void) const
4451 return __invalidatedBounds;
4455 _Control::AddGestureDetector(const _TouchGestureDetector& gestureDetector)
4459 bool exist = __pCoreGestureDetectors->Contains(const_cast<_TouchGestureDetector*>(&gestureDetector));
4460 SysTryReturnResult(NID_UI, exist == false, E_OBJ_ALREADY_EXIST, "[E_OBJ_ALREADY_EXIST]__pCoreGestureDetectors has gesture already");
4462 result r = __pCoreGestureDetectors->Add(const_cast<_TouchGestureDetector*>(&gestureDetector));
4463 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4465 r = const_cast<_TouchGestureDetector&>(gestureDetector).SetControl(*this);
4466 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "Control handle is not valid.");
4468 const_cast<_TouchGestureDetector&>(gestureDetector).OnTouchGestureDetectorAdded();
4474 _Control::RemoveGestureDetector(const _TouchGestureDetector& gestureDetector)
4478 result r = __pCoreGestureDetectors->Remove(&(const_cast<_TouchGestureDetector&>(gestureDetector)));
4484 const_cast<_TouchGestureDetector&>(gestureDetector).OnTouchGestureDetectorRemoved();
4489 IListT <_TouchGestureDetector*>*
4490 _Control::GetGestureDetectorList(void) const
4492 return __pCoreGestureDetectors;
4495 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>*
4496 _Control::GetStartedGestureDetectorEnumeratorN(void) const
4498 return __pDetectStartedGestureMap->GetMapEnumeratorN();
4501 IListT <_TouchGestureDetector*>*
4502 _Control::GetStartedGestureDetectorListN(void) const
4504 return __pDetectStartedGestureMap->GetKeysN();
4508 _Control::AddStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state)
4512 result r = E_SUCCESS;
4515 __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist);
4519 r = __pDetectStartedGestureMap->Add(const_cast<_TouchGestureDetector*>(&gestureDetector), state);
4526 _Control::SetStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state)
4530 result r = E_SUCCESS;
4533 __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist);
4537 r = __pDetectStartedGestureMap->SetValue(const_cast<_TouchGestureDetector*>(&gestureDetector), state);
4544 _Control::ClearStartedGestureDetectorList(void)
4548 result r = E_SUCCESS;
4550 IListT<_TouchGestureDetector*>* pList = __pDetectStartedGestureMap->GetKeysN();
4553 IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pList->GetEnumeratorN();
4556 while(pEnumerator->MoveNext() == E_SUCCESS)
4558 _TouchGestureDetector* pGestureDetector = null;
4559 pEnumerator->GetCurrent(pGestureDetector);
4561 if (pGestureDetector == null)
4566 __pDetectStartedGestureMap->Remove(pGestureDetector);
4573 IEnumeratorT<_TouchInfo*>* pEnumerator = __pDelayedTouchInfoList->GetEnumeratorN();
4576 while(pEnumerator->MoveNext() == E_SUCCESS)
4578 _TouchInfo* pTouchInfo = null;
4579 pEnumerator->GetCurrent(pTouchInfo);
4580 if (pTouchInfo == null)
4588 __pDelayedTouchInfoList->RemoveAll();
4592 __isSentDelayedEvent = false;
4593 __isSendingDelayedEvent = false;
4599 _Control::IsDelayedTouchEventEnabled(void) const
4601 bool existDelayTouchEventGesture = false;
4603 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4606 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4608 _TouchGestureDetector* pGestureDetector = null;
4609 pMapEnumerator->GetKey(pGestureDetector);
4611 if (pGestureDetector == null)
4616 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4617 pMapEnumerator->GetValue(state);
4619 if (pGestureDetector->IsDelayTouchEventEnabled())
4621 existDelayTouchEventGesture = true;
4624 delete pMapEnumerator;
4627 bool delayTouchEvent = false;
4628 if (existDelayTouchEventGesture)
4630 pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4633 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4635 _TouchGestureDetector* pGestureDetector = null;
4636 pMapEnumerator->GetKey(pGestureDetector);
4638 if (pGestureDetector == null)
4643 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4644 pMapEnumerator->GetValue(state);
4646 if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED)
4648 delayTouchEvent = true;
4652 delete pMapEnumerator;
4655 return delayTouchEvent;
4664 _Control::IsPossibleToSendDelayedTouchEvent(void) const
4666 bool existDelayTouchEventGesture = false;
4668 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4671 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4673 _TouchGestureDetector* pGestureDetector = null;
4674 pMapEnumerator->GetKey(pGestureDetector);
4676 if (pGestureDetector == null)
4681 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4682 pMapEnumerator->GetValue(state);
4684 if (pGestureDetector->IsDelayTouchEventEnabled())
4686 existDelayTouchEventGesture = true;
4689 delete pMapEnumerator;
4692 bool allFailed = true;
4693 if (existDelayTouchEventGesture)
4695 pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4698 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4700 _TouchGestureDetector* pGestureDetector = null;
4701 pMapEnumerator->GetKey(pGestureDetector);
4703 if (pGestureDetector == null)
4708 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4709 pMapEnumerator->GetValue(state);
4711 if (state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS)
4717 delete pMapEnumerator;
4729 _Control::IsCancelOnGestureSuccess(void) const
4731 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4732 SysAssert(pTouchManager != null);
4734 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4737 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4739 _TouchGestureDetector* pGestureDetector = null;
4740 pMapEnumerator->GetKey(pGestureDetector);
4742 if (pGestureDetector == null)
4747 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4748 pMapEnumerator->GetValue(state);
4750 if (pGestureDetector->IsCancelTouchEventOnSuccessEnabled() && state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS && !pTouchManager->IsTouchCanceledOnGestureSuccess())
4752 delete pMapEnumerator;
4756 delete pMapEnumerator;
4763 _Control::IsSentDelayedEvent(void) const
4765 return __isSentDelayedEvent;
4769 _Control::SetSentDelayedEvent(bool sent)
4771 __isSentDelayedEvent = sent;
4775 _Control::SetSendingDelayedEvent(bool sending)
4777 __isSendingDelayedEvent = sending;
4781 _Control::IsSendingDelayedEvent(void) const
4783 return __isSendingDelayedEvent;
4787 _Control::AddTouchInfo(const _TouchInfo& touchInfo)
4789 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4790 SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist.");
4792 _TouchInfo* pTouchInfo = new (std::nothrow) _TouchInfo;
4793 SysTryReturnVoidResult(NID_UI, pTouchInfo, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4795 FloatPoint screenPoint = pTouchManager->GetScreenPoint(touchInfo.GetPointId());
4796 pTouchInfo->SetTouchInfo(touchInfo.GetPointId(), touchInfo.GetTouchStatus(), screenPoint, false, 0);
4797 __pDelayedTouchInfoList->Add(pTouchInfo);
4800 IListT<_TouchInfo*>*
4801 _Control::GetTouchInfoList(void)
4803 return __pDelayedTouchInfoList;
4807 _Control::GetVisualElement(void) const
4809 SysAssert(__pVisualElement);
4810 return __pVisualElement;
4814 _Control::PrintDescription(bool printChildren, int level)
4816 int count = PrintDescription(printChildren, 0, level);
4818 SysLog(NID_UI, "%d controls were printed.", count);
4822 _Control::PrintDescription(bool printChildren, int depth, int level)
4824 const int PRINT_CONTROL_VE = 1;
4825 const int PRINT_CONTROL_EVAS = 2;
4826 const int PRINT_CONTROL_VE_EVAS = 3;
4831 format.Format(LOG_LEN_MAX, L"%d", depth);
4833 for (int i = 0; i < depth; i++)
4835 indent.Append(L" ");
4838 indent.Append(format);
4840 String delimiter(L"-------------------------------------------------------------------------------------------");
4841 SysLog(NID_UI, "%ls", delimiter.GetPointer());
4844 String publicDescription = GetControlDelegate().GetDescription();
4845 if (!publicDescription.IsEmpty())
4847 SysLog(NID_UI, "%ls %ls", indent.GetPointer(), publicDescription.GetPointer());
4851 SysLog(NID_UI, "%ls 0x%x(%d %ls) enable(%d) enableState(%d) visible(%d) visibleState(%d) focusable(%d) clip(%d) movable(%d) resizable(%d) inputEnableState(%d)",
4852 indent.GetPointer(), this, __controlHandle.ToInt(), GetName().GetPointer(), IsEnabled(), GetEnableState(), IsVisible(), GetVisibleState(),
4853 IsFocusable(), IsClipToParent(), IsMovable(), IsResizable(), GetInputEnableState());
4855 Rectangle bounds = GetBounds();
4856 Dimension min = GetMinimumSize();
4857 Dimension max = GetMaximumSize();
4858 Rectangle clientBounds = GetClientBounds();
4859 Rectangle absoluteBounds = GetAbsoluteBounds();
4861 SysLog(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)",
4862 indent.GetPointer(), bounds.x, bounds.y, bounds.width, bounds.height,
4863 min.width, min.height, max.width, max.height,
4864 GetVerticalScrollPosition(), GetHorizontalScrollPosition(),
4865 clientBounds.x, clientBounds.y, clientBounds.width, clientBounds.height,
4866 absoluteBounds.x, absoluteBounds.y, absoluteBounds.width, absoluteBounds.height);
4868 SysLog(NID_UI, "%ls bgColor(0x%x) layoutable(%d) orientation(%d) drag(%d) drop(%d) area(%d) layer(%d)",
4869 indent.GetPointer(), __backgroundColor.GetRGB32(), IsLayoutable(), GetOrientation(), IsDragEnabled(), IsDropEnabled(), GetArea(), GetLayer());
4871 Canvas* pCanvas = GetCanvasN();
4874 Rectangle canvasBounds = pCanvas->GetBounds();
4875 Color canvasBackgroundColor = pCanvas->GetBackgroundColor();
4876 Color canvasForegroundColor = pCanvas->GetForegroundColor();
4878 SysLog(NID_UI, "%ls canvas.bounds(%d %d %d %d) canvas.bgColor(0x%x) canvas.fgColor(0x%x)",
4879 indent.GetPointer(), canvasBounds.x, canvasBounds.y, canvasBounds.width, canvasBounds.height, canvasBackgroundColor.GetRGB32(), canvasForegroundColor.GetRGB32());
4884 SysLog(NID_UI, "%ls DataBindingContext(0x%x) ControlDelegate(0x%x) UserData(0x%x) destroying(%d)",
4885 indent.GetPointer(), __pDataBindingContext, __pControlDelegate, __pUserData, __destroying);
4890 for (int i = 0; i < GetOwneeCount(); ++i)
4893 _Window* pOwnee = GetOwnee(i);
4896 ownee.Format(LOG_LEN_MAX, L"0x%x ", pOwnee);
4897 ownees.Append(ownee);
4901 if (!ownees.IsEmpty())
4903 SysLog(NID_UI, "%ls Ownees(%ls)", indent.GetPointer(), ownees.GetPointer());
4906 _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*__pVisualElement);
4908 SysLog(NID_UI, "%ls _VisualElement(0x%x) _VisualElementImpl(0x%x) VisualElementContentProvider(0x%x) VisualElementEventListener(0x%x)",
4909 indent.GetPointer(), __pVisualElement, pVisualElementImpl, __pVisualElementContentProvider, __pVisualElementEventListener);
4912 SysLog(NID_UI, "%ls LayoutItemHandler(0x%x) PortraitLayout(0x%x) LandscapeLayout(0x%x) LayoutContainer(0x%x)",
4913 indent.GetPointer(), __pLayoutItemHandler, __pPortraitLayout, __pLandscapeLayout, __pLayoutContainer);
4916 String description = GetDescription();
4917 if (!description.IsEmpty())
4919 SysLog(NID_UI, "%ls %ls", indent.GetPointer(), description.GetPointer());
4922 // Print Gesture List
4923 IListT<_TouchGestureDetector*>* pGestureList = GetGestureDetectorList();
4924 SysTryReturn(NID_UI, pGestureList, 0, E_SYSTEM, "[E_SYSTEM] System error occurred.");
4926 IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN();
4927 SysTryReturn(NID_UI, pEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4929 while (pEnumerator->MoveNext() == E_SUCCESS)
4931 _TouchGestureDetector* pGestureDetector = null;
4932 pEnumerator->GetCurrent(pGestureDetector);
4933 if (pGestureDetector)
4935 SysLog(NID_UI, "%ls AddedGesture : %ls", indent.GetPointer(), pGestureDetector->GetDescription().GetPointer());
4941 // Print Started Gesture List
4942 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pStartedGestureEnumerator = GetStartedGestureDetectorEnumeratorN();
4943 SysTryReturn(NID_UI, pStartedGestureEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4945 while (pStartedGestureEnumerator->MoveNext() == E_SUCCESS)
4947 _TouchGestureDetector* pStartedGestureDetector = null;
4948 pStartedGestureEnumerator->GetKey(pStartedGestureDetector);
4949 if (pStartedGestureDetector)
4951 SysLog(NID_UI, "%ls StartedGesture : %ls", indent.GetPointer(), pStartedGestureDetector->GetDescription().GetPointer());
4955 delete pStartedGestureEnumerator;
4957 // Print VE and Evas
4960 case PRINT_CONTROL_VE:
4961 _VeDebug::DumpVeTree(pVisualElementImpl, 0);
4964 case PRINT_CONTROL_EVAS:
4965 _VeDebug::DumpEvasTree(pVisualElementImpl, 0);
4968 case PRINT_CONTROL_VE_EVAS:
4969 _VeDebug::DumpVeTree(pVisualElementImpl, 0);
4970 _VeDebug::DumpEvasTree(pVisualElementImpl, 0);
4977 static int totalCount = 0;
4988 int count = GetChildCount();
4989 totalCount += count;
4991 for (int i = count - 1; i >= 0; --i)
4993 _Control* pChild = GetChild(i);
4996 pChild->PrintDescription(printChildren, depth, level);
5004 _ITouchEventPreviewer*
5005 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>) const
5007 return __pTouchEventPreviewer;
5010 _IKeyEventPreviewer*
5011 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_KEY>) const
5013 return __pKeyEventPreviewer;
5016 _INotificationEventPreviewer*
5017 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>) const
5019 return __pNotificationEventPreviewer;
5023 _Control::GetEventListener(_IntToType<_UI_EVENT_KEY>) const
5025 return __pKeyEventListener;
5028 _IFocusEventListener*
5029 _Control::GetEventListener(_IntToType<_UI_EVENT_FOCUS>) const
5031 return __pFocusEventListener;
5034 _INotificationEventListener*
5035 _Control::GetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>) const
5037 return __pNotificationEventListener;
5041 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>, _ITouchEventPreviewer* pPreviewer)
5043 __pTouchEventPreviewer = pPreviewer;
5047 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_KEY>, _IKeyEventPreviewer* pPreviewer)
5049 __pKeyEventPreviewer = pPreviewer;
5053 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventPreviewer* pPreviewer)
5055 __pNotificationEventPreviewer = pPreviewer;
5059 _Control::SetEventListener(_IntToType<_UI_EVENT_FOCUS>, _IFocusEventListener* pListener)
5061 __pFocusEventListener = pListener;
5065 _Control::SetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventListener* pListener)
5067 __pNotificationEventListener = pListener;
5071 _Control::IsDragEnabled(void) const
5073 return __dragEnabled;
5077 _Control::IsDropEnabled(void) const
5079 return __dropEnabled;
5083 _Control::SetDragEnabled(bool enabled)
5085 __dragEnabled = enabled;
5089 _Control::SetDropEnabled(bool enabled)
5091 __dropEnabled = enabled;
5095 _Control::SetTouchPressThreshold(float distance)
5097 __touchMoveAllowance = static_cast<int>(distance * __screenDpi);
5098 __pressThresHold = distance;
5102 _Control::GetTouchPressThreshold(void) const
5104 return __pressThresHold;
5108 _Control::GetTouchPressThresholdPixel(void) const
5110 return __touchMoveAllowance;
5114 _Control::SetChangingEventTarget(bool isChangingEventTarget)
5116 __isChangingEventTarget = isChangingEventTarget;
5120 _Control::GetChangingEventTarget(void) const
5122 return __isChangingEventTarget;
5126 _Control::SetEventEnableState(bool enableState)
5128 __isEventEnableState = enableState;
5132 _Control::IsEventEnabled(void) const
5134 return __isEventEnableState;
5138 _Control::SetPreviousFocus(_Control* pPreviousFocus)
5140 __pPreviousFocus = pPreviousFocus;
5144 _Control::SetNextFocus(_Control* pNextFocus)
5146 __pNextFocus = pNextFocus;
5149 _Control::GetPreviousFocus(void) const
5151 return __pPreviousFocus;
5154 _Control::GetNextFocus(void) const
5156 return __pNextFocus;
5160 _Control::OnDrawFocus(void)
5162 unique_ptr<VisualElement, _VisualElementDeleter> pFocusVisualElement (new (std::nothrow) VisualElement, _VisualElementDeleter());
5163 SysTryReturn(NID_UI, pFocusVisualElement, , E_SYSTEM, "[E_SYSTEM] System error");
5165 result r = pFocusVisualElement->Construct();
5166 SysTryReturn(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error");
5168 __pFocusVisualElement.reset(pFocusVisualElement.release());
5169 __pFocusVisualElement->SetImplicitAnimationEnabled(false);
5170 __pFocusVisualElement->SetShowState(true);
5172 _VisualElement* pControVisualElement = this->GetVisualElement();
5173 pControVisualElement->AttachChild(*__pFocusVisualElement);
5175 if (__pFocusVisualElement)
5177 Rectangle rectangle = GetBounds();
5178 __pFocusVisualElement->SetBounds(FloatRectangle(0, 0, rectangle.width, rectangle.height));
5179 unique_ptr<Canvas>pCanvas(__pFocusVisualElement->GetCanvasN());
5182 pCanvas->SetBackgroundColor(0x55555555);
5185 Color contentHighlightedColor;
5186 GET_COLOR_CONFIG(FOCUSUI::CONTENT_BG_HIGHLIGHTED, contentHighlightedColor);
5187 Bitmap* pBitmap = null;
5188 Bitmap* pTempBitmap = null;
5189 result r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pTempBitmap);
5190 pBitmap = _BitmapImpl::GetColorReplacedBitmapN(*pTempBitmap, Color::GetColor(COLOR_ID_MAGENTA), contentHighlightedColor);
5194 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
5198 r = pCanvas->DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, rectangle.width, rectangle.height), *pBitmap);
5205 r = pCanvas->DrawBitmap(FloatRectangle(0.0f, 0.0f, rectangle.width, rectangle.height), *pBitmap);
5209 __pFocusVisualElement->SetShowState(true);
5214 _Control::OnChildControlFocusMoved(const _Control& control)
5219 _Control::OnDescendantControlFocusMoved(const _Control& control)
5224 _Control::IsChildControlFocusManage(void) const
5230 _Control::SetFontFromFile(const String& fileName)
5232 result r = E_SUCCESS;
5234 if (__fontFileName.Equals(fileName))
5239 __isControlFontChanged = true;
5240 __fontFileName = fileName;
5243 Font* pFont = GetFallbackFont();
5247 r = GetLastResult();
5248 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5254 _Control::GetFontFile(void) const
5256 return __fontFileName;
5259 _Control::DrawFocus(void)
5261 _IControlDelegate& delegate = GetControlDelegate();
5262 delegate.OnDrawFocus();
5266 _Control::MakeFocusList(const _Control* pControl, IListT<_Control*>* pFocusControlList) const
5268 int childCount = pControl->GetChildCount();
5269 for(int i = 0; i < childCount; i++)
5271 _Control* pChildControl = pControl->GetChild(i);
5272 Rectangle rect = pChildControl->GetAbsoluteBounds();
5273 unique_ptr<IEnumeratorT<_Control*> > pEnum (pFocusControlList->GetEnumeratorN());
5275 while (pEnum->MoveNext() == E_SUCCESS)
5277 _Control* pEnumeratorControl = null;
5278 pEnum->GetCurrent(pEnumeratorControl);
5279 if (pEnumeratorControl != null)
5281 Rectangle enumeratorRect = pEnumeratorControl->GetAbsoluteBounds();
5282 if(enumeratorRect.y > rect.y)
5286 else if (enumeratorRect.y == rect.y)
5288 if(enumeratorRect.x > rect.x)
5297 pFocusControlList->InsertAt(pChildControl, index);
5302 _Control::MakeChildContainerFocusList(const _Control* pControl, int startIndex , IListT<_Control*>* pFocusControlList) const
5304 unique_ptr<IListT<_Control*> > pTempList (new (std::nothrow) ArrayListT<_Control*>);
5305 SysTryReturnVoidResult(NID_UI_CTRL, pTempList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
5306 MakeFocusList(pControl, pTempList.get());
5308 unique_ptr<IEnumeratorT<_Control*> > pTempEnum(pTempList->GetEnumeratorN());
5309 int index = ++startIndex;
5310 while (pTempEnum->MoveNext() == E_SUCCESS)
5312 _Control* pEnumeratorControl = null;
5313 pTempEnum->GetCurrent(pEnumeratorControl);
5314 pFocusControlList->InsertAt(pEnumeratorControl, index);
5319 Tizen::Base::Collection::IListT<_Control*>*
5320 _Control::GetFocusListN(void) const
5322 unique_ptr<IListT<_Control*> > pControlFocusList (new (std::nothrow) ArrayListT<_Control*>);
5323 SysTryReturn(NID_UI_CTRL, pControlFocusList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
5324 MakeFocusList(this, pControlFocusList.get());
5326 unique_ptr<IEnumeratorT<_Control*> > pEnum(pControlFocusList->GetEnumeratorN());
5327 SysTryReturn(NID_UI_CTRL, pEnum, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
5329 int nextContainerIndex = -1;
5330 while (pEnum->MoveNext() == E_SUCCESS)
5332 _Control* pEnumeratorControl = null;
5333 pEnum->GetCurrent(pEnumeratorControl);
5335 if (nextContainerIndex < i)
5337 if (pEnumeratorControl->IsChildControlFocusManage() == false)
5339 MakeChildContainerFocusList(pEnumeratorControl, i, pControlFocusList.get());
5340 nextContainerIndex = i;
5341 pEnum.reset(pControlFocusList->GetEnumeratorN());
5347 return pControlFocusList.release();