X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/75575b6020b5501bdbd4b54346f409fce8347278..01a9232b5e06fc1e24cbd051661d37a46827379d:/src/generic/filedlgg.cpp?ds=sidebyside diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index d513ec1281..2729d5db5d 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -24,6 +24,9 @@ #endif #ifndef WX_PRECOMP + #ifdef __WXMSW__ + #include "wx/msw/wrapwin.h" + #endif #include "wx/hash.h" #include "wx/intl.h" #include "wx/settings.h" @@ -67,7 +70,6 @@ #endif #ifdef __WINDOWS__ - #include "wx/msw/wrapwin.h" #include "wx/msw/mslu.h" #endif @@ -821,8 +823,8 @@ void wxFileCtrl::OnListEndLabelEdit( wxListEvent &event ) wxASSERT( fd ); if ((event.GetLabel().empty()) || - (event.GetLabel() == _(".")) || - (event.GetLabel() == _("..")) || + (event.GetLabel() == wxT(".")) || + (event.GetLabel() == wxT("..")) || (event.GetLabel().First( wxFILE_SEP_PATH ) != wxNOT_FOUND)) { wxMessageDialog dialog(this, _("Illegal directory name."), _("Error"), wxOK | wxICON_ERROR ); @@ -994,6 +996,8 @@ bool wxGenericFileDialog::Create( wxWindow *parent, { m_bypassGenericImpl = bypassGenericImpl; + parent = GetParentForModalDialog(parent); + if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name)) { @@ -1004,7 +1008,7 @@ bool wxGenericFileDialog::Create( wxWindow *parent, return true; if (!wxDialog::Create( parent, wxID_ANY, message, pos, sz, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER, name + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | style, name )) { return false; @@ -1012,6 +1016,7 @@ bool wxGenericFileDialog::Create( wxWindow *parent, ignoreChanges = true; +#if wxUSE_CONFIG if (wxConfig::Get(false)) { wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ViewStyle"), @@ -1019,6 +1024,7 @@ bool wxGenericFileDialog::Create( wxWindow *parent, wxConfig::Get()->Read(wxT("/wxWindows/wxFileDialog/ShowHidden"), &ms_lastShowHidden); } +#endif if ((m_dir.empty()) || (m_dir == wxT("."))) { @@ -1100,7 +1106,7 @@ bool wxGenericFileDialog::Create( wxWindow *parent, mainsizer->Add( staticsizer, 0, wxEXPAND | wxLEFT|wxRIGHT|wxBOTTOM, 10 ); long style2 = ms_lastViewStyle; - if ( !HasFlag(wxFD_MULTIPLE) ) + if ( !HasFdFlag(wxFD_MULTIPLE) ) style2 |= wxLC_SINGLE_SEL; #ifdef __WXWINCE__ @@ -1114,48 +1120,50 @@ bool wxGenericFileDialog::Create( wxWindow *parent, wxDefaultPosition, wxSize(540,200), style2); + m_text = new wxTextCtrl(this, ID_TEXT, m_fileName, + wxDefaultPosition, wxDefaultSize, + wxTE_PROCESS_ENTER); + m_choice = new wxChoice(this, ID_CHOICE); + if (is_pda) { // PDAs have a different screen layout - mainsizer->Add( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 5 ); + mainsizer->Add(m_list, wxSizerFlags(1).Expand().HorzBorder()); - wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL ); - m_text = new wxTextCtrl( this, ID_TEXT, m_fileName, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); - textsizer->Add( m_text, 1, wxCENTER | wxALL, 5 ); - mainsizer->Add( textsizer, 0, wxEXPAND ); + wxBoxSizer *textsizer = new wxBoxSizer(wxHORIZONTAL); + textsizer->Add(m_text, wxSizerFlags(1).Centre().Border()); + mainsizer->Add(textsizer, wxSizerFlags().Expand()); m_check = NULL; - m_choice = new wxChoice( this, ID_CHOICE ); - textsizer->Add( m_choice, 1, wxCENTER|wxALL, 5 ); + textsizer->Add(m_choice, wxSizerFlags(1).Centre().Border()); - wxSizer *bsizer = CreateButtonSizer( wxOK|wxCANCEL , false, 5 ); - if(bsizer->GetChildren().GetCount() > 0 ) - { - mainsizer->Add( bsizer, 0, wxEXPAND | wxALL, 5 ); - } - else - { - delete bsizer; - } + wxSizer *bsizer = CreateButtonSizer(wxOK | wxCANCEL); + if ( bsizer ) + mainsizer->Add(bsizer, wxSizerFlags().Expand().Border()); } - else + else // !is_pda { - mainsizer->Add( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 10 ); - - wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL ); - m_text = new wxTextCtrl( this, ID_TEXT, m_fileName, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER ); - textsizer->Add( m_text, 1, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 ); - textsizer->Add( new wxButton( this, wxID_OK ), 0, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 ); - mainsizer->Add( textsizer, 0, wxEXPAND ); - - wxBoxSizer *choicesizer = new wxBoxSizer( wxHORIZONTAL ); - m_choice = new wxChoice( this, ID_CHOICE ); - choicesizer->Add( m_choice, 1, wxCENTER|wxALL, 10 ); - m_check = new wxCheckBox( this, ID_CHECK, _("Show hidden files") ); - m_check->SetValue( ms_lastShowHidden ); - choicesizer->Add( m_check, 0, wxCENTER|wxALL, 10 ); - choicesizer->Add( new wxButton( this, wxID_CANCEL ), 0, wxCENTER | wxALL, 10 ); - mainsizer->Add( choicesizer, 0, wxEXPAND ); + mainsizer->Add(m_list, wxSizerFlags(1).Expand().DoubleHorzBorder()); + + wxBoxSizer *textsizer = new wxBoxSizer(wxHORIZONTAL); + textsizer->Add(m_text, wxSizerFlags(1).Centre(). + DoubleBorder(wxLEFT | wxRIGHT | wxTOP)); + textsizer->Add(new wxButton(this, wxID_OK), wxSizerFlags().Centre(). + DoubleBorder(wxLEFT | wxRIGHT | wxTOP)); + mainsizer->Add(textsizer, wxSizerFlags().Expand()); + + wxSizerFlags flagsCentre; + flagsCentre.Centre().DoubleBorder(); + + wxBoxSizer *choicesizer = new wxBoxSizer(wxHORIZONTAL); + choicesizer->Add(m_choice, wxSizerFlags(flagsCentre).Proportion(1)); + + m_check = new wxCheckBox(this, ID_CHECK, _("Show &hidden files")); + m_check->SetValue(ms_lastShowHidden); + + choicesizer->Add(m_check, flagsCentre); + choicesizer->Add(new wxButton(this, wxID_CANCEL), flagsCentre); + mainsizer->Add(choicesizer, wxSizerFlags().Expand()); } SetWildcard(wildCard); @@ -1184,6 +1192,7 @@ wxGenericFileDialog::~wxGenericFileDialog() if (!m_bypassGenericImpl) { +#if wxUSE_CONFIG if (wxConfig::Get(false)) { wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ViewStyle"), @@ -1191,6 +1200,7 @@ wxGenericFileDialog::~wxGenericFileDialog() wxConfig::Get()->Write(wxT("/wxWindows/wxFileDialog/ShowHidden"), ms_lastShowHidden); } +#endif const int count = m_choice->GetCount(); for ( int i = 0; i < count; i++ ) @@ -1402,7 +1412,7 @@ void wxGenericFileDialog::HandleAction( const wxString &fn ) } #endif // __UNIX__ - if (!HasFlag(wxFD_SAVE)) + if (!HasFdFlag(wxFD_SAVE)) { if ((filename.Find(wxT('*')) != wxNOT_FOUND) || (filename.Find(wxT('?')) != wxNOT_FOUND)) @@ -1447,13 +1457,13 @@ void wxGenericFileDialog::HandleAction( const wxString &fn ) // VZ: the logic of testing for !wxFileExists() only for the open file // dialog is not entirely clear to me, why don't we allow saving to a // file without extension as well? - if ( !HasFlag(wxFD_OPEN) || !wxFileExists(filename) ) + if ( !HasFdFlag(wxFD_OPEN) || !wxFileExists(filename) ) { filename = AppendExtension(filename, m_filterExtension); } // check that the file [doesn't] exist if necessary - if ( HasFlag(wxFD_SAVE) && HasFlag(wxFD_OVERWRITE_PROMPT) && + if ( HasFdFlag(wxFD_SAVE) && HasFdFlag(wxFD_OVERWRITE_PROMPT) && wxFileExists( filename ) ) { wxString msg; @@ -1462,17 +1472,19 @@ void wxGenericFileDialog::HandleAction( const wxString &fn ) if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES) return; } - else if ( HasFlag(wxFD_OPEN) && HasFlag(wxFD_FILE_MUST_EXIST) && + else if ( HasFdFlag(wxFD_OPEN) && HasFdFlag(wxFD_FILE_MUST_EXIST) && !wxFileExists(filename) ) { wxMessageBox(_("Please choose an existing file."), _("Error"), wxOK | wxICON_ERROR ); + + return; } SetPath( filename ); // change to the directory where the user went if asked - if ( HasFlag(wxFD_CHANGE_DIR) ) + if ( HasFdFlag(wxFD_CHANGE_DIR) ) { wxString cwd; wxSplitPath(filename, &cwd, NULL, NULL); @@ -1627,10 +1639,10 @@ void wxGenericFileDialog::UpdateControls() #endif // defined(__DOS__) || defined(__WINDOWS__) || defined(__OS2__) } -#ifdef wxUSE_GENERIC_FILEDIALOG +#ifdef wxHAS_GENERIC_FILEDIALOG IMPLEMENT_DYNAMIC_CLASS(wxFileDialog, wxGenericFileDialog) -#endif // wxUSE_GENERIC_FILEDIALOG +#endif // wxHAS_GENERIC_FILEDIALOG #endif // wxUSE_FILEDLG