// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "filedlgg.h"
#endif
#if wxUSE_FILEDLG
// NOTE : it probably also supports MAC, untested
-#if !defined(__UNIX__) && !defined(__DOS__) && !defined(__WIN32__)
+#if !defined(__UNIX__) && !defined(__DOS__) && !defined(__WIN32__) && !defined(__OS2__)
#error wxGenericFileDialog currently only supports Unix, win32 and DOS
#endif
#endif
#endif
+#ifdef __WINDOWS__
+ #include "wx/msw/wrapwin.h"
+ #include "wx/msw/mslu.h"
+#endif
+
#ifdef __WATCOMC__
#include <direct.h>
#endif
// ----------------------------------------------------------------------------
static
-int wxFileDataNameCompare( long data1, long data2, long data)
+int wxCALLBACK wxFileDataNameCompare( long data1, long data2, long data)
{
wxFileData *fd1 = (wxFileData*)data1;
wxFileData *fd2 = (wxFileData*)data2;
}
static
-int wxFileDataSizeCompare( long data1, long data2, long data)
+int wxCALLBACK wxFileDataSizeCompare( long data1, long data2, long data)
{
wxFileData *fd1 = (wxFileData*)data1;
wxFileData *fd2 = (wxFileData*)data2;
}
static
-int wxFileDataTypeCompare( long data1, long data2, long data)
+int wxCALLBACK wxFileDataTypeCompare( long data1, long data2, long data)
{
wxFileData *fd1 = (wxFileData*)data1;
wxFileData *fd2 = (wxFileData*)data2;
}
static
-int wxFileDataTimeCompare( long data1, long data2, long data)
+int wxCALLBACK wxFileDataTimeCompare( long data1, long data2, long data)
{
wxFileData *fd1 = (wxFileData*)data1;
wxFileData *fd2 = (wxFileData*)data2;
return fd1->GetDateTime().IsLaterThan(fd2->GetDateTime()) ? int(data) : -int(data);
}
-#ifdef __UNIX__
+#if defined(__UNIX__) && !defined(__OS2__)
#define IsTopMostDir(dir) (dir == wxT("/"))
#endif
-#if defined(__DOS__) || defined(__WINDOWS__)
+#if defined(__DOS__) || defined(__WINDOWS__) || defined (__OS2__)
#define IsTopMostDir(dir) (dir.IsEmpty())
#endif
return;
}
-#if defined(__DOS__) || defined(__WINDOWS__)
+#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
// c:\.. is a drive don't stat it
- if ((fileName == wxT("..")) && (filePath.length() <= 5))
+ if ((m_fileName == wxT("..")) && (m_filePath.length() <= 5))
{
m_type = is_drive;
m_size = 0;
wxStructStat buff;
-#if defined(__UNIX__) && (!defined( __EMX__ ) && !defined(__VMS))
+#if defined(__UNIX__) && (!defined( __OS2__ ) && !defined(__VMS))
lstat( m_filePath.fn_str(), &buff );
m_type |= S_ISLNK( buff.st_mode ) != 0 ? is_link : 0;
#else // no lstat()
buff.st_mode & wxS_IWOTH ? _T('w') : _T('-'),
buff.st_mode & wxS_IXOTH ? _T('x') : _T('-'));
#elif defined(__WIN32__)
- DWORD attribs = GetFileAttributes(filePath);
+ DWORD attribs = GetFileAttributes(m_filePath);
if (attribs != (DWORD)-1)
{
m_permissions.Printf(_T("%c%c%c%c"),
if (IsLink())
{
- wxColour *dg = wxTheColourDatabase->FindColour( _T("MEDIUM GREY") );
- item.SetTextColour(*dg);
+ wxColour dg = wxTheColourDatabase->Find( _T("MEDIUM GREY") );
+ if ( dg.Ok() )
+ item.SetTextColour(dg);
}
item.m_data = (long)this;
}
FreeAllItemsData();
DeleteAllItems();
- wxFileData *fd = (wxFileData *) NULL;
wxListItem item;
item.m_itemId = 0;
item.m_col = 0;
-#if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXMAC__) || defined(__WXPM__)
+#if defined(__WINDOWS__) || defined(__DOS__) || defined(__WXMAC__) || defined(__OS2__)
if ( IsTopMostDir(m_dirName) )
{
wxArrayString names, paths;
for (n=0; n<count; n++)
{
- fd = new wxFileData(paths[n], names[n], wxFileData::is_drive, icons[n]);
+ wxFileData *fd = new wxFileData(paths[n], names[n], wxFileData::is_drive, icons[n]);
Add(fd, item);
item.m_itemId++;
}
if ( !IsTopMostDir(m_dirName) )
{
wxString p(wxPathOnly(m_dirName));
-#ifdef __UNIX__
+#if defined(__UNIX__) && !defined(__OS2__)
if (p.IsEmpty()) p = wxT("/");
#endif // __UNIX__
- fd = new wxFileData(p, wxT(".."), wxFileData::is_dir, wxFileIconsTable::folder);
+ wxFileData *fd = new wxFileData(p, wxT(".."), wxFileData::is_dir, wxFileIconsTable::folder);
Add(fd, item);
item.m_itemId++;
}
wxString dirname(m_dirName);
-#if defined(__DOS__) || defined(__WINDOWS__)
+#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
if (dirname.length() == 2 && dirname[1u] == wxT(':'))
dirname << wxT('\\');
-#endif // defined(__DOS__) || defined(__WINDOWS__)
+#endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
wxDir dir(dirname);
if ( dir.IsOpened() )
cont = dir.GetFirst(&f, wxEmptyString, wxDIR_DIRS | hiddenFlag);
while (cont)
{
- fd = new wxFileData(dirPrefix + f, f, wxFileData::is_dir, wxFileIconsTable::folder);
+ wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_dir, wxFileIconsTable::folder);
Add(fd, item);
item.m_itemId++;
cont = dir.GetNext(&f);
wxDIR_FILES | hiddenFlag);
while (cont)
{
- fd = new wxFileData(dirPrefix + f, f, wxFileData::is_file, wxFileIconsTable::file);
+ wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_file, wxFileIconsTable::file);
Add(fd, item);
item.m_itemId++;
cont = dir.GetNext(&f);
m_dirName.Remove( len-1, 1 );
wxString fname( wxFileNameFromPath(m_dirName) );
m_dirName = wxPathOnly( m_dirName );
-#if defined(__DOS__) || defined(__WINDOWS__)
+#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
if (!m_dirName.IsEmpty())
{
if (m_dirName.Last() == wxT('.'))
#define ID_ACTIVATED (wxID_FILEDLGG + 11)
#define ID_CHECK (wxID_FILEDLGG + 12)
-IMPLEMENT_DYNAMIC_CLASS(wxGenericFileDialog,wxDialog)
+IMPLEMENT_DYNAMIC_CLASS(wxGenericFileDialog, wxFileDialogBase)
BEGIN_EVENT_TABLE(wxGenericFileDialog,wxDialog)
EVT_BUTTON(ID_LIST_MODE, wxGenericFileDialog::OnList)
const wxString& wildCard,
long style,
const wxPoint& pos )
- : wxDialog( parent, -1, message, pos, wxDefaultSize,
- wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
+ :wxFileDialogBase(parent, message, defaultDir, defaultFile, wildCard, style, pos)
{
+ wxDialog::Create( parent, -1, message, pos, wxDefaultSize,
+ wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER );
+
if (wxConfig::Get(FALSE))
{
wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ViewStyle"),
&ms_lastShowHidden);
}
- m_message = message;
- m_dialogStyle = style;
-
if (m_dialogStyle == 0)
m_dialogStyle = wxOPEN;
if ((m_dialogStyle & wxMULTIPLE ) && !(m_dialogStyle & wxOPEN))
m_dialogStyle |= wxOPEN;
- m_dir = defaultDir;
if ((m_dir.empty()) || (m_dir == wxT(".")))
{
m_dir = wxGetCwd();
m_path = m_dir;
m_path += wxFILE_SEP_PATH;
m_path += defaultFile;
- m_fileName = defaultFile;
- m_wildCard = wildCard;
- m_filterIndex = 0;
m_filterExtension = wxEmptyString;
// interpret wildcards
-
- if (m_wildCard.IsEmpty())
- m_wildCard = _("All files (*)|*");
-
wxArrayString wildDescriptions, wildFilters;
- int wild_count = wxParseFileFilter(m_wildCard, wildDescriptions, wildFilters);
-
- wxASSERT_MSG(wild_count > 0, wxT("Wrong file type descripition") );
-
- // if error parsing, add default back
- if (wildFilters.GetCount() < 1u)
+ if ( !ParseWildcard(m_wildCard, wildDescriptions, wildFilters) )
{
- wild_count = 1;
- m_wildCard = _("All files (*)|*");
- wildDescriptions.Add(_("All files (*)"));
- wildFilters.Add(wxT("*"));
+ wxFAIL_MSG( wxT("Wrong file type description") );
}
// layout
// file without extension as well?
if ( !(m_dialogStyle & wxOPEN) || !wxFileExists(filename) )
{
- wxString ext;
- wxSplitPath(filename, NULL, NULL, &ext);
- if ( ext.empty() )
- {
- // append the first extension of the filter string
- filename += m_filterExtension.BeforeFirst(_T(';'));
- }
+ filename = AppendExtension(filename, m_filterExtension);
}
// check that the file [doesn't] exist if necessary
wxFileExists( filename ) )
{
wxString msg;
- msg.Printf( _("File '%s' already exists, do you really want to "
- "overwrite it?"), filename.c_str() );
+ msg.Printf( _("File '%s' already exists, do you really want to overwrite it?"), filename.c_str() );
if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES)
return;
wxString cwd;
wxSplitPath(filename, &cwd, NULL, NULL);
- if ( cwd != wxGetWorkingDirectory() )
+ if ( cwd != wxGetCwd() )
{
wxSetWorkingDirectory(cwd);
}
bool enable = !IsTopMostDir(dir);
m_upDirButton->Enable(enable);
-#if defined(__DOS__) || defined(__WINDOWS__)
+#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
m_newDirButton->Enable(enable);
-#endif // defined(__DOS__) || defined(__WINDOWS__)
+#endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__)
}
#ifdef USE_GENERIC_FILEDIALOG