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::Draw(bool recursive)
1059 Invalidate(recursive);
1060 GetVisualElement()->Draw();
1064 _Control::Show(void)
1066 GetVisualElement()->Flush();
1069 SysAssert(GetLastResult() == E_SUCCESS);
1073 _Control::ChangeLayout(_ControlOrientation orientation, bool callRotation)
1080 _Visitor(_ControlOrientation orientation)
1081 : __orientation(orientation){}
1083 virtual VisitType Visit(_Control& control)
1085 if (control.__orientation != __orientation)
1087 control.__orientation = __orientation;
1088 control.GetControlDelegate().OnChangeLayout(__orientation);
1092 return VISIT_DOWNWARD;
1096 _ControlOrientation __orientation;
1099 _Visitor visitor(orientation);
1102 SysAssert(GetLastResult() == E_SUCCESS);
1104 if (callRotation == true)
1106 _ControlManager* pMgr = _ControlManager::GetInstance();
1109 _ControlRotation rotation = pMgr->GetOrientationStatus();
1110 ChangeLayout(rotation);
1116 _Control::ChangeLayout(_ControlRotation rotation)
1123 _Visitor(_ControlRotation rotation)
1124 : __rotation(rotation){}
1126 virtual VisitType Visit(_Control& control)
1128 if (control.__rotation != __rotation)
1130 control.__rotation = __rotation;
1131 control.GetControlDelegate().OnChangeLayout(__rotation);
1135 return VISIT_DOWNWARD;
1139 _ControlRotation __rotation;
1142 _Visitor visitor(rotation);
1145 SysAssert(GetLastResult() == E_SUCCESS);
1149 _Control::IsLayoutChangable(void) const
1155 _Control::IsOrientationRoot(void) const
1161 _Control::Invalidate(void)
1164 GetVisualElement()->InvalidateRectangle(null);
1168 _Control::Invalidate(bool recursive)
1175 virtual VisitType Visit(_Control& control)
1177 if (control.GetVisibleState() == false)
1182 control.Invalidate();
1185 int owneeCount = control.GetOwneeCount();
1186 for (int i = 0; i < owneeCount; ++i)
1188 _Window* pOwnee = control.GetOwnee(i);
1191 pOwnee->Invalidate(true);
1195 return VISIT_DOWNWARD;
1200 _Layout::Layout* pLayout = GetLayout();
1203 pLayout->UpdateLayout();
1206 if (recursive == false)
1218 _Control::Invalidate(const Rectangle& rect)
1221 FloatRectangle rectf(rect.x, rect.y, rect.width, rect.height);
1222 GetVisualElement()->InvalidateRectangle(&rectf);
1224 __invalidatedBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
1228 _Control::Invalidate(const FloatRectangle& rect)
1231 FloatRectangle rectf(rect.x, rect.y, rect.width, rect.height);
1232 GetVisualElement()->InvalidateRectangle(&rectf);
1234 __invalidatedBounds = rect;
1238 _Control::Contains(const Point& point) const
1242 Rectangle bounds = GetBounds();
1243 bounds.x = bounds.y = 0;
1244 return bounds.Contains(point);
1248 _Control::Contains(const FloatPoint& point) const
1252 FloatRectangle bounds = GetBoundsF();
1253 bounds.x = bounds.y = 0;
1254 return bounds.Contains(point);
1259 _Control::PartialUpdateLayout(void)
1263 _Layout::Layout* pLayout = GetLayout();
1266 pLayout->PartialUpdateLayout();
1271 _Control::UpdateLayout(void)
1275 _Layout::Layout* pLayout = GetLayout();
1278 pLayout->UpdateLayout();
1283 _Control::SetChildAlwaysOnTop(_Control& child)
1287 SysTryReturn(NID_UI,
1288 child.GetParent() == this, E_INVALID_ARG,
1289 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1291 SysTryReturn(NID_UI,
1292 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1293 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1295 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_TOP)
1300 child.SetLayer(_CONTROL_LAYER_CLIENT_TOP);
1306 _Control::SetChildAlwaysAtBottom(_Control& child)
1310 SysTryReturn(NID_UI,
1311 child.GetParent() == this, E_INVALID_ARG,
1312 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1314 SysTryReturn(NID_UI,
1315 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1316 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1318 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_BOTTOM)
1323 child.SetLayer(_CONTROL_LAYER_CLIENT_BOTTOM);
1329 _Control::ResetChildLayer(_Control& child)
1333 SysTryReturn(NID_UI,
1334 child.GetParent() == this, E_INVALID_ARG,
1335 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
1337 SysTryReturn(NID_UI,
1338 child.GetArea() == _CONTROL_AREA_CLIENT, E_SYSTEM,
1339 E_SYSTEM, "[E_SYSTEM] The child is not in the client area.");
1341 if (child.GetLayer() == _CONTROL_LAYER_CLIENT_MIDDLE)
1346 child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE);
1353 _Control::AttachSystemChild(_Control& child)
1356 result r = E_SUCCESS;
1358 r = StartAttaching(child, _CONTROL_AREA_SYSTEM);
1364 ControlList& children = GetChildList();
1365 r = children.Add(&child);
1366 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1368 r = GetVisualElement()->AttachChild(*child.GetVisualElement());
1369 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1371 r = EndAttaching(child);
1377 SysAssert(GetLastResult() == E_SUCCESS);
1383 _Control::DetachSystemChild(_Control& child)
1385 return DetachChild(child);
1389 _Control::HasParent(void) const
1391 return __pParent != null;
1395 _Control::GetArea(void) const
1402 _Control::GetLayer(void) const
1409 _Control::SetLayer(_ControlLayer layer)
1412 _VisualElementImpl* pImpl = _VisualElementImpl::GetInstance(*GetVisualElement());
1414 result r = pImpl->SetZOrderGroup(::GetZOrderGroupOfVisualElement(layer));
1417 SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
1420 const _Control::ControlList&
1421 _Control::GetChildList() const
1423 return const_cast <_Control*>(this)->GetChildList();
1426 _Control::ControlList&
1427 _Control::GetChildList()
1429 return *__pChildren;
1433 _Control::IsCalledCallAttachingToMainTree(void)
1435 return __isCalledCallOnAttachingToMainTree;
1439 _Control::SetCalledCallAttachingToMainTree(bool isAttaching)
1441 __isCalledCallOnAttachingToMainTree = isAttaching;
1445 _Control::IsCalledCallPreAttachedToMainTree(void)
1447 return __isCalledCallOnPreAttachedToMainTree;
1451 _Control::IsCalledCallAttachedToMainTree(void)
1453 return __isCalledCallOnAttachedToMainTree;
1457 _Control::SetCalledCallPreAttachedToMainTree(bool isAttached)
1459 __isCalledCallOnPreAttachedToMainTree = isAttached;
1463 _Control::SetCalledCallAttachedToMainTree(bool isAttached)
1465 __isCalledCallOnAttachedToMainTree = isAttached;
1469 _Control::CallOnAttachingToMainTree(_Control& control)
1471 result r = E_SUCCESS;
1473 ControlList& children = control.GetChildList();
1474 _Control* pChild = null;
1476 int childrenCount = children.GetCount();
1478 for (int index = 0; index < childrenCount; index++)
1480 r = children.GetAt(index, pChild);
1483 SysAssert(r == E_OUT_OF_RANGE);
1484 SysTryReturn(NID_UI,
1485 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1486 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1488 if (!pChild->IsCalledCallAttachingToMainTree())
1490 r = CallOnAttachingToMainTree(*pChild);
1491 pChild->SetCalledCallAttachingToMainTree(true);
1492 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1496 if (!control.IsCalledCallAttachingToMainTree())
1498 r = control.GetControlDelegate().OnAttachingToMainTree(this);
1499 control.SetCalledCallAttachingToMainTree(true);
1500 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1507 _Control::CallOnPreAttachedToMainTree(_Control& control)
1509 result r = E_SUCCESS;
1511 ControlList& children = control.GetChildList();
1512 _Control* pChild = null;
1514 int childrenCount = children.GetCount();
1516 for (int index = 0; index < childrenCount; index++)
1518 r = children.GetAt(index, pChild);
1521 SysAssert(r == E_OUT_OF_RANGE);
1522 SysTryReturn(NID_UI,
1523 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1524 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1527 if (!pChild->IsCalledCallPreAttachedToMainTree())
1529 r = CallOnPreAttachedToMainTree(*pChild);
1530 pChild->SetCalledCallPreAttachedToMainTree(true);
1534 if (!control.IsCalledCallPreAttachedToMainTree())
1536 r = control.GetControlDelegate().OnPreAttachedToMainTree();
1537 control.SetCalledCallPreAttachedToMainTree(true);
1544 _Control::CallOnAttachedToMainTree(_Control& control)
1546 result r = E_SUCCESS;
1548 ControlList& children = control.GetChildList();
1549 _Control* pChild = null;
1551 int childrenCount = children.GetCount();
1553 for (int index = 0; index < childrenCount; index++)
1555 r = children.GetAt(index, pChild);
1558 SysAssert(r == E_OUT_OF_RANGE);
1559 SysTryReturn(NID_UI,
1560 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1561 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1564 if (!pChild->IsCalledCallAttachedToMainTree())
1566 r = CallOnAttachedToMainTree(*pChild);
1567 pChild->SetCalledCallAttachedToMainTree(true);
1571 if (!control.IsCalledCallAttachedToMainTree())
1573 r = control.GetControlDelegate().OnAttachedToMainTree();
1574 control.SetCalledCallAttachedToMainTree(true);
1581 _Control::CallOnDetachingFromMainTree(_Control& control)
1583 result r = E_SUCCESS;
1585 ControlList& children = control.GetChildList();
1586 _Control* pChild = null;
1588 _Window* pTop = control.GetRootWindow();
1591 _Control* pControl = pTop->GetFocusControl(this);
1592 if ((&control) == pControl)
1594 pTop->SetFocusControl(&control, false);
1598 if (!__isPostOrderTraversal)
1600 r = control.GetControlDelegate().OnDetachingFromMainTree();
1601 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1604 int childrenCount = children.GetCount();
1606 for (int index = 0; index < childrenCount; index++)
1608 r = children.GetAt(index, pChild);
1611 SysAssert(r == E_OUT_OF_RANGE);
1612 SysTryReturn(NID_UI,
1613 (r != E_OUT_OF_RANGE), E_OUT_OF_RANGE,
1614 E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
1616 r = CallOnDetachingFromMainTree(*pChild);
1617 pChild->SetCalledCallAttachingToMainTree(false);
1618 pChild->SetCalledCallPreAttachedToMainTree(false);
1619 pChild->SetCalledCallAttachedToMainTree(false);
1620 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1623 if (__isPostOrderTraversal)
1625 r = control.GetControlDelegate().OnDetachingFromMainTree();
1626 control.SetCalledCallAttachingToMainTree(false);
1627 control.SetCalledCallPreAttachedToMainTree(false);
1628 control.SetCalledCallAttachedToMainTree(false);
1629 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1636 _Control::CallOnAncestorVisibleStateChanged(void)
1641 _Visitor(_Control& parent)
1642 : __parent(parent){}
1644 virtual VisitType Visit(_Control& control)
1646 control.GetControlDelegate().OnAncestorVisibleStateChanged(__parent);
1647 return VISIT_DOWNWARD;
1653 _Visitor visitor(*this);
1658 _Control::CallOnAncestorEnableStateChanged(void)
1663 _Visitor(_Control& parent)
1664 : __parent(parent){}
1666 virtual VisitType Visit(_Control& control)
1668 control.GetControlDelegate().OnAncestorEnableStateChanged(__parent);
1669 return VISIT_DOWNWARD;
1675 _Visitor visitor(*this);
1680 _Control::CallOnAncestorInputEnableStateChanged(void)
1685 _Visitor(_Control& parent)
1686 : __parent(parent){}
1688 virtual VisitType Visit(_Control& control)
1690 control.GetControlDelegate().OnAncestorInputEnableStateChanged(__parent);
1691 return VISIT_DOWNWARD;
1697 _Visitor visitor(*this);
1703 // [ToDo] Rollback is difficult.
1705 _Control::StartAttaching(_Control& child, _ControlArea area)
1707 result r = E_SUCCESS;
1709 _Control* pOldParent = child.GetParent();
1711 SysTryReturn(NID_UI,
1712 (pOldParent != this), E_INVALID_ARG,
1713 E_INVALID_ARG, "[E_INVALID_ARG] The child control is already attached to this container.");
1715 SysTryReturn(NID_UI,
1716 pOldParent == null, E_INVALID_ARG,
1717 E_INVALID_ARG, "[E_INVALID_ARG] Unable to add the child which already has another parent.");
1719 r = child.GetControlDelegate().OnAttaching(this);
1720 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1722 if (IsAttachedToMainTree())
1724 r = CallOnAttachingToMainTree(child);
1725 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1728 // [ToDo] Add control to layout
1729 // What should we do about non-layoutable controls?
1730 if (area == _CONTROL_AREA_CLIENT)
1732 _ControlManager* pMgr = _ControlManager::GetInstance();
1733 r = GetLastResult();
1734 SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r));
1736 r = __pLayoutContainer->AddItem(child.GetLayoutContainer());
1739 child.GetControlDelegate().OnAttachingFailed(*this);
1740 SysLogException(NID_UI, E_SYSTEM, "[E_SYSTEM] Failed to apply layout.");
1745 if (IsAttachedToMainTree())
1747 if (!(IsOrientationRoot() && child.IsOrientationRoot()))
1749 child.ChangeLayout(_ControlManager::GetInstance()->GetOrientation());
1753 child.__area = area;
1755 if (area == _CONTROL_AREA_CLIENT)
1757 if (child.GetLayer() != _CONTROL_LAYER_CLIENT_TOP && child.GetLayer() != _CONTROL_LAYER_CLIENT_BOTTOM)
1759 child.SetLayer(_CONTROL_LAYER_CLIENT_MIDDLE);
1764 child.SetLayer(_CONTROL_LAYER_SYSTEM);
1767 SysAssert(GetLastResult() == E_SUCCESS);
1772 _Control::EndAttaching(_Control& child)
1774 child.SetParent(this);
1776 FloatRectangle floatBounds(child.GetBoundsF().x, child.GetBoundsF().y, child.GetBoundsF().width, child.GetBoundsF().height);
1778 result r = E_SUCCESS;
1779 if (child.IsLayoutChangable() == false)
1781 r = child.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, floatBounds.width, floatBounds.height));
1785 r = child.UpdateBoundsOfVisualElement(floatBounds);
1787 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1789 r = child.GetControlDelegate().OnAttached();
1790 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1792 if (IsAttachedToMainTree())
1794 r = CallOnPreAttachedToMainTree(child);
1795 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1797 r = CallOnAttachedToMainTree(child);
1798 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1803 GetControlDelegate().OnChildAttached(child);
1813 _Control::AttachChild(_Control& child)
1816 result r = E_SUCCESS;
1818 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1824 ControlList& children = GetChildList();
1825 r = children.Add(&child);
1826 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
1828 r = GetVisualElement()->AttachChild(*child.GetVisualElement());
1830 r = EndAttaching(child);
1836 SysAssert(GetLastResult() == E_SUCCESS);
1842 _Control::UpdateFocusList(void)
1844 _Window* pTop = GetRootWindow();
1847 pTop->ResetFocusList();
1852 _Control::RemoveFocusRing(void)
1854 if (__pFocusVisualElement)
1856 __pFocusVisualElement.reset();
1861 _Control::HasFocusRing(void)
1863 if (__pFocusVisualElement)
1872 _Control::SetFocusNavigateEnabled(bool enable)
1874 __isNavigatable = enable;
1878 _Control::IsFocusNavigateEnabled(void) const
1880 return __isNavigatable;
1884 _Control::SetFocusModeStateEnabled(bool enable)
1886 __isFocusMode = enable;
1887 if (enable == false)
1889 OnFocusModeStateChanged();
1894 _Control::IsFocusModeStateEnabled(void) const
1896 return _FocusManagerImpl::GetInstance()->IsFocusModeStateEnabled();
1903 _Control::InsertChildToBottom(_Control& child)
1906 result r = E_SUCCESS;
1908 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1914 ControlList& children = GetChildList();
1915 r = children.InsertAt(&child, 0);
1916 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1918 GetVisualElement()->InsertChild(*child.GetVisualElement(), null, false);
1919 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1921 r = EndAttaching(child);
1927 SysAssert(GetLastResult() == E_SUCCESS);
1935 _Control::InsertChildAfter(const _Control& targetChild, _Control& child)
1938 result r = E_SUCCESS;
1940 SysTryReturn(NID_UI,
1941 targetChild.GetParent() == this, E_INVALID_ARG,
1942 E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child.");
1944 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1950 int targetIndex = GetChildIndex(targetChild);
1951 SysAssert(targetIndex != -1);
1953 ControlList& children = GetChildList();
1954 r = children.InsertAt(&child, targetIndex + 1);
1955 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1957 GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), true);
1958 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1960 r = EndAttaching(child);
1966 SysAssert(GetLastResult() == E_SUCCESS);
1974 _Control::InsertChildBefore(const _Control& targetChild, _Control& child)
1977 result r = E_SUCCESS;
1979 SysTryReturn(NID_UI,
1980 targetChild.GetParent() == this, E_INVALID_ARG,
1981 E_INVALID_ARG, "[E_INVALID_ARG] The target is not my child.");
1983 r = StartAttaching(child, _CONTROL_AREA_CLIENT);
1989 int targetIndex = GetChildIndex(targetChild);
1990 SysAssert(targetIndex != -1);
1992 ControlList& children = GetChildList();
1993 r = children.InsertAt(&child, targetIndex);
1994 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1996 GetVisualElement()->InsertChild(*child.GetVisualElement(), targetChild.GetVisualElement(), false);
1997 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
1999 r = EndAttaching(child);
2005 SysAssert(GetLastResult() == E_SUCCESS);
2011 _Control::DetachChild(_Control& child)
2014 result r = E_SUCCESS;
2016 SysTryReturn(NID_UI,
2017 child.GetParent() == this, E_INVALID_ARG,
2018 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2020 if (IsAttachedToMainTree())
2022 r = CallOnDetachingFromMainTree(child);
2023 SysTryReturn(NID_UI,
2024 r == E_SUCCESS, E_SYSTEM,
2025 E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent.");
2027 SysTryReturn(NID_UI,
2028 child.GetControlDelegate().OnDetaching() == E_SUCCESS, E_SYSTEM,
2029 E_SYSTEM, "[E_SYSTEM] The child cannot detached from parent.");
2032 GetControlDelegate().OnChildDetaching(child);
2035 r = GetVisualElement()->DetachChild(*child.GetVisualElement());
2036 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2038 ControlList& children = GetChildList();
2039 r = children.Remove(&child);
2040 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2042 // Remove control to layout
2043 if (child.__area == _CONTROL_AREA_CLIENT)
2045 _ControlManager* pMgr = _ControlManager::GetInstance();
2046 r = GetLastResult();
2047 SysTryReturn(NID_UI, pMgr, r, r, "[%s] Propagating.", GetErrorMessage(r));
2049 r = __pLayoutContainer->RemoveItem(child.GetLayoutContainer());
2050 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2053 child.SetParent(null);
2054 child.__area = _CONTROL_AREA_NONE;
2055 child.__layer = _CONTROL_LAYER_NONE;
2057 GetControlDelegate().OnChildDetached(child);
2060 SysAssert(GetLastResult() == E_SUCCESS);
2068 _Control::DetachAllChildren(bool detachSystemChild, bool recursive)
2071 result r = E_SUCCESS;
2073 int childCount = GetChildCount();
2078 while (childCount--)
2080 _Control* pChild = GetChild(itemIndex);
2086 if (!detachSystemChild && (pChild->GetArea() == _CONTROL_AREA_SYSTEM))
2092 int childCount = pChild->GetChildCount();
2093 if (childCount == 0)
2095 r = DetachChild(*pChild);
2098 SysLog(NID_UI, "child is not detached from this container.");
2103 r = DetachChild(*pChild);
2106 SysLog(NID_UI, "child is not detached from this container.");
2108 pChild->DetachAllChildren(detachSystemChild, true);
2114 int notDetachedChildCount = 0;
2115 while (childCount--)
2117 _Control* pChild = GetChild(itemIndex);
2123 if (!detachSystemChild && (pChild->GetArea() == _CONTROL_AREA_SYSTEM))
2128 r = DetachChild(*pChild);
2132 ++notDetachedChildCount;
2136 SysLog(NID_UI, "%d children are not detached from this container.", notDetachedChildCount);
2144 _Control::MoveChildToTop(const _Control& child)
2147 result r = E_SUCCESS;
2149 SysTryReturn(NID_UI,
2150 child.GetParent() == this, E_INVALID_ARG,
2151 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2153 // If already on top,
2154 ControlList& children = GetChildList();
2155 if (GetChildIndex(child) == children.GetCount() - 1)
2157 SysAssert(GetLastResult() == E_SUCCESS);
2161 _Control* pChild = const_cast <_Control*>(&child);
2163 r = children.Remove(pChild);
2164 SysAssert(r == E_SUCCESS);
2166 r = children.Add(pChild);
2167 SysAssert(r == E_SUCCESS);
2169 r = child.GetVisualElement()->SetZOrder(null, true);
2170 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2172 SysAssert(GetLastResult() == E_SUCCESS);
2178 _Control::MoveChildToBottom(const _Control& child)
2181 result r = E_SUCCESS;
2183 SysTryReturn(NID_UI,
2184 child.GetParent() == this, E_INVALID_ARG,
2185 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2187 ControlList& children = GetChildList();
2189 if (GetChildIndex(child) == 0)
2191 SysAssert(GetLastResult() == E_SUCCESS);
2195 _Control* pChild = const_cast <_Control*>(&child);
2197 r = children.Remove(pChild);
2198 SysAssert(r == E_SUCCESS);
2200 r = children.InsertAt(pChild, 0);
2201 SysAssert(r == E_SUCCESS);
2203 r = child.GetVisualElement()->SetZOrder(null, false);
2204 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2206 SysAssert(GetLastResult() == E_SUCCESS);
2212 _Control::MoveChildAfter(const _Control& targetChild, const _Control& child)
2215 result r = E_SUCCESS;
2217 SysTryReturn(NID_UI,
2218 targetChild.GetParent() == this, E_INVALID_ARG,
2219 E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child.");
2221 SysTryReturn(NID_UI,
2222 child.GetParent() == this, E_INVALID_ARG,
2223 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2225 SysTryReturn(NID_UI,
2226 &targetChild != &child, E_INVALID_ARG,
2227 E_INVALID_ARG, "[E_INVALID_ARG] Cannot move after self.");
2229 ControlList& children = GetChildList();
2231 int targetIndex = GetChildIndex(targetChild);
2232 SysAssert(targetIndex != -1);
2234 if (targetIndex + 1 == GetChildIndex(child))
2236 SysAssert(GetLastResult() == E_SUCCESS);
2240 _Control* pChild = const_cast <_Control*>(&child);
2242 r = children.Remove(pChild);
2243 SysAssert(r == E_SUCCESS);
2245 r = children.InsertAt(pChild, targetIndex + 1);
2246 SysAssert(r == E_SUCCESS);
2248 r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), true);
2249 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2251 SysAssert(GetLastResult() == E_SUCCESS);
2257 _Control::MoveChildBefore(const _Control& targetChild, const _Control& child)
2260 result r = E_SUCCESS;
2262 SysTryReturn(NID_UI,
2263 targetChild.GetParent() == this, E_INVALID_ARG,
2264 E_INVALID_ARG, "[E_INVALID_ARG] Target is not my child.");
2266 SysTryReturn(NID_UI,
2267 child.GetParent() == this, E_INVALID_ARG,
2268 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2270 SysTryReturn(NID_UI,
2271 &targetChild != &child, E_INVALID_ARG,
2272 E_INVALID_ARG, "[E_INVALID_ARG] Cannot move before self.");
2274 ControlList& children = GetChildList();
2276 int targetIndex = GetChildIndex(targetChild);
2277 SysAssert(targetIndex != -1);
2279 if (targetIndex - 1 == GetChildIndex(child))
2281 SysAssert(GetLastResult() == E_SUCCESS);
2285 _Control* pChild = const_cast <_Control*>(&child);
2287 r = children.Remove(pChild);
2288 SysAssert(r == E_SUCCESS);
2290 r = children.InsertAt(pChild, targetIndex);
2291 SysAssert(r == E_SUCCESS);
2293 r = child.GetVisualElement()->SetZOrder(targetChild.GetVisualElement(), false);
2294 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
2296 SysAssert(GetLastResult() == E_SUCCESS);
2303 _Control::GetChildIndex(const _Control& child) const
2306 result r = E_SUCCESS;
2308 SysTryReturn(NID_UI,
2309 child.GetParent() == this, -1,
2310 E_INVALID_ARG, "[E_INVALID_ARG] Not my child.");
2312 const ControlList& children = GetChildList();
2315 r = children.IndexOf(const_cast<_Control*>(&child), index);
2318 SysAssert(r == E_OBJ_NOT_FOUND);
2319 SysLogException(NID_UI, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] Unable to find the specified child.");
2323 SysAssert(GetLastResult() == E_SUCCESS);
2329 _Control::GetChild(int index) const
2332 result r = E_SUCCESS;
2334 const ControlList& children = GetChildList();
2336 _Control* pChild = null;
2337 r = children.GetAt(index, pChild);
2340 SysAssert(r == E_OUT_OF_RANGE);
2341 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
2345 SysAssert(GetLastResult() == E_SUCCESS);
2350 _Control::GetChildCount(void) const
2353 return GetChildList().GetCount();
2357 _Control::GetHandle(void) const
2359 return __controlHandle;
2363 _Control::GetUserData(void) const
2369 _Control::SetUserData(void* pUserData)
2371 __pUserData = pUserData;
2375 _Control::GetPropertyName(void) const
2378 return Tizen::Ui::Variant(__name);
2382 _Control::GetName(void) const
2384 Variant name = GetProperty("Name");
2386 return name.ToString();
2390 _Control::SetPropertyName(const Variant& name)
2393 __name = name.ToString();
2399 _Control::SetName(const String& name)
2401 SetProperty("Name", Variant(name));
2405 _Control::GetParent(void) const
2411 _Control::GetCanvasN(void) const
2413 return GetCanvasN(FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height));
2417 _Control::GetCanvasN(const Rectangle& bounds) const
2420 Canvas *pCanvas = GetControlDelegate().OnCanvasRequestedN(FloatRectangle(bounds.x, bounds.y, bounds.width, bounds.height));
2421 if (pCanvas == null)
2423 GetVisualElement()->SetFlushNeeded();
2424 pCanvas = GetVisualElement()->GetCanvasN(bounds);
2425 if (IsFailed(GetLastResult()))
2427 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
2430 if (pCanvas && !__isCalledGetCanvasN)
2432 pCanvas->SetBackgroundColor(GetBackgroundColor());
2434 const_cast <_Control*>(this)->__isCalledGetCanvasN = true;
2441 _Control::GetCanvasN(const FloatRectangle& bounds) const
2444 Canvas *pCanvas = GetControlDelegate().OnCanvasRequestedN(FloatRectangle(bounds));
2445 if (pCanvas == null)
2447 GetVisualElement()->SetFlushNeeded();
2448 pCanvas = GetVisualElement()->GetCanvasN(bounds);
2449 if (IsFailed(GetLastResult()))
2451 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
2454 if (pCanvas && !__isCalledGetCanvasN)
2456 pCanvas->SetBackgroundColor(GetBackgroundColor());
2458 const_cast <_Control*>(this)->__isCalledGetCanvasN = true;
2465 _Control::IsCalledGetCanvasN(void) const
2467 return __isCalledGetCanvasN;
2471 _Control::GetClientCanvasN(void) const
2473 return GetCanvasN(GetClientBounds());
2477 _Control::IsAncestorOf(const _Control& control) const
2481 const _Control* pParent = control.GetParent();
2491 const _Control& __ancestor;
2496 _Visitor(const _Control& ancestor)
2497 : __ancestor(ancestor)
2500 virtual VisitType Visit(_Control& control)
2502 if (&__ancestor == &control)
2509 return VISIT_UPWARD;
2514 _Visitor visitor(*this);
2515 pParent->Accept(visitor);
2517 SysAssert(GetLastResult() == E_SUCCESS);
2522 _Control::GetRootWindow(void) const
2534 virtual VisitType Visit(_Control& control)
2536 pRoot = dynamic_cast <_Window*>(&control);
2542 return VISIT_UPWARD;
2549 SysAssert(GetLastResult() == E_SUCCESS);
2550 return visitor.pRoot;
2554 _Control::IsAttachedToMainTree(void) const
2558 _ControlManager* pMgr = _ControlManager::GetInstance();
2564 _Window* pRootWindow = GetRootWindow();
2565 if (pRootWindow == null)
2570 return pRootWindow->IsAttached();
2574 _Control::IsFocusable(void) const
2581 _Control::SetFocusable(bool focusable)
2584 bool oldState = __focusable;
2585 __focusable = focusable;
2586 if (oldState != __focusable)
2588 GetControlDelegate().OnFocusableStateChanged(focusable);
2593 _Control::IsNativeObjectFocusable(void) const
2596 return __nativeObjectFocusable;
2600 _Control::SetNativeObjectFocusable(bool focusable)
2603 __nativeObjectFocusable = focusable;
2607 _Control::IsFocused(void) const
2611 _Window* pTop = GetRootWindow();
2617 if (this == pTop->GetFocusControl(const_cast<_Control*>(this)))
2626 _Control::SetFocused(bool on)
2630 SysTryReturn(NID_UI,
2631 IsAttachedToMainTree(), E_INVALID_OPERATION,
2632 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This control should have a parent or be attached to the main tree.");
2634 SysTryReturn(NID_UI,
2635 IsFocusable(), E_INVALID_OPERATION,
2636 E_INVALID_OPERATION, "[E_INVALID_OPERATION] This Control isn't focusable control.");
2638 _Window* pTop = GetRootWindow();
2642 pTop->SetFocusControl(this, true);
2646 pTop->SetFocusControl(this, false);
2653 _Control::SetFont(const String& fontName)
2655 result r = E_SUCCESS;
2657 if (__fontName.Equals(fontName))
2662 __isControlFontChanged = true;
2663 __fontName = fontName;
2664 __fontFileName.Clear();
2666 Font* pFont = GetFallbackFont();
2670 r = GetLastResult();
2671 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
2677 _Control::GetFallbackFont(void)
2679 unsigned long style = 0;
2681 float floatTextSize = 0.0f;
2682 result r = E_SUCCESS;
2683 _IControlDelegate& delegate = GetControlDelegate();
2684 delegate.OnFontInfoRequested(style, textSize);
2685 delegate.OnFontInfoRequested(style, floatTextSize);
2686 _ControlManager* pControlManager = _ControlManager::GetInstance();
2687 _FontImpl* pFontImpl = _FontImpl::GetInstance(*__pFont);
2688 if (!(__isControlFontChanged || pControlManager->IsDefaultFontChanged() || pControlManager->IsSystemFontChanged())
2690 && ((__pFont->GetSize() == textSize || __pFont->GetSizeF() == floatTextSize))
2691 && (pFontImpl->GetStyle() == static_cast<int>(style)))
2695 unique_ptr<Font>pTempFont(new(std::nothrow)Font());
2696 SysTryReturn(NID_UI , pTempFont , null , E_OUT_OF_MEMORY, "[%s] Fails to create a __pFont.", GetErrorMessage(r));
2698 if (!__fontName.IsEmpty())
2700 __isControlFontChanged = false;
2701 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2702 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2704 if (floatTextSize > 0.0f)
2706 r = pFontImpl->Construct(__fontName, style, floatTextSize, false);
2710 r = pFontImpl->Construct(__fontName, style, textSize, false);
2713 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2714 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2716 else if (!__fontFileName.IsEmpty())
2718 __isControlFontChanged = false;
2719 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2720 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2722 if (floatTextSize > 0.0f)
2724 r = pFontImpl->Construct(__fontFileName, style, floatTextSize);
2728 r = pFontImpl->Construct(__fontFileName, style, textSize);
2730 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2731 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2734 else if (!pControlManager->GetDefaultFont().IsEmpty())
2736 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2737 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2739 if (floatTextSize > 0.0f)
2741 r = pFontImpl->Construct(pControlManager->GetDefaultFont(), style, floatTextSize, false);
2745 r = pFontImpl->Construct(pControlManager->GetDefaultFont(), style, textSize, false);
2747 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2748 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2750 else if (!pControlManager->GetDefaultFontFile().IsEmpty())
2752 _FontImpl* pFontImpl = _FontImpl::GetInstance(*pTempFont);
2753 SysAssertf(pFontImpl != null, "Getting _FontImpl instance failed.");
2755 if (floatTextSize > 0.0f)
2757 r = pFontImpl->Construct(pControlManager->GetDefaultFontFile(), style, floatTextSize);
2761 r = pFontImpl->Construct(pControlManager->GetDefaultFontFile(), style, textSize);
2763 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2764 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2768 if (floatTextSize > 0.0f)
2770 r = pTempFont->Construct(style, floatTextSize);
2774 r = pTempFont->Construct(style, textSize);
2776 SysTryReturn(NID_UI, r != E_OUT_OF_MEMORY, null, E_OUT_OF_MEMORY, "%s.", GetErrorMessage(r));
2777 SysTryReturn(NID_UI, r == E_SUCCESS, null, E_FILE_NOT_FOUND, "%s.", GetErrorMessage(r));
2785 __pFont = pTempFont.release();
2786 delegate.OnFontChanged(__pFont);
2791 _Control::GetFont(void) const
2797 _Control::IsEnabled(void) const
2809 virtual VisitType Visit(_Control& control)
2811 if (!control.GetEnableState())
2817 return VISIT_UPWARD;
2823 return visitor.enabled;
2827 _Control::GetEnableState(void) const
2830 return __enabledState;
2834 _Control::SetEnableState(bool enabledState)
2837 const bool changed = (__enabledState != enabledState);
2840 __enabledState = enabledState;
2841 CallOnAncestorEnableStateChanged();
2843 __pAccessibilityContainer->SetEnableState(enabledState);
2847 _Control::IsInputEventEnabled(void) const
2857 : inputEnabled(true){}
2859 virtual VisitType Visit(_Control& control)
2861 if (!control.GetInputEnableState())
2863 inputEnabled = false;
2867 return VISIT_UPWARD;
2873 return visitor.inputEnabled;
2877 _Control::GetInputEnableState(void) const
2881 if (__inputLockRefCount != 0)
2892 _Control::LockInputEvent(void)
2894 __inputLockRefCount++;
2895 CallOnAncestorInputEnableStateChanged();
2899 _Control::UnlockInputEvent(void)
2901 __inputLockRefCount--;
2902 if (__inputLockRefCount < 0)
2904 __inputLockRefCount = 0;
2909 _Control::IsVisible(void) const
2913 SysTryReturn(NID_UI, IsAttachedToMainTree(), false, E_SYSTEM, "[E_SYSTEM] This control should be attached to the main tree.");
2923 virtual VisitType Visit(_Control& control)
2925 if (!control.GetVisibleState())
2931 return VISIT_UPWARD;
2938 SysAssert(GetLastResult() == E_SUCCESS);
2939 return visitor.visible;
2943 _Control::GetVisibleState(void) const
2946 return __visibleState;
2950 _Control::SetVisibleState(bool visibleState)
2954 const bool changed = (__visibleState != visibleState) || !__initVisibleState;
2958 GetControlDelegate().OnVisibleStateChanging();
2961 __visibleState = visibleState;
2962 GetVisualElement()->SetShowState(visibleState);
2964 if (visibleState == false)
2966 int owneeCount = GetOwneeCount();
2967 for (int i = 0; i < owneeCount; ++i)
2969 _Window* pWindow = GetOwnee(i);
2972 pWindow->SetVisibleState(visibleState);
2979 GetControlDelegate().OnVisibleStateChanged();
2980 CallOnAncestorVisibleStateChanged();
2981 _Control* pParent = GetParent();
2984 pParent->GetControlDelegate().OnChildVisibleStateChanged(*this);
2990 __initVisibleState = true;
2994 _Control::IsLayoutable(void) const
3001 _Control::IsClipToParent(void) const
3004 // SysAssert(GetVisualElement()->IsClipToParent() == __clipToParent);
3005 return __clipToParent;
3009 _Control::SetClipToParent(bool clipToParent)
3012 result r = E_SUCCESS;
3014 __clipToParent = clipToParent;
3015 r = GetVisualElement()->SetClipToParent(clipToParent);
3016 SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
3022 _Control::SetClipChildrenEnabled(bool clipChildren)
3025 //result r = E_SUCCESS;
3027 GetVisualElement()->SetClipChildrenEnabled(clipChildren);
3028 //SysTryReturn(NID_UI, r == E_SUCCESS, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] System error occurred.");
3034 _Control::GetBounds(void) const
3037 return _CoordinateSystemUtils::ConvertToInteger(__bounds);
3041 _Control::GetBoundsF(void) const
3048 _Control::GetPosition(void) const
3051 return Point(_CoordinateSystemUtils::ConvertToInteger(__bounds.x), _CoordinateSystemUtils::ConvertToInteger(__bounds.y));
3055 _Control::GetPositionF(void) const
3058 return FloatPoint(__bounds.x, __bounds.y);
3062 _Control::GetSize(void) const
3065 return Dimension(_CoordinateSystemUtils::ConvertToInteger(__bounds.width), _CoordinateSystemUtils::ConvertToInteger(__bounds.height));
3069 _Control::GetSizeF(void) const
3072 return FloatDimension(__bounds.width, __bounds.height);
3077 _Control::UpdateBoundsOfVisualElement(const FloatRectangle& controlBounds)
3079 FloatRectangle rect(controlBounds.x, controlBounds.y, controlBounds.width, controlBounds.height);
3081 _Control* pParent = GetParent();
3082 if (__area == _CONTROL_AREA_CLIENT && pParent)
3084 const FloatRectangle clientBounds = pParent->GetClientBoundsF();
3085 rect.x += clientBounds.x;
3086 rect.y += clientBounds.y;
3089 GetVisualElement()->SetBounds(rect);
3095 _Control::AdjustAbsoluteBounds(void)
3100 _Visitor(_Control* pControl)
3101 : __pControl(pControl){}
3103 virtual VisitType Visit(_Control& control)
3105 result r = E_SUCCESS;
3107 if (__pControl == &control)
3109 return VISIT_DOWNWARD;
3111 FloatRectangle fbounds = control.GetBoundsF();
3112 if (control.IsLayoutChangable() == false)
3114 r = control.UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
3118 r = control.UpdateBoundsOfVisualElement(fbounds);
3121 ControlList& children = control.GetChildList();
3123 int childrenCount = children.GetCount();
3124 if (childrenCount <= 0)
3130 return VISIT_DOWNWARD;
3134 _Control* __pControl;
3137 _Visitor visitor(this);
3144 _Control::IsInSizeRange(const Dimension& size) const
3146 return (__minSize.width <= size.width) && (size.width <= __maxSize.width) &&
3147 (__minSize.height <= size.height) && (size.height <= __maxSize.height);
3151 _Control::IsInSizeRange(const FloatDimension& size) const
3153 return (__minSize.width <= size.width) && (size.width <= __maxSize.width) &&
3154 (__minSize.height <= size.height) && (size.height <= __maxSize.height);
3157 // Custom Exception: ex) Location::Map
3159 _Control::SetBoundsFinal(const FloatRectangle& newBounds, bool changeLayoutBaseRect, bool callBoundsChangeCallbacks)
3161 result r = E_SUCCESS;
3163 FloatRectangle bounds(newBounds.x, newBounds.y, newBounds.width, newBounds.height);
3165 _IControlDelegate& delegate = GetControlDelegate();
3167 const bool moved = (__bounds.x != bounds.x) || (__bounds.y != bounds.y);
3168 const bool resized = (__bounds.width != bounds.width) || (__bounds.height != bounds.height);
3170 if ((moved || resized) && callBoundsChangeCallbacks)
3172 r = delegate.OnBoundsChanging(_CoordinateSystemUtils::ConvertToInteger(bounds));
3175 SysLogException(NID_UI, r, "[%s] Callback returns exception.", GetErrorMessage(r));
3176 return r; // Relay the result;
3178 r = delegate.OnBoundsChanging(bounds);
3181 SysLogException(NID_UI, r, "[%s] Callback returns exception.", GetErrorMessage(r));
3182 return r; // Relay the result;
3186 if (moved || resized)
3188 const FloatRectangle fbounds(bounds.x, bounds.y, bounds.width, bounds.height);
3189 if (IsLayoutChangable() == false)
3191 r = UpdateBoundsOfVisualElement(FloatRectangle(0.0f, 0.0f, fbounds.width, fbounds.height));
3195 r = UpdateBoundsOfVisualElement(fbounds);
3199 SysAssert(r == E_SUCCESS); // [ToDo] Exception check and rollback.
3203 if (changeLayoutBaseRect)
3205 __pLayoutContainer->OnChangeBaseRect();
3208 if ((moved || resized) && callBoundsChangeCallbacks)
3210 if (IsMovable() && IsResizable())
3212 SetClientBounds(FloatRectangle(0.0f, 0.0f, GetSizeF().width, GetSizeF().height));
3214 if (__pFocusVisualElement)
3216 __pFocusVisualElement->SetBounds(FloatRectangle(0, 0, __bounds.width, __bounds.height));
3218 delegate.OnBoundsChanged();
3220 _Control* pParent = GetParent();
3223 pParent->GetControlDelegate().OnChildBoundsChanged(*this);
3226 ControlList& children = GetChildList();
3227 _Control* pChild = null;
3228 int childrenCount = children.GetCount();
3230 for (int index = 0; index < childrenCount; index++)
3232 r = children.GetAt(index, pChild);
3235 pChild->GetControlDelegate().OnParentBoundsChanged(*this);
3244 // Custom Exception: ex) Location::Map
3246 _Control::AdjustSizeToRange(void)
3249 result r = E_SUCCESS;
3251 SysAssert(IsResizable());
3253 FloatDimension size = GetSizeF();
3254 bool changed = ::AdjustSizeToRange(size, __minSize, __maxSize);
3260 FloatRectangle newBounds(__bounds.x, __bounds.y, size.width, size.height);
3261 r = SetBoundsFinal(newBounds, true, true);
3270 // Custom Exception: ex) Location::Map
3273 _Control::SetBoundsInternal(const FloatRectangle& bounds, bool callBoundsChangeCallbacks)
3275 SysTryReturn(NID_UI,
3276 IsInSizeRange(Dimension(bounds.width, bounds.height)), E_INVALID_ARG,
3278 "[E_INVALID_ARG] The specified size(%f, %f) is out of range from min size(%d, %d) to max size(%d, %d).",
3279 bounds.width, bounds.height, __minSize.width, __minSize.height, __maxSize.width, __maxSize.height);
3281 SetUpdateLayoutState(true);
3283 return SetBoundsFinal(bounds, true, callBoundsChangeCallbacks);
3286 // Custom Exception: ex) Location::Map
3288 // E_UNSUPPORTED_OPERATION
3290 _Control::SetBounds(const Rectangle& bounds, bool callBoundsChangeCallbacks)
3294 if (callBoundsChangeCallbacks)
3296 SysTryReturn(NID_UI,
3297 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3298 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3300 FloatRectangle floatBounds(bounds.x, bounds.y, bounds.width, bounds.height);
3302 return SetBoundsInternal(floatBounds, callBoundsChangeCallbacks);
3305 // Custom Exception: ex) Location::Map
3307 // E_UNSUPPORTED_OPERATION
3309 _Control::SetBounds(const FloatRectangle& bounds, bool callBoundsChangeCallbacks)
3313 if (callBoundsChangeCallbacks)
3315 SysTryReturn(NID_UI,
3316 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3317 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3320 return SetBoundsInternal(bounds, callBoundsChangeCallbacks);
3323 // A custom Exception can occur. ex) Location::Map
3325 // E_UNSUPPORTED_OPERATION
3327 _Control::SetPosition(const Point& position)
3331 SysTryReturn(NID_UI,
3332 IsMovable(), E_UNSUPPORTED_OPERATION,
3333 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable.");
3335 return SetBoundsInternal(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height), true);
3339 _Control::SetPosition(const FloatPoint& position)
3343 SysTryReturn(NID_UI,
3344 IsMovable(), E_UNSUPPORTED_OPERATION,
3345 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable.");
3347 return SetBoundsInternal(FloatRectangle(position.x, position.y, __bounds.width, __bounds.height), true);
3350 // Custom Exception: ex) Location::Map
3352 // E_UNSUPPORTED_OPERATION
3354 _Control::SetSize(const Dimension& size)
3358 SysTryReturn(NID_UI,
3359 IsResizable(), E_UNSUPPORTED_OPERATION,
3360 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3362 return SetBoundsInternal(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height), true);
3366 _Control::SetSize(const FloatDimension& size)
3370 SysTryReturn(NID_UI,
3371 IsResizable(), E_UNSUPPORTED_OPERATION,
3372 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3374 return SetBoundsInternal(FloatRectangle(__bounds.x, __bounds.y, size.width, size.height), true);
3378 _Control::GetMinimumSize(void) const
3382 return _CoordinateSystemUtils::ConvertToInteger(__minSize);
3386 _Control::GetMinimumSizeF(void) const
3394 _Control::GetMaximumSize(void) const
3398 return _CoordinateSystemUtils::ConvertToInteger(__maxSize);
3402 _Control::GetMaximumSizeF(void) const
3409 // Custom Exception: ex) Location::Map
3410 // E_UNSUPPORTED_OPERATION
3413 _Control::SetMinimumSize(const Dimension& newMinSize)
3417 SysTryReturn(NID_UI,
3418 IsResizable(), E_UNSUPPORTED_OPERATION,
3419 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3421 SysTryReturn(NID_UI,
3422 (newMinSize.width >= 0 && newMinSize.height >= 0), E_INVALID_ARG,
3423 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3425 SysTryReturn(NID_UI,
3426 (newMinSize.width <= MAX_LENGTH && newMinSize.height <= MAX_LENGTH), E_INVALID_ARG,
3427 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3429 if (__maxSize.width < newMinSize.width)
3431 __maxSize.width = newMinSize.width;
3433 if (__maxSize.height < newMinSize.height)
3435 __maxSize.height = newMinSize.height;
3438 __minSize = _CoordinateSystemUtils::ConvertToFloat(newMinSize);
3439 return AdjustSizeToRange();
3443 _Control::SetMinimumSize(const FloatDimension& newMinSize)
3447 SysTryReturn(NID_UI,
3448 IsResizable(), E_UNSUPPORTED_OPERATION,
3449 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3451 SysTryReturn(NID_UI,
3452 (newMinSize.width >= 0 && newMinSize.height >= 0), E_INVALID_ARG,
3453 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3455 SysTryReturn(NID_UI,
3456 (newMinSize.width <= MAX_LENGTH && newMinSize.height <= MAX_LENGTH), E_INVALID_ARG,
3457 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3459 if (__maxSize.width < newMinSize.width)
3461 __maxSize.width = newMinSize.width;
3463 if (__maxSize.height < newMinSize.height)
3465 __maxSize.height = newMinSize.height;
3468 __minSize = newMinSize;
3469 return AdjustSizeToRange();
3472 // Custom Exception: ex) Location::Map
3473 // E_UNSUPPORTED_OPERATION
3476 _Control::SetMaximumSize(const Dimension& newMaxSize)
3480 SysTryReturn(NID_UI,
3481 IsResizable(), E_UNSUPPORTED_OPERATION,
3482 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3484 SysTryReturn(NID_UI,
3485 (newMaxSize.width >= 0 && newMaxSize.height >= 0), E_INVALID_ARG,
3486 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3488 SysTryReturn(NID_UI,
3489 (newMaxSize.width <= MAX_LENGTH && newMaxSize.height <= MAX_LENGTH), E_INVALID_ARG,
3490 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3492 if (newMaxSize.width < __minSize.width)
3494 __minSize.width = newMaxSize.width;
3496 if (newMaxSize.height < __minSize.height)
3498 __minSize.height = newMaxSize.height;
3501 __maxSize = _CoordinateSystemUtils::ConvertToFloat(newMaxSize);
3502 return AdjustSizeToRange();
3506 _Control::SetMaximumSize(const FloatDimension& newMaxSize)
3510 SysTryReturn(NID_UI,
3511 IsResizable(), E_UNSUPPORTED_OPERATION,
3512 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not resizable.");
3514 SysTryReturn(NID_UI,
3515 (newMaxSize.width >= 0 && newMaxSize.height >= 0), E_INVALID_ARG,
3516 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is smaller than 0.");
3518 SysTryReturn(NID_UI,
3519 (newMaxSize.width <= MAX_LENGTH && newMaxSize.height <= MAX_LENGTH), E_INVALID_ARG,
3520 E_INVALID_ARG, "[E_INVALID_ARG] The width or height is greater than %d.", MAX_LENGTH);
3522 if (newMaxSize.width < __minSize.width)
3524 __minSize.width = newMaxSize.width;
3526 if (newMaxSize.height < __minSize.height)
3528 __minSize.height = newMaxSize.height;
3531 __maxSize = newMaxSize;
3532 return AdjustSizeToRange();
3537 _Control::ConvertToControlPosition(const Point& screenPosition) const
3539 Point controlPosition;
3540 Rectangle absoluteBounds = GetAbsoluteBounds();
3542 controlPosition.x = screenPosition.x - absoluteBounds.x;
3543 controlPosition.y = screenPosition.y - absoluteBounds.y;
3545 return controlPosition;
3549 _Control::ConvertToControlPosition(const FloatPoint& screenPosition) const
3551 FloatPoint controlPosition;
3552 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
3554 controlPosition.x = screenPosition.x - absoluteBounds.x;
3555 controlPosition.y = screenPosition.y - absoluteBounds.y;
3557 return controlPosition;
3561 _Control::ConvertToScreenPosition(const Point& controlPosition) const
3563 Point screenPosition;
3564 Rectangle absoluteBounds = GetAbsoluteBounds();
3566 screenPosition.x = controlPosition.x + absoluteBounds.x;
3567 screenPosition.y = controlPosition.y + absoluteBounds.y;
3569 return screenPosition;
3573 _Control::ConvertToScreenPosition(const FloatPoint& controlPosition) const
3575 FloatPoint screenPosition;
3576 FloatRectangle absoluteBounds = GetAbsoluteBoundsF();
3578 screenPosition.x = controlPosition.x + absoluteBounds.x;
3579 screenPosition.y = controlPosition.y + absoluteBounds.y;
3581 return screenPosition;
3585 _Control::GetClientBounds(void) const
3587 if (!__isSetClientBounds)
3589 return Rectangle(0, 0, __bounds.width, __bounds.height);
3592 return _CoordinateSystemUtils::ConvertToInteger(__clientBounds);
3596 _Control::GetClientBoundsF(void) const
3598 if (!__isSetClientBounds)
3600 return FloatRectangle(0.0f, 0.0f, __bounds.width, __bounds.height);
3603 return __clientBounds;
3608 _Control::GetClientBounds(const Tizen::Graphics::Dimension& size) const
3610 if (!__isSetClientBounds)
3612 return Rectangle(0, 0, size.width, size.height);
3615 return _CoordinateSystemUtils::ConvertToInteger(__clientBounds);
3620 _Control::GetClientBoundsF(const Tizen::Graphics::FloatDimension& size) const
3622 if (!__isSetClientBounds)
3624 return FloatRectangle(0.0f, 0.0f, size.width, size.height);
3627 return __clientBounds;
3631 _Control::GetAbsoluteBounds(void) const
3634 Rectangle absoluteBounds;
3635 Rectangle clientBounds;
3637 const _Control* pSelf = this;
3638 const _Control* pParent = GetParent();
3642 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent)
3644 clientBounds = pParent->GetClientBounds();
3645 accumPoint += Point(clientBounds.x, clientBounds.y);
3646 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3647 accumPoint.y -= pParent->GetVerticalScrollPosition();
3650 accumPoint += pSelf->GetPosition();
3652 pParent = pParent->GetParent();
3655 _Window* pWindow = GetRootWindow();
3659 Point winPoint = pWindow->GetPosition();
3661 accumPoint.x += winPoint.x;
3662 accumPoint.y += winPoint.y;
3665 absoluteBounds.x = accumPoint.x;
3666 absoluteBounds.y = accumPoint.y;
3667 absoluteBounds.width = __bounds.width;
3668 absoluteBounds.height = __bounds.height;
3670 return absoluteBounds;
3674 _Control::GetAbsoluteBoundsF(void) const
3676 FloatPoint accumPoint;
3677 FloatRectangle absoluteBounds;
3678 FloatRectangle clientBounds;
3680 const _Control* pSelf = this;
3681 const _Control* pParent = GetParent();
3685 if ((pSelf->GetArea() == _CONTROL_AREA_CLIENT) && pParent)
3687 clientBounds = pParent->GetClientBoundsF();
3688 accumPoint += FloatPoint(clientBounds.x, clientBounds.y);
3689 accumPoint.x -= pParent->GetHorizontalScrollPosition();
3690 accumPoint.y -= pParent->GetVerticalScrollPosition();
3693 accumPoint += pSelf->GetPositionF();
3695 pParent = pParent->GetParent();
3698 _Window* pWindow = GetRootWindow();
3702 FloatPoint winPoint = pWindow->GetPositionF();
3704 accumPoint.x += winPoint.x;
3705 accumPoint.y += winPoint.y;
3708 absoluteBounds.x = accumPoint.x;
3709 absoluteBounds.y = accumPoint.y;
3710 absoluteBounds.width = __bounds.width;
3711 absoluteBounds.height = __bounds.height;
3713 return absoluteBounds;
3717 _Control::SetClientBounds(const Rectangle& bounds)
3721 const bool moved = (__clientBounds.x != _CoordinateSystemUtils::ConvertToFloat(bounds).x) || (__clientBounds.y != _CoordinateSystemUtils::ConvertToFloat(bounds).y);
3722 const bool resized = (__clientBounds.width != _CoordinateSystemUtils::ConvertToFloat(bounds).width) || (__clientBounds.height != _CoordinateSystemUtils::ConvertToFloat(bounds).height);
3724 SysTryReturn(NID_UI,
3725 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3726 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3727 __clientBounds = _CoordinateSystemUtils::ConvertToFloat(bounds);
3728 __isSetClientBounds = true;
3730 if (moved || resized)
3732 result r = AdjustAbsoluteBounds();
3733 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3735 SetUpdateLayoutState(true);
3741 _Control::SetClientBounds(const FloatRectangle& bounds)
3745 const bool moved = (__clientBounds.x != bounds.x) || (__clientBounds.y != bounds.y);
3746 const bool resized = (__clientBounds.width != bounds.width) || (__clientBounds.height != bounds.height);
3748 SysTryReturn(NID_UI,
3749 IsMovable() && IsResizable(), E_UNSUPPORTED_OPERATION,
3750 E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Not movable nor resizable.");
3751 __clientBounds = bounds;
3752 __isSetClientBounds = true;
3754 if (moved || resized)
3756 result r = AdjustAbsoluteBounds();
3757 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
3759 SetUpdateLayoutState(true);
3766 _Control::IsCalledSetClientBounds(void)
3768 return __isSetClientBounds;
3772 _Control::UpdateClientBounds(const FloatDimension& size, FloatRectangle& clientBounds)
3774 clientBounds.width = size.width;
3775 clientBounds.height = size.height;
3779 _Control::GetBackgroundColor(void) const
3782 return __backgroundColor;
3786 _Control::SetBackgroundColor(const Color& color)
3789 __backgroundColor = color;
3791 _ControlVisualElement* pCVE = dynamic_cast <_ControlVisualElement*>(GetVisualElement());
3794 pCVE->SetBackgroundColor(
3796 (float)color.GetRed() / 255.0f,
3797 (float)color.GetGreen() / 255.0f,
3798 (float)color.GetBlue() / 255.0f,
3799 (float)color.GetAlpha() / 255.0f
3804 GetControlDelegate().OnBackgroundColorChanged(const_cast<Color&>(color));
3808 _Control::~_Control(void)
3810 __destroying = true;
3812 DetachAllChildren();
3814 _ControlManager::GetInstance()->TakeFocusFromControl(*this);
3824 _Window* pWindow = GetRootWindow();
3828 _Control* pFocusTraversalControl = pWindow->GetFocusTraversalControl(this);
3829 if (pFocusTraversalControl == this)
3831 pWindow->SetFocusTraversalControl(null);
3835 // Dangerous: it clears last result and log in catch block.
3836 // ClearLastResult();
3840 _Control::DisposeControl(void)
3842 __pControlDelegate = null;
3844 delete __pLayoutItemHandler;
3845 __pLayoutItemHandler = null;
3847 delete __pLayoutContainer;
3848 __pLayoutContainer = null;
3856 if (__pVisualElement)
3858 __pVisualElement->Destroy();
3860 __pVisualElement = null;
3862 delete __pVisualElementContentProvider;
3863 __pVisualElementContentProvider = null;
3865 delete __pVisualElementEventListener;
3866 __pVisualElementEventListener = null;
3868 delete __pCoreGestureDetectors;
3869 __pCoreGestureDetectors = null;
3871 delete __pDataBindingContext;
3872 __pDataBindingContext = null;
3874 ClearStartedGestureDetectorList();
3875 delete __pDetectStartedGestureMap;
3876 __pDetectStartedGestureMap = null;
3878 delete __pDelayedTouchInfoList;
3879 __pDelayedTouchInfoList = null;
3881 delete __pAccessibilityContainer;
3882 __pAccessibilityContainer = null;
3884 if (__pFocusVisualElement)
3886 __pFocusVisualElement.release();
3892 _Control::_Control(void)
3897 , __bounds(0.0f, 0.0f, 0.0f, 0.0f)
3898 , __contentAreaBounds(0.0f, 0.0f, 0.0f, 0.0f)
3899 , __clientBounds(0.0f, 0.0f, 0.0f, 0.0f)
3900 , __absoluteBounds(0.0f, 0.0f, 0.0f, 0.0f)
3901 , __invalidatedBounds(0.0f, 0.0f, 0.0f, 0.0f)
3902 , __minSize(FloatDimension(0.0f, 0.0f))
3903 , __maxSize(FloatDimension(MAX_LENGTH, MAX_LENGTH))
3904 , __backgroundColor(Color::GetColor(COLOR_ID_BLACK))
3908 , __nativeObjectFocusable(true)
3909 , __enabledState(true)
3910 , __visibleState(true)
3911 , __initVisibleState(false)
3912 , __clipToParent(true)
3913 , __multiTouchEnabled(false)
3914 , __dragEnabled(false)
3915 , __dropEnabled(false)
3916 , __drawWhenVisible(true)
3917 , __isPostOrderTraversal(false)
3918 , __isCalledCallOnAttachingToMainTree(false)
3919 , __isCalledCallOnPreAttachedToMainTree(false)
3920 , __isCalledCallOnAttachedToMainTree(false)
3921 , __isSetClientBounds(false)
3922 , __isCalledGetCanvasN(false)
3923 , __isFocusMode(false)
3924 , __isNavigatable(true)
3925 , __pVisualElementContentProvider(null)
3926 , __pVisualElement(null)
3927 , __pVisualElementEventListener(null)
3928 , __pLayoutItemHandler(null)
3929 , __pPortraitLayout(null)
3930 , __pLandscapeLayout(null)
3931 , __pLayoutContainer(null)
3932 , __area(_CONTROL_AREA_NONE)
3933 , __layer(_CONTROL_LAYER_NONE)
3934 , __orientation(_CONTROL_ORIENTATION_PORTRAIT)
3935 , __rotation(_CONTROL_ROTATION_0)
3936 , __pTouchEventPreviewer(null)
3937 , __pKeyEventPreviewer(null)
3938 , __pNotificationEventPreviewer(null)
3939 , __pKeyEventListener(null)
3940 , __pFocusEventListener(null)
3941 , __pNotificationEventListener(null)
3942 , __pCoreGestureDetectors(null)
3943 , __pDetectStartedGestureMap(null)
3944 , __pDelayedTouchInfoList(null)
3945 , __touchMoveAllowance(3)
3946 , __pressThresHold(0.0f)
3947 , __inputLockRefCount(0)
3949 , __isSentDelayedEvent(false)
3950 , __isSendingDelayedEvent(false)
3951 , __isChangingEventTarget(false)
3952 , __pDataBindingContext(null)
3953 , __pControlDelegate(null)
3955 , __destroying(false)
3956 , __isEventEnableState(true)
3957 , __isEffectSoundEnabled(true)
3958 , __isControlFontChanged(false)
3961 , __fontFileName(L"")
3962 , __pPreviousFocus(null)
3963 , __pNextFocus(null)
3967 SetControlDelegate(*this);
3968 __pAccessibilityContainer = new (std::nothrow) _AccessibilityContainer(*this);
3969 __pAccessibilityContainer->Activate(true);
3971 __pLayoutItemHandler = new (std::nothrow) LayoutItemHandler(this);
3972 if (!__pLayoutItemHandler)
3977 __pLayoutContainer = CreateLayoutContainerN(__pLayoutItemHandler);
3978 if (!__pLayoutContainer)
3983 __pChildren = ::CreateControlListN();
3989 __pOwnees = ::CreateWindowListN();
3995 __pVisualElement = ::CreateVisualElementN();
3996 if (!__pVisualElement)
4001 __pVisualElement->SetUserData(this);
4002 __pVisualElement->SetClipChildrenEnabled(true);
4003 __pVisualElement->SetRedrawOnResizeEnabled(true);
4005 __pVisualElementContentProvider = new (std::nothrow) ControlVisualElementContentProvider(*this);
4006 SysTryCatch(NID_UI, __pVisualElementContentProvider, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4008 GetVisualElement()->SetContentProvider(__pVisualElementContentProvider);
4010 __pVisualElementEventListener = new (std::nothrow) ControlVisualElementEventListener(*this);
4011 SysTryCatch(NID_UI, __pVisualElementEventListener, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4013 GetVisualElement()->SetVisualElementEventListener(__pVisualElementEventListener);
4015 __pDetectStartedGestureMap = ::CreateGestureMapN();
4016 if (!__pDetectStartedGestureMap)
4021 __pCoreGestureDetectors = new (std::nothrow) LinkedListT<_TouchGestureDetector*>;
4022 if (!__pCoreGestureDetectors)
4027 __pDelayedTouchInfoList = new (std::nothrow) LinkedListT<_TouchInfo*>;
4028 if (!__pDelayedTouchInfoList)
4033 SetEventPreviewer<_UI_EVENT_TOUCH>(this);
4034 SetEventPreviewer<_UI_EVENT_KEY>(this);
4035 SetEventPreviewer<_UI_EVENT_NOTIFICAITON>(this);
4037 SetEventListener<_UI_EVENT_NOTIFICAITON>(this);
4038 SetEventListener<_UI_EVENT_FOCUS>(this);
4040 SetPropagatedTouchEventListener(this);
4041 SetPropagatedKeyEventListener(this);
4042 GET_COLOR_CONFIG(BASIC::background, __backgroundColor);
4044 if (IsFailed(GetLastResult()))
4046 SysLog(NID_UI_CTRL, "[%s] Propagated", GetErrorMessage(GetLastResult()));
4049 __screenDpi = _ControlManager::GetInstance()->GetScreenDpi();
4059 _Control::AcquireHandle(void)
4061 __controlHandle = _ControlManager::GetInstance()->Register(this); // [ToDo] exception?
4065 _Control::ReleaseHandle(void)
4067 _ControlManager::GetInstance()->Release(__controlHandle); // [ToDo] exception?
4071 _Control::SetDrawWhenVisible(bool draw)
4073 __drawWhenVisible = draw;
4077 _Control::IsDrawWhenVisible(void)
4079 return __drawWhenVisible;
4083 _Control::SetTerminatingOrder(bool postOrderTraversal)
4085 __isPostOrderTraversal = postOrderTraversal;
4089 _Control::IsPostOrderTraversal(void)
4091 return __isPostOrderTraversal;
4095 _Control::SetParent(_Control* pParent)
4098 __pParent = pParent;
4102 // Only called by _Window::SetOwner(pOwner)
4104 _Control::AttachOwnee(_Window& window)
4107 result r = E_SUCCESS;
4109 _Control* pOldOwner = window.GetOwner();
4112 pOldOwner->DetachOwnee(window);
4115 r = __pOwnees->Add(&window);
4118 SysLogException(NID_UI, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4119 return E_OUT_OF_MEMORY;
4126 _Control::GetOwneeCount(void) const
4129 return __pOwnees->GetCount();
4134 _Control::GetOwnee(int index) const
4137 result r = E_SUCCESS;
4139 _Window* pOwnee = null;
4140 r = __pOwnees->GetAt(index, pOwnee);
4143 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
4150 // Called by _Window::SetOwner(null)
4152 _Control::DetachOwnee(_Window& ownee)
4155 result r = E_SUCCESS;
4157 _Control* pOwner = ownee.GetOwner();
4163 r = __pOwnees->Remove(&ownee);
4166 SysLogException(NID_UI, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] The specified index is out of range.");
4171 _Control::DetachAllOwnees(void)
4175 int owneeCount = GetOwneeCount();
4176 while (owneeCount--)
4178 _Window* pOwnee = GetOwnee(0);
4184 pOwnee->SetOwner(null);
4188 _Layout::LayoutContainer&
4189 _Control::GetLayoutContainer() const
4191 return *__pLayoutContainer;
4195 _Control::SetMultiTouchEnabled(bool enabled)
4198 __multiTouchEnabled = enabled;
4202 _Control::IsMultiTouchEnabled(void) const
4205 return __multiTouchEnabled;
4209 _Control::SetMovable(bool movable)
4212 __movable = movable;
4216 _Control::SetResizable(bool resizable)
4222 __minSize = __maxSize = GetSizeF();
4225 if (!__resizable && resizable)
4227 __minSize = FloatDimension(0.0f, 0.0f);
4228 __maxSize = FloatDimension(MAX_LENGTH, MAX_LENGTH);
4231 __resizable = resizable;
4235 _Control::GetLayout(void) const
4238 _Layout::Layout* pLayout = __pLayoutContainer->GetLayout();
4240 SysAssert(GetLastResult() == E_SUCCESS);
4245 _Control::SetCurrentLayout(_Layout::Layout& layout)
4248 return __pLayoutContainer->SetCurrentLayout(layout);
4252 _Control::AddLayout(_Layout::Layout& layout)
4255 return __pLayoutContainer->AddLayout(layout);
4259 _Control::SetUpdateLayoutState(bool state)
4261 _Layout::Layout* pLayout = GetLayout();
4264 pLayout->SetUpdateState(state);
4269 _Control::SetEffectSoundEnabled(bool enable)
4271 __isEffectSoundEnabled = enable;
4275 _Control::IsEffectSoundEnabled(void) const
4277 return __isEffectSoundEnabled;
4280 _DataBindingContext*
4281 _Control::GetDataBindingContext(void)
4283 return __pDataBindingContext;
4285 _AccessibilityContainer*
4286 _Control::GetAccessibilityContainer(void)
4288 return __pAccessibilityContainer;
4291 _Control::SetDataBindingContext(_DataBindingContext* pDataBindingContext)
4293 __pDataBindingContext = pDataBindingContext;
4297 _Control::GetDescription(void) const
4303 _Control::SetTouchCapture(bool allowOutOfBounds, bool allowOwnerBounds)
4305 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4306 SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null");
4308 pTouchManager->SetCapturedControl(this, allowOutOfBounds, allowOwnerBounds);
4312 _Control::ReleaseTouchCapture(void)
4314 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4315 SysTryReturnVoidResult(NID_UI, pTouchManager != null, E_SYSTEM, "[E_SYSTEM] TouchManager Instance is null");
4317 pTouchManager->SetCapturedControl(null, false, false);
4321 _Control::GetTopmostChildAt(const Point& point) const
4323 _Control* pTouchedControl = null;
4324 FloatPoint ptf((float) point.x, (float) point.y);
4325 _ControlManager* pControlManager = _ControlManager::GetInstance();
4326 SysTryReturn(NID_UI, pControlManager, null, E_SYSTEM, "[E_SYSTEM] _ControlManager does not exist.");
4328 _Window* pRootWindow = GetRootWindow();
4329 SysTryReturn(NID_UI, pRootWindow, null, E_SYSTEM, "[E_SYSTEM] GetRootWindow() is null, this control is detached from the main trree");
4331 _ControlVisualElement* pRootControlElement = dynamic_cast <_ControlVisualElement*>(pRootWindow->GetVisualElement());
4332 SysTryReturn(NID_UI, pRootControlElement, null, E_SYSTEM, "[E_SYSTEM] pRootControlElement is null.");
4334 _ControlVisualElement* pHitTestElm = pRootControlElement->GetControlChildAtPoint(ptf);
4335 SysTryReturn(NID_UI, pHitTestElm, null, E_SYSTEM, "[E_SYSTEM] pHitTestElm is null.");
4337 pTouchedControl = static_cast <_Control*>(pHitTestElm->GetUserData());
4339 return pTouchedControl;
4343 _Control::SetContentAreaBounds(const Rectangle& rect)
4347 __contentAreaBounds = _CoordinateSystemUtils::ConvertToFloat(rect);
4351 _Control::SetContentAreaBounds(const FloatRectangle& rect)
4355 __contentAreaBounds = rect;
4359 _Control::GetContentAreaBounds(void) const
4361 return _CoordinateSystemUtils::ConvertToInteger(__contentAreaBounds);
4365 _Control::GetContentAreaBoundsF(void) const
4367 return __contentAreaBounds;
4371 _Control::GetCapturedBitmapN(bool includeChildren) const
4373 result r = E_SUCCESS;
4375 Canvas* pCanvas = null;
4376 Bitmap* pBitmap = null;
4378 pBitmap = GetControlDelegate().OnCapturedBitmapRequestedN();
4379 if (pBitmap == null)
4381 FloatRectangle rect;
4383 Rectangle boundsInCanvas = GetBounds();
4384 boundsInCanvas.x = boundsInCanvas.y = 0;
4386 pCanvas = new (std::nothrow) Canvas;
4387 SysTryReturn(NID_UI, pCanvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4389 r = pCanvas->Construct(boundsInCanvas);
4390 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
4392 GetVisualElement()->Draw();
4393 ClearLastResult(); // [ToDo] Temp.
4395 rect.SetBounds(boundsInCanvas.x, boundsInCanvas.y, boundsInCanvas.width, boundsInCanvas.height);
4397 r = GetVisualElement()->Capture(*pCanvas, rect, includeChildren);
4398 SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagated.", GetErrorMessage(r));
4400 pBitmap = new (std::nothrow) Bitmap;
4401 SysTryCatch(NID_UI, pBitmap != null, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4403 r = pBitmap->Construct(*pCanvas, boundsInCanvas);
4406 SysAssert(r == E_OUT_OF_MEMORY);
4407 SysTryCatch(NID_UI, r == E_SUCCESS, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4410 SysLog(NID_UI, "Bitmap (width:%d, height:%d)", pBitmap->GetWidth(), pBitmap->GetHeight());
4414 _BitmapImpl::ConvertToNonpremultiplied(*pBitmap, true);
4426 Tizen::Graphics::Rectangle
4427 _Control::GetInvalidatedBounds(void) const
4429 return _CoordinateSystemUtils::ConvertToInteger(__invalidatedBounds);
4432 Tizen::Graphics::FloatRectangle
4433 _Control::GetInvalidatedBoundsF(void) const
4435 return __invalidatedBounds;
4439 _Control::AddGestureDetector(const _TouchGestureDetector& gestureDetector)
4443 bool exist = __pCoreGestureDetectors->Contains(const_cast<_TouchGestureDetector*>(&gestureDetector));
4444 SysTryReturnResult(NID_UI, exist == false, E_OBJ_ALREADY_EXIST, "[E_OBJ_ALREADY_EXIST]__pCoreGestureDetectors has gesture already");
4446 result r = __pCoreGestureDetectors->Add(const_cast<_TouchGestureDetector*>(&gestureDetector));
4447 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
4449 r = const_cast<_TouchGestureDetector&>(gestureDetector).SetControl(*this);
4450 SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "Control handle is not valid.");
4452 const_cast<_TouchGestureDetector&>(gestureDetector).OnTouchGestureDetectorAdded();
4458 _Control::RemoveGestureDetector(const _TouchGestureDetector& gestureDetector)
4462 result r = __pCoreGestureDetectors->Remove(&(const_cast<_TouchGestureDetector&>(gestureDetector)));
4468 const_cast<_TouchGestureDetector&>(gestureDetector).OnTouchGestureDetectorRemoved();
4473 IListT <_TouchGestureDetector*>*
4474 _Control::GetGestureDetectorList(void) const
4476 return __pCoreGestureDetectors;
4479 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>*
4480 _Control::GetStartedGestureDetectorEnumeratorN(void) const
4482 return __pDetectStartedGestureMap->GetMapEnumeratorN();
4485 IListT <_TouchGestureDetector*>*
4486 _Control::GetStartedGestureDetectorListN(void) const
4488 return __pDetectStartedGestureMap->GetKeysN();
4492 _Control::AddStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state)
4496 result r = E_SUCCESS;
4499 __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist);
4503 r = __pDetectStartedGestureMap->Add(const_cast<_TouchGestureDetector*>(&gestureDetector), state);
4510 _Control::SetStartedGestureDetector(const _TouchGestureDetector& gestureDetector, _TouchGestureDetectorState state)
4514 result r = E_SUCCESS;
4517 __pDetectStartedGestureMap->ContainsKey(const_cast<_TouchGestureDetector*>(&gestureDetector), exist);
4521 r = __pDetectStartedGestureMap->SetValue(const_cast<_TouchGestureDetector*>(&gestureDetector), state);
4528 _Control::ClearStartedGestureDetectorList(void)
4532 result r = E_SUCCESS;
4534 IListT<_TouchGestureDetector*>* pList = __pDetectStartedGestureMap->GetKeysN();
4537 IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pList->GetEnumeratorN();
4540 while(pEnumerator->MoveNext() == E_SUCCESS)
4542 _TouchGestureDetector* pGestureDetector = null;
4543 pEnumerator->GetCurrent(pGestureDetector);
4545 if (pGestureDetector == null)
4550 __pDetectStartedGestureMap->Remove(pGestureDetector);
4557 IEnumeratorT<_TouchInfo*>* pEnumerator = __pDelayedTouchInfoList->GetEnumeratorN();
4560 while(pEnumerator->MoveNext() == E_SUCCESS)
4562 _TouchInfo* pTouchInfo = null;
4563 pEnumerator->GetCurrent(pTouchInfo);
4564 if (pTouchInfo == null)
4572 __pDelayedTouchInfoList->RemoveAll();
4576 __isSentDelayedEvent = false;
4577 __isSendingDelayedEvent = false;
4583 _Control::IsDelayedTouchEventEnabled(void) const
4585 bool existDelayTouchEventGesture = false;
4587 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4590 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4592 _TouchGestureDetector* pGestureDetector = null;
4593 pMapEnumerator->GetKey(pGestureDetector);
4595 if (pGestureDetector == null)
4600 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4601 pMapEnumerator->GetValue(state);
4603 if (pGestureDetector->IsDelayTouchEventEnabled())
4605 existDelayTouchEventGesture = true;
4608 delete pMapEnumerator;
4611 bool delayTouchEvent = false;
4612 if (existDelayTouchEventGesture)
4614 pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4617 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4619 _TouchGestureDetector* pGestureDetector = null;
4620 pMapEnumerator->GetKey(pGestureDetector);
4622 if (pGestureDetector == null)
4627 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4628 pMapEnumerator->GetValue(state);
4630 if (state == _TOUCH_GESTURE_DETECTOR_STATE_STARTED)
4632 delayTouchEvent = true;
4636 delete pMapEnumerator;
4639 return delayTouchEvent;
4648 _Control::IsPossibleToSendDelayedTouchEvent(void) const
4650 bool existDelayTouchEventGesture = false;
4652 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4655 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4657 _TouchGestureDetector* pGestureDetector = null;
4658 pMapEnumerator->GetKey(pGestureDetector);
4660 if (pGestureDetector == null)
4665 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4666 pMapEnumerator->GetValue(state);
4668 if (pGestureDetector->IsDelayTouchEventEnabled())
4670 existDelayTouchEventGesture = true;
4673 delete pMapEnumerator;
4676 bool allFailed = true;
4677 if (existDelayTouchEventGesture)
4679 pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4682 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4684 _TouchGestureDetector* pGestureDetector = null;
4685 pMapEnumerator->GetKey(pGestureDetector);
4687 if (pGestureDetector == null)
4692 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4693 pMapEnumerator->GetValue(state);
4695 if (state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS)
4701 delete pMapEnumerator;
4713 _Control::IsCancelOnGestureSuccess(void) const
4715 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4716 SysAssert(pTouchManager != null);
4718 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pMapEnumerator = __pDetectStartedGestureMap->GetMapEnumeratorN();
4721 while(pMapEnumerator->MoveNext() == E_SUCCESS)
4723 _TouchGestureDetector* pGestureDetector = null;
4724 pMapEnumerator->GetKey(pGestureDetector);
4726 if (pGestureDetector == null)
4731 _TouchGestureDetectorState state = _TOUCH_GESTURE_DETECTOR_STATE_READY;
4732 pMapEnumerator->GetValue(state);
4734 if (pGestureDetector->IsCancelTouchEventOnSuccessEnabled() && state == _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS && !pTouchManager->IsTouchCanceledOnGestureSuccess())
4736 delete pMapEnumerator;
4740 delete pMapEnumerator;
4747 _Control::IsSentDelayedEvent(void) const
4749 return __isSentDelayedEvent;
4753 _Control::SetSentDelayedEvent(bool sent)
4755 __isSentDelayedEvent = sent;
4759 _Control::SetSendingDelayedEvent(bool sending)
4761 __isSendingDelayedEvent = sending;
4765 _Control::IsSendingDelayedEvent(void) const
4767 return __isSendingDelayedEvent;
4771 _Control::AddTouchInfo(const _TouchInfo& touchInfo)
4773 _TouchManager* pTouchManager = _TouchManager::GetInstance();
4774 SysTryReturnVoidResult(NID_UI, pTouchManager, E_SYSTEM, "[E_SYSTEM] _TouchManager does not exist.");
4776 _TouchInfo* pTouchInfo = new (std::nothrow) _TouchInfo;
4777 SysTryReturnVoidResult(NID_UI, pTouchInfo, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
4779 FloatPoint screenPoint = pTouchManager->GetScreenPoint(touchInfo.GetPointId());
4780 pTouchInfo->SetTouchInfo(touchInfo.GetPointId(), touchInfo.GetTouchStatus(), screenPoint, false, 0);
4781 __pDelayedTouchInfoList->Add(pTouchInfo);
4784 IListT<_TouchInfo*>*
4785 _Control::GetTouchInfoList(void)
4787 return __pDelayedTouchInfoList;
4791 _Control::GetVisualElement(void) const
4793 SysAssert(__pVisualElement);
4794 return __pVisualElement;
4798 _Control::PrintDescription(bool printChildren, int level)
4800 int count = PrintDescription(printChildren, 0, level);
4802 SysLog(NID_UI, "%d controls were printed.", count);
4806 _Control::PrintDescription(bool printChildren, int depth, int level)
4808 const int PRINT_CONTROL_VE = 1;
4809 const int PRINT_CONTROL_EVAS = 2;
4810 const int PRINT_CONTROL_VE_EVAS = 3;
4815 format.Format(LOG_LEN_MAX, L"%d", depth);
4817 for (int i = 0; i < depth; i++)
4819 indent.Append(L" ");
4822 indent.Append(format);
4824 String delimiter(L"-------------------------------------------------------------------------------------------");
4825 SysLog(NID_UI, "%ls", delimiter.GetPointer());
4828 String publicDescription = GetControlDelegate().GetDescription();
4829 if (!publicDescription.IsEmpty())
4831 SysLog(NID_UI, "%ls %ls", indent.GetPointer(), publicDescription.GetPointer());
4835 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)",
4836 indent.GetPointer(), this, __controlHandle.ToInt(), GetName().GetPointer(), IsEnabled(), GetEnableState(), IsVisible(), GetVisibleState(),
4837 IsFocusable(), IsClipToParent(), IsMovable(), IsResizable(), GetInputEnableState());
4839 Rectangle bounds = GetBounds();
4840 Dimension min = GetMinimumSize();
4841 Dimension max = GetMaximumSize();
4842 Rectangle clientBounds = GetClientBounds();
4843 Rectangle absoluteBounds = GetAbsoluteBounds();
4845 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)",
4846 indent.GetPointer(), bounds.x, bounds.y, bounds.width, bounds.height,
4847 min.width, min.height, max.width, max.height,
4848 GetVerticalScrollPosition(), GetHorizontalScrollPosition(),
4849 clientBounds.x, clientBounds.y, clientBounds.width, clientBounds.height,
4850 absoluteBounds.x, absoluteBounds.y, absoluteBounds.width, absoluteBounds.height);
4852 SysLog(NID_UI, "%ls bgColor(0x%x) layoutable(%d) orientation(%d) drag(%d) drop(%d) area(%d) layer(%d)",
4853 indent.GetPointer(), __backgroundColor.GetRGB32(), IsLayoutable(), GetOrientation(), IsDragEnabled(), IsDropEnabled(), GetArea(), GetLayer());
4855 Canvas* pCanvas = GetCanvasN();
4858 Rectangle canvasBounds = pCanvas->GetBounds();
4859 Color canvasBackgroundColor = pCanvas->GetBackgroundColor();
4860 Color canvasForegroundColor = pCanvas->GetForegroundColor();
4862 SysLog(NID_UI, "%ls canvas.bounds(%d %d %d %d) canvas.bgColor(0x%x) canvas.fgColor(0x%x)",
4863 indent.GetPointer(), canvasBounds.x, canvasBounds.y, canvasBounds.width, canvasBounds.height, canvasBackgroundColor.GetRGB32(), canvasForegroundColor.GetRGB32());
4868 SysLog(NID_UI, "%ls DataBindingContext(0x%x) ControlDelegate(0x%x) UserData(0x%x) destroying(%d)",
4869 indent.GetPointer(), __pDataBindingContext, __pControlDelegate, __pUserData, __destroying);
4874 for (int i = 0; i < GetOwneeCount(); ++i)
4877 _Window* pOwnee = GetOwnee(i);
4880 ownee.Format(LOG_LEN_MAX, L"0x%x ", pOwnee);
4881 ownees.Append(ownee);
4885 if (!ownees.IsEmpty())
4887 SysLog(NID_UI, "%ls Ownees(%ls)", indent.GetPointer(), ownees.GetPointer());
4890 _VisualElementImpl* pVisualElementImpl = _VisualElementImpl::GetInstance(*__pVisualElement);
4892 SysLog(NID_UI, "%ls _VisualElement(0x%x) _VisualElementImpl(0x%x) VisualElementContentProvider(0x%x) VisualElementEventListener(0x%x)",
4893 indent.GetPointer(), __pVisualElement, pVisualElementImpl, __pVisualElementContentProvider, __pVisualElementEventListener);
4896 SysLog(NID_UI, "%ls LayoutItemHandler(0x%x) PortraitLayout(0x%x) LandscapeLayout(0x%x) LayoutContainer(0x%x)",
4897 indent.GetPointer(), __pLayoutItemHandler, __pPortraitLayout, __pLandscapeLayout, __pLayoutContainer);
4900 String description = GetDescription();
4901 if (!description.IsEmpty())
4903 SysLog(NID_UI, "%ls %ls", indent.GetPointer(), description.GetPointer());
4906 // Print Gesture List
4907 IListT<_TouchGestureDetector*>* pGestureList = GetGestureDetectorList();
4908 SysTryReturn(NID_UI, pGestureList, 0, E_SYSTEM, "[E_SYSTEM] System error occurred.");
4910 IEnumeratorT<_TouchGestureDetector*>* pEnumerator = pGestureList->GetEnumeratorN();
4911 SysTryReturn(NID_UI, pEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4913 while (pEnumerator->MoveNext() == E_SUCCESS)
4915 _TouchGestureDetector* pGestureDetector = null;
4916 pEnumerator->GetCurrent(pGestureDetector);
4917 if (pGestureDetector)
4919 SysLog(NID_UI, "%ls AddedGesture : %ls", indent.GetPointer(), pGestureDetector->GetDescription().GetPointer());
4925 // Print Started Gesture List
4926 IMapEnumeratorT <_TouchGestureDetector*, _TouchGestureDetectorState>* pStartedGestureEnumerator = GetStartedGestureDetectorEnumeratorN();
4927 SysTryReturn(NID_UI, pStartedGestureEnumerator, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
4929 while (pStartedGestureEnumerator->MoveNext() == E_SUCCESS)
4931 _TouchGestureDetector* pStartedGestureDetector = null;
4932 pStartedGestureEnumerator->GetKey(pStartedGestureDetector);
4933 if (pStartedGestureDetector)
4935 SysLog(NID_UI, "%ls StartedGesture : %ls", indent.GetPointer(), pStartedGestureDetector->GetDescription().GetPointer());
4939 delete pStartedGestureEnumerator;
4941 // Print VE and Evas
4944 case PRINT_CONTROL_VE:
4945 _VeDebug::DumpVeTree(pVisualElementImpl, 0);
4948 case PRINT_CONTROL_EVAS:
4949 _VeDebug::DumpEvasTree(pVisualElementImpl, 0);
4952 case PRINT_CONTROL_VE_EVAS:
4953 _VeDebug::DumpVeTree(pVisualElementImpl, 0);
4954 _VeDebug::DumpEvasTree(pVisualElementImpl, 0);
4961 static int totalCount = 0;
4972 int count = GetChildCount();
4973 totalCount += count;
4975 for (int i = count - 1; i >= 0; --i)
4977 _Control* pChild = GetChild(i);
4980 pChild->PrintDescription(printChildren, depth, level);
4988 _ITouchEventPreviewer*
4989 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>) const
4991 return __pTouchEventPreviewer;
4994 _IKeyEventPreviewer*
4995 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_KEY>) const
4997 return __pKeyEventPreviewer;
5000 _INotificationEventPreviewer*
5001 _Control::GetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>) const
5003 return __pNotificationEventPreviewer;
5007 _Control::GetEventListener(_IntToType<_UI_EVENT_KEY>) const
5009 return __pKeyEventListener;
5012 _IFocusEventListener*
5013 _Control::GetEventListener(_IntToType<_UI_EVENT_FOCUS>) const
5015 return __pFocusEventListener;
5018 _INotificationEventListener*
5019 _Control::GetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>) const
5021 return __pNotificationEventListener;
5025 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_TOUCH>, _ITouchEventPreviewer* pPreviewer)
5027 __pTouchEventPreviewer = pPreviewer;
5031 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_KEY>, _IKeyEventPreviewer* pPreviewer)
5033 __pKeyEventPreviewer = pPreviewer;
5037 _Control::SetEventPreviewer(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventPreviewer* pPreviewer)
5039 __pNotificationEventPreviewer = pPreviewer;
5043 _Control::SetEventListener(_IntToType<_UI_EVENT_FOCUS>, _IFocusEventListener* pListener)
5045 __pFocusEventListener = pListener;
5049 _Control::SetEventListener(_IntToType<_UI_EVENT_NOTIFICAITON>, _INotificationEventListener* pListener)
5051 __pNotificationEventListener = pListener;
5055 _Control::IsDragEnabled(void) const
5057 return __dragEnabled;
5061 _Control::IsDropEnabled(void) const
5063 return __dropEnabled;
5067 _Control::SetDragEnabled(bool enabled)
5069 __dragEnabled = enabled;
5073 _Control::SetDropEnabled(bool enabled)
5075 __dropEnabled = enabled;
5079 _Control::SetTouchPressThreshold(float distance)
5081 __touchMoveAllowance = static_cast<int>(distance * __screenDpi);
5082 __pressThresHold = distance;
5086 _Control::GetTouchPressThreshold(void) const
5088 return __pressThresHold;
5092 _Control::GetTouchPressThresholdPixel(void) const
5094 return __touchMoveAllowance;
5098 _Control::SetChangingEventTarget(bool isChangingEventTarget)
5100 __isChangingEventTarget = isChangingEventTarget;
5104 _Control::GetChangingEventTarget(void) const
5106 return __isChangingEventTarget;
5110 _Control::SetEventEnableState(bool enableState)
5112 __isEventEnableState = enableState;
5116 _Control::IsEventEnabled(void) const
5118 return __isEventEnableState;
5122 _Control::SetPreviousFocus(_Control* pPreviousFocus)
5124 __pPreviousFocus = pPreviousFocus;
5128 _Control::SetNextFocus(_Control* pNextFocus)
5130 __pNextFocus = pNextFocus;
5133 _Control::GetPreviousFocus(void) const
5135 return __pPreviousFocus;
5138 _Control::GetNextFocus(void) const
5140 return __pNextFocus;
5144 _Control::OnDrawFocus(void)
5146 unique_ptr<VisualElement, _VisualElementDeleter> pFocusVisualElement (new (std::nothrow) VisualElement, _VisualElementDeleter());
5147 SysTryReturn(NID_UI, pFocusVisualElement, , E_SYSTEM, "[E_SYSTEM] System error");
5149 result r = pFocusVisualElement->Construct();
5150 SysTryReturn(NID_UI, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] System error");
5152 __pFocusVisualElement.reset(pFocusVisualElement.release());
5153 __pFocusVisualElement->SetImplicitAnimationEnabled(false);
5154 __pFocusVisualElement->SetShowState(true);
5156 _VisualElement* pControVisualElement = this->GetVisualElement();
5157 pControVisualElement->AttachChild(*__pFocusVisualElement);
5159 if (__pFocusVisualElement)
5161 Rectangle rectangle = GetBounds();
5162 __pFocusVisualElement->SetBounds(FloatRectangle(0, 0, rectangle.width, rectangle.height));
5163 unique_ptr<Canvas>pCanvas(__pFocusVisualElement->GetCanvasN());
5166 pCanvas->SetBackgroundColor(0x55555555);
5169 Bitmap* pBitmap = null;
5170 result r = GET_BITMAP_CONFIG_N(FOCUSUI::FOCUS, BITMAP_PIXEL_FORMAT_ARGB8888, pBitmap);
5174 if (_BitmapImpl::CheckNinePatchedBitmapStrictly(*pBitmap))
5178 r = pCanvas->DrawNinePatchedBitmap(FloatRectangle(0.0f, 0.0f, rectangle.width, rectangle.height), *pBitmap);
5185 r = pCanvas->DrawBitmap(FloatRectangle(0.0f, 0.0f, rectangle.width, rectangle.height), *pBitmap);
5189 __pFocusVisualElement->SetShowState(true);
5194 _Control::OnChildControlFocusMoved(const _Control& control)
5199 _Control::IsChildControlFocusManage(void) const
5205 _Control::SetFontFromFile(const String& fileName)
5207 result r = E_SUCCESS;
5209 if (__fontFileName.Equals(fileName))
5214 __isControlFontChanged = true;
5215 __fontFileName = fileName;
5218 Font* pFont = GetFallbackFont();
5222 r = GetLastResult();
5223 SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
5229 _Control::GetFontFile(void) const
5231 return __fontFileName;
5234 _Control::DrawFocus(void)
5236 _IControlDelegate& delegate = GetControlDelegate();
5237 delegate.OnDrawFocus();
5241 _Control::MakeFocusList(const _Control* pControl, IListT<_Control*>* pFocusControlList) const
5243 int childCount = pControl->GetChildCount();
5244 for(int i = 0; i < childCount; i++)
5246 _Control* pChildControl = pControl->GetChild(i);
5247 Rectangle rect = pChildControl->GetAbsoluteBounds();
5248 unique_ptr<IEnumeratorT<_Control*> > pEnum (pFocusControlList->GetEnumeratorN());
5250 while (pEnum->MoveNext() == E_SUCCESS)
5252 _Control* pEnumeratorControl = null;
5253 pEnum->GetCurrent(pEnumeratorControl);
5254 if (pEnumeratorControl != null)
5256 Rectangle enumeratorRect = pEnumeratorControl->GetAbsoluteBounds();
5257 if(enumeratorRect.y > rect.y)
5261 else if (enumeratorRect.y == rect.y)
5263 if(enumeratorRect.x > rect.x)
5272 pFocusControlList->InsertAt(pChildControl, index);
5277 _Control::MakeChildContainerFocusList(const _Control* pControl, int startIndex , IListT<_Control*>* pFocusControlList) const
5279 unique_ptr<IListT<_Control*> > pTempList (new (std::nothrow) ArrayListT<_Control*>);
5280 SysTryReturnVoidResult(NID_UI_CTRL, pTempList, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient.");
5281 MakeFocusList(pControl, pTempList.get());
5283 unique_ptr<IEnumeratorT<_Control*> > pTempEnum(pTempList->GetEnumeratorN());
5284 int index = ++startIndex;
5285 while (pTempEnum->MoveNext() == E_SUCCESS)
5287 _Control* pEnumeratorControl = null;
5288 pTempEnum->GetCurrent(pEnumeratorControl);
5289 pFocusControlList->InsertAt(pEnumeratorControl, index);
5294 Tizen::Base::Collection::IListT<_Control*>*
5295 _Control::GetFocusListN(void) const
5297 unique_ptr<IListT<_Control*> > pControlFocusList (new (std::nothrow) ArrayListT<_Control*>);
5298 SysTryReturn(NID_UI_CTRL, pControlFocusList, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
5299 MakeFocusList(this, pControlFocusList.get());
5301 unique_ptr<IEnumeratorT<_Control*> > pEnum(pControlFocusList->GetEnumeratorN());
5302 SysTryReturn(NID_UI_CTRL, pEnum, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
5304 int nextContainerIndex = -1;
5305 while (pEnum->MoveNext() == E_SUCCESS)
5307 _Control* pEnumeratorControl = null;
5308 pEnum->GetCurrent(pEnumeratorControl);
5309 _ContainerImpl* pTempContainerImpl = dynamic_cast<_ContainerImpl*>(static_cast <_ControlImpl* >(pEnumeratorControl->GetUserData()));
5311 if (pTempContainerImpl != null && (nextContainerIndex < i))
5313 if (pEnumeratorControl->IsChildControlFocusManage() == false)
5315 MakeChildContainerFocusList(pEnumeratorControl, i, pControlFocusList.get());
5316 nextContainerIndex = i;
5317 pEnum.reset(pControlFocusList->GetEnumeratorN());
5323 return pControlFocusList.release();