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