- wxCHECK_RET( pszFileName, _("NULL file name in wxSplitPath") );
-
- const char *pDot = strrchr(pszFileName, FILE_SEP_EXT);
- const char *pSepUnix = strrchr(pszFileName, FILE_SEP_PATH_UNIX);
- const char *pSepDos = strrchr(pszFileName, FILE_SEP_PATH_DOS);
-
- // take the last of the two
- size_t nPosUnix = pSepUnix ? pSepUnix - pszFileName : 0;
- size_t nPosDos = pSepDos ? pSepDos - pszFileName : 0;
- if ( nPosDos > nPosUnix )
- nPosUnix = nPosDos;
-// size_t nLen = Strlen(pszFileName);
-
- if ( pstrPath )
- *pstrPath = wxString(pszFileName, nPosUnix);
- if ( pDot ) {
- size_t nPosDot = pDot - pszFileName;
- if ( pstrName )
- *pstrName = wxString(pszFileName + nPosUnix + 1, nPosDot - nPosUnix);
- if ( pstrExt )
- *pstrExt = wxString(pszFileName + nPosDot + 1);
- }
- else {
- if ( pstrName )
- *pstrName = wxString(pszFileName + nPosUnix + 1);
- if ( pstrExt )
- pstrExt->Empty();
- }
+ descriptions.Clear();
+ filters.Clear();
+
+ wxString str(filterStr);
+
+ wxString description, filter;
+ int pos = 0;
+ while( pos != wxNOT_FOUND )
+ {
+ pos = str.Find(wxT('|'));
+ if ( pos == wxNOT_FOUND )
+ {
+ // if there are no '|'s at all in the string just take the entire
+ // string as filter and make description empty for later autocompletion
+ if ( filters.IsEmpty() )
+ {
+ descriptions.Add(wxEmptyString);
+ filters.Add(filterStr);
+ }
+ else
+ {
+ wxFAIL_MSG( _T("missing '|' in the wildcard string!") );
+ }
+
+ break;
+ }
+
+ description = str.Left(pos);
+ str = str.Mid(pos + 1);
+ pos = str.Find(wxT('|'));
+ if ( pos == wxNOT_FOUND )
+ {
+ filter = str;
+ }
+ else
+ {
+ filter = str.Left(pos);
+ str = str.Mid(pos + 1);
+ }
+
+ descriptions.Add(description);
+ filters.Add(filter);
+ }
+
+#if defined(__WXMOTIF__)
+ // split it so there is one wildcard per entry
+ for( size_t i = 0 ; i < descriptions.GetCount() ; i++ )
+ {
+ pos = filters[i].Find(wxT(';'));
+ if (pos != wxNOT_FOUND)
+ {
+ // first split only filters
+ descriptions.Insert(descriptions[i],i+1);
+ filters.Insert(filters[i].Mid(pos+1),i+1);
+ filters[i]=filters[i].Left(pos);
+
+ // autoreplace new filter in description with pattern:
+ // C/C++ Files(*.cpp;*.c;*.h)|*.cpp;*.c;*.h
+ // cause split into:
+ // C/C++ Files(*.cpp)|*.cpp
+ // C/C++ Files(*.c;*.h)|*.c;*.h
+ // and next iteration cause another split into:
+ // C/C++ Files(*.cpp)|*.cpp
+ // C/C++ Files(*.c)|*.c
+ // C/C++ Files(*.h)|*.h
+ for ( size_t k=i;k<i+2;k++ )
+ {
+ pos = descriptions[k].Find(filters[k]);
+ if (pos != wxNOT_FOUND)
+ {
+ wxString before = descriptions[k].Left(pos);
+ wxString after = descriptions[k].Mid(pos+filters[k].Len());
+ pos = before.Find(_T('('),true);
+ if (pos>before.Find(_T(')'),true))
+ {
+ before = before.Left(pos+1);
+ before << filters[k];
+ pos = after.Find(_T(')'));
+ int pos1 = after.Find(_T('('));
+ if (pos != wxNOT_FOUND && (pos<pos1 || pos1==wxNOT_FOUND))
+ {
+ before << after.Mid(pos);
+ descriptions[k] = before;
+ }
+ }
+ }
+ }
+ }
+ }
+#endif
+
+ // autocompletion
+ for( size_t j = 0 ; j < descriptions.GetCount() ; j++ )
+ {
+ if ( descriptions[j] == wxEmptyString && filters[j] != wxEmptyString )
+ {
+ descriptions[j].Printf(_("Files (%s)"), filters[j].c_str());
+ }
+ }
+
+ return filters.GetCount();