00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: t -*- */ 00002 /* AbiSource Application Framework 00003 * Copyright (C) 1998 AbiSource, Inc. 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00018 * 02110-1301 USA. 00019 */ 00020 00021 #ifndef XAP_DIALOG_FILEOPENSAVEAS_H 00022 #define XAP_DIALOG_FILEOPENSAVEAS_H 00023 00024 #include "xap_Dialog.h" 00025 class XAP_App; 00026 00027 #include <boost/bind.hpp> 00028 #include <boost/function.hpp> 00029 00030 00031 // we return some special values for file types depending 00032 // on how the derived classes do different things for different 00033 // platforms. 00034 #define XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO -1 00035 00036 /***************************************************************** 00037 ** This is the XAP and XP base-class for the file-open and 00038 ** file-save-as dialogs. 00039 *****************************************************************/ 00040 00041 class ABI_EXPORT XAP_Dialog_FileOpenSaveAs : public XAP_Dialog_AppPersistent 00042 { 00043 public: 00044 XAP_Dialog_FileOpenSaveAs(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id); 00045 virtual ~XAP_Dialog_FileOpenSaveAs(void); 00046 00047 virtual void useStart(void); 00048 virtual void runModal(XAP_Frame * pFrame) = 0; 00049 virtual void useEnd(void); 00050 00051 typedef enum { a_VOID, a_OK, a_CANCEL } tAnswer; 00052 00053 void setCurrentPathname(const std::string & pathname); 00054 void setSuggestFilename(bool); 00055 XAP_Dialog_FileOpenSaveAs::tAnswer getAnswer(void) const; 00056 const std::string & getPathname(void) const; 00057 00058 // the caller supplies three lists of equal length of descriptions for menu 00059 // labels, suffixes if the platform dialog uses them for filters, and 00060 // enumerated (any encoding, really) values for each type. 00061 void setFileTypeList(const char ** szDescriptions, 00062 const char ** szSuffixes, 00063 const UT_sint32 * nTypeList); 00064 void setDefaultFileType(UT_sint32 nType); 00065 00066 // this dialog reserves the negative number space to return an 00067 // "automatically detected" type, so the caller should NOT supply one 00068 // in the list. This is done because each platform has a different notion 00069 // of auto-detect (Windows is strictly by extension, Unix can be anything, 00070 // etc.) and XP, AP-level code shouldn't have to know 00071 // what type of suffix (ala "*.*" or "*") is appropriate. 00072 UT_sint32 getFileType(void) const; 00073 00074 typedef boost::function<std::string (std::string,UT_sint32)> m_appendDefaultSuffixFunctor_t; 00075 void setAppendDefaultSuffixFunctor( m_appendDefaultSuffixFunctor_t f ); 00076 00077 protected: 00078 std::string m_persistPathname; 00079 std::string m_initialPathname; 00080 std::string m_finalPathname; 00081 00082 const char ** m_szDescriptions; 00083 const char ** m_szSuffixes; 00084 const UT_sint32 * m_nTypeList; 00085 00086 // derived classes set this for query 00087 UT_sint32 m_nFileType; 00088 UT_sint32 m_nDefaultFileType; 00089 00090 bool m_bSuggestName; 00091 XAP_Dialog_FileOpenSaveAs::tAnswer m_answer; 00092 00093 m_appendDefaultSuffixFunctor_t m_appendDefaultSuffixFunctor; 00094 }; 00095 00096 ABI_EXPORT XAP_Dialog_FileOpenSaveAs::m_appendDefaultSuffixFunctor_t 00097 getAppendDefaultSuffixFunctorUsing_IE_Exp_preferredSuffixForFileType(); 00098 00099 #endif /* XAP_DIALOG_FILEOPENSAVEAS_H */