From 72824bc2691c4e2ec43854c24e31dfa33f96ee5d Mon Sep 17 00:00:00 2001 From: Ilya Sinitsyn Date: Wed, 29 Jan 2020 05:06:03 +0700 Subject: [PATCH] Fix text cropping when using ellipsization in wxGrid A text is cropped for cells with ellipsization enabled when width of the cell nearly equal to width of the text because wxGrid::DrawTextRectangle function variant with the parameter of type wxArrayString adds the offset before actually drawing the text using dc.DrawText or dc.DrawRotatedText. --- src/generic/grid.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 047c6f95f2..3b48669133 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -6831,13 +6831,16 @@ void wxGrid::DrawTextRectangle(wxDC& dc, { attr.GetNonDefaultAlignment(&hAlign, &vAlign); + // The text will be displaced in final wxGrid::DrawTextRectangle function. + const int textMargin = 2; + // This does nothing if there is no need to ellipsize. const wxString& ellipsizedText = wxControl::Ellipsize ( text, dc, attr.GetFitMode().GetEllipsizeMode(), - rect.GetWidth(), + rect.GetWidth() - textMargin, wxELLIPSIZE_FLAGS_NONE );