00001
00002
00003
00004
00005
00006
00007
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __filetypes_h__
00019 #define __filetypes_h__
00020
00021 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
00022 #pragma interface
00023 #endif
00024
00025 #include "wx/defs.h"
00026
00027 #ifndef WX_PRECOMP
00028 #include <wx/wx.h>
00029 #endif
00030
00031 #include <wx/filename.h>
00032 #include <wx/image.h>
00033
00034
00035
00036
00037
00038
00039
00040 #if _MSC_VER > 1000
00041 # pragma warning (disable : 4786) // identifier was truncated to '255' characters in the browser information
00042 #endif // _MSC_VER > 1000
00043
00044 #include <map>
00045
00046 typedef std::map<wxString, wxString> ExtraVerbs;
00047
00048 class wxFileType2
00049 {
00050 public:
00051
00052 wxFileType2(const wxString& sNewName);
00053
00054
00055 wxFileType2();
00056
00057 public:
00058 bool IsValid() const;
00059 bool IsExecutable() const;
00060
00061
00062 wxString GetName() const;
00063 void SetName(const wxString& sNewName);
00064 wxString GetDescription() const;
00065 void SetDescription(const wxString& sNewDescription);
00066 wxIcon GetIcon() const;
00067 wxFileName GetIconPath(long * nIndex = NULL) const;
00068 void SetIconPath(const wxFileName& fnmIcon, const long& nIndex = 0);
00069 wxString GetDefaultCommand() const;
00070 void SetDefaultCommand(const wxString& sNewDefaultCommand);
00071 wxString GetVerb(const wxString& sVerb) const;
00072 void SetVerb(const wxString& sVerb, const wxString& sValue);
00073 void DeleteVerb(const wxString& sVerb);
00074 wxArrayString GetExtensions() const;
00075 void SetExtensions(const wxArrayString& asNewExtensions);
00076
00077
00078 static bool IsExecutable(const wxString& sFileType);
00079
00080 private:
00081 wxString sName;
00082 wxString sDescription;
00083 wxIconLocation icl;
00084 wxString sCommand;
00085 wxArrayString asExtensions;
00086 ExtraVerbs exv;
00087 };
00088
00089 class wxFileTypesImpl
00090 {
00091 public:
00092 virtual ~wxFileTypesImpl()
00093 {};
00094
00095
00096
00097 virtual bool IsLoaded() const = 0;
00098 virtual wxString GetFileType(const wxString& sFileURL) const = 0;
00099 virtual wxFileType2 LoadFileType(const wxString& sFileType) const = 0;
00100 virtual bool SaveFileType(const wxFileType2& fti) const = 0;
00101
00102
00103 virtual wxArrayString GetApplications(const wxString& sFileURL) const = 0;
00104 virtual bool AddApplication(const wxString& sFileURL, const wxString& sNewApplicationId) const = 0;
00105 virtual bool RemoveApplication(const wxString& sFileURL, const wxString& sApplicationId) const = 0;
00106 virtual wxString GetCommand(const wxString& sApplicationId) const = 0;
00107 virtual bool SetCommand(const wxString& sApplicationId, const wxString& sNewCommand) const = 0;
00108 };
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 enum wxFileTypeSource
00123 {
00124 wxFILE_TYPE_SOURCE_DEFAULT = 0,
00125 wxFILE_TYPE_SOURCE_MAILCAP = 1,
00126 wxFILE_TYPE_SOURCE_GNOME = 2,
00127 wxFILE_TYPE_SOURCE_KDE = 3,
00128 wxFILE_TYPE_SOURCE_WINDOWSREGISTRY = 4,
00129 };
00130
00131 class wxFileTypesManager
00132 {
00133 public:
00134 wxFileTypesManager(const wxFileTypeSource& src = wxFILE_TYPE_SOURCE_DEFAULT);
00135 ~wxFileTypesManager();
00136
00137 public:
00138 bool IsLoaded() const;
00139 wxString GetFileType(const wxString& sFileURL) const;
00140 wxFileType2 LoadFileType(const wxString& sFileType) const;
00141 bool SaveFileType(const wxFileType2& fti) const;
00142
00143 wxArrayString GetApplications(const wxString& sFileURL) const;
00144 bool AddApplication(const wxString& sFileURL, const wxString& sNewApplicationId) const;
00145 bool RemoveApplication(const wxString& sFileURL, const wxString& sApplicationId) const;
00146 wxString GetCommand(const wxString& sApplicationId) const;
00147 bool SetCommand(const wxString& sApplicationId, const wxString& sNewCommand) const;
00148
00149 private:
00150 wxFileTypesImpl * m_pImpl;
00151 };
00152
00153 #ifdef __UNIX__
00154 #ifdef __WXGTK__
00155 #include <wx/gtk/gnome/gnomefiletypes.h>
00156 #endif
00157
00158 #endif
00159
00160 #ifdef __WXMSW__
00161 #include <wx/msw/mswfiletypes.h>
00162 #endif
00163
00164
00165 #endif
00166