Note that there are some explanatory texts on larger screens.

plurals
  1. POSWT: Nested Layouts with ScrolledComposite exceeds available space
    primarykey
    data
    text
    <p>I want to build a Master-Detail layout for one of my applications using SWT.</p> <p>Container, Content, Sidebar and Part1 are Composite instances. Scrolled is a ScrolledComposite</p> <p>The desired layout is something like:</p> <pre><code>+--Container-------------------------------------+ |+--Content----------------------++--Sidebar----+| || ||+--Part1----+|| || ||| ||| || ||| ||| || ||| ||| || ||| ||| || ||| ||| || ||+-----------+|| || ||+--Scrolled-+|| || ||| ||| || ||| ||| || ||| ||| || ||| ||| || ||| ||| || ||+-----------+|| |+-------------------------------++-------------+| +------------------------------------------------+ </code></pre> <p>The Content should grab all the space horizontally and vertically that is available.</p> <p>The sidebar is basically a container for Part1 and Scrolled which should be of equal height.</p> <p>Scrolled is the container for a Composite containing a dynamic number of sub items which are arranged in the content composite. Because there can be a large variation of the number of sub-items, this Composite should be scrollable.</p> <p>I have now implemented this in the following way:</p> <ul> <li><p>Container has a GridLayout with 2 colums.</p></li> <li><p>Inside of that the content has FILL_BOTH behaviour and grabs also all HORIZONTAL/VERTICAL space.</p></li> <li><p>The sidebar has a FillLayout(SWT.VERTICAL) and contains the Part1 and Scrolled Childs.</p></li> </ul> <p><strong>Problem:</strong> When putting a lot of items into the scrolled composite and the layout just overflows the available space and there is no scrolling available where it should be.</p> <p>When I use a FillLayout(SWT.HORIZONTAL) for the container the behaviour is as desired, since there is a scrolling and everything is "inside bounds".</p> <p>Is there a way to achieve this behaviour also when using a GridLayout because I want the content to grab most of the space.</p> <p>Attached the current test SWT snippet:</p> <pre><code>public class Scrolled { public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout(2,false)); //shell.setLayout(new FillLayout(SWT.HORIZONTAL)); Composite content = new Composite(shell, SWT.BORDER); content.setLayoutData(new GridData(SWT.LEFT,SWT.CENTER,false,false)); Composite sidebar = new Composite(shell, SWT.BORDER); sidebar.setLayout(new FillLayout(SWT.VERTICAL)); sidebar.setLayoutData(new GridData(SWT.LEFT,SWT.CENTER,false,false)); Composite cc = new Composite(sidebar, SWT.BORDER); ScrolledComposite sc = new ScrolledComposite(sidebar, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); sc.setLayout(new GridLayout(1,true)); Composite c = new Composite(sc, SWT.NONE); c.setSize(400, 400); c.setLayout(new GridLayout(1, true)); for(int i = 0; i &lt; 1000; i++){ new Button(c, SWT.PUSH).setText("Text"); } sc.setMinSize(c.computeSize(SWT.DEFAULT, SWT.DEFAULT)); sc.setContent(c); sc.setExpandHorizontal(true); sc.setExpandVertical(true); sc.setAlwaysShowScrollBars(true); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload