Revert " modify license, permission and remove ^M char"
[framework/osp/uifw.git] / src / ui / FUi_Window.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17
18 /**
19  * @file                FUi_Window.cpp
20  * @brief               This is the implementation file for the _Window class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FUiAnimDisplayContext.h>
25 #include <FUiWindow.h>
26 #include <FBase_Log.h>
27 #include <FBaseColArrayListT.h>
28 #include "FUi_Window.h"
29 #include "FUi_ControlManager.h"
30 #include "FUi_TouchManager.h"
31 #include "FUiAnim_DisplayContextImpl.h"
32 #include "FUiAnim_RootVisualElement.h"
33 #include "FUiAnim_VisualElement.h"
34 #include "FUi_EcoreEvasMgr.h"
35 #include "FUi_EcoreEvas.h"
36 #include "FUiAnim_DisplayManager.h"
37 #include "FUiAnim_EflLayer.h"
38 #include "FUiCtrl_Form.h"
39 #include "FUiCtrl_FormImpl.h"
40 #include "FUiCtrl_FrameImpl.h"
41
42 using namespace Tizen::Base;
43 using namespace Tizen::Base::Collection;
44 using namespace Tizen::Graphics;
45 using namespace Tizen::Ui::Animations;
46 using namespace Tizen::Ui::Controls;
47
48 namespace Tizen { namespace Ui
49 {
50
51 _Window*
52 _Window::CreateWindowN(void)
53 {
54         _Window* pWindow = new (std::nothrow) _Window;
55         SysTryReturn(NID_UI, pWindow, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage.");
56
57         result r = E_SUCCESS;
58
59         if (IsFailed(GetLastResult()))
60         {
61                 goto CATCH;
62         }
63
64         r = pWindow->CreateRootVisualElement();
65         SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
66
67         pWindow->AcquireHandle();
68
69         return pWindow;
70
71 CATCH:
72         delete pWindow;
73         return null;
74 }
75
76 _Window::~_Window(void)
77 {
78         __destroying = true;
79         Close();
80         SetOwner(null);
81
82         if (__pDisplayContext)
83         {
84                 _DisplayContextImpl::DestroyPublicInstance(*__pDisplayContext);
85                 __pDisplayContext = null;
86         }
87
88         if(__pLayer)
89         {
90                 //_EflLayer* pLayer = static_cast<_EflLayer*>(__pLayer);
91                 //Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pLayer->GetEcoreEvas());
92                 //SysLog(NID_UI, "[Multi_Window] destroy x window(0x%x)", win);
93
94                 if(__pRootVisualElement)
95                 {
96                         __pRootVisualElement->DetachChild(*GetVisualElement());
97                 }
98                 delete __pLayer;
99                 __pLayer = NULL;
100         }
101
102         delete __pDimmingLayer;
103         __pDimmingLayer = null;
104
105         __pRootVisualElement =NULL;
106 }
107
108 _IWindowDelegate&
109 _Window::GetWindowDelegate(void) const
110 {
111         if (__destroying)
112         {
113                 return const_cast<_Window&>(*this);
114         }
115
116         SysAssert(__pWindowDelegate);
117         return *__pWindowDelegate;
118 }
119
120 String
121 _Window::GetDescription(void) const
122 {
123         String description = _Control::GetDescription();
124         String descriptionTemp(L"");
125
126         descriptionTemp.Format(LOG_LEN_MAX, L"_Window: xid(0x%x) owner(0x%x) delegate(0x%x) activated(%d) destroying(%d) displayContext(0x%x)",
127                 GetNativeHandle(), __pOwner, __pWindowDelegate, __activated, __destroying, __pDisplayContext);
128
129         description.Append(descriptionTemp);
130
131         return description;
132 }
133
134 void
135 _Window::SetRootVisualElement(const Tizen::Ui::Animations::_RootVisualElement& rootVisualElement)
136 {
137         _RootVisualElement* pRootVE = const_cast<_RootVisualElement*>(&rootVisualElement);
138
139         __pRootVisualElement = pRootVE;
140 }
141
142 void
143 _Window::SetLayer(const Tizen::Ui::Animations::_NativeLayer& layer)
144 {
145         _NativeLayer* pLayer = const_cast<_NativeLayer*>(&layer);
146
147         __pLayer = pLayer;
148 }
149
150 bool
151 _Window::IsActivatedOnOpen(void) const
152 {
153         return true;
154 }
155
156 bool
157 _Window::IsActivated(void) const
158 {
159         return __activated;
160 }
161
162 void
163 _Window::SetWindowDelegate(_IWindowDelegate& delegate)
164 {
165         ClearLastResult();
166         __pWindowDelegate = &delegate;
167 }
168
169 void
170 _Window::ResetWindowDelegate(void)
171 {
172         ClearLastResult();
173         __pWindowDelegate = this;
174 }
175
176 bool
177 _Window::IsAttached(void) const
178 {
179         return _ControlManager::GetInstance()->IsWindowAttached(*this);
180 }
181
182 result
183 _Window::Open(bool drawAndShow)
184 {
185         bool visibleState = GetVisibleState();
186         if (!__isOpened && visibleState)
187         {
188                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
189                 SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
190                 pEcoreEvas->SetWindowVisibleState(*GetRootWindow(), visibleState);
191                 __isOpened = true;
192                 __isInitialized = true;
193                 return _ControlManager::GetInstance()->OpenWindow(*this, drawAndShow);
194         }
195
196         return E_SUCCESS;
197 }
198
199 void
200 _Window::Close(void)
201 {
202         if (__isOpened)
203         {
204                 bool visibleState = GetVisibleState();
205                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
206                 SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
207                 pEcoreEvas->SetWindowVisibleState(*GetRootWindow(), visibleState);
208
209                 _ControlManager::GetInstance()->CloseWindow(*this);
210                 __isOpened = false;
211         }
212 }
213
214 _Control*
215 _Window::GetOwner(void) const
216 {
217         ClearLastResult();
218         return __pOwner;
219 }
220
221 void
222 _Window::SetOwner(_Control* pOwner)
223 {
224         ClearLastResult();
225
226         if (pOwner)
227         {
228                 _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
229                 if (pEcoreEvas)
230                 {
231                         if (__transient == true)
232                         {
233                                 pEcoreEvas->SetOwner(*this, *pOwner);
234                         }
235
236                         __transient = true;
237                 }
238         }
239
240         if (pOwner == __pOwner)
241         {
242                 return;
243         }
244
245         if (__pOwner)
246         {
247                 __pOwner->DetachOwnee(*this);
248         }
249
250         if (pOwner)
251         {
252                 pOwner->AttachOwnee(*this);
253         }
254
255         _Control* pOldOwner = __pOwner;
256         __pOwner = pOwner;
257         GetWindowDelegate().OnOwnerChanged(pOldOwner);
258 }
259
260 result
261 _Window::CreateRootVisualElement(_WindowType windowType)
262 {
263         __type = windowType;
264
265         result r = CreateLayer();
266         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
267
268         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
269         SysAssert(pEcoreEvas);
270 #if !defined(WINDOW_BASE_ROTATE)
271         pEcoreEvas->SetWindowOrientationEnabled(*this, false);
272 #else
273         __rotation = pEcoreEvas->GetWindowRotation(*this);
274         pEcoreEvas->RegisterWindowStateCallback(*this);
275 #endif
276
277         // Get visual element.
278         _VisualElement* pVisualElement = GetVisualElement();
279         SysAssert(pVisualElement);
280
281         pVisualElement->SetName(L"Window");
282         pVisualElement->SetClipChildrenEnabled(false);
283         pVisualElement->SetRenderOperation(_VisualElement::RENDER_OPERATION_COPY);
284
285         // Attach visual element to root visual element.
286         __pRootVisualElement->AttachChild(*GetVisualElement());
287
288 #if defined(WINDOW_BASE_ROTATE)
289         if (__type == _WINDOW_TYPE_MAIN)
290         {
291                 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x, BASIC] Create.", GetNativeHandle());
292         }
293         else
294         {
295                 pEcoreEvas->SetWindowType(*this, _WINDOW_TYPE_SUB);
296                 SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x, UTILITY] Create.", GetNativeHandle());
297         }
298 #endif
299
300         return E_SUCCESS;
301 }
302
303 result
304 _Window::CreateLayer(void)
305 {
306         _DisplayManager* pDisplayManager = _DisplayManager::GetInstance();
307         SysAssert(pDisplayManager);
308
309         if (__type == _WINDOW_TYPE_MAIN)
310         {
311                 __pLayer = _NativeLayer::CreateInstanceN();
312         }
313         else
314         {
315                 __pLayer = _NativeLayer::CreateInstanceN(false);
316         }
317
318         SysAssert(__pLayer);
319         __pRootVisualElement = __pLayer->GetRootVisualElement();
320
321         _EflLayer* pLayer = static_cast<_EflLayer*>(__pLayer);
322         SysAssert(pLayer);
323
324         int rootWindowW = 0;
325         int rootWindowH = 0;
326         ecore_x_window_size_get(ecore_x_window_root_get((Ecore_X_Window)ecore_evas_window_get(pLayer->GetEcoreEvas())), &rootWindowW, &rootWindowH);
327
328         pLayer->SetBounds(FloatRectangle(0.0f, 0.0f, (float)rootWindowW, (float)rootWindowH));
329         pLayer->SetOpacity(0);
330
331         __pRootVisualElement->SetName(L"Root");
332
333         return E_SUCCESS;
334 }
335
336 bool
337 _Window::IsFocusableDescendant(const _Control* pFocus) const
338 {
339         return true;
340 }
341
342 void
343 _Window::SetActivationEnabled(bool enable)
344 {
345         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
346         SysTryReturnVoidResult(NID_UI, pEcoreEvas, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
347
348         pEcoreEvas->SetWindowActivationEnabled(*GetRootWindow(), enable);
349
350         SetLastResult(E_SUCCESS);
351 }
352
353 bool
354 _Window::IsActivationEnabled(void)
355 {
356         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
357         SysTryReturn(NID_UI, pEcoreEvas, true, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
358
359         bool enable = pEcoreEvas->IsWindowActivationEnabled(*GetRootWindow());
360
361         SetLastResult(E_SUCCESS);
362
363         return enable;
364 }
365
366 #if !defined(WINDOW_BASE_ROTATE)
367 void
368 _Window::SetOrientationEnabled(bool enable)
369 {
370         __orientationEnabled = enable;
371 }
372
373 bool
374 _Window::IsOrientationEnabled(void)
375 {
376         return __orientationEnabled;
377 }
378 #endif
379
380 _RootVisualElement*
381 _Window::GetRootVisualElement(void) const
382 {
383         return __pRootVisualElement;
384 }
385
386 NativeWindowHandle
387 _Window::GetNativeHandle(void) const
388 {
389         _RootVisualElement* pRootVE = GetRootVisualElement();
390         SysAssert(pRootVE);
391
392         _EflLayer* pLayer = static_cast<_EflLayer*>(pRootVE->GetNativeLayer());
393         SysAssert(pLayer);
394
395         Ecore_Evas* pEcoreEvas = pLayer->GetEcoreEvas();
396         Ecore_X_Window win = (Ecore_X_Window) ecore_evas_window_get(pEcoreEvas);
397
398         return win;
399 }
400
401 void
402 _Window::OnActivated(void)
403 {
404         bool isFrameActivated = _ControlManager::GetInstance()->IsFrameActivated();
405         SysLog(NID_UI, "frameActivated(%d)", isFrameActivated);
406
407         _Control* focusedControl = GetFocusedControl();
408
409         if (focusedControl)
410         {
411                 focusedControl->SetFocused();
412         }
413
414         if (!isFrameActivated)
415         {
416                 return;
417         }
418
419         _Control* pFocus = GetFocused();
420         if (pFocus)
421         {
422                 pFocus->SetFocused();
423         }
424         else
425         {
426                 SetFocused();
427         }
428
429         _TouchManager* pTouchMgr = _TouchManager::GetInstance();
430         if (pTouchMgr)
431         {
432                 pTouchMgr->SetTouchCanceled(null);
433         }
434 }
435
436 void
437 _Window::OnNativeWindowActivated(void)
438 {
439
440 }
441
442 bool
443 _Window::OnNotifiedN(const _Control& source, IList* pArgs)
444 {
445         SysTryReturn(NID_UI_CTRL, pArgs, false, E_SYSTEM, "[E_SYSTEM] pArgs is null.")
446
447         String* pType = dynamic_cast <String*>(pArgs->GetAt(0));
448         SysTryReturn(NID_UI_CTRL, pType, false, E_SYSTEM, "[E_SYSTEM] pType is null.")
449
450         if (*pType == L"VisibilityEvent")
451         {
452                 int obscured = 0;
453
454                 Integer* pObscured = dynamic_cast<Integer*>(pArgs->GetAt(1));
455                 if (pObscured == null)
456                 {
457                         pArgs->RemoveAll(true);
458                         delete pArgs;
459
460                         return true;
461                 }
462
463                 obscured = pObscured->ToInt();
464                 if (obscured == 0)
465                 {
466                         GetWindowDelegate().OnNativeWindowActivated();
467                 }
468
469                 pArgs->RemoveAll(true);
470                 delete pArgs;
471
472                 return true;
473         }
474
475         return false;
476 }
477
478 void
479 _Window::OnDeactivated(void)
480 {
481         bool isFrameActivated = _ControlManager::GetInstance()->IsFrameActivated();
482         SysLog(NID_UI, "frameActivated(%d)", isFrameActivated);
483 }
484
485 void
486 _Window::OnOwnerChanged(_Control* pOldOwner)
487 {
488
489 }
490
491 result
492 _Window::OnBoundsChanging(const FloatRectangle& bounds)
493 {
494         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
495         SysTryReturn(NID_UI, pEcoreEvas, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred.");
496
497         pEcoreEvas->SetWindowBounds(*GetRootWindow(), bounds);
498         result r = GetLastResult();
499         SysTryReturn(NID_UI, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r));
500
501         return r;
502 }
503
504 void
505 _Window::OnVisibleStateChanged(void)
506 {
507         ClearLastResult();
508
509         bool visibleState = GetVisibleState();
510         if (visibleState == false)
511         {
512                 Close();
513         }
514
515         result r = GetLastResult();
516         SysTryReturnVoidResult(NID_UI, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
517
518         SetLastResult(E_SUCCESS);
519 }
520
521 result
522 _Window::OnAttachingToMainTree(const _Control* pParent)
523 {
524         _EflLayer* pLayer = static_cast<_EflLayer*>(__pRootVisualElement->GetNativeLayer());
525         SysAssert(pLayer);
526         SetVisibleState(true);
527         pLayer->SetShowState(true);
528
529         return E_SUCCESS;
530 }
531
532 result
533 _Window::OnDetachingFromMainTree(void)
534 {
535         _EflLayer* pLayer = static_cast<_EflLayer*>(__pRootVisualElement->GetNativeLayer());
536         SysAssert(pLayer);
537         pLayer->SetShowState(false);
538
539         return E_SUCCESS;
540 }
541
542 #if defined(WINDOW_BASE_ROTATE)
543 void
544 _Window::OnWindowStateChanged(void)
545 {
546         // <0>
547         // Update rotation
548         // <1>
549         // Find current form
550         // Call UpdateOrientation
551         // <2>
552         // Find current frame
553         // Call UpdateOrientation
554         // <3>
555         // Find window
556         // Change layout
557         // Rotate window
558
559         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
560         if (!pEcoreEvas)
561         {
562                 return;
563         }
564
565         int rotation = pEcoreEvas->GetWindowRotation(*this);
566
567         Rectangle winBounds = GetBounds();
568         SysLog(NID_UI, "[Window Manager Rotation][Window : 0x%x, %d, %d, %d, %d] OnWindowStateChanged : prev rot = %d, cur rot = %d", GetNativeHandle(), winBounds.x, winBounds.y, winBounds.width, winBounds.height, __rotation, rotation);
569
570         if (rotation == __rotation)
571         {
572                 return;
573         }
574
575         __rotation = rotation;
576
577         // <1>
578         int childCount = GetChildCount();
579         for (int i = childCount; i > 0; i--)
580         {
581                 _Control* pChild = GetChild(i - 1);
582                 
583                 _Form* pForm = dynamic_cast<_Form*>(pChild);
584                 if (pForm)
585                 {
586                         if (pForm->IsVisible())
587                         {
588                                 // Current Form
589                                 _FormImpl* pFormImpl = static_cast<_FormImpl*>(pForm->GetUserData());
590                                 if (pFormImpl)
591                                 {
592                                         pFormImpl->UpdateOrientation();
593                                 }
594
595                                 return;
596                         }
597                 }
598         }
599
600         // <2>
601         if (IsOrientationRoot())
602         {
603                 _FrameImpl* pFrameImpl = static_cast<_FrameImpl*>(GetUserData());
604                 if (pFrameImpl)
605                 {
606                         pFrameImpl->UpdateOrientation();
607                 }
608
609                 return;
610         }
611
612         // <3>
613         SysLog(NID_UI, "[Window Manager Rotation] ---------- Update Ownee Window : START ----------");
614
615         _ControlOrientation controlOrientation = (rotation == 0 || rotation == 180) ? _CONTROL_ORIENTATION_PORTRAIT : _CONTROL_ORIENTATION_LANDSCAPE;
616         ChangeLayout(controlOrientation);
617
618         pEcoreEvas->RotateWindow(*this, __rotation);
619
620         Invalidate(true);
621
622         SysLog(NID_UI, "[Window Manager Rotation] ---------- Update Ownee Window : END ----------");
623 }
624
625 void
626 _Window::SetPreferredRotation(bool enable)
627 {
628         __preferredRotation = enable;
629 }
630
631 bool
632 _Window::GetPreferredRotation(void) const
633 {
634         return __preferredRotation;
635 }
636
637 #if defined(WINDOW_OWNEE_PREFERRED)
638 bool
639 _Window::IsRotationSynchronized(void) const
640 {
641         return false;
642 }
643 #endif
644 #endif
645
646 bool
647 _Window::IsLayoutChangable(void) const
648 {
649         return false;
650 }
651
652 #if defined(WINDOW_BASE_ROTATE)
653 void
654 _Window::SetRotation(int rotation)
655 {
656         __rotation = rotation;
657 }
658 #endif
659
660 void
661 _Window::OnChangeLayout(_ControlOrientation orientation)
662 {
663         _DimmingLayer *pLayer = GetDimmingLayer();
664         if (pLayer)
665         {
666                 result r = GetDimmingLayer()->Rearrange();
667                 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
668         }
669
670         // if window, change its size specially for full-screen(Form, Frame, etc.).
671         _Control::OnChangeLayout(orientation); // if called, layout will be changed.
672 }
673
674 WindowState
675 _Window::GetWindowState(void) const
676 {
677         ClearLastResult();
678         return __windowState;
679 }
680
681 void
682 _Window::SetWindowState(WindowState windowState)
683 {
684         __windowState = windowState;
685 }
686
687 DisplayContext*
688 _Window::GetDisplayContext(void) const
689 {
690         if (!__pDisplayContext)
691         {
692                 SysTryReturn(NID_UI, __pLayer, null, E_SYSTEM, "[E_SYSTEM] Cannot gain the DisplayContext. This window is not completed.");
693
694                 __pDisplayContext = _DisplayContextImpl::CreatePublicInstance(*__pLayer);
695         }
696
697         result r = GetLastResult();
698         SysTryReturn(NID_UI, __pDisplayContext, null, r, "[%s] Propagating.", GetErrorMessage(r));
699
700         return __pDisplayContext;
701 }
702
703 result
704 _Window::SetZOrderGroup(int windowZOrderGroup)
705 {
706         _EcoreEvas* pEcoreEvas = GetEcoreEvasMgr()->GetEcoreEvas();
707
708         if (windowZOrderGroup == WINDOW_Z_ORDER_GROUP_HIGHEST)
709         {
710                 pEcoreEvas->SetWindowLevel(*this, _WINDOW_LEVEL_NOTIFICATION_HIGH);
711         }
712         else if (windowZOrderGroup == WINDOW_Z_ORDER_GROUP_HIGH)
713         {
714                 pEcoreEvas->SetWindowLevel(*this, _WINDOW_LEVEL_NOTIFICATION_MIDDLE);
715         }
716         else if (windowZOrderGroup == WINDOW_Z_ORDER_GROUP_NORMAL)
717         {
718                 pEcoreEvas->SetWindowLevel(*this, _WINDOW_LEVEL_NORMAL);
719         }
720
721         __transient = false;
722
723         bool visible = pEcoreEvas->IsWindowVisible(*this);
724         bool activationEnabled = pEcoreEvas->IsWindowActivationEnabled(*this);
725
726         if ((visible == true) && (activationEnabled == true))
727         {
728                 pEcoreEvas->ActivateWindow(*this);
729         }
730
731         return E_SUCCESS;
732 }
733
734 _Window::_Window()
735         : __type(_WINDOW_TYPE_MAIN)
736         , __windowState(WINDOW_STATE_INITIALIZED)
737         , __pOwner(null)
738         , __pWindowDelegate(null)
739         , __activated(false)
740         , __destroying(false)
741         , __pRootVisualElement(null)
742         , __pLayer(null)
743         , __pDimmingLayer(null)
744         , __pDisplayContext(null)
745         , __systemWindow(false)
746         , __isOpened(false)
747         , __isInitialized(false)
748         , __pFocusedControl(null)
749         , __transient(true)
750         , __dimmingEnabled(false)
751 #if !defined(WINDOW_BASE_ROTATE)
752         , __orientationEnabled(false)
753 #else
754 #if !defined(WINDOW_OWNEE_PREFERRED)
755         , __rotation(0)
756 #else
757         , __rotation(-1)
758 #endif
759         , __preferredRotation(false)
760 #endif
761 {
762         SetControlDelegate(*this);
763         SetWindowDelegate(*this);
764         SetClipToParent(false); // [ToDo] exception check.
765 }
766
767 void
768 _Window::Activate(void)
769 {
770         if (__activated)
771         {
772                 return;
773         }
774
775         __activated = true;
776         GetWindowDelegate().OnActivated();
777 }
778
779 void
780 _Window::Deactivate(void)
781 {
782         __activated = false;
783
784         if (__destroying == false)
785         {
786                 GetWindowDelegate().OnDeactivated();
787         }
788 }
789
790 void
791 _Window::SetSystemWindow(bool systemWindow)
792 {
793         __systemWindow = systemWindow;
794 }
795
796 bool
797 _Window::IsSystemWindow(void) const
798 {
799         return __systemWindow;
800 }
801
802 void
803 _Window::SetFocusedControl(const _Control* pControl)
804 {
805         __pFocusedControl = const_cast<_Control*>(pControl);
806 }
807
808 _Control*
809 _Window::GetFocusedControl(void) const
810 {
811         return __pFocusedControl;
812 }
813
814 IListT<_Control*>*
815 _Window::GetFocusList(void) const
816 {
817         if(!__pFocusControlList)
818         {
819                 __pFocusControlList.reset(GetFocusListN());
820                 __pFocusControlList->InsertAt(const_cast<_Window*>(this), 0);
821         }
822         return __pFocusControlList.get();
823 }
824
825 void 
826 _Window::ResetFocusList(void)
827 {
828         if(__pFocusControlList)
829         {
830                 __pFocusControlList.reset();
831         }
832 }
833
834 result
835 _Window::SetDimmingEnabled(bool enabled)
836 {
837         __dimmingEnabled = enabled;
838
839         return E_SUCCESS;
840 }
841
842 bool
843 _Window::IsDimmingEnabled(void) const
844 {
845         return __dimmingEnabled;        
846 }
847
848 void 
849 _Window::SetDimmingLayer(_DimmingLayer* pLayer)
850 {
851         __pDimmingLayer = pLayer;
852 }
853
854 _DimmingLayer* 
855 _Window::GetDimmingLayer(void)
856 {
857         return __pDimmingLayer;
858 }
859
860 }} // Tizen::Ui