Documented wxMotif filedialog limitations WRT wildcard syntax.
Modified filedialog to either extract the wildcard (if only one wildcard is present) or assert (if more than one is present). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18681 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "wx/intl.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/settings.h"
|
||||
#include "wx/tokenzr.h"
|
||||
|
||||
#ifdef __VMS__
|
||||
#pragma message disable nosimpint
|
||||
@@ -118,6 +119,14 @@ wxString wxFileSelectorEx(const char *title,
|
||||
wxString wxFileDialog::m_fileSelectorAnswer = "";
|
||||
bool wxFileDialog::m_fileSelectorReturned = FALSE;
|
||||
|
||||
static void wxFileSelClose(Widget WXUNUSED(w),
|
||||
void* WXUNUSED(client_data),
|
||||
XmAnyCallbackStruct *WXUNUSED(call_data))
|
||||
{
|
||||
wxFileDialog::m_fileSelectorAnswer = "";
|
||||
wxFileDialog::m_fileSelectorReturned = TRUE;
|
||||
}
|
||||
|
||||
void wxFileSelCancel( Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data),
|
||||
XmFileSelectionBoxCallbackStruct *WXUNUSED(cbs) )
|
||||
{
|
||||
@@ -140,6 +149,26 @@ void wxFileSelOk(Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data), XmFileSel
|
||||
}
|
||||
}
|
||||
|
||||
static wxString ParseWildCard( const wxString& wild )
|
||||
{
|
||||
static const wxChar* msg =
|
||||
_T("Motif file dialog does not understand this ")
|
||||
_T("wildcard syntax");
|
||||
|
||||
wxStringTokenizer tok( wild, _T("|") );
|
||||
|
||||
wxCHECK_MSG( tok.CountTokens() <= 2, _T("*.*"), msg );
|
||||
|
||||
if( tok.CountTokens() == 1 ) return wild;
|
||||
|
||||
// CountTokens == 2
|
||||
tok.GetNextToken();
|
||||
wxStringTokenizer tok2( tok.GetNextToken(), _T(";") );
|
||||
|
||||
wxCHECK_MSG( tok2.CountTokens() == 1, tok2.GetNextToken(), msg );
|
||||
return tok2.GetNextToken();
|
||||
}
|
||||
|
||||
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
|
||||
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
|
||||
long style, const wxPoint& pos)
|
||||
@@ -255,13 +284,15 @@ int wxFileDialog::ShowModal()
|
||||
|
||||
if (m_wildCard != "")
|
||||
{
|
||||
wxString filter("");
|
||||
// return something understandable by Motif
|
||||
wxString wildCard = ParseWildCard( m_wildCard );
|
||||
wxString filter;
|
||||
if (m_dir != "")
|
||||
filter = m_dir + wxString("/") + m_wildCard;
|
||||
filter = m_dir + wxString("/") + wildCard;
|
||||
else
|
||||
filter = m_wildCard;
|
||||
filter = wildCard;
|
||||
|
||||
XmTextSetString(filterWidget, (char*) (const char*) filter);
|
||||
XmTextSetString(filterWidget, (char*)filter.c_str());
|
||||
XmFileSelectionDoSearch(fileSel, NULL);
|
||||
}
|
||||
|
||||
@@ -281,6 +312,8 @@ int wxFileDialog::ShowModal()
|
||||
|
||||
XtAddCallback(fileSel, XmNcancelCallback, (XtCallbackProc)wxFileSelCancel, (XtPointer)NULL);
|
||||
XtAddCallback(fileSel, XmNokCallback, (XtCallbackProc)wxFileSelOk, (XtPointer)NULL);
|
||||
XtAddCallback(fileSel, XmNunmapCallback,
|
||||
(XtCallbackProc)wxFileSelClose, (XtPointer)this);
|
||||
|
||||
//#if XmVersion > 1000
|
||||
// I'm not sure about what you mean with XmVersion.
|
||||
|
||||
Reference in New Issue
Block a user