[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / windowing / windows / WinSystemWin32.h
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #ifndef WINDOW_SYSTEM_WIN32_H
22 #define WINDOW_SYSTEM_WIN32_H
23
24 #include "windowing/WinSystem.h"
25
26 struct MONITOR_DETAILS
27 {
28   // Windows desktop info
29   int       ScreenWidth;
30   int       ScreenHeight;
31   int       RefreshRate;
32   int       Bpp;
33   bool      Interlaced;
34
35   HMONITOR  hMonitor;
36   char      MonitorName[128];
37   char      CardName[128];
38   char      DeviceName[128];
39   int       ScreenNumber; // XBMC POV, not Windows. Windows primary is XBMC #0, then each secondary is +1.
40 };
41
42 #ifndef WM_GESTURE
43
44 #define WM_GESTURE       0x0119
45 #define WM_GESTURENOTIFY 0x011A
46
47 // Gesture Information Flags
48 #define GF_BEGIN   0x00000001
49 #define GF_INERTIA 0x00000002
50 #define GF_END     0x00000004
51
52 // Gesture IDs
53 #define GID_BEGIN                       1
54 #define GID_END                         2
55 #define GID_ZOOM                        3
56 #define GID_PAN                         4
57 #define GID_ROTATE                      5
58 #define GID_TWOFINGERTAP                6
59 #define GID_PRESSANDTAP                 7
60 #define GID_ROLLOVER                    GID_PRESSANDTAP
61
62 #define GC_ALLGESTURES 0x00000001
63
64 // Zoom Gesture Confiration Flags
65 #define GC_ZOOM 0x00000001
66
67 // Pan Gesture Configuration Flags
68 #define GC_PAN 0x00000001
69 #define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
70 #define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
71 #define GC_PAN_WITH_GUTTER 0x00000008
72 #define GC_PAN_WITH_INERTIA 0x00000010
73
74 // Rotate Gesture Configuration Flags
75 #define GC_ROTATE 0x00000001
76
77 // Two finger tap configuration flags
78 #define GC_TWOFINGERTAP 0x00000001
79
80 // Press and tap Configuration Flags
81 #define GC_PRESSANDTAP 0x00000001
82 #define GC_ROLLOVER GC_PRESSANDTAP
83
84 typedef struct _GESTUREINFO {
85   UINT      cbSize;
86   DWORD     dwFlags;
87   DWORD     dwID;
88   HWND      hwndTarget;
89   POINTS    ptsLocation;
90   DWORD     dwInstanceID;
91   DWORD     dwSequenceID;
92   ULONGLONG ullArguments;
93   UINT      cbExtraArgs;
94 }GESTUREINFO, *PGESTUREINFO;
95
96 // GESTURECONFIG struct defintion
97 typedef struct tagGESTURECONFIG {
98     DWORD dwID;                     // gesture ID
99     DWORD dwWant;                   // settings related to gesture ID that are to be turned on
100     DWORD dwBlock;                  // settings related to gesture ID that are to be turned off
101 } GESTURECONFIG, *PGESTURECONFIG;
102
103 /*
104  * Gesture notification structure
105  *   - The WM_GESTURENOTIFY message lParam contains a pointer to this structure.
106  *   - The WM_GESTURENOTIFY message notifies a window that gesture recognition is
107  *     in progress and a gesture will be generated if one is recognized under the
108  *     current gesture settings.
109  */
110 typedef struct tagGESTURENOTIFYSTRUCT {
111     UINT cbSize;                    // size, in bytes, of this structure
112     DWORD dwFlags;                  // unused
113     HWND hwndTarget;                // handle to window targeted by the gesture
114     POINTS ptsLocation;             // starting location
115     DWORD dwInstanceID;             // internally used
116 } GESTURENOTIFYSTRUCT, *PGESTURENOTIFYSTRUCT;
117
118 DECLARE_HANDLE(HGESTUREINFO);
119
120 #endif
121
122 class CWinSystemWin32 : public CWinSystemBase
123 {
124 public:
125   CWinSystemWin32();
126   virtual ~CWinSystemWin32();
127
128   // CWinSystemBase
129   virtual bool InitWindowSystem();
130   virtual bool DestroyWindowSystem();
131   virtual bool CreateNewWindow(const CStdString& name, bool fullScreen, RESOLUTION_INFO& res, PHANDLE_EVENT_FUNC userFunction);
132   virtual bool ResizeWindow(int newWidth, int newHeight, int newLeft, int newTop);
133   virtual bool SetFullScreen(bool fullScreen, RESOLUTION_INFO& res, bool blankOtherDisplays);
134   virtual void UpdateResolutions();
135   virtual bool CenterWindow();
136   virtual void NotifyAppFocusChange(bool bGaining);
137   virtual int  GetNumScreens() { return m_MonitorsInfo.size(); };
138   virtual int  GetCurrentScreen();
139   virtual void ShowOSMouse(bool show);
140   virtual bool WindowedMode() { return true; }
141   virtual bool HasInertialGestures(){ return true; }//if win32 has touchscreen - it uses the win32 gesture api for inertial scrolling
142
143   virtual bool Minimize();
144   virtual bool Restore();
145   virtual bool Hide();
146   virtual bool Show(bool raise = true);
147
148   // CWinSystemWin32
149   HWND GetHwnd() { return m_hWnd; }
150   bool IsAlteringWindow() { return m_IsAlteringWindow; }
151
152   // touchscreen support
153   typedef BOOL (WINAPI *pGetGestureInfo)(HGESTUREINFO, PGESTUREINFO);
154   typedef BOOL (WINAPI *pSetGestureConfig)(HWND, DWORD, UINT, PGESTURECONFIG, UINT);
155   typedef BOOL (WINAPI *pCloseGestureInfoHandle)(HGESTUREINFO);
156   pGetGestureInfo         PtrGetGestureInfo;
157   pSetGestureConfig       PtrSetGestureConfig;
158   pCloseGestureInfoHandle PtrCloseGestureInfoHandle;
159
160 protected:
161   bool ChangeResolution(RESOLUTION_INFO res);
162   virtual bool ResizeInternal(bool forceRefresh = false);
163   virtual bool UpdateResolutionsInternal();
164   virtual bool CreateBlankWindows();
165   virtual bool BlankNonActiveMonitors(bool bBlank);
166   const MONITOR_DETAILS &GetMonitor(int screen) const;
167   void RestoreDesktopResolution(int screen);
168   RECT ScreenRect(int screen);
169   /*!
170    \brief Adds a resolution to the list of resolutions if we don't already have it
171    \param res resolution to add.
172    */
173   void AddResolution(const RESOLUTION_INFO &res);
174
175   HWND m_hWnd;
176   std::vector<HWND> m_hBlankWindows;
177   HDC m_hDC;
178   HINSTANCE m_hInstance;
179   HICON m_hIcon;
180   std::vector<MONITOR_DETAILS> m_MonitorsInfo;
181   int m_nPrimary;
182   bool m_ValidWindowedPosition;
183   bool m_IsAlteringWindow;
184 };
185
186 extern HWND g_hWnd;
187
188 #endif // WINDOW_SYSTEM_H
189