Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342197 - Control.getBorderWidth () always returns 0
Summary: Control.getBorderWidth () always returns 0
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.6.2   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Lakshmi P Shanmugam CLA
QA Contact: Silenio Quarti CLA
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-07 13:40 EDT by William Kilian CLA
Modified: 2019-11-27 07:00 EST (History)
2 users (show)

See Also:


Attachments
patch (3.55 KB, patch)
2011-04-11 05:55 EDT, Lakshmi P Shanmugam CLA
no flags Details | Diff
patch-2 (5.10 KB, patch)
2011-04-11 16:23 EDT, Lakshmi P Shanmugam CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description William Kilian CLA 2011-04-07 13:40:49 EDT
Build Identifier: 20110218-0911

This is apparently a regression of bug 213937.

Source code for Control.getBorderWidth():

public int getBorderWidth () {
	checkWidget();
    return 0;
}


Reproducible: Always
Comment 1 Lakshmi P Shanmugam CLA 2011-04-08 06:44:03 EDT
Are you using the Cocoa or Carbon build?
Comment 2 William Kilian CLA 2011-04-08 09:32:21 EDT
I'm using the Cocoa build.
Comment 3 Lakshmi P Shanmugam CLA 2011-04-11 05:55:39 EDT
Created attachment 192920 [details]
patch

patch implements getBorderWidth() for the controls that have border.
Silenio, please review.
Comment 4 Silenio Quarti CLA 2011-04-11 11:59:16 EDT
These are the values I am getting for border width of some widgets (with patch):

Canvas {} 2
List {} 2
Table {} 2
Tree {} 2
Text {MULTI} 2
Text {SINGLE} 4
Link {} 2
Label {} 0
Spinner {} 4
DateTime {} 0

I am sure the values are right for Table/Tree/List, given that they have the focus ring. Note that the value for Text {SINGLE} is 4 because of the focus ring. I believe Link, Canvas and Text {MULTI} are right (no focus ring).

Label is actually reporting the right value, because we are not adding border. We should have a separate bug for this problem.

I am not sure about DateTime and Spinner. Which one is correct? Given that the border/focus ring is not around the whole widget. I would say Spinner.

Unrelated problems:
- I think DateTime should turn of the focus ring when SWT.BORDER is not set.
- the DateTime border is a black. Not the same is the "Date & Time" tab in the System Preferences.
Comment 5 Silenio Quarti CLA 2011-04-11 13:41:32 EDT
Note that I released a fix for the unrelated problems I mentioned above.
Comment 6 Lakshmi P Shanmugam CLA 2011-04-11 16:23:46 EDT
Created attachment 192975 [details]
patch-2

Thanks Silenio, I didn't see that the border width was related to focus ring. I've modified the patch so that if the control has border but will not show focus ring then the border width is 0. The getBorderWidth() is implemented in the controls and not in Scrollable.
Text {MULTI} should draw the focus ring so it still returns 2 for border width.
I'm not sure how to get the border width for the DateTime widget, so  
hardcoded the value to 2 because it is using bezel border style. Please review.
Comment 7 Silenio Quarti CLA 2011-04-18 10:30:48 EDT
(In reply to comment #6)
> Created attachment 192975 [details]
> patch-2

The border width is related to the focus ring because when you create a widget with SWT.BORDER you get both: the bezel border and the focus ring.

I believe the previous patch was closer. With this patch Canvas{SWT.BORDER} returns 0 for example.  My concern with the previous patch was that Table/Tree/List/DateTime were not returning 4.   I think they should since Text{SWT.SINGLE} returns 4.  Table/Tree/List/DateTime/Text{SWT.SINGLE} show the focus ring, so the border should be bigger.
Comment 8 William Kilian CLA 2012-06-18 10:29:57 EDT
While looking at an unrelated bug, noticed this is unchanged in 3.7.2.
Comment 9 Lars Vogel CLA 2019-11-27 07:00:03 EST
This bug hasn't had any activity in quite some time. Maybe the problem got
resolved, was a duplicate of something else, or became less pressing for some
reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it.
The information can be, for example, that the problem still occurs, that you
still want the feature, that more information is needed, or that the bug is
(for whatever reason) no longer relevant.

If the bug is still relevant, please remove the stalebug whiteboard tag.