diff options
Diffstat (limited to 'wxWidgets-Fix/grid.cpp.patch')
-rw-r--r-- | wxWidgets-Fix/grid.cpp.patch | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/wxWidgets-Fix/grid.cpp.patch b/wxWidgets-Fix/grid.cpp.patch new file mode 100644 index 00000000..af9bd684 --- /dev/null +++ b/wxWidgets-Fix/grid.cpp.patch @@ -0,0 +1,71 @@ +--- old 2009-03-06 11:00:48.000000000 +0100 ++++ src\generic\grid.cpp 2009-10-24 17:12:24.484375000 +0200 +@@ -5605,6 +5605,59 @@ + } + } + ++ ++void wxGrid::AutoSizeColFast(int col, bool doRefresh) ++{ ++ if (col < 0) ++ return; ++ ++ int rowMax = -1; ++ size_t lenMax = 0; ++ for (int row = 0; row < GetNumberRows(); ++row) ++ if (GetCellValue(row, col).size() > lenMax) ++ { ++ lenMax = GetCellValue(row, col).size(); ++ rowMax = row; ++ } ++ ++ wxCoord extentMax = 0; ++ ++ //calculate width of (most likely) widest cell ++ wxClientDC dc(GetGridWindow()); ++ if (rowMax > -1) ++ { ++ wxGridCellAttr* attr = GetCellAttr(rowMax, col); ++ if (attr) ++ { ++ wxGridCellRenderer* renderer = attr->GetRenderer(this, rowMax, col); ++ if (renderer) ++ { ++ const wxSize size = renderer->GetBestSize(*this, *attr, dc, rowMax, col); ++ extentMax = std::max(extentMax, size.x); ++ renderer->DecRef(); ++ } ++ attr->DecRef(); ++ } ++ } ++ ++ //consider column label ++ dc.SetFont(GetLabelFont()); ++ wxCoord w = 0; ++ wxCoord h = 0; ++ dc.GetMultiLineTextExtent(GetColLabelValue(col), &w, &h ); ++ if (GetColLabelTextOrientation() == wxVERTICAL) ++ w = h; ++ extentMax = std::max(extentMax, w); ++ ++ extentMax += 15; //leave some space around text ++ ++ SetColSize(col, extentMax); ++ ++ if (doRefresh) ++ Refresh(); ++} ++ ++ + void wxGrid::ProcessColLabelMouseEvent( wxMouseEvent& event ) + { + int x, y, col; +@@ -5829,7 +5882,7 @@ + else + { + // adjust column width depending on label text +- AutoSizeColLabelSize( col ); ++ AutoSizeColFast( col ); + + ChangeCursorMode(WXGRID_CURSOR_SELECT_CELL, m_colLabelWin); + m_dragLastPos = -1; |