Debian Codegraph @

src/af/xap/xp/xap_Dlg_FileOpenSaveAs.h

raw
1 /* AbiSource Application Framework
2 * Copyright (C) 1998 AbiSource, Inc.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #ifndef XAP_DIALOG_FILEOPENSAVEAS_H
21 #define XAP_DIALOG_FILEOPENSAVEAS_H
22
23 #include "xap_Dialog.h"
24 class XAP_App;
25
26 #include <boost/bind.hpp>
27 #include <boost/function.hpp>
28
29
30 // we return some special values for file types depending
31 // on how the derived classes do different things for different
32 // platforms.
33 #define XAP_DIALOG_FILEOPENSAVEAS_FILE_TYPE_AUTO -1
34
35 /*****************************************************************
36 ** This is the XAP and XP base-class for the file-open and
37 ** file-save-as dialogs.
38 *****************************************************************/
39
40 class ABI_EXPORT XAP_Dialog_FileOpenSaveAs : public XAP_Dialog_AppPersistent
41 {
42 public:
43 XAP_Dialog_FileOpenSaveAs(XAP_DialogFactory * pDlgFactory, XAP_Dialog_Id id);
44 virtual ~XAP_Dialog_FileOpenSaveAs(void);
45
46 virtual void useStart(void);
47 virtual void runModal(XAP_Frame * pFrame) = 0;
48 virtual void useEnd(void);
49
50 typedef enum { a_VOID, a_OK, a_CANCEL } tAnswer;
51
52 void setCurrentPathname(const char * szPathname);
53 void setSuggestFilename(bool);
54 XAP_Dialog_FileOpenSaveAs::tAnswer getAnswer(void) const;
55 const char * getPathname(void) const;
56
57 // the caller supplies three lists of equal length of descriptions for menu
58 // labels, suffixes if the platform dialog uses them for filters, and
59 // enumerated (any encoding, really) values for each type.
60 void setFileTypeList(const char ** szDescriptions,
61 const char ** szSuffixes,
62 const UT_sint32 * nTypeList);
63 void setDefaultFileType(UT_sint32 nType);
64
65 // this dialog reserves the negative number space to return an
66 // "automatically detected" type, so the caller should NOT supply one
67 // in the list. This is done because each platform has a different notion
68 // of auto-detect (Windows is strictly by extension, Unix can be anything,
69 // etc.) and XP, AP-level code shouldn't have to know
70 // what type of suffix (ala "*.*" or "*") is appropriate.
71 UT_sint32 getFileType(void) const;
72
73 typedef boost::function<std::string (std::string,UT_sint32)> m_appendDefaultSuffixFunctor_t;
74 void setAppendDefaultSuffixFunctor( m_appendDefaultSuffixFunctor_t f );
75
76 protected:
77 char * m_szPersistPathname;
78 char * m_szInitialPathname;
79 char * m_szFinalPathname;
80
81 const char ** m_szDescriptions;
82 const char ** m_szSuffixes;
83 const UT_sint32 * m_nTypeList;
84
85 // derived classes set this for query
86 UT_sint32 m_nFileType;
87 UT_sint32 m_nDefaultFileType;
88
89 bool m_bSuggestName;
90 XAP_Dialog_FileOpenSaveAs::tAnswer m_answer;
91
92 m_appendDefaultSuffixFunctor_t m_appendDefaultSuffixFunctor;
93 };
94
95 ABI_EXPORT XAP_Dialog_FileOpenSaveAs::m_appendDefaultSuffixFunctor_t
96 getAppendDefaultSuffixFunctorUsing_IE_Exp_preferredSuffixForFileType();
97
98 #endif /* XAP_DIALOG_FILEOPENSAVEAS_H */