Merge branch 'grid-ellipsize-offset' of https://github.com/thesiv/wxWidgets

Fix text cropping when using ellipsization in wxGrid.

See https://github.com/wxWidgets/wxWidgets/pull/1720
This commit is contained in:
Vadim Zeitlin
2020-02-04 02:14:19 +01:00

View File

@@ -114,6 +114,9 @@ const int DRAG_SENSITIVITY = 3;
// the space between the cell edge and the checkbox mark
const int GRID_CELL_CHECKBOX_MARGIN = 2;
// the margin between a cell vertical line and a cell text
const int GRID_TEXT_MARGIN = 1;
} // anonymous namespace
#include "wx/arrimpl.cpp"
@@ -6814,9 +6817,9 @@ void wxGrid::DrawTextRectangle(wxDC& dc,
{
case wxALIGN_BOTTOM:
if ( textOrientation == wxHORIZONTAL )
y = rect.y + (rect.height - textHeight - 1);
y = rect.y + (rect.height - textHeight - GRID_TEXT_MARGIN);
else
x = rect.x + rect.width - textWidth;
x = rect.x + (rect.width - textWidth - GRID_TEXT_MARGIN);
break;
case wxALIGN_CENTRE:
@@ -6829,9 +6832,9 @@ void wxGrid::DrawTextRectangle(wxDC& dc,
case wxALIGN_TOP:
default:
if ( textOrientation == wxHORIZONTAL )
y = rect.y + 1;
y = rect.y + GRID_TEXT_MARGIN;
else
x = rect.x + 1;
x = rect.x + GRID_TEXT_MARGIN;
break;
}
@@ -6855,9 +6858,9 @@ void wxGrid::DrawTextRectangle(wxDC& dc,
{
case wxALIGN_RIGHT:
if ( textOrientation == wxHORIZONTAL )
x = rect.x + (rect.width - lineWidth - 1);
x = rect.x + (rect.width - lineWidth - GRID_TEXT_MARGIN);
else
y = rect.y + lineWidth + 1;
y = rect.y + lineWidth + GRID_TEXT_MARGIN;
break;
case wxALIGN_CENTRE:
@@ -6870,9 +6873,9 @@ void wxGrid::DrawTextRectangle(wxDC& dc,
case wxALIGN_LEFT:
default:
if ( textOrientation == wxHORIZONTAL )
x = rect.x + 1;
x = rect.x + GRID_TEXT_MARGIN;
else
y = rect.y + rect.height - 1;
y = rect.y + rect.height - GRID_TEXT_MARGIN;
break;
}
@@ -6904,7 +6907,7 @@ void wxGrid::DrawTextRectangle(wxDC& dc,
text,
dc,
attr.GetFitMode().GetEllipsizeMode(),
rect.GetWidth(),
rect.GetWidth() - 2 * GRID_TEXT_MARGIN,
wxELLIPSIZE_FLAGS_NONE
);