/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is the Mozilla browser. * * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 2001 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): * Makoto Hamanaka * Paul Ashford * Sergei Dolgov */ #ifndef nsFilePicker_h__ #define nsFilePicker_h__ #ifndef DEBUG // XXX adding mLastUsedDirectory and code for handling last used folder on File Open/Save // caused crashes in DEBUG builds on some machines - see comments for bug 177720 // works well on "normal" builds #define FILEPICKER_SAVE_LAST_DIR 1 #endif #include "nsICharsetConverterManager.h" #include "nsBaseFilePicker.h" #include "nsString.h" #include "nsdefs.h" #include "nsIFileChannel.h" #include "nsILocalFile.h" #include "nsISimpleEnumerator.h" #include "nsISupportsArray.h" // // Native BeOS FileSelector wrapper // #include #include #include #include class nsFilePicker : public nsBaseFilePicker { public: nsFilePicker(); virtual ~nsFilePicker(); NS_DECL_ISUPPORTS // nsIFilePicker (less what's in nsBaseFilePicker) NS_IMETHOD GetDefaultString(nsAString& aDefaultString); NS_IMETHOD SetDefaultString(const nsAString& aDefaultString); NS_IMETHOD GetDefaultExtension(nsAString& aDefaultExtension); NS_IMETHOD SetDefaultExtension(const nsAString& aDefaultExtension); NS_IMETHOD GetDisplayDirectory(nsILocalFile * *aDisplayDirectory); NS_IMETHOD SetDisplayDirectory(nsILocalFile * aDisplayDirectory); NS_IMETHOD GetFile(nsILocalFile * *aFile); NS_IMETHOD GetFileURL(nsIFileURL * *aFileURL); NS_IMETHOD GetFiles(nsISimpleEnumerator **aFiles); NS_IMETHOD Show(PRInt16 *_retval); NS_IMETHOD AppendFilter(const nsAString& aTitle, const nsAString& aFilter); protected: // method from nsBaseFilePicker virtual void InitNative(nsIWidget *aParent, const nsAString& aTitle, PRInt16 aMode); void GetFilterListArray(nsString& aFilterList); BWindow* mParentWindow; nsString mTitle; PRInt16 mMode; nsCString mFile; nsString mDefault; nsString mFilterList; nsIUnicodeEncoder* mUnicodeEncoder; nsIUnicodeDecoder* mUnicodeDecoder; nsCOMPtr mDisplayDirectory; PRInt16 mSelectedType; nsCOMPtr mFiles; #ifdef FILEPICKER_SAVE_LAST_DIR static char mLastUsedDirectory[]; #endif }; class nsFilePanelBeOS : public BLooper, public BFilePanel { public: nsFilePanelBeOS(file_panel_mode mode, uint32 node_flavors, bool allow_multiple_selection, bool modal, bool hide_when_done); virtual ~nsFilePanelBeOS(); virtual void MessageReceived(BMessage *message); virtual void WaitForSelection(); virtual bool IsOpenSelected() { return (SelectedActivity() == OPEN_SELECTED); } virtual bool IsSaveSelected() { return (SelectedActivity() == SAVE_SELECTED); } virtual bool IsCancelSelected() { return (SelectedActivity() == CANCEL_SELECTED); } virtual uint32 SelectedActivity(); virtual BList *OpenRefs() { return &mOpenRefs; } virtual BString SaveFileName() { return mSaveFileName; } virtual entry_ref SaveDirRef() { return mSaveDirRef; } enum { NOT_SELECTED = 0, OPEN_SELECTED = 1, SAVE_SELECTED = 2, CANCEL_SELECTED = 3 }; protected: sem_id wait_sem ; uint32 mSelectedActivity; bool mIsSelected; BString mSaveFileName; entry_ref mSaveDirRef; BList mOpenRefs; }; #endif // nsFilePicker_h__