From 939fadc8aab8cc85906685ed6cdcb46d28f27903 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 1 Jun 2003 16:10:17 +0000 Subject: [PATCH] Applied patch [ 710608 ] wxImage::GetImageExtWildcard for image load/save dialogs. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20824 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/image.tex | 25 ++++++++++++++++++++++++- include/wx/image.h | 2 ++ src/common/image.cpp | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/docs/latex/wx/image.tex b/docs/latex/wx/image.tex index 77cc3231c7..378663ced1 100644 --- a/docs/latex/wx/image.tex +++ b/docs/latex/wx/image.tex @@ -29,7 +29,7 @@ alpha value with \helpref{HasAlpha}{wximagehasalpha}. In fact, currently only images loaded from PNG files with transparency information will have alpha channel but support for it will be added to the other formats as well (as well as support for saving images with alpha channel which is not still implemented -neither). +either). \wxheading{Available image handlers} @@ -355,6 +355,29 @@ A pointer to the handler if found, NULL otherwise. \helpref{wxImageHandler}{wximagehandler} +\membersection{wxImage::GetImageExtWildcard} + +\func{static wxString}{GetImageExtWildcard}{\void} + +Iterates all registered wxImageHandler objects, and returns a string containing file extension masks +suitable for passing to file open/save dialog boxes. + +\wxheading{Return value} + +The format of the returned string is "(*.ext1;*.ext2)|*.ext1;*.ext2". + +It is usually a good idea to prepend a description before passing the result to the dialog. + +Example: + +\begin{verbatim} + wxFileDialog FileDlg( this, "Choose Image", ::wxGetWorkingDirectory(), "", _("Image Files ") + wxImage::GetImageExtWildcard(), wxOPEN ); +\end{verbatim} + +\wxheading{See also} + +\helpref{wxImageHandler}{wximagehandler} + \membersection{wxImage::GetAlpha}\label{wximagegetalpha} \constfunc{unsigned char}{GetAlpha}{\param{int}{ x}, \param{int}{ y}} diff --git a/include/wx/image.h b/include/wx/image.h index 12a0223cc7..9253a4bdb4 100644 --- a/include/wx/image.h +++ b/include/wx/image.h @@ -306,6 +306,8 @@ public: static wxImageHandler *FindHandler( long imageType ); static wxImageHandler *FindHandlerMime( const wxString& mimetype ); + static wxString GetImageExtWildcard(); + static void CleanUpHandlers(); static void InitStandardHandlers(); diff --git a/src/common/image.cpp b/src/common/image.cpp index 14b9e91fe3..10035ce965 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -1390,6 +1390,24 @@ void wxImage::CleanUpHandlers() } +wxString wxImage::GetImageExtWildcard() +{ + wxString fmts; + + wxList& Handlers = wxImage::GetHandlers(); + wxNode* Node = Handlers.GetFirst(); + while ( Node ) + { + wxImageHandler* Handler = (wxImageHandler*)Node->GetData(); + fmts += wxT("*.") + Handler->GetExtension(); + Node = Node->GetNext(); + if ( Node ) fmts += wxT(";"); + } + + return wxT("(") + fmts + wxT(")|") + fmts; +} + + //----------------------------------------------------------------------------- // wxImageHandler //----------------------------------------------------------------------------- -- 2.45.2