# include <time.h>
#include <unistd.h>
+#ifndef __DOS__
#include "wx/generic/home.xpm"
+#endif
#include "wx/generic/listview.xpm"
#include "wx/generic/repview.xpm"
#include "wx/generic/new_dir.xpm"
+#if wxUSE_MIMETYPE
+// VS: we don't need this function w/o wxMimeTypesManager because we'll only have
+// one icon and we won't resize it
+
static wxBitmap CreateAntialiasedBitmap(const wxImage& img)
{
wxImage small(16, 16);
return small.ConvertToBitmap();
}
-
// finds empty borders and return non-empty area of image:
static wxImage CutEmptyBorders(const wxImage& img)
{
return img.GetSubImage(wxRect(left, top, right - left + 1, bottom - top + 1));
}
+#endif // wxUSE_MIMETYPE
wxFileCtrl::wxFileCtrl()
{
+#if defined(__UNIX__)
m_dirName = wxT("/");
+#elif defined(__DOS__)
+ m_dirName = wxT("C:\\");
+#endif
m_showHidden = FALSE;
}
long my_style = GetWindowStyleFlag();
if (my_style & wxLC_REPORT)
{
+#ifdef __UNIX__
+ const int noEntries = 5;
+#else
+ const int noEntries = 4;
+#endif
ret = InsertItem( item );
- for (int i = 1; i < 5; i++) SetItem( item.m_itemId, i, fd->GetEntry( i) );
+ for (int i = 1; i < noEntries; i++)
+ SetItem( item.m_itemId, i, fd->GetEntry( i) );
}
else if (my_style & wxLC_LIST)
{
InsertColumn( 1, _("Size"), wxLIST_FORMAT_LEFT, 60 );
InsertColumn( 2, _("Date"), wxLIST_FORMAT_LEFT, 65 );
InsertColumn( 3, _("Time"), wxLIST_FORMAT_LEFT, 50 );
+#ifdef __UNIX__
InsertColumn( 4, _("Permissions"), wxLIST_FORMAT_LEFT, 120 );
+#endif
}
wxFileData *fd = (wxFileData *) NULL;
wxListItem item;
item.m_itemId++;
}
+#if defined(__UNIX__)
wxString res = m_dirName + wxT("/*");
+#elif defined(__DOS__)
+ wxString res = m_dirName + wxT("\\*.*");
+#endif
wxString f( wxFindFirstFile( res.GetData(), wxDIR ) );
while (!f.IsEmpty())
{
wxStringTokenizer tokenWild( m_wild, ";" );
while ( tokenWild.HasMoreTokens() )
{
- res = m_dirName + wxT("/") + tokenWild.GetNextToken();
+ res = m_dirName + wxFILE_SEP_PATH + tokenWild.GetNextToken();
f = wxFindFirstFile( res.GetData(), wxFILE );
while (!f.IsEmpty())
{
{
wxString new_name( wxT("NewName") );
wxString path( m_dirName );
- path += wxT("/");
+ path += wxFILE_SEP_PATH;
path += new_name;
if (wxFileExists(path))
{
new_name += num;
path = m_dirName;
- path += wxT("/");
+ path += wxFILE_SEP_PATH;
path += new_name;
i++;
} while (wxFileExists(path));
{
if (m_dirName != wxT("/"))
{
+ size_t len = m_dirName.Len();
+ if (m_dirName[len-1] == wxFILE_SEP_PATH)
+ m_dirName.Remove( len-1, 1 );
wxString fname( wxFileNameFromPath(m_dirName) );
m_dirName = wxPathOnly( m_dirName );
if (m_dirName.IsEmpty()) m_dirName = wxT("/");
if ((event.GetLabel().IsEmpty()) ||
(event.GetLabel() == _(".")) ||
(event.GetLabel() == _("..")) ||
- (event.GetLabel().First( wxT("/") ) != wxNOT_FOUND))
+ (event.GetLabel().First( wxFILE_SEP_PATH ) != wxNOT_FOUND))
{
wxMessageDialog dialog(this, _("Illegal directory name."), _("Error"), wxOK | wxICON_ERROR );
dialog.ShowModal();
}
wxString new_name( wxPathOnly( fd->GetFullName() ) );
- new_name += wxT("/");
+ new_name += wxFILE_SEP_PATH;
new_name += event.GetLabel();
wxLogNull log;
m_dialogStyle |= wxOPEN;
m_dir = defaultDir;
- if ((m_dir.IsEmpty()) || (m_dir == wxT(".")))
+ if ((m_dir.empty()) || (m_dir == wxT(".")))
{
- char buf[200];
- m_dir = getcwd( buf, sizeof(buf) );
+ m_dir = wxGetCwd();
}
- m_path = defaultDir;
- m_path += wxT("/");
+
+ size_t len = m_dir.Len();
+ if ((len > 1) && (m_dir[len-1] == wxFILE_SEP_PATH))
+ m_dir.Remove( len-1, 1 );
+
+ m_path = m_dir;
+ m_path += wxFILE_SEP_PATH;
m_path += defaultFile;
m_fileName = defaultFile;
m_wildCard = wildCard;
#endif
buttonsizer->Add( but, 0, wxALL, 5 );
+#ifndef __DOS__ // VS: Home directory is senseless in MS-DOS...
but = new wxBitmapButton( this, ID_PARENT_DIR, wxBitmap(home_xpm) );
#if wxUSE_TOOLTIPS
but->SetToolTip( _("Go to home directory") );
buttonsizer->Add( but, 0, wxALL, 5);
buttonsizer->Add( 20, 20 );
+#endif //!__DOS__
but = new wxBitmapButton( this, ID_NEW_DIR, wxBitmap(new_dir_xpm) );
#if wxUSE_TOOLTIPS
wxString dir;
m_list->GetDir( dir );
- if (dir != wxT("/")) dir += wxT("/");
+ if (dir != wxT("/")) dir += wxFILE_SEP_PATH;
dir += filename;
if (wxDirExists(dir)) return;
return;
}
+#ifdef __UNIX__
if (filename == wxT("~"))
{
m_list->GoToHomeDir();
tmp += filename;
filename = tmp;
}
+#endif // __UNIX__
if ((filename.Find(wxT('*')) != wxNOT_FOUND) ||
(filename.Find(wxT('?')) != wxNOT_FOUND))
{
- if (filename.Find(wxT('/')) != wxNOT_FOUND)
+ if (filename.Find(wxFILE_SEP_PATH) != wxNOT_FOUND)
{
wxMessageBox(_("Illegal file specification."), _("Error"), wxOK | wxICON_ERROR );
return;
return;
}
- if (dir != wxT("/")) dir += wxT("/");
+ if (dir != wxT("/")) dir += wxFILE_SEP_PATH;
if (filename[0u] != wxT('/'))
{
dir += filename;
if ( (m_dialogStyle & wxSAVE) && (m_dialogStyle & wxOVERWRITE_PROMPT) )
{
if (filename.Find( wxT('.') ) == wxNOT_FOUND ||
- filename.AfterLast( wxT('.') ).Find( wxT('/') ) != wxNOT_FOUND)
+ filename.AfterLast( wxT('.') ).Find( wxFILE_SEP_PATH ) != wxNOT_FOUND)
filename << m_filterExtension;
if (wxFileExists( filename ))
{
{
if ( !wxFileExists( filename ) )
if (filename.Find( wxT('.') ) == wxNOT_FOUND ||
- filename.AfterLast( wxT('.') ).Find( wxT('/') ) != wxNOT_FOUND)
+ filename.AfterLast( wxT('.') ).Find( wxFILE_SEP_PATH ) != wxNOT_FOUND)
filename << m_filterExtension;
if ( m_dialogStyle & wxFILE_MUST_EXIST )
wxString dir;
m_list->GetDir( dir );
- if (dir != wxT("/")) dir += wxT("/");
+ if (dir != wxT("/")) dir += wxFILE_SEP_PATH;
wxListItem item;
item.m_mask = wxLIST_MASK_TEXT;