Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » scrolling behaviour of scrolledcomposite within scrolledcomposite
scrolling behaviour of scrolledcomposite within scrolledcomposite [message #454081] Fri, 15 April 2005 13:39 Go to next message
Rudolf Traunmüller is currently offline Rudolf TraunmüllerFriend
Messages: 21
Registered: July 2009
Junior Member
i've a scrolledcomposite whose parent is also a scrolledcomposite.
Right now, whenever I add controls to the inner scrolledcomposite so
its conent height extends the available height, the inner
scrolledcomposite's height increase and the scrollbars of the outer
scrolledcomposite appear. How can I change this behaviour so that the
inner scrolledcomposite's scrollbars appear whenever the content
becomes to large? the inner scrolledcomposite should layouts itself
according to the layout manager of the outer composite. so for example
have a 5 pixel margin on each side.
Re: scrolling behaviour of scrolledcomposite within scrolledcomposite [message #454082 is a reply to message #454081] Fri, 15 April 2005 16:01 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
You need to use layouts to manage the size and growth of your children.

For example:


public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());
final ScrolledComposite outer = new ScrolledComposite(shell,
SWT.V_SCROLL | SWT.H_SCROLL);
final Composite contentOuter = new Composite(outer, SWT.NONE);
contentOuter.setLayout(new GridLayout(2, false));
contentOuter.setBackground(display.getSystemColor(SWT.COLOR_ BLUE));
final ScrolledComposite inner = new ScrolledComposite(contentOuter,
SWT.V_SCROLL | SWT.H_SCROLL);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 6);
data.widthHint = 323;
data.heightHint = 200;
inner.setLayoutData(data);
for (int i = 0; i < 5; i++) {
Button b = new Button(contentOuter, SWT.PUSH);
b.setText("Outer Button "+i);
}
final Composite contentInner = new Composite(inner, SWT.NONE);
contentInner.setLayout(new GridLayout(3, false));
contentInner.setBackground(display.getSystemColor(SWT.COLOR_ RED));
Button doit = new Button(contentInner, SWT.PUSH);
doit.setText("add more children");
doit.addListener(SWT.Selection, new Listener() {
int index = 0;
public void handleEvent(Event e) {
Button b = new Button(contentInner, SWT.PUSH);
b.setText("New Button "+index++);
Point size = contentInner.computeSize(SWT.DEFAULT,
SWT.DEFAULT);
inner.setMinSize(size);
contentInner.layout(false);
}
});
for (int i = 0; i < 5; i++) {
Button b = new Button(contentInner, SWT.PUSH);
b.setText("Inner Button "+i);
}
inner.setContent(contentInner);
inner.setExpandHorizontal(true);
inner.setExpandVertical(true);
Point size = contentInner.computeSize(SWT.DEFAULT, SWT.DEFAULT);
inner.setMinSize(size);

outer.setContent(contentOuter);
outer.setExpandHorizontal(true);
outer.setExpandVertical(true);
outer.setMinSize(contentOuter.computeSize(SWT.DEFAULT,
SWT.DEFAULT));

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

