381def37033289059b6bf7d7dd82b3f3f5cafdbb
[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    * @brief Called when the window property is changed.
58    */
59   bool OnWindowPropertyChanged( void* data, int type, TWinEventInfo *event );
60
61   /**
62    * Called when the window receives a delete request
63    */
64   void OnDeleteRequest();
65
66   /**
67    * @brief Called when the window gains focus.
68    */
69   void OnFocusIn( void* data, int type, TWinEventInfo *event );
70
71   /**
72    * @brief Called when the window loses focus.
73    */
74   void OnFocusOut( void* data, int type, TWinEventInfo *event );
75
76   /**
77    * @brief Called when the window is damaged.
78    */
79   void OnWindowDamaged( void* data, int type, TWinEventInfo *event );
80
81   /**
82    * @brief Called when a touch down is received.
83    */
84   void OnMouseButtonDown( void* data, int type, TWinEventInfo *event );
85
86   /**
87    * @brief Called when a touch up is received.
88    */
89   void OnMouseButtonUp( void* data, int type, TWinEventInfo *event );
90
91   /**
92    * @brief Called when a touch motion is received.
93    */
94   void OnMouseButtonMove( void* data, int type, TWinEventInfo *event );
95
96   /**
97    * @brief Called when a mouse wheel is received.
98    */
99   void OnMouseWheel( void* data, int type, TWinEventInfo *event );
100
101   /**
102    * @brief Called when a key down is received.
103    */
104   void OnKeyDown( void* data, int type, TWinEventInfo *event );
105
106   /**
107    * @brief Called when a key up is received.
108    */
109   void OnKeyUp( void* data, int type, TWinEventInfo *event );
110
111   /**
112    * @brief Called when the source window notifies us the content in clipboard is selected.
113    */
114   void OnSelectionClear( void* data, int type, TWinEventInfo *event );
115
116   /**
117    * @brief Called when the source window sends us about the selected content.
118    */
119   void OnSelectionNotify( void* data, int type, TWinEventInfo *event );
120
121 public:
122
123   /**
124    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
125    */
126   virtual Any GetNativeWindow() override;
127
128   /**
129    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
130    */
131   virtual int GetNativeWindowId() override;
132
133   /**
134    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
135    */
136   virtual EGLNativeWindowType CreateEglWindow( int width, int height ) override;
137
138   /**
139    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
140    */
141   virtual void DestroyEglWindow() override;
142
143   /**
144    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
145    */
146   virtual void SetEglWindowRotation( int angle ) override;
147
148   /**
149    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
150    */
151   virtual void SetEglWindowBufferTransform( int angle ) override;
152
153   /**
154    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
155    */
156   virtual void SetEglWindowTransform( int angle ) override;
157
158   /**
159    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
160    */
161   virtual void ResizeEglWindow( PositionSize positionSize ) override;
162
163   /**
164    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
165    */
166   virtual bool IsEglWindowRotationSupported() override;
167
168   /**
169    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
170    */
171   virtual void Move( PositionSize positionSize ) override;
172
173   /**
174    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
175    */
176   virtual void Resize( PositionSize positionSize ) override;
177
178   /**
179    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
180    */
181   virtual void MoveResize( PositionSize positionSize ) override;
182
183   /**
184    * @copydoc Dali::Internal::Adaptor::WindowBase::ShowIndicator()
185    */
186   virtual void ShowIndicator( Dali::Window::IndicatorVisibleMode visibleMode, Dali::Window::IndicatorBgOpacity opacityMode ) override;
187
188   /**
189    * @copydoc Dali::Internal::Adaptor::WindowBase::SetIndicatorProperties()
190    */
191   virtual void SetIndicatorProperties( bool isShow, Dali::Window::WindowOrientation lastOrientation ) override;
192
193   /**
194    * @copydoc Dali::Internal::Adaptor::WindowBase::IndicatorTypeChanged()
195    */
196   virtual void IndicatorTypeChanged( IndicatorInterface::Type type ) override;
197
198   /**
199    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
200    */
201   virtual void SetClass( const std::string& name, const std::string& className ) override;
202
203   /**
204    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
205    */
206   virtual void Raise() override;
207
208   /**
209    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
210    */
211   virtual void Lower() override;
212
213   /**
214    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
215    */
216   virtual void Activate() override;
217
218   /**
219    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableOrientations()
220    */
221   virtual void SetAvailableOrientations( const std::vector< Dali::Window::WindowOrientation >& orientations ) override;
222
223   /**
224    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredOrientation()
225    */
226   virtual void SetPreferredOrientation( Dali::Window::WindowOrientation orientation ) override;
227
228   /**
229    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
230    */
231   virtual void SetAcceptFocus( bool accept ) override;
232
233   /**
234    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
235    */
236   virtual void Show() override;
237
238   /**
239    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
240    */
241   virtual void Hide() override;
242
243   /**
244    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
245    */
246   virtual unsigned int GetSupportedAuxiliaryHintCount() const override;
247
248   /**
249    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
250    */
251   virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
252
253   /**
254    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
255    */
256   virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
257
258   /**
259    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
260    */
261   virtual bool RemoveAuxiliaryHint( unsigned int id ) override;
262
263   /**
264    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
265    */
266   virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
267
268   /**
269    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
270    */
271   virtual std::string GetAuxiliaryHintValue( unsigned int id ) const override;
272
273   /**
274    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
275    */
276   virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
277
278   /**
279    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
280    */
281   virtual void SetInputRegion( const Rect< int >& inputRegion ) override;
282
283   /**
284    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
285    */
286   virtual void SetType( Dali::Window::Type type ) override;
287
288   /**
289    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
290    */
291   virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
292
293   /**
294    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
295    */
296   virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
297
298   /**
299    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
300    */
301   virtual void SetOpaqueState( bool opaque ) override;
302
303   /**
304    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
305    */
306   virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
307
308   /**
309    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
310    */
311   virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
312
313   /**
314    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
315    */
316   virtual bool SetBrightness( int brightness ) override;
317
318   /**
319    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
320    */
321   virtual int GetBrightness() const override;
322
323   /**
324    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
325    */
326   virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
327
328   /**
329    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
330    */
331   virtual bool UngrabKey( Dali::KEY key ) override;
332
333   /**
334    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
335    */
336   virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
337
338   /**
339    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
340    */
341   virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
342
343   /**
344    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
345    */
346   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
347
348   /**
349    * @copydoc Dali::Internal::Adaptor::WindowBase::SetViewMode()
350    */
351   virtual void SetViewMode( ViewMode viewMode ) override;
352
353   /**
354    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
355    */
356   virtual int GetScreenRotationAngle() override;
357
358   /**
359    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
360    */
361   virtual void SetWindowRotationAngle( int degree ) override;
362
363   /**
364    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
365    */
366   virtual void WindowRotationCompleted( int degree, int width, int height ) override;
367
368   /**
369    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
370    */
371   virtual void SetTransparency( bool transparent ) override;
372
373 private:
374
375   /**
376    * Second stage initialization
377    */
378   void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
379
380   /**
381    * @brief Get the surface id if the surface parameter is not empty
382    * @param surface Any containing a surface id, or can be empty
383    * @return surface id, or zero if surface is empty
384    */
385   unsigned int GetSurfaceId( Any surface ) const;
386
387   /**
388    * @brief Create window
389    */
390   void CreateWinWindow( PositionSize positionSize, bool isTransparent );
391
392 protected:
393
394   // Undefined
395   WindowBaseWin(const WindowBaseWin&) = delete;
396
397   // Undefined
398   WindowBaseWin& operator=(const WindowBaseWin& rhs) = delete;
399
400 private:
401
402   Dali::Vector< Event_Handler >        mEventHandler;
403   Win_Window_Handle                    mWin32Window;        ///< Native window handle
404   bool                                 mOwnSurface:1;       ///< Whether we own the surface (responsible for deleting it)
405   bool                                 mIsTransparent;      ///< Whether the window is transparent (32 bit or 24 bit)
406   bool                                 mRotationAppSet:1;
407 };
408
409 } // namespace Adaptor
410
411 } // namespace internal
412
413 } // namespace Dali
414
415 #endif // DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H