X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0d1f53ca16a9a794a7660561a5c5b4632f8675e0..dcbd3762e86258781ed81202977f680665190528:/src/generic/dirdlgg.cpp diff --git a/src/generic/dirdlgg.cpp b/src/generic/dirdlgg.cpp index dc756a642c..9009fa3757 100644 --- a/src/generic/dirdlgg.cpp +++ b/src/generic/dirdlgg.cpp @@ -58,7 +58,7 @@ static const int ID_GO_HOME = 1006; // --------------------------------------------------------------------------- /* Macro for avoiding #ifdefs when value have to be different depending on size of - device we display on + device we display on - take it from something like wxDesktopPolicy in the future */ #if defined(__SMARTPHONE__) @@ -100,10 +100,22 @@ wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title, wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); - // Smartphone does not have buttons + // smart phones does not support or do not waste space for wxButtons #if defined(__SMARTPHONE__) - // FIXME: make 'new dir' and 'home' in local dialog menu + wxMenu *dirMenu = new wxMenu; + dirMenu->Append(ID_GO_HOME, _("Home")); + + if (style & wxDD_NEW_DIR_BUTTON) + { + dirMenu->Append(ID_NEW, _("New directory")); + } + + dirMenu->AppendCheckItem(ID_SHOW_HIDDEN, _("Show hidden directories")); + dirMenu->AppendSeparator(); + dirMenu->Append(wxID_CANCEL, _("Cancel")); + + SetRightMenu(wxID_ANY, _("Options"), dirMenu); #else @@ -170,11 +182,7 @@ wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title, m_input = new wxTextCtrl( this, ID_TEXTCTRL, m_path, wxDefaultPosition ); topsizer->Add( m_input, 0, wxTOP|wxLEFT|wxRIGHT | wxEXPAND, wxLARGESMALL(10,0) ); -#ifdef __SMARTPHONE__ - - SetRightMenu(wxID_CANCEL, _("Cancel")); - -#else // __SMARTPHONE__/!__SMARTPHONE__ +#ifndef __SMARTPHONE__ #if wxUSE_STATLINE // 3) Static line @@ -182,21 +190,11 @@ wxGenericDirDialog::wxGenericDirDialog(wxWindow* parent, const wxString& title, #endif // 4) Buttons - buttonsizer = new wxBoxSizer( wxHORIZONTAL ); - - // OK and Cancel button should be at the right bottom - wxButton* okButton = new wxButton(this, wxID_OK); - buttonsizer->Add( okButton, 0, wxLEFT|wxRIGHT, 10 ); - wxButton* cancelButton = new wxButton(this, wxID_CANCEL); - buttonsizer->Add( cancelButton, 0, wxLEFT|wxRIGHT, 10 ); - - topsizer->Add( buttonsizer, 0, wxLEFT|wxTOP|wxBOTTOM | wxALIGN_RIGHT, 10 ); - - okButton->SetDefault(); + topsizer->Add( CreateButtonSizer( wxOK|wxCANCEL ), 0, wxEXPAND | wxALL, 10 ); #endif // !__SMARTPHONE__ - m_dirCtrl->SetFocus(); + m_input->SetFocus(); SetAutoLayout( true ); SetSizer( topsizer ); @@ -270,7 +268,13 @@ void wxGenericDirDialog::OnTreeSelected( wxTreeEvent &event ) if (!m_dirCtrl) return; - wxDirItemData *data = (wxDirItemData*)m_dirCtrl->GetTreeCtrl()->GetItemData(event.GetItem()); + wxTreeItemId item = event.GetItem(); + + wxDirItemData *data = NULL; + + if(item.IsOk()) + data = (wxDirItemData*)m_dirCtrl->GetTreeCtrl()->GetItemData(item); + if (data) m_input->SetValue( data->m_path ); }; @@ -314,7 +318,7 @@ void wxGenericDirDialog::OnNew( wxCommandEvent& WXUNUSED(event) ) if (!wxEndsWithPathSeparator(path)) path += wxFILE_SEP_PATH; path += new_name; - if (wxFileExists(path)) + if (wxPathExists(path)) { // try NewName0, NewName1 etc. int i = 0; @@ -329,7 +333,7 @@ void wxGenericDirDialog::OnNew( wxCommandEvent& WXUNUSED(event) ) path += wxFILE_SEP_PATH; path += new_name; i++; - } while (wxFileExists(path)); + } while (wxPathExists(path)); } wxLogNull log;