Skip to content

TextPainter.getPreferredHeight() with calculateWrappedHeight ignores horizontal padding from wrapper painter #92

@thomasa299792

Description

@thomasa299792

(Forwarded from https://bugs.eclipse.org/bugs/show_bug.cgi?id=583350)

I encountered this in v2.0.5, but the TextPainter code appears to be the same in 2.4.0.

The method TextPainter.getPreferredHeight(), when calculateWrappedHeight is set, computes the text to display based off cell bounds adjusted for grid lines -- but not adjusted for any horizontal padding added by a wrapping PaddingDecorator.

    ICellPainter cellPainter = new TextPainter(m_shouldAutoWrap, false);
    cellPainter = new PaddingDecorator( cellPainter, 
        V_PADDING, H_PADDING, V_PADDING, H_PADDING );

As a consequence, the preferred cell height can be too low when the cell width is just below that required to avoid wrapping the text.

And then the preferred height of the row can be too low, and setting that incorrect preferred height can lead to the row not being tall enough to display the actual wrapping when trimming is considered.

    table.doCommand( new TurnViewportOffCommand());
    int[] rowPositions = new int[] { 0 }; // header row
    int[] gridRowHeights = MaxCellBoundsHelper.getPreferredRowHeights(
        table.getConfigRegistry(),
	new GCFactory(table),
	table,
	rowPositions);
    if (gridRowHeights != null) {
        table.doCommand( new MultiRowResizeCommand(
            table, rowPositions, gridRowHeights));
    }
    table.doCommand( new TurnViewportOnCommand());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions