From eaf40b230e00a249af2cc9e3b06406b3a64fd167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 19 Jan 2000 00:59:11 +0000 Subject: [PATCH] generic wxFileDialog now stores customizations to registry/dotfile if possible git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5511 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/filedlgg.h | 4 ++-- src/generic/filedlgg.cpp | 32 ++++++++++++++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/include/wx/generic/filedlgg.h b/include/wx/generic/filedlgg.h index ad2c76ab2b..aee6a30925 100644 --- a/include/wx/generic/filedlgg.h +++ b/include/wx/generic/filedlgg.h @@ -193,8 +193,8 @@ private: DECLARE_DYNAMIC_CLASS(wxFileDialog) DECLARE_EVENT_TABLE() - static long m_lastViewStyle; // list or report? - static bool m_lastShowHidden; + static long s_lastViewStyle; // list or report? + static bool s_lastShowHidden; }; // File selector - backward compatibility diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 3ff7328060..ea76456652 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -35,6 +35,7 @@ #include "wx/mimetype.h" #include "wx/image.h" #include "wx/module.h" +#include "wx/config.h" #if wxUSE_TOOLTIPS @@ -711,8 +712,8 @@ BEGIN_EVENT_TABLE(wxFileDialog,wxDialog) EVT_CHECKBOX(ID_CHECK,wxFileDialog::OnCheck) END_EVENT_TABLE() -long wxFileDialog::m_lastViewStyle = wxLC_LIST; -bool wxFileDialog::m_lastShowHidden = FALSE; +long wxFileDialog::s_lastViewStyle = wxLC_LIST; +bool wxFileDialog::s_lastShowHidden = FALSE; wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, @@ -725,6 +726,12 @@ wxFileDialog::wxFileDialog(wxWindow *parent, { wxBeginBusyCursor(); + if (wxConfig::Get(FALSE)) + { + wxConfig::Get() -> Read(wxT("/wxWindows/wxFileDialog/ViewStyle"), &s_lastViewStyle); + wxConfig::Get() -> Read(wxT("/wxWindows/wxFileDialog/ShowHidden"), &s_lastShowHidden); + } + m_message = message; m_dialogStyle = style; @@ -821,11 +828,11 @@ wxFileDialog::wxFileDialog(wxWindow *parent, if (m_dialogStyle & wxMULTIPLE) m_list = new wxFileCtrl( this, ID_LIST_CTRL, m_dir, firstWild, wxDefaultPosition, - wxSize(440,180), m_lastViewStyle | wxSUNKEN_BORDER ); + wxSize(440,180), s_lastViewStyle | wxSUNKEN_BORDER ); else m_list = new wxFileCtrl( this, ID_LIST_CTRL, m_dir, firstWild, wxDefaultPosition, - wxSize(440,180), m_lastViewStyle | wxSUNKEN_BORDER | wxLC_SINGLE_SEL ); - m_list -> ShowHidden(m_lastShowHidden); + wxSize(440,180), s_lastViewStyle | wxSUNKEN_BORDER | wxLC_SINGLE_SEL ); + m_list -> ShowHidden(s_lastShowHidden); mainsizer->Add( m_list, 1, wxEXPAND | wxLEFT|wxRIGHT, 10 ); wxBoxSizer *textsizer = new wxBoxSizer( wxHORIZONTAL ); @@ -838,7 +845,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, 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( m_lastShowHidden ); + m_check->SetValue( s_lastShowHidden ); choicesizer->Add( m_check, 0, wxCENTER|wxALL, 10 ); choicesizer->Add( new wxButton( this, wxID_CANCEL, _("Cancel") ), 0, wxCENTER | wxALL, 10 ); mainsizer->Add( choicesizer, 0, wxEXPAND ); @@ -857,7 +864,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, mainsizer->Fit( this ); mainsizer->SetSizeHints( this ); - + Centre( wxBOTH ); if (m_fileName.IsEmpty()) @@ -870,6 +877,11 @@ wxFileDialog::wxFileDialog(wxWindow *parent, wxFileDialog::~wxFileDialog() { + if (wxConfig::Get(FALSE)) + { + wxConfig::Get() -> Write(wxT("/wxWindows/wxFileDialog/ViewStyle"), s_lastViewStyle); + wxConfig::Get() -> Write(wxT("/wxWindows/wxFileDialog/ShowHidden"), s_lastShowHidden); + } } void wxFileDialog::OnChoice( wxCommandEvent &event ) @@ -889,7 +901,7 @@ void wxFileDialog::OnChoice( wxCommandEvent &event ) void wxFileDialog::OnCheck( wxCommandEvent &event ) { - m_list->ShowHidden( (m_lastShowHidden = event.GetInt() != 0) ); + m_list->ShowHidden( (s_lastShowHidden = event.GetInt() != 0) ); } void wxFileDialog::OnActivated( wxListEvent &event ) @@ -1029,14 +1041,14 @@ void wxFileDialog::OnListOk( wxCommandEvent &WXUNUSED(event) ) void wxFileDialog::OnList( wxCommandEvent &WXUNUSED(event) ) { m_list->ChangeToListMode(); - m_lastViewStyle = wxLC_LIST; + s_lastViewStyle = wxLC_LIST; m_list->SetFocus(); } void wxFileDialog::OnReport( wxCommandEvent &WXUNUSED(event) ) { m_list->ChangeToReportMode(); - m_lastViewStyle = wxLC_REPORT; + s_lastViewStyle = wxLC_REPORT; m_list->SetFocus(); }