X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/94248d2ed19bb207a49cf1a5bd9bfea0fd04760b..77c8efc8c37da6d6a5e2e8022d21d1cd7d76371d:/src/common/listctrlcmn.cpp diff --git a/src/common/listctrlcmn.cpp b/src/common/listctrlcmn.cpp index 861beef994..a4cd12f288 100644 --- a/src/common/listctrlcmn.cpp +++ b/src/common/listctrlcmn.cpp @@ -136,6 +136,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent) // wxListCtrlBase implementation // ---------------------------------------------------------------------------- +long +wxListCtrlBase::AppendColumn(const wxString& heading, + int format, + int width) +{ + return InsertColumn(GetColumnCount(), heading, format, width); +} + long wxListCtrlBase::InsertColumn(long col, const wxString& heading, @@ -145,7 +153,9 @@ wxListCtrlBase::InsertColumn(long col, wxListItem item; item.m_mask = wxLIST_MASK_TEXT | wxLIST_MASK_FORMAT; item.m_text = heading; - if ( width > -1 ) + if ( width >= 0 + || width == wxLIST_AUTOSIZE + || width == wxLIST_AUTOSIZE_USEHEADER ) { item.m_mask |= wxLIST_MASK_WIDTH; item.m_width = width; @@ -175,6 +185,9 @@ wxSize wxListCtrlBase::DoGetBestClientSize() const if ( !InReportView() ) return wxControl::DoGetBestClientSize(); + int totalWidth; + wxClientDC dc(const_cast(this)); + // In report mode, we use only the column headers, not items, to determine // the best width. The reason for this is that it's easier (we can't just // iterate over all items, especially not in a virtual control, so we'd @@ -186,15 +199,17 @@ wxSize wxListCtrlBase::DoGetBestClientSize() const // headers are just truncated if there is not enough place for them. const int columns = GetColumnCount(); if ( HasFlag(wxLC_NO_HEADER) || !columns ) - return wxControl::DoGetBestClientSize(); - - wxClientDC dc(const_cast(this)); - - // Total width of all headers determines the best control width. - int totalWidth = 0; - for ( int col = 0; col < columns; col++ ) { - totalWidth += GetColumnWidth(col); + // Use some arbitrary width. + totalWidth = 50*dc.GetCharWidth(); + } + else // We do have columns, use them to determine the best width. + { + totalWidth = 0; + for ( int col = 0; col < columns; col++ ) + { + totalWidth += GetColumnWidth(col); + } } // Use some arbitrary height, there is no good way to determine it.