X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/49f89f4d4bf889afd1b38997f05b7f0a4b910310..a39815bd30c62e13089f318028c9ee547940c4ad:/src/generic/datavgen.cpp diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index e8d83fed0a..5fd5797d8c 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -3599,7 +3599,7 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event ) wxDataViewColumn *editableCol = FindColumnForEditing(item, wxDATAVIEW_CELL_EDITABLE); if ( editableCol ) - GetOwner()->StartEditor(item, GetOwner()->GetColumnIndex(editableCol)); + GetOwner()->EditItem(item, editableCol); } } break; @@ -4647,13 +4647,7 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const m_clientArea->GetRowHeight()); if ( m_headerArea ) - { - int header_width = m_headerArea->GetTextExtent(column->GetTitle()).x; - // Labels on native MSW header are indented on both sides - header_width += - wxRendererNative::Get().GetHeaderButtonMargin(m_headerArea); - calculator.UpdateWithWidth(header_width); - } + calculator.UpdateWithWidth(m_headerArea->GetColumnTitleWidth(*column)); // The code below deserves some explanation. For very large controls, we // simply can't afford to calculate sizes for all items, it takes too @@ -4809,7 +4803,6 @@ void wxDataViewCtrl::OnInternalIdle() int wxDataViewCtrl::GetColumnPosition( const wxDataViewColumn *column ) const { -#if 1 unsigned int len = GetColumnCount(); for ( unsigned int i = 0; i < len; i++ ) { @@ -4819,25 +4812,6 @@ int wxDataViewCtrl::GetColumnPosition( const wxDataViewColumn *column ) const } return wxNOT_FOUND; -#else - // This returns the position in pixels which is not what we want. - int ret = 0, - dummy = 0; - unsigned int len = GetColumnCount(); - for ( unsigned int i = 0; i < len; i++ ) - { - wxDataViewColumn * col = GetColumnAt(i); - if (col->IsHidden()) - continue; - ret += col->GetWidth(); - if (column==col) - { - CalcScrolledPosition( ret, dummy, &ret, &dummy ); - break; - } - } - return ret; -#endif } wxDataViewColumn *wxDataViewCtrl::GetSortingColumn() const @@ -4864,6 +4838,11 @@ void wxDataViewCtrl::DoSetCurrentItem(const wxDataViewItem& item) } } +wxDataViewColumn *wxDataViewCtrl::GetCurrentColumn() const +{ + return m_clientArea->GetCurrentColumn(); +} + int wxDataViewCtrl::GetSelectedItemsCount() const { return m_clientArea->GetSelections().size(); @@ -5042,13 +5021,12 @@ bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const return false; } -void wxDataViewCtrl::StartEditor( const wxDataViewItem & item, unsigned int column ) +void wxDataViewCtrl::EditItem(const wxDataViewItem& item, const wxDataViewColumn *column) { - wxDataViewColumn* col = GetColumn( column ); - if (!col) - return; + wxCHECK_RET( item.IsOk(), "invalid item" ); + wxCHECK_RET( column, "no column provided" ); - m_clientArea->StartEditing(item, col); + m_clientArea->StartEditing(item, column); } #endif // !wxUSE_GENERICDATAVIEWCTRL