Restore overflowing for cells with non-default vertical alignment

Since the changes in a40acbb28e (Add CanOverflow function to
wxGridCellAttr, 2020-02-06), cells with non-default vertical alignment
didn't overflow any more, even if their horizontal alignment was
unchanged and still defaulted to left-aligned.

This was due to assuming that if the alignment of wxGridCellAttr itself
was different from wxALIGN_LEFT, it meant that it wasn't left-aligned,
which seems logical but is in fact false, as the alignment can also be
wxALIGN_INVALID, in which case the real alignment is taken from the
default grid attribute.

Fix this by using GetNonDefaultAlignment() to get the alignment value
effectively used and add a unit test, as well as an example in the
sample, showing that this now works correctly.
This commit is contained in:
Vadim Zeitlin
2020-03-31 19:27:34 +02:00
parent 5834bef2f7
commit ca30169767
3 changed files with 20 additions and 3 deletions

View File

@@ -647,9 +647,17 @@ wxGridFitMode wxGridCellAttr::GetFitMode() const
bool wxGridCellAttr::CanOverflow() const
{
int hAlign;
GetAlignment(&hAlign, NULL);
return GetOverflow() && (hAlign == wxALIGN_LEFT);
// If overflow is disabled anyhow, we definitely can't overflow.
if ( !GetOverflow() )
return false;
// But if it is enabled, we still don't use it for right-aligned or
// centered cells because it's not really clear how it should work for
// them.
int hAlign = wxALIGN_LEFT;
GetNonDefaultAlignment(&hAlign, NULL);
return hAlign == wxALIGN_LEFT;
}
// GetRenderer and GetEditor use a slightly different decision path about