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