Fixes to generic dir dialog
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8473 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1183,8 +1183,8 @@ BEGIN_EVENT_TABLE(wxGenericDirDialog, wxDialog)
|
|||||||
EVT_BUTTON(wxID_OK, wxGenericDirDialog::OnOK)
|
EVT_BUTTON(wxID_OK, wxGenericDirDialog::OnOK)
|
||||||
EVT_BUTTON (wxID_NEW, wxGenericDirDialog::OnNew)
|
EVT_BUTTON (wxID_NEW, wxGenericDirDialog::OnNew)
|
||||||
EVT_CLOSE(wxGenericDirDialog::OnCloseWindow)
|
EVT_CLOSE(wxGenericDirDialog::OnCloseWindow)
|
||||||
EVT_TREE_KEY_DOWN (ID_DIRCTRL, wxGenericDirDialog::OnTreeKeyDown)
|
EVT_TREE_KEY_DOWN (-1, wxGenericDirDialog::OnTreeKeyDown)
|
||||||
EVT_TREE_SEL_CHANGED (ID_DIRCTRL, wxGenericDirDialog::OnTreeSelected)
|
EVT_TREE_SEL_CHANGED (-1, wxGenericDirDialog::OnTreeSelected)
|
||||||
EVT_TEXT_ENTER (ID_TEXTCTRL, wxGenericDirDialog::OnOK)
|
EVT_TEXT_ENTER (ID_TEXTCTRL, wxGenericDirDialog::OnOK)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@@ -1192,6 +1192,9 @@ wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title,
|
|||||||
const wxString& defaultPath, long style, const wxPoint& pos, const wxSize& sz, const wxString& name):
|
const wxString& defaultPath, long style, const wxPoint& pos, const wxSize& sz, const wxString& name):
|
||||||
wxDialog(parent, ID_DIRCTRL, title, pos, sz, style, name)
|
wxDialog(parent, ID_DIRCTRL, title, pos, sz, style, name)
|
||||||
{
|
{
|
||||||
|
m_dirCtrl = NULL;
|
||||||
|
m_path = defaultPath;
|
||||||
|
|
||||||
wxBusyCursor cursor;
|
wxBusyCursor cursor;
|
||||||
|
|
||||||
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
|
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
|
||||||
@@ -1204,7 +1207,7 @@ wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title,
|
|||||||
topsizer->Add( m_dirCtrl, 1, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, 10 );
|
topsizer->Add( m_dirCtrl, 1, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, 10 );
|
||||||
|
|
||||||
// 2) text ctrl
|
// 2) text ctrl
|
||||||
m_input = new wxTextCtrl( this, ID_TEXTCTRL, wxEmptyString, wxDefaultPosition );
|
m_input = new wxTextCtrl( this, ID_TEXTCTRL, m_path, wxDefaultPosition );
|
||||||
topsizer->Add( m_input, 0, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, 10 );
|
topsizer->Add( m_input, 0, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, 10 );
|
||||||
|
|
||||||
#if wxUSE_STATLINE
|
#if wxUSE_STATLINE
|
||||||
@@ -1228,8 +1231,6 @@ wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title,
|
|||||||
okButton->SetDefault();
|
okButton->SetDefault();
|
||||||
m_dirCtrl->SetFocus();
|
m_dirCtrl->SetFocus();
|
||||||
|
|
||||||
m_input->SetValue(defaultPath);
|
|
||||||
|
|
||||||
SetAutoLayout( TRUE );
|
SetAutoLayout( TRUE );
|
||||||
SetSizer( topsizer );
|
SetSizer( topsizer );
|
||||||
|
|
||||||
@@ -1281,21 +1282,25 @@ void wxGenericDirDialog::OnOK(wxCommandEvent& event)
|
|||||||
void wxGenericDirDialog::SetPath(const wxString& path)
|
void wxGenericDirDialog::SetPath(const wxString& path)
|
||||||
{
|
{
|
||||||
m_dirCtrl->SetPath(path);
|
m_dirCtrl->SetPath(path);
|
||||||
|
m_path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxGenericDirDialog::GetPath(void) const
|
wxString wxGenericDirDialog::GetPath(void) const
|
||||||
{
|
{
|
||||||
return m_dirCtrl->GetPath();
|
return m_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxGenericDirDialog::ShowModal()
|
int wxGenericDirDialog::ShowModal()
|
||||||
{
|
{
|
||||||
m_input->SetValue( m_path );
|
//m_input->SetValue( m_path );
|
||||||
return wxDialog::ShowModal();
|
return wxDialog::ShowModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGenericDirDialog::OnTreeSelected( wxTreeEvent &event )
|
void wxGenericDirDialog::OnTreeSelected( wxTreeEvent &event )
|
||||||
{
|
{
|
||||||
|
if (!m_dirCtrl)
|
||||||
|
return;
|
||||||
|
|
||||||
wxDirItemDataEx *data = (wxDirItemDataEx*)m_dirCtrl->GetTreeCtrl()->GetItemData(event.GetItem());
|
wxDirItemDataEx *data = (wxDirItemDataEx*)m_dirCtrl->GetTreeCtrl()->GetItemData(event.GetItem());
|
||||||
if (data)
|
if (data)
|
||||||
m_input->SetValue( data->m_path );
|
m_input->SetValue( data->m_path );
|
||||||
@@ -1303,6 +1308,9 @@ void wxGenericDirDialog::OnTreeSelected( wxTreeEvent &event )
|
|||||||
|
|
||||||
void wxGenericDirDialog::OnTreeKeyDown( wxTreeEvent &WXUNUSED(event) )
|
void wxGenericDirDialog::OnTreeKeyDown( wxTreeEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
|
if (!m_dirCtrl)
|
||||||
|
return;
|
||||||
|
|
||||||
wxDirItemDataEx *data = (wxDirItemDataEx*)m_dirCtrl->GetTreeCtrl()->GetItemData(m_dirCtrl->GetTreeCtrl()->GetSelection());
|
wxDirItemDataEx *data = (wxDirItemDataEx*)m_dirCtrl->GetTreeCtrl()->GetItemData(m_dirCtrl->GetTreeCtrl()->GetSelection());
|
||||||
if (data)
|
if (data)
|
||||||
m_input->SetValue( data->m_path );
|
m_input->SetValue( data->m_path );
|
||||||
|
Reference in New Issue
Block a user