1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsFilePicker_h_
8 #define nsFilePicker_h_
10 #include "nsBaseFilePicker.h"
12 #include "nsCOMArray.h"
16 class nsILocalFileMac
;
19 class nsFilePicker final
: public nsBaseFilePicker
{
20 class AsyncShowFilePicker
;
24 using nsIFilePicker::ResultCode
;
28 // nsIFilePicker (less what's in nsBaseFilePicker)
29 NS_IMETHOD
Open(nsIFilePickerShownCallback
* aCallback
) override
;
30 NS_IMETHOD
GetDefaultString(nsAString
& aDefaultString
) override
;
31 NS_IMETHOD
SetDefaultString(const nsAString
& aDefaultString
) override
;
32 NS_IMETHOD
GetDefaultExtension(nsAString
& aDefaultExtension
) override
;
33 NS_IMETHOD
GetFilterIndex(int32_t* aFilterIndex
) override
;
34 NS_IMETHOD
SetFilterIndex(int32_t aFilterIndex
) override
;
35 NS_IMETHOD
SetDefaultExtension(const nsAString
& aDefaultExtension
) override
;
36 NS_IMETHOD
GetFile(nsIFile
** aFile
) override
;
37 NS_IMETHOD
GetFileURL(nsIURI
** aFileURL
) override
;
38 NS_IMETHOD
GetFiles(nsISimpleEnumerator
** aFiles
) override
;
39 NS_IMETHOD
AppendFilter(const nsAString
& aTitle
,
40 const nsAString
& aFilter
) override
;
43 * Returns the current filter list in the format used by Cocoa's NSSavePanel
45 * Returns nil if no filter currently apply.
47 NSArray
* GetFilterList();
50 virtual ~nsFilePicker();
52 virtual void InitNative(nsIWidget
* aParent
, const nsAString
& aTitle
) override
;
53 nsresult
Show(ResultCode
* _retval
);
55 // actual implementations of get/put dialogs using NSOpenPanel & NSSavePanel
56 // aFile is an existing but unspecified file. These functions must specify it.
58 // will return |returnCancel| or |returnOK| as result.
59 ResultCode
GetLocalFiles(bool inAllowMultiple
, nsCOMArray
<nsIFile
>& outFiles
);
60 ResultCode
GetLocalFolder(nsIFile
** outFile
);
61 ResultCode
PutLocalFile(nsIFile
** outFile
);
63 void SetDialogTitle(const nsString
& inTitle
, id aDialog
);
64 NSString
* PanelDefaultDirectory();
65 NSView
* GetAccessoryView();
68 nsCOMArray
<nsIFile
> mFiles
;
69 nsString mDefaultFilename
;
71 nsTArray
<nsString
> mFilters
;
72 nsTArray
<nsString
> mTitles
;
74 int32_t mSelectedTypeIndex
= 0;
77 #endif // nsFilePicker_h_