X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/564a150b1f7c63a060c1b205a7cd50035031cd4b..e0c5c96f67eaf13ccbd378616bdf98c8dba01e78:/src/generic/filedlgg.cpp diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 69335d597f..83c51c893e 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -1,4 +1,4 @@ -///////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// // Name: filedlgg.cpp // Purpose: wxGenericFileDialog // Author: Robert Roebling @@ -23,7 +23,7 @@ #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 @@ -134,11 +134,11 @@ int wxCALLBACK wxFileDataTimeCompare( long data1, long data2, long data) 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 @@ -154,17 +154,6 @@ extern size_t wxGetAvailableDrives(wxArrayString &paths, wxArrayString &names, w // wxFileData //----------------------------------------------------------------------------- -wxFileData::wxFileData( const wxFileData& fileData ) -{ - m_fileName = fileData.GetFileName(); - m_filePath = fileData.GetFilePath(); - m_size = fileData.GetSize(); - m_dateTime = fileData.GetDateTime(); - m_permissions = fileData.GetPermissions(); - m_type = fileData.GetType(); - m_image = GetImageId(); -} - wxFileData::wxFileData( const wxString &filePath, const wxString &fileName, fileType type, int image_id ) { m_fileName = fileName; @@ -175,6 +164,17 @@ wxFileData::wxFileData( const wxString &filePath, const wxString &fileName, file ReadData(); } +void wxFileData::Copy( const wxFileData& fileData ) +{ + m_fileName = fileData.GetFileName(); + m_filePath = fileData.GetFilePath(); + m_size = fileData.GetSize(); + m_dateTime = fileData.GetDateTime(); + m_permissions = fileData.GetPermissions(); + m_type = fileData.GetType(); + m_image = GetImageId(); +} + void wxFileData::ReadData() { if (IsDrive()) @@ -183,7 +183,7 @@ void wxFileData::ReadData() return; } -#if defined(__DOS__) || defined(__WINDOWS__) +#if defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) // c:\.. is a drive don't stat it if ((m_fileName == wxT("..")) && (m_filePath.length() <= 5)) { @@ -195,7 +195,7 @@ void wxFileData::ReadData() 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() @@ -208,10 +208,13 @@ void wxFileData::ReadData() // try to get a better icon if (m_image == wxFileIconsTable::file) { - if (IsExe()) + if (m_fileName.Find(wxT('.'), TRUE) != wxNOT_FOUND) + { + m_image = wxTheFileIconsTable->GetIconID( m_fileName.AfterLast(wxT('.'))); + } else if (IsExe()) + { m_image = wxFileIconsTable::executable; - else if (m_fileName.Find(wxT('.'), TRUE) != wxNOT_FOUND) - m_image = wxTheFileIconsTable->GetIconID(m_fileName.AfterLast(wxT('.'))); + } } m_size = buff.st_size; @@ -358,6 +361,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxFileCtrl,wxListCtrl) BEGIN_EVENT_TABLE(wxFileCtrl,wxListCtrl) EVT_LIST_DELETE_ITEM(-1, wxFileCtrl::OnListDeleteItem) + EVT_LIST_DELETE_ALL_ITEMS(-1, wxFileCtrl::OnListDeleteAllItems) EVT_LIST_END_LABEL_EDIT(-1, wxFileCtrl::OnListEndLabelEdit) EVT_LIST_COL_CLICK(-1, wxFileCtrl::OnListColClick) END_EVENT_TABLE() @@ -488,14 +492,13 @@ void wxFileCtrl::UpdateFiles() wxBusyCursor bcur; // this may take a while... - FreeAllItemsData(); DeleteAllItems(); 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; @@ -505,8 +508,10 @@ void wxFileCtrl::UpdateFiles() for (n=0; nAdd( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 5 ); - wxBoxSizer *choicesizer = new wxBoxSizer( wxHORIZONTAL ); - m_choice = new wxChoice( this, ID_CHOICE ); - choicesizer->Add( m_choice, 1, wxCENTER|wxALL, 5 ); - mainsizer->Add( choicesizer, 0, wxEXPAND ); - wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL ); m_text = new wxTextCtrl( this, ID_TEXT, m_fileName, wxDefaultPosition, wxDefaultSize, wxPROCESS_ENTER ); textsizer->Add( m_text, 1, wxCENTER | wxALL, 5 ); mainsizer->Add( textsizer, 0, wxEXPAND ); - m_check = new wxCheckBox( this, ID_CHECK, _("Show hidden files") ); - m_check->SetValue( ms_lastShowHidden ); - textsizer->Add( m_check, 0, wxCENTER|wxALL, 5 ); + m_check = NULL; + m_choice = new wxChoice( this, ID_CHOICE ); + textsizer->Add( m_choice, 1, wxCENTER|wxALL, 5 ); buttonsizer = new wxBoxSizer( wxHORIZONTAL ); buttonsizer->Add( new wxButton( this, wxID_OK, _("OK") ), 0, wxCENTER | wxALL, 5 ); @@ -1040,6 +1059,18 @@ int wxGenericFileDialog::ShowModal() return wxDialog::ShowModal(); } +bool wxGenericFileDialog::Show( bool show ) +{ + if (show) + { + m_list->GoToDir(m_dir); + UpdateControls(); + m_text->SetValue(m_fileName); + } + + return wxDialog::Show( show ); +} + void wxGenericFileDialog::DoSetFilterIndex(int filterindex) { wxString *str = (wxString*) m_choice->GetClientData( filterindex ); @@ -1355,9 +1386,9 @@ void wxGenericFileDialog::UpdateControls() 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