Bug 386666 - Label shouldn't compute text position using it's preferred size field.
Summary: Label shouldn't compute text position using it's preferred size field.
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.5.2   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-06 05:53 EDT by Jan Krakora CLA
Modified: 2012-08-06 05:53 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Krakora CLA 2012-08-06 05:53:11 EDT
A Label showing numbers should paint its text right aligned, but the position of the text is computed with regard of its preferred size:

Dimension offset = getSize().getDifference(getPreferredSize());

When using GridLayout and GridData, the GridData sets the Figure's preferred size directly:

Dimension size = figure.getPreferredSize(widthHint, heightHint);
if (widthHint != -1)
    size.width = widthHint;
if (heightHint != -1)
    size.height = heightHint;

The problem is, when you use a hint:

Label label = new Label("0");
label.setLabelAlignment(PositionConstants.RIGHT);

GridData data = new GridData();
data.horizontalAlignment = SWT.FILL:
data.widthHint = 100;

container.add(label, data);

Then is the text painted on the left side instead of right size.