Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUi_ControlManager.h
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  * @file        FUi_ControlManager.h
19  * @brief       This is the header file for the _ControlManager class.
20  *
21  * This header file contains the declarations of the %_ControlManager class.
22  */
23
24 #ifndef _FUI_INTERNAL_CONTROL_MANAGER_H_
25 #define _FUI_INTERNAL_CONTROL_MANAGER_H_
26
27 #include <FBaseColIListT.h>
28 #include <FBaseColHashMapT.h>
29 #include <FGrp_CoordinateSystem.h>
30 #include <FSysISettingEventListener.h>
31 #include "FUi_Types.h"
32
33 #if defined(MULTI_WINDOW)
34 namespace Tizen { namespace Base { namespace Collection
35 {
36 template<class T> class LinkedListT;
37 }}} // Tizen::Base::Collection
38 #endif
39
40 namespace Tizen { namespace Ui
41 {
42
43 class _Window;
44 class _IWindow;
45 class _IUiEventListener;
46 class _TouchGestureDetector;
47
48 class _OSP_EXPORT_ _ControlManager
49         :       public Tizen::System::ISettingEventListener
50 {
51 public:
52 // Initialize, Access, Release
53         static void Initialize(void);
54         static void Release(void);
55         static _ControlManager* GetInstance(void);
56         static void InitInstance(void);
57
58 // Control Handle Management
59         _ControlHandle Register(_Control* pObject);
60         _Control* Release(const _ControlHandle& handle);
61         _Control* GetObject(const _ControlHandle& handle);
62         const _Control* GetObject(const _ControlHandle& handle) const;
63         int GetUsedHandleCount(void) const;
64
65 // Operations
66         _Window* GetWindow(int index) const;
67         int GetWindowCount(void) const;
68         _Window* GetTopWindow(void) const;
69 #if defined(MULTI_WINDOW)
70         _Window* GetTopVisibleWindow(void) const;
71         _Window* GetTopVisibleWindowAt(const Tizen::Graphics::Point& point) const;
72 #endif
73         bool IsWindowOnTop(const _Window& window) const;
74         bool IsWindowAttached(const _Window& window) const;
75         result OpenWindow(_Window& window, bool invalidate);
76         result CloseWindow(_Window& window);
77
78 // Orientation
79         _ControlOrientation GetOrientation(void) const;
80         void SetOrientation(_ControlOrientation orientation);
81
82 // Screen Rotation
83         _ControlRotation GetScreenRotation(void) const;
84
85 // Informations
86         Tizen::Graphics::Dimension GetScreenSize(void) const;
87
88 // Font
89         result SetDefaultFont(const Tizen::Base::String& appFontName);
90         Tizen::Base::String GetDefaultFont(void);
91         bool IsDefaultFontChanged(void);
92         void SetDefaultFontChangeState(bool isDefaultFontChanged);
93
94 // Coordinate system info
95         bool IsCoordinateSystemLogical(void) const;
96         int GetCoordinateSystem(void) const;
97         Tizen::Graphics::_BaseScreenSize GetLogicalBaseScreenSize(void) const;
98
99 // Focus
100         _Control* GetFocusedControl(void) const;
101         void SetFocusedControl(const _Control& control);
102         bool TakeFocusFromControl(const _Control& control);
103
104 // Queries
105         _Control* GetTopmostTouchedControl(const Tizen::Graphics::Point& point);
106         _Window* GetCurrentFrame(void) const;
107         bool IsFrameActivated(void) const;
108
109 #if !defined(MULTI_WINDOW)
110 // Root Control
111         const _Control& GetRoot(void) const;
112         _Control& GetRoot(void);
113 #endif
114
115 // Global Gesture
116         result AddGestureDetector(const _TouchGestureDetector& gesture);
117         result RemoveGestureDetector(const _TouchGestureDetector& gesture);
118         Tizen::Base::Collection::IListT<_TouchGestureDetector*>* GetGestureDetectorList(void) const;
119         int GetGestureMaxTimeDuration(void) const;
120
121 // Do not use. System only.
122         void SetOrientationStatus(_ControlRotation orientationStatus);
123         void RotateScreen(_ControlRotation screenRotation);
124         void RotateScreen(const _Control& control, _ControlRotation screenRotation);
125         void OnScreenRotated(int rotation);
126         void OnWindowRotated(int rotation);
127 #if defined(MULTI_WINDOW)
128         void SetTouchedWindow(unsigned int window);
129         _Window* GetTouchedWindow(void) const;
130 #endif
131         result MoveWindowToTop(const _Window& window);
132         result MoveWindowToBottom(const _Window& window);
133
134 private:
135         ~_ControlManager(void);
136         _ControlManager(void);
137         _ControlManager(const _ControlManager&);
138         _ControlManager& operator =(const _ControlManager&);
139
140 // Coordinate system info
141          result GetAppCoordinateSystem(bool& isCoordinateSystemLogical, int& logicalCoordinateSystemInt, Tizen::Graphics::_BaseScreenSize& logicalBaseScreenSize);
142
143         result AttachWindow(_Window& window);
144         result InsertWindowToBottom(_Window& window);
145         result InsertWindowAfter(const _Window& targetWindow, _Window& window);
146         result InsertWindowBefore(const _Window& targetWindow, _Window& window);
147         result DetachWindow(_Window& window);
148         void DetachAllWindows(void);
149
150         result MoveWindowAfter(const _Window& targetWindow, const _Window& window);
151         result MoveWindowBefore(const _Window& targetWindow, const _Window& window);
152
153         result ActivateWindow(_Window& window);
154
155         result CallOnAttachingToMainTree(_Control& control);
156         result CallOnAttachedToMainTree(_Control& control);
157         result CallOnDetachingFromMainTree(_Control& control);
158
159         virtual void OnSettingChanged(Tizen::Base::String& key);
160
161 private:
162         Tizen::Base::_ObjectManagerT <_Control> __objectManager;
163
164 #if !defined(MULTI_WINDOW)
165         _Control* __pRoot;
166 #else
167         Tizen::Base::Collection::LinkedListT<_Window*>* __pWindowList;
168 #endif
169         bool __isCoordinateSystemLogical;
170         int __logicalCoordinateSystem;
171         Tizen::Graphics::_BaseScreenSize __logicalBaseScreenSize;
172         Tizen::Base::Collection::LinkedListT<_Window*>* __pSystemWindowList;
173         _Control* __pFocusedControl;
174         _ControlRotation __screenRotation;
175         _ControlRotation __orientationStatus;
176         _ControlOrientation __orientation;
177 #if !defined(MULTI_WINDOW)
178         _IWindow* __pWindowPi;
179 #endif
180         _Window* __pCurrentFrame;
181         Tizen::Base::Collection::IListT<_TouchGestureDetector*>* __pGestureList;
182         int __gestureMaxDuration;
183 #if defined(MULTI_WINDOW)
184         unsigned int __touchedWindow; // [SLP]
185 #endif
186         bool __isDefaultFontChanged;
187         Tizen::Base::String __defaultFontName;
188         static _ControlManager* __pInstance;
189 }; // _ControlManager
190
191 }} // Tizen::Ui
192
193 #endif // _FUI_INTERNAL_CONTROL_MANAGER_H_