|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
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/. */ |
|
6 |
|
7 #ifndef nsFilePicker_h_ |
|
8 #define nsFilePicker_h_ |
|
9 |
|
10 #include "nsBaseFilePicker.h" |
|
11 #include "nsString.h" |
|
12 #include "nsIFileChannel.h" |
|
13 #include "nsIFile.h" |
|
14 #include "nsCOMArray.h" |
|
15 #include "nsTArray.h" |
|
16 |
|
17 class nsILocalFileMac; |
|
18 @class NSArray; |
|
19 |
|
20 class nsFilePicker : public nsBaseFilePicker |
|
21 { |
|
22 public: |
|
23 nsFilePicker(); |
|
24 virtual ~nsFilePicker(); |
|
25 |
|
26 NS_DECL_ISUPPORTS |
|
27 |
|
28 // nsIFilePicker (less what's in nsBaseFilePicker) |
|
29 NS_IMETHOD GetDefaultString(nsAString& aDefaultString); |
|
30 NS_IMETHOD SetDefaultString(const nsAString& aDefaultString); |
|
31 NS_IMETHOD GetDefaultExtension(nsAString& aDefaultExtension); |
|
32 NS_IMETHOD GetFilterIndex(int32_t *aFilterIndex); |
|
33 NS_IMETHOD SetFilterIndex(int32_t aFilterIndex); |
|
34 NS_IMETHOD SetDefaultExtension(const nsAString& aDefaultExtension); |
|
35 NS_IMETHOD GetFile(nsIFile * *aFile); |
|
36 NS_IMETHOD GetFileURL(nsIURI * *aFileURL); |
|
37 NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles); |
|
38 NS_IMETHOD Show(int16_t *_retval); |
|
39 NS_IMETHOD AppendFilter(const nsAString& aTitle, const nsAString& aFilter); |
|
40 |
|
41 /** |
|
42 * Returns the current filter list in the format used by Cocoa's NSSavePanel |
|
43 * and NSOpenPanel. |
|
44 * Returns nil if no filter currently apply. |
|
45 */ |
|
46 NSArray* GetFilterList(); |
|
47 |
|
48 protected: |
|
49 |
|
50 virtual void InitNative(nsIWidget *aParent, const nsAString& aTitle); |
|
51 |
|
52 // actual implementations of get/put dialogs using NSOpenPanel & NSSavePanel |
|
53 // aFile is an existing but unspecified file. These functions must specify it. |
|
54 // |
|
55 // will return |returnCancel| or |returnOK| as result. |
|
56 int16_t GetLocalFiles(const nsString& inTitle, bool inAllowMultiple, nsCOMArray<nsIFile>& outFiles); |
|
57 int16_t GetLocalFolder(const nsString& inTitle, nsIFile** outFile); |
|
58 int16_t PutLocalFile(const nsString& inTitle, const nsString& inDefaultName, nsIFile** outFile); |
|
59 |
|
60 void SetDialogTitle(const nsString& inTitle, id aDialog); |
|
61 NSString *PanelDefaultDirectory(); |
|
62 NSView* GetAccessoryView(); |
|
63 |
|
64 nsString mTitle; |
|
65 nsCOMArray<nsIFile> mFiles; |
|
66 nsString mDefault; |
|
67 |
|
68 nsTArray<nsString> mFilters; |
|
69 nsTArray<nsString> mTitles; |
|
70 |
|
71 int32_t mSelectedTypeIndex; |
|
72 }; |
|
73 |
|
74 #endif // nsFilePicker_h_ |