0df8dae84e5948337e5351152c34cfbb24cea37d
[platform/core/uifw/dali-adaptor.git] / adaptors / public-api / adaptor-framework / window.h
1 #ifndef __DALI_WINDOW_H__
2 #define __DALI_WINDOW_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23 #include <dali/public-api/math/rect.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/object/base-handle.h>
26 #include <dali/public-api/object/any.h>
27 #include <dali/public-api/signals/dali-signal.h>
28
29 namespace Dali
30 {
31 /**
32  * @addtogroup dali_adaptor_framework
33  * @{
34  */
35
36 typedef Dali::Rect<int> PositionSize;
37
38 namespace Internal DALI_INTERNAL
39 {
40 namespace Adaptor
41 {
42 class Window;
43 }
44 }
45
46 class DragAndDropDetector;
47 class Orientation;
48
49 /**
50  * @brief The window class is used internally for drawing.
51  *
52  * A Window has an orientation and indicator properties.
53  * You can get a valid Window handle by calling Dali::Application::GetWindow().
54  * @SINCE_1_0.0
55  */
56 class DALI_IMPORT_API Window : public BaseHandle
57 {
58 public:
59   typedef Signal< void (bool) > IndicatorSignalType;
60
61 public:
62
63   // Enumerations
64
65   /**
66    * @brief Orientation of the window is the way in which a rectangular page is oriented for normal viewing.
67    * @SINCE_1_0.0
68    */
69   enum WindowOrientation
70   {
71     PORTRAIT = 0,  ///< Portrait orientation. The height of the display area is greater than the width. @SINCE_1_0.0
72     LANDSCAPE = 90,  ///< Landscape orientation. A wide view area is needed. @SINCE_1_0.0
73     PORTRAIT_INVERSE = 180,  ///< Portrait inverse orientation @SINCE_1_0.0
74     LANDSCAPE_INVERSE = 270  ///< Landscape inverse orientation @SINCE_1_0.0
75   };
76
77   /**
78    * @brief Opacity of the indicator.
79    * @SINCE_1_0.0
80    */
81   enum IndicatorBgOpacity
82   {
83     OPAQUE = 100, ///< Fully opaque indicator Bg @SINCE_1_0.0
84     TRANSLUCENT = 50, ///< Semi translucent indicator Bg @SINCE_1_0.0
85     TRANSPARENT = 0 ///< Fully transparent indicator Bg @SINCE_1_0.0
86   };
87
88   /**
89    * @brief Visible mode of the indicator.
90    * @SINCE_1_0.0
91    */
92   enum IndicatorVisibleMode
93   {
94     INVISIBLE = 0, ///< Hide indicator @SINCE_1_0.0
95     VISIBLE = 1, ///< Show indicator @SINCE_1_0.0
96     AUTO = 2 ///< Hide in default, will show when necessary @SINCE_1_0.0
97   };
98
99   // Methods
100
101   /**
102    * @brief Create an initialized handle to a new Window.
103    * @SINCE_1_0.0
104    * @param[in] windowPosition The position and size of the window
105    * @param[in] name The window title
106    * @param[in] isTransparent Whether window is transparent
107    * @return a new window
108    */
109   static Window New(PositionSize windowPosition, const std::string& name, bool isTransparent = false);
110
111   /**
112    * @brief Create an initialized handle to a new Window.
113    * @SINCE_1_0.0
114    * @param[in] windowPosition The position and size of the window
115    * @param[in] name The window title
116    * @param[in] className The window class name
117    * @param[in] isTransparent Whether window is transparent
118    * @return a new window
119    */
120   static Window New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent = false);
121
122   /**
123    * @brief Create an uninitalized handle.
124    *
125    * This can be initialized using Dali::Application::GetWindow() or
126    * Dali::Window::New()
127    * @SINCE_1_0.0
128    */
129   Window();
130
131   /**
132    * @brief Destructor
133    *
134    * This is non-virtual since derived Handle types must not contain data or virtual methods.
135    * @SINCE_1_0.0
136    */
137   ~Window();
138
139   /**
140    * @brief This copy constructor is required for (smart) pointer semantics.
141    *
142    * @SINCE_1_0.0
143    * @param [in] handle A reference to the copied handle
144    */
145   Window(const Window& handle);
146
147   /**
148    * @brief This assignment operator is required for (smart) pointer semantics.
149    *
150    * @SINCE_1_0.0
151    * @param [in] rhs  A reference to the copied handle
152    * @return A reference to this
153    */
154   Window& operator=(const Window& rhs);
155
156   /**
157    * @brief This sets whether the indicator bar should be shown or not.
158    * @SINCE_1_0.0
159    * @param[in] visibleMode Visible mode for indicator bar, VISIBLE in default
160    */
161   void ShowIndicator( IndicatorVisibleMode visibleMode );
162
163   /**
164    * @brief This sets the opacity mode of indicator bar.
165    * @SINCE_1_0.0
166    * @param[in] opacity The opacity mode
167    */
168   void SetIndicatorBgOpacity( IndicatorBgOpacity opacity );
169
170   /**
171    * @brief This sets the orientation of indicator bar.
172    *
173    * It does not implicitly show the indicator if it is currently
174    * hidden.
175    * @SINCE_1_0.0
176    * @param[in] orientation The orientation
177    */
178   void RotateIndicator(WindowOrientation orientation);
179
180   /**
181    * @brief Set the window name and class string.
182    * @SINCE_1_0.0
183    * @param[in] name The name of the window
184    * @param[in] klass The class of the window
185    */
186   void SetClass(std::string name, std::string klass);
187
188   /**
189    * @brief Raise window to top of window stack.
190    * @SINCE_1_0.0
191    */
192   void Raise();
193
194   /**
195    * @brief Lower window to bottom of window stack.
196    * @SINCE_1_0.0
197    */
198   void Lower();
199
200   /**
201    * @brief Activate window to top of window stack even it is iconified.
202    * @SINCE_1_0.0
203    */
204   void Activate();
205
206   /**
207    * @brief Add an orientation to the list of available orientations.
208    * @SINCE_1_0.0
209    */
210   void AddAvailableOrientation( WindowOrientation orientation );
211
212   /**
213    * @brief Remove an orientation from the list of available orientations.
214    * @SINCE_1_0.0
215    */
216   void RemoveAvailableOrientation( WindowOrientation orientation );
217
218   /**
219    * @brief Set a preferred orientation.
220    * @SINCE_1_0.0
221    * @param[in] orientation The preferred orientation
222    * @pre orientation is in the list of available orientations
223    */
224   void SetPreferredOrientation( WindowOrientation orientation );
225
226   /**
227    * @brief Get the preferred orientation.
228    * @SINCE_1_0.0
229    * @return The preferred orientation if previously set, or none.
230    */
231   WindowOrientation GetPreferredOrientation();
232
233   /**
234    * @brief Returns the Drag & drop detector which can be used to receive drag & drop events.
235    * @note  Not intended for application developers.
236    * @SINCE_1_0.0
237    * @return A handle to the DragAndDropDetector.
238    */
239   DragAndDropDetector GetDragAndDropDetector() const;
240
241   /**
242    * @brief Get the native handle of the window.
243    *
244    * When users call this function, it wraps the actual type used by the underlying window system.
245    * @SINCE_1_0.0
246    * @return The native handle of the window or an empty handle.
247    */
248   Any GetNativeHandle() const;
249
250 public: // Signals
251   /**
252    * @brief The user should connect to this signal to get a timing when indicator was shown / hidden.
253    * @SINCE_1_0.0
254    */
255   IndicatorSignalType& IndicatorVisibilityChangedSignal();
256
257 public: // Not intended for application developers
258   /**
259    * @internal
260    * @brief This constructor is used by Dali::Application::GetWindow().
261    * @SINCE_1_0.0
262    * @param[in] window A pointer to the window.
263    */
264   explicit DALI_INTERNAL Window( Internal::Adaptor::Window* window );
265 };
266
267 /**
268  * @}
269  */
270 } // namespace Dali
271
272 #endif // __DALI_WINDOW_H__