+wxCoord wxGrid::CalcColOrRowLabelAreaMinSize(wxGridDirection direction)
+{
+ // calculate size for the rows or columns?
+ const bool calcRows = direction == wxGRID_ROW;
+
+ wxClientDC dc(calcRows ? GetGridRowLabelWindow()
+ : GetGridColLabelWindow());
+ dc.SetFont(GetLabelFont());
+
+ // which dimension should we take into account for calculations?
+ //
+ // for columns, the text can be only horizontal so it's easy but for rows
+ // we also have to take into account the text orientation
+ const bool
+ useWidth = calcRows || (GetColLabelTextOrientation() == wxVERTICAL);
+
+ wxArrayString lines;
+ wxCoord extentMax = 0;
+
+ const int numRowsOrCols = calcRows ? m_numRows : m_numCols;
+ for ( int rowOrCol = 0; rowOrCol < numRowsOrCols; rowOrCol++ )
+ {
+ lines.Clear();
+
+ wxString label = calcRows ? GetRowLabelValue(rowOrCol)
+ : GetColLabelValue(rowOrCol);
+ StringToLines(label, lines);
+
+ long w, h;
+ GetTextBoxSize(dc, lines, &w, &h);
+
+ const wxCoord extent = useWidth ? w : h;
+ if ( extent > extentMax )
+ extentMax = extent;
+ }
+
+ if ( !extentMax )
+ {
+ // empty column - give default extent (notice that if extentMax is less
+ // than default extent but != 0, it's OK)
+ extentMax = calcRows ? GetDefaultRowLabelSize()
+ : GetDefaultColLabelSize();
+ }
+
+ // leave some space around text (taken from AutoSizeColOrRow)
+ if ( calcRows )
+ extentMax += 10;
+ else
+ extentMax += 6;
+
+ return extentMax;
+}
+