X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6305f044a1d4cce68128529fa939a2cc1d35df85..010d821b3138ae39c43403da64eb0bcde9af82ae:/src/generic/filectrlg.cpp diff --git a/src/generic/filectrlg.cpp b/src/generic/filectrlg.cpp index a5355661c6..1dfba4421c 100644 --- a/src/generic/filectrlg.cpp +++ b/src/generic/filectrlg.cpp @@ -3,7 +3,6 @@ // Purpose: wxGenericFileCtrl Implementation // Author: Diaa M. Sami // Created: 2007-07-07 -// RCS-ID: $Id$ // Copyright: (c) Diaa M. Sami // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -35,7 +34,7 @@ #include "wx/tokenzr.h" #include "wx/imaglist.h" -#ifdef __WXMSW__ +#ifdef __WINDOWS__ #include "wx/msw/wrapwin.h" #endif @@ -53,7 +52,7 @@ // ---------------------------------------------------------------------------- static -int wxCALLBACK wxFileDataNameCompare( long data1, long data2, wxIntPtr sortOrder) +int wxCALLBACK wxFileDataNameCompare( wxIntPtr data1, wxIntPtr data2, wxIntPtr sortOrder) { wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1); wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2); @@ -71,7 +70,7 @@ int wxCALLBACK wxFileDataNameCompare( long data1, long data2, wxIntPtr sortOrder } static -int wxCALLBACK wxFileDataSizeCompare(long data1, long data2, wxIntPtr sortOrder) +int wxCALLBACK wxFileDataSizeCompare(wxIntPtr data1, wxIntPtr data2, wxIntPtr sortOrder) { wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1); wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2); @@ -93,7 +92,7 @@ int wxCALLBACK wxFileDataSizeCompare(long data1, long data2, wxIntPtr sortOrder) } static -int wxCALLBACK wxFileDataTypeCompare(long data1, long data2, wxIntPtr sortOrder) +int wxCALLBACK wxFileDataTypeCompare(wxIntPtr data1, wxIntPtr data2, wxIntPtr sortOrder) { wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1); wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2); @@ -115,7 +114,7 @@ int wxCALLBACK wxFileDataTypeCompare(long data1, long data2, wxIntPtr sortOrder) } static -int wxCALLBACK wxFileDataTimeCompare(long data1, long data2, wxIntPtr sortOrder) +int wxCALLBACK wxFileDataTimeCompare(wxIntPtr data1, wxIntPtr data2, wxIntPtr sortOrder) { wxFileData *fd1 = (wxFileData *)wxUIntToPtr(data1); wxFileData *fd2 = (wxFileData *)wxUIntToPtr(data2); @@ -223,32 +222,39 @@ void wxFileData::ReadData() wxStructStat buff; #if defined(__UNIX__) && (!defined( __OS2__ ) && !defined(__VMS)) - lstat( m_filePath.fn_str(), &buff ); - m_type |= S_ISLNK(buff.st_mode) ? is_link : 0; + const bool hasStat = lstat( m_filePath.fn_str(), &buff ) == 0; + if ( hasStat ) + m_type |= S_ISLNK(buff.st_mode) ? is_link : 0; #else // no lstat() - wxStat( m_filePath, &buff ); + const bool hasStat = wxStat( m_filePath, &buff ) == 0; #endif - m_type |= (buff.st_mode & S_IFDIR) != 0 ? is_dir : 0; - m_type |= (buff.st_mode & wxS_IXUSR) != 0 ? is_exe : 0; + if ( hasStat ) + { + m_type |= (buff.st_mode & S_IFDIR) != 0 ? is_dir : 0; + m_type |= (buff.st_mode & wxS_IXUSR) != 0 ? is_exe : 0; - m_size = buff.st_size; + m_size = buff.st_size; - m_dateTime = buff.st_mtime; + m_dateTime = buff.st_mtime; + } #endif // __WXWINCE__ #if defined(__UNIX__) - m_permissions.Printf(wxT("%c%c%c%c%c%c%c%c%c"), - buff.st_mode & wxS_IRUSR ? wxT('r') : wxT('-'), - buff.st_mode & wxS_IWUSR ? wxT('w') : wxT('-'), - buff.st_mode & wxS_IXUSR ? wxT('x') : wxT('-'), - buff.st_mode & wxS_IRGRP ? wxT('r') : wxT('-'), - buff.st_mode & wxS_IWGRP ? wxT('w') : wxT('-'), - buff.st_mode & wxS_IXGRP ? wxT('x') : wxT('-'), - buff.st_mode & wxS_IROTH ? wxT('r') : wxT('-'), - buff.st_mode & wxS_IWOTH ? wxT('w') : wxT('-'), - buff.st_mode & wxS_IXOTH ? wxT('x') : wxT('-')); + if ( hasStat ) + { + m_permissions.Printf(wxT("%c%c%c%c%c%c%c%c%c"), + buff.st_mode & wxS_IRUSR ? wxT('r') : wxT('-'), + buff.st_mode & wxS_IWUSR ? wxT('w') : wxT('-'), + buff.st_mode & wxS_IXUSR ? wxT('x') : wxT('-'), + buff.st_mode & wxS_IRGRP ? wxT('r') : wxT('-'), + buff.st_mode & wxS_IWGRP ? wxT('w') : wxT('-'), + buff.st_mode & wxS_IXGRP ? wxT('x') : wxT('-'), + buff.st_mode & wxS_IROTH ? wxT('r') : wxT('-'), + buff.st_mode & wxS_IWOTH ? wxT('w') : wxT('-'), + buff.st_mode & wxS_IXOTH ? wxT('x') : wxT('-')); + } #elif defined(__WIN32__) DWORD attribs = ::GetFileAttributes(m_filePath.c_str()); if (attribs != (DWORD)-1) @@ -377,7 +383,7 @@ void wxFileData::MakeItem( wxListItem &item ) if (IsLink()) { wxColour dg = wxTheColourDatabase->Find( wxT("MEDIUM GREY") ); - if ( dg.Ok() ) + if ( dg.IsOk() ) item.SetTextColour(dg); } item.m_data = wxPtrToUInt(this); @@ -677,14 +683,14 @@ void wxFileListCtrl::MakeDir() wxListItem item; item.m_itemId = 0; item.m_col = 0; - long id = Add( fd, item ); + long itemid = Add( fd, item ); - if (id != -1) + if (itemid != -1) { SortItems(m_sort_field, m_sort_forward); - id = FindItem( 0, wxPtrToUInt(fd) ); - EnsureVisible( id ); - EditLabel( id ); + itemid = FindItem( 0, wxPtrToUInt(fd) ); + EnsureVisible( itemid ); + EditLabel( itemid ); } else delete fd; @@ -883,9 +889,9 @@ wxFileListCtrl::~wxFileListCtrl() // wxGenericFileCtrl implementation /////////////////////////////////////////////////////////////////////////////// -IMPLEMENT_DYNAMIC_CLASS( wxGenericFileCtrl, wxPanel ) +IMPLEMENT_DYNAMIC_CLASS( wxGenericFileCtrl, wxNavigationEnabled ) -BEGIN_EVENT_TABLE( wxGenericFileCtrl, wxPanel ) +BEGIN_EVENT_TABLE( wxGenericFileCtrl, wxNavigationEnabled ) EVT_LIST_ITEM_SELECTED( ID_FILELIST_CTRL, wxGenericFileCtrl::OnSelected ) EVT_LIST_ITEM_ACTIVATED( ID_FILELIST_CTRL, wxGenericFileCtrl::OnActivated ) EVT_CHOICE( ID_CHOICE, wxGenericFileCtrl::OnChoiceFilter ) @@ -916,7 +922,11 @@ bool wxGenericFileCtrl::Create( wxWindow *parent, wxASSERT_MSG( !( ( m_style & wxFC_SAVE ) && ( m_style & wxFC_MULTIPLE ) ), wxT( "wxFC_MULTIPLE can't be used with wxFC_SAVE" ) ); - wxPanel::Create( parent, id, pos, size, wxTAB_TRAVERSAL, name ); + wxNavigationEnabled::Create( parent, id, + pos, size, + wxTAB_TRAVERSAL, + wxDefaultValidator, + name ); m_dir = defaultDirectory;