Refactored image loaders, added public API
[platform/core/uifw/dali-adaptor.git] / adaptors / public-api / window.h
1 #ifndef __DALI_WINDOW_H__
2 #define __DALI_WINDOW_H__
3
4 /*
5  * Copyright (c) 2014 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 /**
22  * @addtogroup CAPI_DALI_ADAPTOR_MODULE
23  * @{
24  */
25
26 // EXTERNAL INCLUDES
27 #include <string>
28 #include <dali/public-api/math/rect.h>
29 #include <dali/public-api/math/vector2.h>
30 #include <dali/public-api/object/base-handle.h>
31
32 namespace Dali DALI_IMPORT_API
33 {
34 typedef Dali::Rect<int> PositionSize;
35
36 namespace Internal DALI_INTERNAL
37 {
38 namespace Adaptor
39 {
40 class Window;
41 }
42 }
43
44 class DragAndDropDetector;
45 class Orientation;
46
47 /**
48  * @brief The window class is used internally for drawing.
49  *
50  * It has an orientation
51  * and indicator properties.
52  */
53 class Window : public BaseHandle
54 {
55 public:
56
57   // Enumerations
58
59   /**
60    * @brief Orientation of the window.
61    */
62   enum WindowOrientation
63   {
64     PORTRAIT = 0,
65     LANDSCAPE = 90,
66     PORTRAIT_INVERSE = 180,
67     LANDSCAPE_INVERSE = 270
68   };
69
70   /**
71    * @brief Opacity of the indicator.
72    */
73   enum IndicatorBgOpacity
74   {
75     OPAQUE = 100, // Fully opaque indicator Bg
76     TRANSLUCENT = 50, // Semi translucent indicator Bg
77     TRANSPARENT = 0 // Fully transparent indicator Bg
78   };
79
80   /**
81    * @brief Visible mode of the indicator.
82    */
83   enum IndicatorVisibleMode
84   {
85     INVISIBLE = 0, // hide indicator
86     VISIBLE = 1, // show indicator
87     AUTO = 2 // hide in default, will show when necessary
88   };
89
90   /**
91    * @brief Style of the indicator.
92    */
93   enum IndicatorStyle
94   {
95     FIXED_COLOR = 0, // fixed color style
96     CHANGEABLE_COLOR // changeable color style
97   };
98
99   // Methods
100
101   /**
102    * @brief Create an initialized handle to a new Window.
103    * @param[in] windowPosition The position and size of the window
104    * @param[in] name The window title
105    * @param[in] isTransparent Whether window is transparent
106    * @return a new window
107    */
108   static Window New(PositionSize windowPosition, std::string name, bool isTransparent = false);
109
110   /**
111    * @brief Create an uninitalized handle.
112    *
113    * This can be initialized using Dali::Application::GetWindow() or
114    * Dali::Window::New()
115    */
116   Window();
117
118   /**
119    * @brief Destructor
120    *
121    * This is non-virtual since derived Handle types must not contain data or virtual methods.
122    */
123   ~Window();
124
125   /**
126    * @brief This copy constructor is required for (smart) pointer semantics.
127    *
128    * @param [in] handle A reference to the copied handle
129    */
130   Window(const Window& handle);
131
132   /**
133    * @brief This assignment operator is required for (smart) pointer semantics.
134    *
135    * @param [in] rhs  A reference to the copied handle
136    * @return A reference to this
137    */
138   Window& operator=(const Window& rhs);
139
140   /**
141    * @brief This method is defined to allow assignment of the NULL value,
142    * and will throw an exception if passed any other value.
143    *
144    * Assigning to NULL is an alias for Reset().
145    * @param [in] rhs  A NULL pointer
146    * @return A reference to this handle
147    */
148   Window& operator=(BaseHandle::NullType* rhs);
149
150   /**
151    * @brief This sets the style of indicator
152    * @param[in] style style type of the indicator
153    *
154    * @note This should be called before ShowIndicator()
155    */
156   void SetIndicatorStyle( IndicatorStyle style );
157
158   /**
159    * @brief This sets whether the indicator bar should be shown or not.
160    * @param[in] visibleMode visible mode for indicator bar, VISIBLE in default
161    */
162   void ShowIndicator( IndicatorVisibleMode visibleMode );
163
164   /**
165    * @brief This sets the opacity mode of indicator bar.
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    * @param[in] orientation The orientation
176    */
177   void RotateIndicator(WindowOrientation orientation);
178
179   /**
180    * @brief Set the window name and class string.
181    * @param[in] name The name of the window
182    * @param[in] klass The class of the window
183    */
184   void SetClass(std::string name, std::string klass);
185
186   /**
187    * @brief Raise window to top of window stack.
188    */
189   void Raise();
190
191   /**
192    * @brief Lower window to bottom of window stack.
193    */
194   void Lower();
195
196   /**
197    * @brief Activate window to top of window stack even it is iconified.
198    */
199   void Activate();
200
201   /**
202    * @brief Get the orientation class ( to allow signal connection ).
203    */
204   Orientation GetOrientation();
205
206   /**
207    * @brief Add an orientation to the list of available orientations.
208    */
209   void AddAvailableOrientation( WindowOrientation orientation );
210
211   /**
212    * @brief Remove an orientation from the list of available orientations.
213    */
214   void RemoveAvailableOrientation( WindowOrientation orientation );
215
216   /**
217    * @brief Set the orientations that this window can rotate to.
218    *
219    * By default, the window does not change orientation.
220    * @param[in] orientations The list of orientations
221    */
222   void SetAvailableOrientations( const std::vector<WindowOrientation>& orientations );
223
224   /**
225    * @brief Get the list of orientations this window can rotate to.
226    * @return the list of orientations
227    */
228   const std::vector<WindowOrientation>& GetAvailableOrientations();
229
230   /**
231    * @brief Set a preferred orientation.
232    * @pre orientation is in the list of available orientations
233    * @param[in] orientation The preferred orientation
234    */
235   void SetPreferredOrientation( WindowOrientation orientation );
236
237   /**
238    * @brief Get the preferred orientation.
239    * @return The preferred orientation if previously set, or none.
240    */
241   WindowOrientation GetPreferredOrientation();
242
243   /**
244    * @brief Returns the Drag & drop detector which can be used to receive drag & drop events.
245    * @return A handle to the DragAndDropDetector.
246    */
247   DragAndDropDetector GetDragAndDropDetector() const;
248
249 public: // Not intended for application developers
250   /**
251    * @brief This constructor is used by Dali::Application::GetWindow().
252    * @param[in] window A pointer to the window.
253    */
254   explicit Window( Internal::Adaptor::Window* window );
255 };
256
257 } // namespace Dali
258
259
260 /**
261  * @}
262  */
263 #endif // __DALI_WINDOW_H__