Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Problem with ScrolledComposite drawing a long list of Labels
Problem with ScrolledComposite drawing a long list of Labels [message #499552] Mon, 23 November 2009 10:21 Go to next message
Eclipse UserFriend
Originally posted by: stefan.noebauer.kgu-consulting.de

Hi,

I Have a problem with the Scrolled Composite listing a long list of labels.

I used the snippet166 with small changes to verify that same phenomenon. I
tried to add 2000 Labels to the Composite but only about 1800 where drawn.
Is there a limit on the scrolled Composite?

I use RCP 3.3.2.


My Code Sample:

public class Snippet166 {

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());

final ScrolledComposite scrollComposite = new
ScrolledComposite(shell,
SWT.V_SCROLL | SWT.BORDER);

final Composite parent = new Composite(scrollComposite, SWT.NONE);
for (int i = 0; i <= 2000; i++) {
Label label = new Label(parent, SWT.BORDER);
label.setText(String.valueOf(i));
}

parent.pack();

RowLayout layout = new RowLayout(SWT.VERTICAL);
layout.wrap = true;
parent.setLayout(layout);

scrollComposite.setContent(parent);
scrollComposite.setExpandVertical(true);
scrollComposite.setExpandHorizontal(true);
scrollComposite.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
Rectangle r = scrollComposite.getClientArea();
scrollComposite.setMinSize(parent.computeSize(r.width,
SWT.DEFAULT));
}
});

shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
}



--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
Re: Problem with ScrolledComposite drawing a long list of Labels [message #499640 is a reply to message #499552] Mon, 23 November 2009 15:23 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi,

Yes, there is a width/height limit of 32767, and
"parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)" indicates that the snippet's
height is exceeding this. Unfortunately this limit is imposed by the OS,
and there's no workaround other than to re-work the UI layout to not require
as much height or height.

Grant


"Stefan N
Re: Problem with ScrolledComposite drawing a long list of Labels [message #499792 is a reply to message #499640] Tue, 24 November 2009 07:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stefan.noebauer.kgu-consulting.de

I tryed the Gallary Composite of Eclipse Nebula. Why is that Composite
working with a very long list of items? Or is that component not using the
scrolled Composite?


Am 23.11.2009, 16:23 Uhr, schrieb Grant Gayed <grant_gayed@ca.ibm.com>:

> Hi,
>
> Yes, there is a width/height limit of 32767, and
> "parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)" indicates that the
> snippet's
> height is exceeding this. Unfortunately this limit is imposed by the OS,
> and there's no workaround other than to re-work the UI layout to not
> require
> as much height or height.
>
> Grant
>
>
> "Stefan Nöbauer" <stefan.noebauer@kgu-consulting.de> wrote in message
> news:op.u3ue1pmg011itz@kgu04.kgu-intern.local...
>> Hi,
>>
>> I Have a problem with the Scrolled Composite listing a long list of
> labels.
>>
>> I used the snippet166 with small changes to verify that same
>> phenomenon. I
>> tried to add 2000 Labels to the Composite but only about 1800 where
>> drawn.
>> Is there a limit on the scrolled Composite?
>>
>> I use RCP 3.3.2.
>>
>>
>> My Code Sample:
>>
>> public class Snippet166 {
>>
>> public static void main(String[] args) {
>> Display display = new Display();
>> Shell shell = new Shell(display);
>> shell.setLayout(new FillLayout());
>>
>> final ScrolledComposite scrollComposite = new
>> ScrolledComposite(shell,
>> SWT.V_SCROLL | SWT.BORDER);
>>
>> final Composite parent = new Composite(scrollComposite,
> SWT.NONE);
>> for (int i = 0; i <= 2000; i++) {
>> Label label = new Label(parent, SWT.BORDER);
>> label.setText(String.valueOf(i));
>> }
>>
>> parent.pack();
>>
>> RowLayout layout = new RowLayout(SWT.VERTICAL);
>> layout.wrap = true;
>> parent.setLayout(layout);
>>
>> scrollComposite.setContent(parent);
>> scrollComposite.setExpandVertical(true);
>> scrollComposite.setExpandHorizontal(true);
>> scrollComposite.addControlListener(new ControlAdapter() {
>> @Override
>> public void controlResized(ControlEvent e) {
>> Rectangle r = scrollComposite.getClientArea();
>> scrollComposite.setMinSize(parent.computeSize(r.width,
>> SWT.DEFAULT));
>> }
>> });
>>
>> shell.open();
>> while (!shell.isDisposed()) {
>> if (!display.readAndDispatch()) {
>> display.sleep();
>> }
>> }
>> display.dispose();
>> }
>> }
>>
>>
>>
>> --
>> Erstellt mit Operas revolutionärem E-Mail-Modul:
> http://www.opera.com/mail/
>
>


--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/
Re: Problem with ScrolledComposite drawing a long list of Labels [message #499940 is a reply to message #499792] Tue, 24 November 2009 14:44 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
I don't know how Gallery Composite is implemented, but my guess is that it
draws the content on an as-needed basis when it's scrolled into the
viewport, rather than creating a huge scrollable composite up-front with all
of the content. Controls can have conceptual bounds of > 32767 (eg.- large
Trees will often exceed this), but their physically-allocated bounds cannot
exceed this size. So when I said that there was no workaround available, I
guess this ignored the possibility of implementing a custom solution. An
example of this, though for a different problem than yours, is
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet48.java?view=co ,
where the scrollbar max sizes are set large to reflect the image's bounds,
but the Canvas' physical size does not exceed that of its parent Shell.

Grant


"Stefan N
Previous Topic:Dialog shell problem
Next Topic:add toolbar to section
Goto Forum:
  


Current Time: Fri Apr 19 01:11:16 GMT 2024

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

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

Back to the top