CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / widget / src / beos / nsFilePicker.h
blob71f3423c74905bb18301257b97c3d8fa2d079f85
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is the Mozilla browser.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 2001
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
24 * Makoto Hamanaka <VYA04230@nifty.com>
25 * Paul Ashford <arougthopher@lizardland.net>
26 * Sergei Dolgov <sergei_d@fi.tartu.ee>
28 * Alternatively, the contents of this file may be used under the terms of
29 * either the GNU General Public License Version 2 or later (the "GPL"), or
30 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 * in which case the provisions of the GPL or the LGPL are applicable instead
32 * of those above. If you wish to allow use of your version of this file only
33 * under the terms of either the GPL or the LGPL, and not to allow others to
34 * use your version of this file under the terms of the MPL, indicate your
35 * decision by deleting the provisions above and replace them with the notice
36 * and other provisions required by the GPL or the LGPL. If you do not delete
37 * the provisions above, a recipient may use your version of this file under
38 * the terms of any one of the MPL, the GPL or the LGPL.
40 * ***** END LICENSE BLOCK ***** */
42 #ifndef nsFilePicker_h__
43 #define nsFilePicker_h__
45 #ifndef DEBUG
46 // XXX adding mLastUsedDirectory and code for handling last used folder on File Open/Save
47 // caused crashes in DEBUG builds on some machines - see comments for bug 177720
48 // works well on "normal" builds
49 #define FILEPICKER_SAVE_LAST_DIR 1
50 #endif
52 #include "nsICharsetConverterManager.h"
53 #include "nsBaseFilePicker.h"
54 #include "nsString.h"
55 #include "nsdefs.h"
56 #include "nsIFileChannel.h"
57 #include "nsILocalFile.h"
58 #include "nsISimpleEnumerator.h"
59 #include "nsCOMArray.h"
62 // Native BeOS FileSelector wrapper
65 #include <StorageKit.h>
66 #include <Message.h>
67 #include <Window.h>
68 #include <String.h>
69 class BButton;
71 class nsFilePicker : public nsBaseFilePicker
73 public:
74 NS_DECL_ISUPPORTS
76 nsFilePicker();
77 virtual ~nsFilePicker();
79 // nsIFilePicker (less what's in nsBaseFilePicker)
80 NS_IMETHOD GetDefaultString(nsAString& aDefaultString);
81 NS_IMETHOD SetDefaultString(const nsAString& aDefaultString);
82 NS_IMETHOD GetDefaultExtension(nsAString& aDefaultExtension);
83 NS_IMETHOD SetDefaultExtension(const nsAString& aDefaultExtension);
84 NS_IMETHOD GetFile(nsILocalFile * *aFile);
85 NS_IMETHOD GetFileURL(nsIURI * *aFileURL);
86 NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles);
87 NS_IMETHOD Show(PRInt16 *_retval);
88 NS_IMETHOD AppendFilter(const nsAString& aTitle, const nsAString& aFilter);
90 protected:
91 // method from nsBaseFilePicker
92 virtual void InitNative(nsIWidget *aParent, const nsAString& aTitle,
93 PRInt16 aMode);
96 void GetFilterListArray(nsString& aFilterList);
98 BWindow* mParentWindow;
99 nsString mTitle;
100 PRInt16 mMode;
101 nsCString mFile;
102 nsString mDefault;
103 nsString mFilterList;
104 nsIUnicodeEncoder* mUnicodeEncoder;
105 nsIUnicodeDecoder* mUnicodeDecoder;
106 PRInt16 mSelectedType;
107 nsCOMArray<nsILocalFile> mFiles;
109 #ifdef FILEPICKER_SAVE_LAST_DIR
110 static char mLastUsedDirectory[];
111 #endif
114 class nsFilePanelBeOS : public BLooper, public BFilePanel
116 public:
117 nsFilePanelBeOS(file_panel_mode mode,
118 uint32 node_flavors,
119 bool allow_multiple_selection,
120 bool modal,
121 bool hide_when_done);
122 virtual ~nsFilePanelBeOS();
124 virtual void MessageReceived(BMessage *message);
125 virtual void WaitForSelection();
127 virtual void SelectionChanged();
129 virtual bool IsOpenSelected() {
130 return (SelectedActivity() == OPEN_SELECTED);
132 virtual bool IsSaveSelected() {
133 return (SelectedActivity() == SAVE_SELECTED);
135 virtual bool IsCancelSelected() {
136 return (SelectedActivity() == CANCEL_SELECTED);
138 virtual uint32 SelectedActivity();
140 virtual BList *OpenRefs() { return &mOpenRefs; }
141 virtual BString SaveFileName() { return mSaveFileName; }
142 virtual entry_ref SaveDirRef() { return mSaveDirRef; }
144 enum {
145 NOT_SELECTED = 0,
146 OPEN_SELECTED = 1,
147 SAVE_SELECTED = 2,
148 CANCEL_SELECTED = 3
151 protected:
152 BButton *mDirectoryButton;
153 sem_id wait_sem ;
154 uint32 mSelectedActivity;
155 bool mIsSelected;
156 BString mSaveFileName;
157 entry_ref mSaveDirRef;
158 BList mOpenRefs;
161 #endif // nsFilePicker_h__