X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7941ba111cac53f21eafdeeeed6b543c3a2ba610..64d78265d0256eb00ae59b717aa97e4c5786e003:/src/generic/filedlgg.cpp diff --git a/src/generic/filedlgg.cpp b/src/generic/filedlgg.cpp index 5a6f3fe328..909355ded6 100644 --- a/src/generic/filedlgg.cpp +++ b/src/generic/filedlgg.cpp @@ -133,6 +133,7 @@ wxFileData::wxFileData( const wxString &name, const wxString &fname ) m_month = t->tm_mon+1; m_day = t->tm_mday; m_year = t->tm_year; + m_year += 1900; m_permissions.sprintf( wxT("%c%c%c"), ((( buff.st_mode & S_IRUSR ) == S_IRUSR ) ? wxT('r') : wxT('-')), @@ -181,30 +182,37 @@ wxString wxFileData::GetEntry( int num ) switch (num) { case 0: + { s = m_name; - break; + } + break; case 1: + { if (m_isDir) s = _(""); else if (m_isLink) s = _(""); else s = LongToString( m_size ); - break; + } + break; case 2: + { if (m_day < 10) s = wxT("0"); else s = wxT(""); s += IntToString( m_day ); s += wxT("."); if (m_month < 10) s += wxT("0"); s += IntToString( m_month ); s += wxT("."); - if (m_year < 10) s += wxT("0"); // this should happen real soon... s += IntToString( m_year ); - break; + } + break; case 3: + { if (m_hour < 10) s = wxT("0"); else s = wxT(""); s += IntToString( m_hour ); s += wxT(":"); if (m_minute < 10) s += wxT("0"); s += IntToString( m_minute ); break; + } case 4: s = m_permissions; break; @@ -244,14 +252,14 @@ void wxFileData::SetNewName( const wxString &name, const wxString &fname ) void wxFileData::MakeItem( wxListItem &item ) { item.m_text = m_name; - item.m_colour = wxBLACK; - if (IsExe()) item.m_colour = wxRED; - if (IsDir()) item.m_colour = wxBLUE; - if (IsDir()) item.m_image = 0; else item.m_image = -1; + item.ClearAttributes(); + if (IsExe()) item.SetTextColour(*wxRED); + if (IsDir()) item.SetTextColour(*wxBLUE); + item.m_image = IsDir() ? 0 : -1; if (IsLink()) { wxColour *dg = wxTheColourDatabase->FindColour( "MEDIUM GREY" ); - item.m_colour = dg; + item.SetTextColour(*dg); } item.m_data = (long)this; } @@ -339,7 +347,7 @@ void wxFileCtrl::Update() { InsertColumn( 0, _("Name"), wxLIST_FORMAT_LEFT, 130 ); InsertColumn( 1, _("Size"), wxLIST_FORMAT_LEFT, 60 ); - InsertColumn( 2, _("Date"), wxLIST_FORMAT_LEFT, 55 ); + InsertColumn( 2, _("Date"), wxLIST_FORMAT_LEFT, 70 ); InsertColumn( 3, _("Time"), wxLIST_FORMAT_LEFT, 50 ); InsertColumn( 4, _("Permissions"), wxLIST_FORMAT_LEFT, 120 ); } @@ -388,6 +396,10 @@ void wxFileCtrl::Update() } SortItems( ListCompare, 0 ); + + SetColumnWidth( 2, wxLIST_AUTOSIZE ); + SetColumnWidth( 3, wxLIST_AUTOSIZE ); + SetColumnWidth( 4, wxLIST_AUTOSIZE ); } void wxFileCtrl::SetWild( const wxString &wild ) @@ -431,7 +443,7 @@ void wxFileCtrl::MakeDir() wxListItem item; item.m_itemId = 0; item.m_col = 0; - int id = Add( fd, item ); + long id = Add( fd, item ); if (id != -1) { @@ -450,7 +462,7 @@ void wxFileCtrl::GoToParentDir() m_dirName = wxPathOnly( m_dirName ); if (m_dirName.IsEmpty()) m_dirName = wxT("/"); Update(); - int id = FindItem( 0, fname ); + long id = FindItem( 0, fname ); if (id != -1) { SetItemState( id, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); @@ -576,10 +588,10 @@ wxFileDialog::wxFileDialog(wxWindow *parent, m_dialogStyle = style; if ((m_dialogStyle & wxMULTIPLE ) && !(m_dialogStyle & wxOPEN)) - m_dialogStyle &= ~wxMULTIPLE; + m_dialogStyle |= wxOPEN; m_dir = defaultDir; - if (m_dir.IsEmpty()) + if ((m_dir.IsEmpty()) || (m_dir == wxT("."))) { char buf[200]; m_dir = getcwd( buf, sizeof(buf) ); @@ -715,9 +727,10 @@ wxFileDialog::~wxFileDialog() void wxFileDialog::OnChoice( wxCommandEvent &event ) { - wxString *str = (wxString*) m_choice->GetClientData( event.GetInt() ); + int index = (int)event.GetInt(); + wxString *str = (wxString*) m_choice->GetClientData( index ); m_list->SetWild( *str ); - m_filterIndex = event.GetInt(); + m_filterIndex = index; } void wxFileDialog::OnCheck( wxCommandEvent &event ) @@ -901,6 +914,12 @@ void wxFileDialog::SetPath( const wxString& path ) void wxFileDialog::GetPaths( wxArrayString& paths ) const { paths.Empty(); + if (m_list->GetSelectedItemCount() == 0) + { + paths.Add( GetPath() ); + return; + } + paths.Alloc( m_list->GetSelectedItemCount() ); wxString dir; @@ -922,6 +941,11 @@ void wxFileDialog::GetPaths( wxArrayString& paths ) const void wxFileDialog::GetFilenames(wxArrayString& files) const { files.Empty(); + if (m_list->GetSelectedItemCount() == 0) + { + files.Add( GetFilename() ); + return; + } files.Alloc( m_list->GetSelectedItemCount() ); wxListItem item;