| Summary: | [Button] computeSize algorithm is wrong when using SWT.WRAP | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Sebastien Arod <sebastien.arod> | ||||
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | ||||||
| Version: | 2.1 | ||||||
| Target Milestone: | 2.2 M3 | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 236490 [details]
Patch proposal
Here is a patch for this bug.
When wHint != SWT.DEFAULT we use the remaining width to do the wraping of the text.
I was tempted to compute text related size computation as the last element of the computeSize method however I didn't do it because I didn't undertsand the logic about "if( height == 0 ) { height = 10; }"
So I had to duplicate the part of the width computation for check and radios.
I did some polishing to your patch. Fixed in master with commit 8c26af41dd8bd97f79a31a4793c541864e9ff272. Thanks |
On Button when using SWT.WRAP the Button.computeSize seems wrong and so button with long text are often layed-out with truncated text. From what I can see this problems comes from using wHint directly at Line 391: extent = TextSizeUtil.textExtent( getFont(), text, wHint ); instead of using wHint we should use the wrapWidth: int wrapWidth = SWT.DEFAULT; if (wHint != SWT.DEFAULT) { // Width is constrained so we compute the remaining width for text wrapWidth = wHint - borderwidth*2 - padding.width; if (hasImage) { // remove space related to image wrapWidth = imageBoundx.width - spacing; } } extent = TextSizeUtil.textExtent( getFont(), text, wrapWidth );