Skip to content

Commit

Permalink
If WordWrap is enabled the alignment is ignored
Browse files Browse the repository at this point in the history
Currently if one set wordwrap to true a textlayout is used to render the
text, but if one combines this with for example a center align the text
still is left aligned.

This now sets the alignment into the textlayout to perform desired
rendering.
  • Loading branch information
laeubi committed Jun 10, 2024
1 parent 1d505ce commit 30a9e34
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public Point computeSize(GC gc, int wHint, int hHint, Object value)
getTextLayout(gc, column);
textLayout.setText(column.getText());
textLayout.setWidth(plainTextWidth < 1 ? 1 : plainTextWidth);
textLayout.setAlignment(getHorizontalAlignment());

x += plainTextWidth + rightMargin;

Expand Down Expand Up @@ -202,6 +203,7 @@ else if (column.getAlignment() == SWT.CENTER)
getTextLayout(gc, column);
textLayout.setWidth(width < 1 ? 1 : width);
textLayout.setText(text);
textLayout.setAlignment(getHorizontalAlignment());
y -= textLayout.getBounds().height;

// remove the first line shift
Expand Down

0 comments on commit 30a9e34

Please sign in to comment.