- Added wxXmlResource::GetResourceNode().
- Optimize wxString::Replace() to use an O(N) algorithm (Kuang-che Wu).
- Added support of %l format specifier to wxDateTime::ParseFormat().
+- wxImage handlers can now support multiple extensions (Ivan Krestinin).
All (Unix):
void SetName(const wxString& name) { m_name = name; }
void SetExtension(const wxString& ext) { m_extension = ext; }
+ void SetAlExtensions(const wxArrayString& exts) { m_altExtensions = exts; }
void SetType(wxBitmapType type) { m_type = type; }
void SetMimeType(const wxString& type) { m_mime = type; }
const wxString& GetName() const { return m_name; }
const wxString& GetExtension() const { return m_extension; }
+ const wxArrayString& GetAltExtensions() const { return m_altExtensions; }
wxBitmapType GetType() const { return m_type; }
const wxString& GetMimeType() const { return m_mime; }
wxString m_name;
wxString m_extension;
+ wxArrayString m_altExtensions;
wxString m_mime;
wxBitmapType m_type;
{
m_name = wxT("JPEG file");
m_extension = wxT("jpg");
+ m_altExtensions.Add(wxT("jpeg"));
+ m_altExtensions.Add(wxT("jpe"));
m_type = wxBITMAP_TYPE_JPEG;
m_mime = wxT("image/jpeg");
}
{
m_name = wxT("PNM file");
m_extension = wxT("pnm");
+ m_altExtensions.Add(wxT("ppm"));
+ m_altExtensions.Add(wxT("pgm"));
+ m_altExtensions.Add(wxT("pbm"));
m_type = wxBITMAP_TYPE_PNM;
m_mime = wxT("image/pnm");
}
{
m_name = wxT("TGA file");
m_extension = wxT("tga");
+ m_altExtensions.Add(wxT("tpic"));
m_type = wxBITMAP_TYPE_TGA;
m_mime = wxT("image/tga");
}
virtual ~wxImageHandler();
/**
- Gets the file extension associated with this handler.
+ Gets the preferred file extension associated with this handler.
+
+ @see GetAltExtensions()
*/
const wxString& GetExtension() const;
+ /**
+ Returns the other file extensions associated with this handler.
+
+ The preferred extension for this handler is returned by GetExtension().
+
+ @since 2.9.0
+ */
+ const wxArrayString& GetAltExtensions() const;
+
/**
If the image file contains more than one image and the image handler is capable
of retrieving these individually, this function will return the number of
bool verbose = true);
/**
- Sets the handler extension.
+ Sets the preferred file extension associated with this handler.
@param extension
- Handler extension.
+ File extension without leading dot.
+
+ @see SetAltExtensions()
*/
void SetExtension(const wxString& extension);
+ /**
+ Sets the alternative file extensions associated with this handler.
+
+ @param extensions
+ Array of file extensions.
+
+ @see SetExtension()
+
+ @since 2.9.0
+ */
+ void SetAltExtensions(const wxArrayString& extensions);
+
/**
Sets the handler MIME type.
while (node)
{
wxImageHandler *handler = (wxImageHandler*)node->GetData();
- if ( (handler->GetExtension().Cmp(extension) == 0) &&
- ( (bitmapType == wxBITMAP_TYPE_ANY) || (handler->GetType() == bitmapType)) )
+ if ((bitmapType == wxBITMAP_TYPE_ANY) || (handler->GetType() == bitmapType))
{
- return handler;
+ if (handler->GetExtension() == extension)
+ return handler;
+ if (handler->GetAltExtensions().Index(extension, false) != wxNOT_FOUND)
+ return handler;
}
node = node->GetNext();
}
{
wxImageHandler* Handler = (wxImageHandler*)Node->GetData();
fmts += wxT("*.") + Handler->GetExtension();
+ for (size_t i = 0; i < Handler->GetAltExtensions().size(); i++)
+ fmts += wxT(";*.") + Handler->GetAltExtensions()[i];
Node = Node->GetNext();
if ( Node ) fmts += wxT(";");
}
{
m_name = wxT("TIFF file");
m_extension = wxT("tif");
+ m_altExtensions.Add(wxT("tiff"));
m_type = wxBITMAP_TYPE_TIF;
m_mime = wxT("image/tiff");
TIFFSetWarningHandler((TIFFErrorHandler) TIFFwxWarningHandler);