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"
13 #include "nsCOMArray.h"
16 class nsILocalFileMac
;
19 class nsFilePicker
: public nsBaseFilePicker
{
22 using nsIFilePicker::ResultCode
;
26 // nsIFilePicker (less what's in nsBaseFilePicker)
27 NS_IMETHOD
GetDefaultString(nsAString
& aDefaultString
) override
;
28 NS_IMETHOD
SetDefaultString(const nsAString
& aDefaultString
) override
;
29 NS_IMETHOD
GetDefaultExtension(nsAString
& aDefaultExtension
) override
;
30 NS_IMETHOD
GetFilterIndex(int32_t* aFilterIndex
) override
;
31 NS_IMETHOD
SetFilterIndex(int32_t aFilterIndex
) override
;
32 NS_IMETHOD
SetDefaultExtension(const nsAString
& aDefaultExtension
) override
;
33 NS_IMETHOD
GetFile(nsIFile
** aFile
) override
;
34 NS_IMETHOD
GetFileURL(nsIURI
** aFileURL
) override
;
35 NS_IMETHOD
GetFiles(nsISimpleEnumerator
** aFiles
) override
;
36 NS_IMETHOD
AppendFilter(const nsAString
& aTitle
,
37 const nsAString
& aFilter
) override
;
40 * Returns the current filter list in the format used by Cocoa's NSSavePanel
42 * Returns nil if no filter currently apply.
44 NSArray
* GetFilterList();
47 virtual ~nsFilePicker();
49 virtual void InitNative(nsIWidget
* aParent
, const nsAString
& aTitle
) override
;
50 nsresult
Show(ResultCode
* _retval
) override
;
52 // actual implementations of get/put dialogs using NSOpenPanel & NSSavePanel
53 // aFile is an existing but unspecified file. These functions must specify it.
55 // will return |returnCancel| or |returnOK| as result.
56 ResultCode
GetLocalFiles(bool inAllowMultiple
, nsCOMArray
<nsIFile
>& outFiles
);
57 ResultCode
GetLocalFolder(nsIFile
** outFile
);
58 ResultCode
PutLocalFile(nsIFile
** outFile
);
60 void SetDialogTitle(const nsString
& inTitle
, id aDialog
);
61 NSString
* PanelDefaultDirectory();
62 NSView
* GetAccessoryView();
65 nsCOMArray
<nsIFile
> mFiles
;
66 nsString mDefaultFilename
;
68 nsTArray
<nsString
> mFilters
;
69 nsTArray
<nsString
> mTitles
;
71 int32_t mSelectedTypeIndex
;
74 #endif // nsFilePicker_h_