1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include <objbase.h>
43 #ifndef QFILEDIAG_WIN_P_H
44 #define QFILEDIAG_WIN_P_H
45 
46 //these are the interface declarations needed for the file dialog on Vista and up
47 
48 //At some point we can hope that all compilers/sdk will support that interface
49 //and we won't have to declare it ourselves
50 
51 //declarations
52 #define FOS_OVERWRITEPROMPT	   0x2
53 #define FOS_STRICTFILETYPES	   0x4
54 #define FOS_NOCHANGEDIR	       0x8
55 #define FOS_PICKFOLDERS	       0x20
56 #define FOS_FORCEFILESYSTEM	   0x40
57 #define FOS_ALLNONSTORAGEITEMS 0x80
58 #define FOS_NOVALIDATE         0x100
59 #define FOS_ALLOWMULTISELECT   0x200
60 #define FOS_PATHMUSTEXIST      0x800
61 #define FOS_FILEMUSTEXIST      0x1000
62 #define FOS_CREATEPROMPT       0x2000
63 #define FOS_SHAREAWARE         0x4000
64 #define FOS_NOREADONLYRETURN   0x8000
65 #define FOS_NOTESTFILECREATE   0x10000
66 #define FOS_HIDEMRUPLACES      0x20000
67 #define FOS_HIDEPINNEDPLACES   0x40000
68 #define FOS_NODEREFERENCELINKS 0x100000
69 #define FOS_DONTADDTORECENT    0x2000000
70 #define FOS_FORCESHOWHIDDEN    0x10000000
71 #define FOS_DEFAULTNOMINIMODE  0x20000000
72 #define FOS_FORCEPREVIEWPANEON 0x40000000
73 
74 typedef int GETPROPERTYSTOREFLAGS;
75 #define GPS_DEFAULT               0x00000000
76 #define GPS_HANDLERPROPERTIESONLY 0x00000001
77 #define GPS_READWRITE             0x00000002
78 #define GPS_TEMPORARY             0x00000004
79 #define GPS_FASTPROPERTIESONLY    0x00000008
80 #define GPS_OPENSLOWITEM          0x00000010
81 #define GPS_DELAYCREATION         0x00000020
82 #define GPS_BESTEFFORT            0x00000040
83 #define GPS_MASK_VALID            0x0000007F
84 
85 typedef int (QT_WIN_CALLBACK* BFFCALLBACK)(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData);
86 // message from browser
87 #define BFFM_INITIALIZED        1
88 #define BFFM_SELCHANGED         2
89 #define BFFM_ENABLEOK           (WM_USER + 101)
90 #define BFFM_SETSELECTION       (WM_USER + 103)
91 #define BFFM_SETSTATUSTEXT      (WM_USER + 104)
92 
93 // Browsing for directory.
94 #define BIF_RETURNONLYFSDIRS   0x0001
95 #define BIF_DONTGOBELOWDOMAIN  0x0002
96 #define BIF_STATUSTEXT         0x0004
97 #define BIF_RETURNFSANCESTORS  0x0008
98 #define BIF_EDITBOX            0x0010
99 #define BIF_VALIDATE           0x0020
100 #define BIF_NEWDIALOGSTYLE     0x0040
101 #define BIF_BROWSEINCLUDEURLS  0x0080
102 #define BIF_UAHINT             0x0100
103 #define BIF_NONEWFOLDERBUTTON  0x0200
104 #define BIF_NOTRANSLATETARGETS 0x0400
105 #define BIF_BROWSEFORCOMPUTER  0x1000
106 #define BIF_BROWSEFORPRINTER   0x2000
107 #define BIF_BROWSEINCLUDEFILES 0x4000
108 #define BIF_SHAREABLE          0x8000
109 
110 //the enums
111 typedef enum {
112     SIATTRIBFLAGS_AND	= 0x1,
113     SIATTRIBFLAGS_OR	= 0x2,
114     SIATTRIBFLAGS_APPCOMPAT	= 0x3,
115     SIATTRIBFLAGS_MASK	= 0x3
116 } 	SIATTRIBFLAGS;
117 typedef enum {
118     SIGDN_NORMALDISPLAY = 0x00000000,
119     SIGDN_PARENTRELATIVEPARSING = 0x80018001,
120     SIGDN_PARENTRELATIVEFORADDRESSBAR = 0x8001c001,
121     SIGDN_DESKTOPABSOLUTEPARSING = 0x80028000,
122     SIGDN_PARENTRELATIVEEDITING = 0x80031001,
123     SIGDN_DESKTOPABSOLUTEEDITING = 0x8004c000,
124     SIGDN_FILESYSPATH = 0x80058000,
125     SIGDN_URL = 0x80068000
126 } SIGDN;
127 typedef enum {
128     FDAP_BOTTOM = 0x00000000,
129     FDAP_TOP = 0x00000001
130 } FDAP;
131 typedef enum {
132     FDESVR_DEFAULT = 0x00000000,
133     FDESVR_ACCEPT = 0x00000001,
134     FDESVR_REFUSE = 0x00000002
135 } FDE_SHAREVIOLATION_RESPONSE;
136 typedef FDE_SHAREVIOLATION_RESPONSE FDE_OVERWRITE_RESPONSE;
137 
138 //the structs
139 typedef struct {
140     LPCWSTR pszName;
141     LPCWSTR pszSpec;
142 } qt_COMDLG_FILTERSPEC;
143 typedef struct {
144     GUID fmtid;
145     DWORD pid;
146 } qt_PROPERTYKEY;
147 
148 typedef struct {
149 	USHORT	cb;
150 	BYTE	abID[1];
151 } qt_SHITEMID, *qt_LPSHITEMID;
152 typedef struct {
153 	qt_SHITEMID mkid;
154 } qt_ITEMIDLIST, *qt_LPITEMIDLIST;
155 typedef const qt_ITEMIDLIST *qt_LPCITEMIDLIST;
156 typedef struct {
157     HWND          hwndOwner;
158     qt_LPCITEMIDLIST pidlRoot;
159     LPWSTR        pszDisplayName;
160     LPCWSTR       lpszTitle;
161     UINT          ulFlags;
162     BFFCALLBACK   lpfn;
163     LPARAM        lParam;
164     int           iImage;
165 } qt_BROWSEINFO;
166 
167 DECLARE_INTERFACE(IFileDialogEvents);
DECLARE_INTERFACE_(IShellItem,IUnknown)168 DECLARE_INTERFACE_(IShellItem, IUnknown)
169 {
170     STDMETHOD(BindToHandler)(THIS_ IBindCtx *pbc, REFGUID bhid, REFIID riid, void **ppv) PURE;
171     STDMETHOD(GetParent)(THIS_ IShellItem **ppsi) PURE;
172     STDMETHOD(GetDisplayName)(THIS_ SIGDN sigdnName, LPWSTR *ppszName) PURE;
173     STDMETHOD(GetAttributes)(THIS_ ULONG sfgaoMask, ULONG *psfgaoAttribs) PURE;
174     STDMETHOD(Compare)(THIS_ IShellItem *psi, DWORD hint, int *piOrder) PURE;
175 };
DECLARE_INTERFACE_(IShellItemFilter,IUnknown)176 DECLARE_INTERFACE_(IShellItemFilter, IUnknown)
177 {
178     STDMETHOD(IncludeItem)(THIS_ IShellItem *psi) PURE;
179     STDMETHOD(GetEnumFlagsForItem)(THIS_ IShellItem *psi, DWORD *pgrfFlags) PURE;
180 };
DECLARE_INTERFACE_(IEnumShellItems,IUnknown)181 DECLARE_INTERFACE_(IEnumShellItems, IUnknown)
182 {
183     STDMETHOD(Next)(THIS_ ULONG celt, IShellItem **rgelt, ULONG *pceltFetched) PURE;
184     STDMETHOD(Skip)(THIS_ ULONG celt) PURE;
185     STDMETHOD(Reset)(THIS_) PURE;
186     STDMETHOD(Clone)(THIS_ IEnumShellItems **ppenum) PURE;
187 };
DECLARE_INTERFACE_(IShellItemArray,IUnknown)188 DECLARE_INTERFACE_(IShellItemArray, IUnknown)
189 {
190     STDMETHOD(BindToHandler)(THIS_ IBindCtx *pbc, REFGUID rbhid, REFIID riid, void **ppvOut) PURE;
191     STDMETHOD(GetPropertyStore)(THIS_ GETPROPERTYSTOREFLAGS flags, REFIID riid, void **ppv) PURE;
192     STDMETHOD(GetPropertyDescriptionList)(THIS_ const qt_PROPERTYKEY *keyType, REFIID riid, void **ppv) PURE;
193     STDMETHOD(GetAttributes)(THIS_ SIATTRIBFLAGS dwAttribFlags, ULONG sfgaoMask, ULONG *psfgaoAttribs) PURE;
194     STDMETHOD(GetCount)(THIS_ DWORD *pdwNumItems) PURE;
195     STDMETHOD(GetItemAt)(THIS_ DWORD dwIndex, IShellItem **ppsi) PURE;
196     STDMETHOD(EnumItems)(THIS_ IEnumShellItems **ppenumShellItems) PURE;
197 };
DECLARE_INTERFACE_(IModalWindow,IUnknown)198 DECLARE_INTERFACE_(IModalWindow, IUnknown)
199 {
200     STDMETHOD(Show)(THIS_ HWND hwndParent) PURE;
201 };
DECLARE_INTERFACE_(IFileDialog,IModalWindow)202 DECLARE_INTERFACE_(IFileDialog, IModalWindow)
203 {
204     STDMETHOD(SetFileTypes)(THIS_ UINT cFileTypes, const qt_COMDLG_FILTERSPEC *rgFilterSpec) PURE;
205     STDMETHOD(SetFileTypeIndex)(THIS_ UINT iFileType) PURE;
206     STDMETHOD(GetFileTypeIndex)(THIS_ UINT *piFileType) PURE;
207     STDMETHOD(Advise)(THIS_ IFileDialogEvents *pfde, DWORD *pdwCookie) PURE;
208     STDMETHOD(Unadvise)(THIS_ DWORD dwCookie) PURE;
209     STDMETHOD(SetOptions)(THIS_ DWORD fos) PURE;
210     STDMETHOD(GetOptions)(THIS_ DWORD *pfos) PURE;
211     STDMETHOD(SetDefaultFolder)(THIS_ IShellItem *psi) PURE;
212     STDMETHOD(SetFolder)(THIS_ IShellItem *psi) PURE;
213     STDMETHOD(GetFolder)(THIS_ IShellItem **ppsi) PURE;
214     STDMETHOD(GetCurrentSelection)(THIS_ IShellItem **ppsi) PURE;
215     STDMETHOD(SetFileName)(THIS_ LPCWSTR pszName) PURE;
216     STDMETHOD(GetFileName)(THIS_ LPWSTR *pszName) PURE;
217     STDMETHOD(SetTitle)(THIS_ LPCWSTR pszTitle) PURE;
218     STDMETHOD(SetOkButtonLabel)(THIS_ LPCWSTR pszText) PURE;
219     STDMETHOD(SetFileNameLabel)(THIS_ LPCWSTR pszLabel) PURE;
220     STDMETHOD(GetResult)(THIS_ IShellItem **ppsi) PURE;
221     STDMETHOD(AddPlace)(THIS_ IShellItem *psi, FDAP fdap) PURE;
222     STDMETHOD(SetDefaultExtension)(THIS_ LPCWSTR pszDefaultExtension) PURE;
223     STDMETHOD(Close)(THIS_ HRESULT hr) PURE;
224     STDMETHOD(SetClientGuid)(THIS_ REFGUID guid) PURE;
225     STDMETHOD(ClearClientData)(THIS_) PURE;
226     STDMETHOD(SetFilter)(THIS_ IShellItemFilter *pFilter) PURE;
227 };
DECLARE_INTERFACE_(IFileDialogEvents,IUnknown)228 DECLARE_INTERFACE_(IFileDialogEvents, IUnknown)
229 {
230     STDMETHOD(OnFileOk)(THIS_ IFileDialog *pfd) PURE;
231     STDMETHOD(OnFolderChanging)(THIS_ IFileDialog *pfd, IShellItem *psiFolder) PURE;
232     STDMETHOD(OnFolderChange)(THIS_ IFileDialog *pfd) PURE;
233     STDMETHOD(OnSelectionChange)(THIS_ IFileDialog *pfd) PURE;
234     STDMETHOD(OnShareViolation)(THIS_ IFileDialog *pfd, IShellItem *psi, FDE_SHAREVIOLATION_RESPONSE *pResponse) PURE;
235     STDMETHOD(OnTypeChange)(THIS_ IFileDialog *pfd) PURE;
236     STDMETHOD(OnOverwrite)(THIS_ IFileDialog *pfd, IShellItem *psi, FDE_OVERWRITE_RESPONSE *pResponse) PURE;
237 };
DECLARE_INTERFACE_(IFileOpenDialog,IFileDialog)238 DECLARE_INTERFACE_(IFileOpenDialog, IFileDialog)
239 {
240     STDMETHOD(GetResults)(THIS_ IShellItemArray **ppenum) PURE;
241     STDMETHOD(GetSelectedItems)(THIS_ IShellItemArray **ppsai) PURE;
242 };
243 #endif
244