Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Scroll bar appears in Win 7 and not in Win XP
Scroll bar appears in Win 7 and not in Win XP [message #898290] Thu, 26 July 2012 06:50 Go to next message
sam mn is currently offline sam mnFriend
Messages: 25
Registered: August 2010
Junior Member
we have one strange issue with scroll bar. Issue is like this:
Eclipse Indigo
SWT:3.5.2
We have created a scrolled composite and then we have created a swt table (with some 4 rows of data) in it. A new gridData is created for that table and a height hint is set as 100.

Problem is when our RCP product is launched (initial state), we see a scroll bar appearing for the table in Windows 7, however in Windows XP we do not see a scroll bar.

To fix this I have increased the height hint from 100 to 103. With this fix I do not see a scroll bar in Windows 7.

I tried searching for this, but couldn't find much information.
1. Is there any platform differences in the behavior of scrolledcomposite.computeSize for Win 7 and Win XP ?
2. We are setting a minimum size for scrolledcomposite. This is actually done for setting the initial size when the product is launched. Does this have anything to do with my scroll bar issue ?

I have pasted my code below:

ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
final Composite top = new Composite(scrolledComposite, SWT.NONE);
top.setLayout(new GridLayout(2, false));
top.setLayoutData(new GridData(GridData.FILL_BOTH));
scrolledComposite.setContent(top);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
scrolledComposite.setMinSize(top.computeSize(215, 225));


Label label = new Label(top, SWT.NONE);
label.setText(".details");
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
label.setLayoutData(gridData);

detailsTable = new ModelPropertyTable();
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
gridData.heightHint = 103;
detailsTable.createControls(top, gridData, Style.EDIT);
detailsTable.getTableProvider().addListener(this);


Thanks,
Sam

[Updated on: Thu, 26 July 2012 06:58]

Report message to a moderator

Re: Scroll bar appears in Win 7 and not in Win XP [message #899144 is a reply to message #898290] Mon, 30 July 2012 16:31 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
Hi,

It's very possible that the metrics for native tables changed between XP
and Windows 7, which could make your hardcoded height hint of 100 no
longer enough to show your content.

Since you're using a layout to size/position your controls, you need to
compute the Table's preferred size. Do this by creating the Table's
four items, set whether the Table's header should be visible or not, and
set its GridData's height hint to the height returned by
Table.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).

Also note that if your Table will never physically grow beyond its
initial size then you can create it with style SWT.NO_SCROLL, which will
eliminate space that is reserved for scrollbars.

Grant


On 7/26/2012 2:50 AM, mnsam Mising name wrote:
> we have one strange issue with scroll bar. Issue is like this:
> Eclipse Indigo
> SWT:3.5.2
> We have created a scrolled composite and then we have created a swt
> table (with some 4 rows of data) in it. A new gridData is created for
> that table and a height hint is set as 100.
>
> Problem is when our RCP product is launched (initial state), we see a
> scroll bar appearing for the table in Windows 7, however in Windows XP
> we do not see a scroll bar.
>
> To fix this I have increased the height hint from 100 to 103. With this
> fix I do not see a scroll bar in Windows 7.
>
> I tried searching for this, but couldn't find much information. 1. Is
> there any platform differences in the behavior of
> scrolledcomposite.computeSize for Win 7 and Win XP ?
> 2. We are setting a minimum size for scrolledcomposite. This is actually
> done for setting the initial size when the product is launched. Does
> this have anything to do with my scroll bar issue ?
>
> I have pasted my code below:
>
> ScrolledComposite scrolledComposite = new ScrolledComposite(parent,
> SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
> final Composite top = new Composite(scrolledComposite, SWT.NONE);
> top.setLayout(new GridLayout(2, false));
> top.setLayoutData(new GridData(GridData.FILL_BOTH));
> scrolledComposite.setContent(top);
> scrolledComposite.setExpandHorizontal(true);
> scrolledComposite.setExpandVertical(true);
> scrolledComposite.setMinSize(top.computeSize(215, 225));
>
> createTreeViewer(top);
>
> Label label = new Label(top, SWT.NONE);
> label.setText(".details");
> GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
> gridData.horizontalSpan = 2;
> label.setLayoutData(gridData);
>
> detailsTable = new ModelPropertyTable();
> gridData = new GridData(GridData.FILL_HORIZONTAL);
> gridData.horizontalSpan = 2;
> gridData.heightHint = 103;
> detailsTable.createControls(top, gridData, Style.EDIT);
> detailsTable.getTableProvider().addListener(this);
>
>
> Thanks,
> Sam
>
Re: Scroll bar appears in Win 7 and not in Win XP [message #899774 is a reply to message #899144] Thu, 02 August 2012 10:06 Go to previous messageGo to next message
sam mn is currently offline sam mnFriend
Messages: 25
Registered: August 2010
Junior Member
Thanks for the reply Grant.

I am now calculating heightHint for the gridData of Table by doing:
gridData.heightHint = NUMBER_OF_TABLE_ROWS * detailsPaneTable.getItemHeight()+ detailsPaneTable.getHeaderHeight();

And this has helped me resolve this issue. One more intricacy what I observed was the presence of checkbox with in a table cell. This checkbox was also adding to the size of each table item and triggering the scroll bar.
Re: Scroll bar appears in Win 7 and not in Win XP [message #899839 is a reply to message #899774] Thu, 02 August 2012 14:26 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2151
Registered: July 2009
Senior Member
I would suggest using Table.computeSize() if possible because it will
take into account additional trim the table may have. Your current
approach may work on your test platforms, but may not be adequate on
other platforms, or even in future releases of Windows. If
Table.computeSize() is not giving a large enough answer once your Table
has been populated with its items then you're seeing a bug in Table.

Grant


On 8/2/2012 6:06 AM, sam mn wrote:
> Thanks for the reply Grant.
>
> I am now calculating heightHint for the gridData of Table by doing:
> gridData.heightHint = NUMBER_OF_TABLE_ROWS *
> detailsPaneTable.getItemHeight()+ detailsPaneTable.getHeaderHeight();
>
> And this has helped me resolve this issue. One more intricacy what I
> observed was the presence of checkbox with in a table cell. This
> checkbox was also adding to the size of each table item and triggering
> the scroll bar.
Previous Topic:the controls in a row should not be centered vertically. why??
Next Topic:How to disable user editing/typing in a combo box editor in a table?
Goto Forum:
  


Current Time: Fri Nov 28 04:30:56 GMT 2014

Powered by FUDForum. Page generated in 0.01772 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software