05b208e87132686d03705d74c50ac21561bc09b2
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / windows / window-base-win.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H
3
4 /*
5  * Copyright (c) 2018 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 // INTERNAL INCLUDES
22 #include <dali/internal/window-system/common/window-base.h>
23 #include <dali/internal/window-system/windows/platform-implement-win.h>
24 #include <dali/internal/window-system/windows/event-system-win.h>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30 namespace Adaptor
31 {
32
33 class Window;
34 class WindowRenderSurface;
35 class WindowRenderSurfaceWin;
36
37 /**
38  * WindowBaseWin class provides an WindowBase Win32 implementation.
39  */
40 class WindowBaseWin : public WindowBase
41 {
42 public:
43
44   /**
45    * @brief Constructor
46    */
47   WindowBaseWin( PositionSize positionSize, Any surface, bool isTransparent );
48
49   /**
50    * @brief Destructor
51    */
52   virtual ~WindowBaseWin();
53
54 public:
55
56   /**
57    * Called when the window receives a delete request
58    */
59   void OnDeleteRequest();
60
61   /**
62    * @brief Called when the window gains focus.
63    */
64   void OnFocusIn( int type, TWinEventInfo *event );
65
66   /**
67    * @brief Called when the window loses focus.
68    */
69   void OnFocusOut( int type, TWinEventInfo *event );
70
71   /**
72    * @brief Called when the window is damaged.
73    */
74   void OnWindowDamaged( int type, TWinEventInfo *event );
75
76   /**
77    * @brief Called when a touch down is received.
78    */
79   void OnMouseButtonDown( int type, TWinEventInfo *event );
80
81   /**
82    * @brief Called when a touch up is received.
83    */
84   void OnMouseButtonUp( int type, TWinEventInfo *event );
85
86   /**
87    * @brief Called when a touch motion is received.
88    */
89   void OnMouseButtonMove( int type, TWinEventInfo *event );
90
91   /**
92    * @brief Called when a mouse wheel is received.
93    */
94   void OnMouseWheel( int type, TWinEventInfo *event );
95
96   /**
97    * @brief Called when a key down is received.
98    */
99   void OnKeyDown( int type, TWinEventInfo *event );
100
101   /**
102    * @brief Called when a key up is received.
103    */
104   void OnKeyUp( int type, TWinEventInfo *event );
105
106
107 public:
108
109   /**
110    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
111    */
112   virtual Any GetNativeWindow() override;
113
114   /**
115    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
116    */
117   virtual int GetNativeWindowId() override;
118
119   /**
120    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
121    */
122   virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override;
123
124   /**
125    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
126    */
127   virtual void DestroyEglWindow() override;
128
129   /**
130    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
131    */
132   virtual void SetEglWindowRotation( int angle ) override;
133
134   /**
135    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
136    */
137   virtual void SetEglWindowBufferTransform( int angle ) override;
138
139   /**
140    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
141    */
142   virtual void SetEglWindowTransform( int angle ) override;
143
144   /**
145    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
146    */
147   virtual void ResizeEglWindow( PositionSize positionSize ) override;
148
149   /**
150    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
151    */
152   virtual bool IsEglWindowRotationSupported() override;
153
154   /**
155    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
156    */
157   virtual void Move( PositionSize positionSize ) override;
158
159   /**
160    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
161    */
162   virtual void Resize( PositionSize positionSize ) override;
163
164   /**
165    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
166    */
167   virtual void MoveResize( PositionSize positionSize ) override;
168
169   /**
170    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
171    */
172   virtual void SetClass( const std::string& name, const std::string& className ) override;
173
174   /**
175    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
176    */
177   virtual void Raise() override;
178
179   /**
180    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
181    */
182   virtual void Lower() override;
183
184   /**
185    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
186    */
187   virtual void Activate() override;
188
189   /**
190    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
191    */
192   virtual void SetAvailableAnlges( const std::vector< int >& angles ) override;
193
194   /**
195    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
196    */
197   virtual void SetPreferredAngle( int angle ) override;
198
199   /**
200    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
201    */
202   virtual void SetAcceptFocus( bool accept ) override;
203
204   /**
205    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
206    */
207   virtual void Show() override;
208
209   /**
210    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
211    */
212   virtual void Hide() override;
213
214   /**
215    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
216    */
217   virtual unsigned int GetSupportedAuxiliaryHintCount() const override;
218
219   /**
220    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
221    */
222   virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
223
224   /**
225    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
226    */
227   virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
228
229   /**
230    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
231    */
232   virtual bool RemoveAuxiliaryHint( unsigned int id ) override;
233
234   /**
235    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
236    */
237   virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
238
239   /**
240    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
241    */
242   virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override;
243
244   /**
245    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
246    */
247   virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
248
249   /**
250    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
251    */
252   virtual void SetInputRegion( const Rect< int >& inputRegion ) override;
253
254   /**
255    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
256    */
257   virtual void SetType( Dali::Window::Type type ) override;
258
259   /**
260    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
261    */
262   virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
263
264   /**
265    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
266    */
267   virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
268
269   /**
270    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
271    */
272   virtual void SetOpaqueState( bool opaque ) override;
273
274   /**
275    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
276    */
277   virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
278
279   /**
280    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
281    */
282   virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
283
284   /**
285    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
286    */
287   virtual bool SetBrightness( int brightness ) override;
288
289   /**
290    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
291    */
292   virtual int GetBrightness() const override;
293
294   /**
295    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
296    */
297   virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
298
299   /**
300    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
301    */
302   virtual bool UngrabKey( Dali::KEY key ) override;
303
304   /**
305    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
306    */
307   virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
308
309   /**
310    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
311    */
312   virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
313
314   /**
315    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
316    */
317   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
318
319   /**
320    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
321    */
322   virtual int GetScreenRotationAngle() override;
323
324   /**
325    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
326    */
327   virtual void SetWindowRotationAngle( int degree ) override;
328
329   /**
330    * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
331    */
332   virtual void GetWindowRotationAngle() override;
333
334   /**
335    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
336    */
337   virtual void WindowRotationCompleted( int degree, int width, int height ) override;
338
339   /**
340    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
341    */
342   virtual void SetTransparency( bool transparent ) override;
343
344   /**
345    * @brief Return the orientation of the surface.
346    * @return The orientation
347    */
348   virtual int GetOrientation() const override;
349
350   /**
351    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
352    */
353   virtual void SetParent( WindowBase* parentWinBase ) override;
354
355 private:
356
357   /**
358    * Second stage initialization
359    */
360   void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
361
362   /**
363    * @brief Get the surface id if the surface parameter is not empty
364    * @param surface Any containing a surface id, or can be empty
365    * @return surface id, or zero if surface is empty
366    */
367   unsigned int GetSurfaceId( Any surface ) const;
368
369   /**
370    * @brief Create window
371    */
372   void CreateWinWindow( PositionSize positionSize, bool isTransparent );
373
374   /**
375    * @brief Sets up an already created window.
376    */
377   void SetWinWindow( unsigned int surfaceId );
378
379 private:
380
381   // Undefined
382   WindowBaseWin(const WindowBaseWin&) = delete;
383
384   // Undefined
385   WindowBaseWin& operator=(const WindowBaseWin& rhs) = delete;
386
387 private:
388   void EventEntry( TWinEventInfo *event );
389
390 private:
391   WinWindowHandle                      mWin32Window;        ///< Native window handle
392   bool                                 mOwnSurface:1;       ///< Whether we own the surface (responsible for deleting it)
393   bool                                 mIsTransparent:1;    ///< Whether the window is transparent (32 bit or 24 bit)
394   bool                                 mRotationAppSet:1;
395
396   WindowsPlatformImplementation::WindowImpl mWindowImpl;
397 };
398
399 } // namespace Adaptor
400
401 } // namespace internal
402
403 } // namespace Dali
404
405 #endif // DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H