ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
mingw-compat.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 // TODO: Remove header when the latest changes to the Windows SDK have been integrated into MingW
22 // For reference, the interface definitions here are imported from the SDK headers and MingW-w64
23 
24 #ifndef BACKEND_WIN32_DIALOGS_MINGW_H
25 #define BACKEND_WIN32_DIALOGS_MINGW_H
26 
27 #if defined(WIN32)
28 #if defined(__GNUC__)
29 #ifdef __MINGW32__
30 
31 #ifdef _WIN32_WINNT
32  #undef _WIN32_WINNT
33 #endif
34 #define _WIN32_WINNT 0x0501
35 #include <windows.h>
36 #include <commctrl.h>
37 #include <initguid.h>
38 #include <shlwapi.h>
39 #include <shlguid.h>
40 
41 // MinGW does not understand COM interfaces
42 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
43 
44 // Dialog GUID definitions
45 DEFINE_GUID(CLSID_FileOpenDialog, 0xdc1c5a9c, 0xe88a, 0x4dde, 0xa5,0xa1, 0x60,0xf8,0x2a,0x20,0xae,0xf7);
46 DEFINE_GUID(IID_IFileOpenDialog, 0xd57c7288, 0xd4ad, 0x4768, 0xbe,0x02, 0x9d,0x96,0x95,0x32,0xd9,0x60);
47 DEFINE_GUID(IID_IShellItem, 0x43826d1e, 0xe718, 0x42ee, 0xbc,0x55, 0xa1,0xe2,0x61,0xc3,0x7b,0xfe);
48 
49 typedef enum _SIGDN {
50  SIGDN_NORMALDISPLAY = 0,
51  SIGDN_PARENTRELATIVEPARSING = 0x80018001,
52  SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000,
53  SIGDN_PARENTRELATIVEEDITING = 0x80031001,
54  SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000,
55  SIGDN_FILESYSPATH = 0x80058000,
56  SIGDN_URL = 0x80068000,
57  SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8007c001,
58  SIGDN_PARENTRELATIVE = 0x80080001,
59  SIGDN_PARENTRELATIVEFORUI = 0x80094001
60 } SIGDN;
61 
62 enum _SICHINTF {
63  SICHINT_DISPLAY = 0,
64  SICHINT_ALLFIELDS = 0x80000000,
65  SICHINT_CANONICAL = 0x10000000,
66  SICHINT_TEST_FILESYSPATH_IF_NOT_EQUAL = 0x20000000
67 } ;
68 typedef DWORD SICHINTF;
69 
70 // Shell item
71 #define INTERFACE IShellItem
72 DECLARE_INTERFACE_(IShellItem, IUnknown) {
73  STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
74  STDMETHOD_(ULONG,AddRef) (THIS) PURE;
75  STDMETHOD_(ULONG,Release) (THIS) PURE;
76  STDMETHOD (BindToHandler) (IBindCtx *pbc, REFGUID bhid, REFIID riid, void **ppv) PURE;
77  STDMETHOD (GetParent) (IShellItem **ppsi) PURE;
78  STDMETHOD (GetDisplayName) (SIGDN sigdnName, LPWSTR *ppszName) PURE;
79  STDMETHOD (GetAttributes) (SFGAOF sfgaoMask, SFGAOF *psfgaoAttribs) PURE;
80  STDMETHOD (Compare) (IShellItem *psi, SICHINTF hint, int *piOrder) PURE;
81 };
82 #undef INTERFACE
83 
84 // Mingw-specific defines for dialog integration
85 typedef struct _COMDLG_FILTERSPEC {
86  LPCWSTR pszName;
87  LPCWSTR pszSpec;
88 } COMDLG_FILTERSPEC;
89 
90 typedef enum FDAP {
91  FDAP_BOTTOM = 0,
92  FDAP_TOP = 1
93 } FDAP;
94 
95 enum _FILEOPENDIALOGOPTIONS {
96  FOS_OVERWRITEPROMPT = 0x2,
97  FOS_STRICTFILETYPES = 0x4,
98  FOS_NOCHANGEDIR = 0x8,
99  FOS_PICKFOLDERS = 0x20,
100  FOS_FORCEFILESYSTEM = 0x40,
101  FOS_ALLNONSTORAGEITEMS = 0x80,
102  FOS_NOVALIDATE = 0x100,
103  FOS_ALLOWMULTISELECT = 0x200,
104  FOS_PATHMUSTEXIST = 0x800,
105  FOS_FILEMUSTEXIST = 0x1000,
106  FOS_CREATEPROMPT = 0x2000,
107  FOS_SHAREAWARE = 0x4000,
108  FOS_NOREADONLYRETURN = 0x8000,
109  FOS_NOTESTFILECREATE = 0x10000,
110  FOS_HIDEMRUPLACES = 0x20000,
111  FOS_HIDEPINNEDPLACES = 0x40000,
112  FOS_NODEREFERENCELINKS = 0x100000,
113  FOS_DONTADDTORECENT = 0x2000000,
114  FOS_FORCESHOWHIDDEN = 0x10000000,
115  FOS_DEFAULTNOMINIMODE = 0x20000000,
116  FOS_FORCEPREVIEWPANEON = 0x40000000,
117  FOS_SUPPORTSTREAMABLEITEMS = 0x80000000
118 };
119 typedef DWORD FILEOPENDIALOGOPTIONS;
120 
121 // TODO: Need to implement these if they ever get used
122 typedef interface IFileDialogEvents IFileDialogEvents;
123 typedef interface IShellItemFilter IShellItemFilter;
124 typedef interface IShellItemArray IShellItemArray;
125 
126 // Open dialog interface
127 #define INTERFACE IFileOpenDialog
128 DECLARE_INTERFACE_(IFileOpenDialog, IUnknown) {
129  // IUnknown
130  STDMETHOD(QueryInterface) (THIS_ REFIID riid, void **ppv) PURE;
131  STDMETHOD_(ULONG,AddRef) (THIS) PURE;
132  STDMETHOD_(ULONG,Release) (THIS) PURE;
133  // IModalWindow
134  STDMETHOD (Show) (THIS_ HWND hwndOwner) PURE;
135  // IFileDialog
136  STDMETHOD (SetFileTypes) (THIS_ UINT cFileTypes, const COMDLG_FILTERSPEC *rgFilterSpec) PURE;
137  STDMETHOD (SetFileTypeIndex) (THIS_ UINT iFileType) PURE;
138  STDMETHOD (GetFileTypeIndex) (THIS_ UINT *piFileType) PURE;
139  STDMETHOD (Advise) (THIS_ IFileDialogEvents *pfde, DWORD *pdwCookie) PURE;
140  STDMETHOD (Unadvise) (THIS_ DWORD dwCookie) PURE;
141  STDMETHOD (SetOptions) (THIS_ FILEOPENDIALOGOPTIONS fos) PURE;
142  STDMETHOD (GetOptions) (THIS_ FILEOPENDIALOGOPTIONS *pfos) PURE;
143  STDMETHOD (SetDefaultFolder) (THIS_ IShellItem *psi) PURE;
144  STDMETHOD (SetFolder) (THIS_ IShellItem *psi) PURE;
145  STDMETHOD (GetFolder) (THIS_ IShellItem **ppsi) PURE;
146  STDMETHOD (GetCurrentSelection) (THIS_ IShellItem **ppsi) PURE;
147  STDMETHOD (SetFileName) (THIS_ LPCWSTR pszName) PURE;
148  STDMETHOD (GetFileName) (THIS_ LPWSTR *pszName) PURE;
149  STDMETHOD (SetTitle) (THIS_ LPCWSTR pszTitle) PURE;
150  STDMETHOD (SetOkButtonLabel) (THIS_ LPCWSTR pszText) PURE;
151  STDMETHOD (SetFileNameLabel) (THIS_ LPCWSTR pszLabel) PURE;
152  STDMETHOD (GetResult) (THIS_ IShellItem **ppsi) PURE;
153  STDMETHOD (AddPlace) (THIS_ IShellItem *psi, FDAP fdap) PURE;
154  STDMETHOD (SetDefaultExtension) (THIS_ LPCWSTR pszDefaultExtension) PURE;
155  STDMETHOD (Close) (THIS_ HRESULT hr) PURE;
156  STDMETHOD (SetClientGuid) (THIS_ REFGUID guid) PURE;
157  STDMETHOD (ClearClientData) (THIS) PURE;
158  STDMETHOD (SetFilter) (THIS_ IShellItemFilter *pFilter) PURE;
159  // IFileOpenDialog
160  STDMETHOD (GetResults) (THIS_ IShellItemArray **ppenum) PURE;
161  STDMETHOD (GetSelectedItems) (THIS_ IShellItemArray **ppsai) PURE;
162 };
163 #undef INTERFACE
164 
165 #endif // __MINGW32__
166 #endif // __GNUC__
167 #endif // WIN32
168 
169 #endif // BACKEND_WIN32_DIALOGS_MINGW_H