mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-09-28 15:50:17 +08:00
added wxFileType::GetMimeTypes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5601 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -125,6 +125,16 @@ The destructor of this class is not virtual, so it should not be derived from.
|
||||
If the function returns TRUE, the string pointed to by {\it mimeType} is filled
|
||||
with full MIME type specification for this file type: for example, "text/plain".
|
||||
|
||||
\membersection{wxFileType::GetMimeTypes}\label{wxfiletypegetmimetypes}
|
||||
|
||||
\func{bool}{GetMimeType}{\param{wxArrayString&}{ mimeTypes}}
|
||||
|
||||
Same as \helpref{GetMimeType}{wxfiletypegetmimetype} but returns array of MIME
|
||||
types. This array will contain only one item in most cases but sometimes,
|
||||
notably under Unix with KDE, may contain more MIME types. This happens when
|
||||
one file extension is mapped to different MIME types by KDE, mailcap and
|
||||
mime.types.
|
||||
|
||||
\membersection{wxFileType::GetExtensions}\label{wxfiletypegetextensions}
|
||||
|
||||
\func{bool}{GetExtensions}{\param{wxArrayString\&}{ extensions}}
|
||||
|
||||
@@ -51,6 +51,7 @@ public:
|
||||
// implement accessor functions
|
||||
bool GetExtensions(wxArrayString& extensions);
|
||||
bool GetMimeType(wxString *mimeType) const;
|
||||
bool GetMimeTypes(wxArrayString& mimeTypes) const;
|
||||
bool GetIcon(wxIcon *icon) const;
|
||||
bool GetDescription(wxString *desc) const;
|
||||
bool GetOpenCommand(wxString *openCmd,
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
// parameters are unchanged)
|
||||
// return the MIME type for this file type
|
||||
bool GetMimeType(wxString *mimeType) const;
|
||||
bool GetMimeTypes(wxArrayString& mimeTypes) const;
|
||||
// fill passed in array with all extensions associated with this file
|
||||
// type
|
||||
bool GetExtensions(wxArrayString& extensions);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/mimetype.h
|
||||
// Name: wx/msw/mimetype.h
|
||||
// Purpose: classes and functions to manage MIME types
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
@@ -43,6 +43,7 @@ public:
|
||||
// implement accessor functions
|
||||
bool GetExtensions(wxArrayString& extensions);
|
||||
bool GetMimeType(wxString *mimeType) const;
|
||||
bool GetMimeTypes(wxArrayString& mimeTypes) const;
|
||||
bool GetIcon(wxIcon *icon) const;
|
||||
bool GetDescription(wxString *desc) const;
|
||||
bool GetOpenCommand(wxString *openCmd,
|
||||
|
||||
@@ -76,20 +76,23 @@ private:
|
||||
static ArrayIconHandlers ms_iconHandlers;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class WXDLLEXPORT wxFileTypeImpl
|
||||
{
|
||||
public:
|
||||
// initialization functions
|
||||
void Init(wxMimeTypesManagerImpl *manager, size_t index)
|
||||
{ m_manager = manager; m_index = index; }
|
||||
{ m_manager = manager; m_index.Add(index); }
|
||||
|
||||
// accessors
|
||||
bool GetExtensions(wxArrayString& extensions);
|
||||
bool GetMimeType(wxString *mimeType) const
|
||||
{ *mimeType = m_manager->m_aTypes[m_index]; return TRUE; }
|
||||
{ *mimeType = m_manager->m_aTypes[m_index[0]]; return TRUE; }
|
||||
bool GetMimeTypes(wxArrayString& mimeTypes) const;
|
||||
bool GetIcon(wxIcon *icon) const;
|
||||
bool GetDescription(wxString *desc) const
|
||||
{ *desc = m_manager->m_aDescriptions[m_index]; return TRUE; }
|
||||
{ *desc = m_manager->m_aDescriptions[m_index[0]]; return TRUE; }
|
||||
|
||||
bool GetOpenCommand(wxString *openCmd,
|
||||
const wxFileType::MessageParameters& params) const
|
||||
@@ -113,7 +116,7 @@ private:
|
||||
bool open) const;
|
||||
|
||||
wxMimeTypesManagerImpl *m_manager;
|
||||
size_t m_index; // in the wxMimeTypesManagerImpl arrays
|
||||
wxArrayInt m_index; // in the wxMimeTypesManagerImpl arrays
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -217,6 +217,11 @@ bool wxFileType::GetMimeType(wxString *mimeType) const
|
||||
return m_impl->GetMimeType(mimeType);
|
||||
}
|
||||
|
||||
bool wxFileType::GetMimeTypes(wxArrayString& mimeTypes) const
|
||||
{
|
||||
return m_impl->GetMimeTypes(mimeTypes);
|
||||
}
|
||||
|
||||
bool wxFileType::GetIcon(wxIcon *icon) const
|
||||
{
|
||||
return m_impl->GetIcon(icon);
|
||||
|
||||
@@ -73,6 +73,20 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
|
||||
{
|
||||
wxString s;
|
||||
|
||||
if (GetMimeType(&s))
|
||||
{
|
||||
mimeTypes.Clear();
|
||||
mimeTypes.Add(s);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
|
||||
{
|
||||
// no such file type or no value or incorrect icon entry
|
||||
|
||||
@@ -73,6 +73,20 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
|
||||
{
|
||||
wxString s;
|
||||
|
||||
if (GetMimeType(&s))
|
||||
{
|
||||
mimeTypes.Clear();
|
||||
mimeTypes.Add(s);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
|
||||
{
|
||||
// no such file type or no value or incorrect icon entry
|
||||
|
||||
+17
-1
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: common/mimetype.cpp
|
||||
// Name: msw/mimetype.cpp
|
||||
// Purpose: classes and functions to manage MIME types
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
@@ -235,6 +235,22 @@ bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool wxFileTypeImpl::GetMimeTypes(wxArrayString& mimeTypes) const
|
||||
{
|
||||
wxString s;
|
||||
|
||||
if (GetMimeType(&s))
|
||||
{
|
||||
mimeTypes.Clear();
|
||||
mimeTypes.Add(s);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
|
||||
{
|
||||
#if wxUSE_GUI
|
||||
|
||||
+167
-29
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user