| Summary: | FigureCanvas doesn't compute size properly with SWT.BORDER style | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Randy Hudson <hudsonr> |
| Component: | GEF-Legacy Draw2d | Assignee: | Randy Hudson <hudsonr> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | ahunter.eclipse |
| Version: | 3.4 | ||
| Target Milestone: | 3.5.0 (Galileo) M5 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Randy Hudson
Changed FigureCanvas#computeSize to determine the border size using SWT's reported "trim". The trim is subtracted from the hints if necessary. Finally, the root figure's preferred size is augmented with trim and then maxed with the hints (according to SWT conventions).
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed) {
// TODO not accounting for scrollbars and trim
+ int borderSize = computeTrim(0, 0, 0, 0).x * -2;
+ if (wHint >= 0)
+ wHint = Math.max(0, wHint - borderSize);
+ if (hHint >= 0)
+ hHint = Math.max(0, hHint - borderSize);
~ Dimension size = getLightweightSystem()
~ .getRootFigure()
~ .getPreferredSize(wHint, hHint)
+ .getExpanded(borderSize, borderSize);
size.union(new Dimension(wHint, hHint));
return new org.eclipse.swt.graphics.Point(size.width, size.height);
}
Yuck, I also just noticed that the original code modified the root figure's preferred Dimension, which is potentially returned by reference.
I've just updated the TODO comment in that method as well to reflect the current state of things. |