Slightly improve best size calculation for wxListCtrl with wxLC_NO_HEADER.
Use some arbitrary but relatively large width and height instead of falling back to wxControlBase best size computation which, at least in wxGTK, simply returns (1, 1) resulting in list control of unusably small size. This is, of course, still far from ideal and we should really use the items to calculate the best width but it at least allow the list control in the generic log dialog to be shown correctly in wxGTK. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@71733 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -185,6 +185,9 @@ wxSize wxListCtrlBase::DoGetBestClientSize() const
|
|||||||
if ( !InReportView() )
|
if ( !InReportView() )
|
||||||
return wxControl::DoGetBestClientSize();
|
return wxControl::DoGetBestClientSize();
|
||||||
|
|
||||||
|
int totalWidth;
|
||||||
|
wxClientDC dc(const_cast<wxListCtrlBase*>(this));
|
||||||
|
|
||||||
// In report mode, we use only the column headers, not items, to determine
|
// 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
|
// 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
|
// iterate over all items, especially not in a virtual control, so we'd
|
||||||
@@ -196,15 +199,17 @@ wxSize wxListCtrlBase::DoGetBestClientSize() const
|
|||||||
// headers are just truncated if there is not enough place for them.
|
// headers are just truncated if there is not enough place for them.
|
||||||
const int columns = GetColumnCount();
|
const int columns = GetColumnCount();
|
||||||
if ( HasFlag(wxLC_NO_HEADER) || !columns )
|
if ( HasFlag(wxLC_NO_HEADER) || !columns )
|
||||||
return wxControl::DoGetBestClientSize();
|
|
||||||
|
|
||||||
wxClientDC dc(const_cast<wxListCtrlBase*>(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.
|
// Use some arbitrary height, there is no good way to determine it.
|
||||||
|
Reference in New Issue
Block a user