"Rudolf Traunm
Re: scrolling behaviour of scrolledcomposite within scrolledcomposite [message #454087 is a reply to message #454082] Fri, 15 April 2005 20:56 Go to previous messageGo to next message
Rudolf Traunmüller is currently offline Rudolf TraunmüllerFriend
Messages: 21
Registered: July 2009
Junior Member
thx for the answer, this is really useful!

However, I've a similar problem in the IDetailsPart of a
MasterDetailsBlock -> i've a table with many items in my detailpart.
The problem is that the scrollbars appear on the form, not on the the
table, so both, the table and the form, are very large. How can I fix
this behaviour?

On Fri, 15 Apr 2005 12:01:48 -0400, "Veronika Irvine"
<veronika_irvine@oti.com> wrote:

>You need to use layouts to manage the size and growth of your children.
>
>For example:
>
>
>public static void main (String [] args) {
> Display display = new Display ();
> Shell shell = new Shell (display);
> shell.setLayout(new FillLayout());
> final ScrolledComposite outer = new ScrolledComposite(shell,
>SWT.V_SCROLL | SWT.H_SCROLL);
> final Composite contentOuter = new Composite(outer, SWT.NONE);
> contentOuter.setLayout(new GridLayout(2, false));
> contentOuter.setBackground(display.getSystemColor(SWT.COLOR_ BLUE));
> final ScrolledComposite inner = new ScrolledComposite(contentOuter,
>SWT.V_SCROLL | SWT.H_SCROLL);
> GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 6);
> data.widthHint = 323;
> data.heightHint = 200;
> inner.setLayoutData(data);
> for (int i = 0; i < 5; i++) {
> Button b = new Button(contentOuter, SWT.PUSH);
> b.setText("Outer Button "+i);
> }
> final Composite contentInner = new Composite(inner, SWT.NONE);
> contentInner.setLayout(new GridLayout(3, false));
> contentInner.setBackground(display.getSystemColor(SWT.COLOR_ RED));
> Button doit = new Button(contentInner, SWT.PUSH);
> doit.setText("add more children");
> doit.addListener(SWT.Selection, new Listener() {
> int index = 0;
> public void handleEvent(Event e) {
> Button b = new Button(contentInner, SWT.PUSH);
> b.setText("New Button "+index++);
> Point size = contentInner.computeSize(SWT.DEFAULT,
>SWT.DEFAULT);
> inner.setMinSize(size);
> contentInner.layout(false);
> }
> });
> for (int i = 0; i < 5; i++) {
> Button b = new Button(contentInner, SWT.PUSH);
> b.setText("Inner Button "+i);
> }
> inner.setContent(contentInner);
> inner.setExpandHorizontal(true);
> inner.setExpandVertical(true);
> Point size = contentInner.computeSize(SWT.DEFAULT, SWT.DEFAULT);
> inner.setMinSize(size);
>
> outer.setContent(contentOuter);
> outer.setExpandHorizontal(true);
> outer.setExpandVertical(true);
> outer.setMinSize(contentOuter.computeSize(SWT.DEFAULT,
>SWT.DEFAULT));
>
> shell.pack();
> shell.open ();
> while (!shell.isDisposed ()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
>}
>
>"Rudolf Traunmüller" <rudolf.traunmueller.privat@maat.at> wrote in message
>news:tlgv515sponaga3cni748utm11np35kush@4ax.com...
>> i've a scrolledcomposite whose parent is also a scrolledcomposite.
>> Right now, whenever I add controls to the inner scrolledcomposite so
>> its conent height extends the available height, the inner
>> scrolledcomposite's height increase and the scrollbars of the outer
>> scrolledcomposite appear. How can I change this behaviour so that the
>> inner scrolledcomposite's scrollbars appear whenever the content
>> becomes to large? the inner scrolledcomposite should layouts itself
>> according to the layout manager of the outer composite. so for example
>> have a 5 pixel margin on each side.
>
Re: scrolling behaviour of scrolledcomposite within scrolledcomposite [message #454088 is a reply to message #454087] Fri, 15 April 2005 23:49 Go to previous message
Rudolf Traunmüller is currently offline Rudolf TraunmüllerFriend
Messages: 21
Registered: July 2009
Junior Member
solved. you have to add a widthHint and heightHint on the GridData of
the table.

On Fri, 15 Apr 2005 22:56:46 +0200, Rudolf Traunmüller
<rudolf.traunmueller.privat@maat.at> wrote:

>thx for the answer, this is really useful!
>
>However, I've a similar problem in the IDetailsPart of a
>MasterDetailsBlock -> i've a table with many items in my detailpart.
>The problem is that the scrollbars appear on the form, not on the the
>table, so both, the table and the form, are very large. How can I fix
>this behaviour?
>
>On Fri, 15 Apr 2005 12:01:48 -0400, "Veronika Irvine"
><veronika_irvine@oti.com> wrote:
>
>>You need to use layouts to manage the size and growth of your children.
>>
>>For example:
>>
>>
>>public static void main (String [] args) {
>> Display display = new Display ();
>> Shell shell = new Shell (display);
>> shell.setLayout(new FillLayout());
>> final ScrolledComposite outer = new ScrolledComposite(shell,
>>SWT.V_SCROLL | SWT.H_SCROLL);
>> final Composite contentOuter = new Composite(outer, SWT.NONE);
>> contentOuter.setLayout(new GridLayout(2, false));
>> contentOuter.setBackground(display.getSystemColor(SWT.COLOR_ BLUE));
>> final ScrolledComposite inner = new ScrolledComposite(contentOuter,
>>SWT.V_SCROLL | SWT.H_SCROLL);
>> GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 6);
>> data.widthHint = 323;
>> data.heightHint = 200;
>> inner.setLayoutData(data);
>> for (int i = 0; i < 5; i++) {
>> Button b = new Button(contentOuter, SWT.PUSH);
>> b.setText("Outer Button "+i);
>> }
>> final Composite contentInner = new Composite(inner, SWT.NONE);
>> contentInner.setLayout(new GridLayout(3, false));
>> contentInner.setBackground(display.getSystemColor(SWT.COLOR_ RED));
>> Button doit = new Button(contentInner, SWT.PUSH);
>> doit.setText("add more children");
>> doit.addListener(SWT.Selection, new Listener() {
>> int index = 0;
>> public void handleEvent(Event e) {
>> Button b = new Button(contentInner, SWT.PUSH);
>> b.setText("New Button "+index++);
>> Point size = contentInner.computeSize(SWT.DEFAULT,
>>SWT.DEFAULT);
>> inner.setMinSize(size);
>> contentInner.layout(false);
>> }
>> });
>> for (int i = 0; i < 5; i++) {
>> Button b = new Button(contentInner, SWT.PUSH);
>> b.setText("Inner Button "+i);
>> }
>> inner.setContent(contentInner);
>> inner.setExpandHorizontal(true);
>> inner.setExpandVertical(true);
>> Point size = contentInner.computeSize(SWT.DEFAULT, SWT.DEFAULT);
>> inner.setMinSize(size);
>>
>> outer.setContent(contentOuter);
>> outer.setExpandHorizontal(true);
>> outer.setExpandVertical(true);
>> outer.setMinSize(contentOuter.computeSize(SWT.DEFAULT,
>>SWT.DEFAULT));
>>
>> shell.pack();
>> shell.open ();
>> while (!shell.isDisposed ()) {
>> if (!display.readAndDispatch ()) display.sleep ();
>> }
>> display.dispose ();
>>}
>>
>>"Rudolf Traunmüller" <rudolf.traunmueller.privat@maat.at> wrote in message
>>news:tlgv515sponaga3cni748utm11np35kush@4ax.com...
>>> i've a scrolledcomposite whose parent is also a scrolledcomposite.
>>> Right now, whenever I add controls to the inner scrolledcomposite so
>>> its conent height extends the available height, the inner
>>> scrolledcomposite's height increase and the scrollbars of the outer
>>> scrolledcomposite appear. How can I change this behaviour so that the
>>> inner scrolledcomposite's scrollbars appear whenever the content
>>> becomes to large? the inner scrolledcomposite should layouts itself
>>> according to the layout manager of the outer composite. so for example
>>> have a 5 pixel margin on each side.
>>
Previous Topic:Launching the system mail reader
Next Topic:Changing the size of a Tables rows
Goto Forum:
  


Current Time: Thu Apr 25 07:08:27 GMT 2024

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

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

Back to the top