Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » ScollableComposite and different layouts
ScollableComposite and different layouts [message #460486] Mon, 29 August 2005 20:13
Eclipse UserFriend
Originally posted by: stefan_30.gmx.net

Hi there,
I have a large problem...

I have to develop an application for a Compaq iPaq Pocket PC 3970. The shell
is divided into two composites. The lower area contains always different
tables (only one table is visible) and has an own composite.
The upper composite contains buttons, labels and textfields.

If the keyboard will be opened, the lower area (tables) should be
"minimized" and scrollable (like figure 4 and 5 in the following link)
http://www.eclipse.org/articles/Article-small-cup-of-swt/poc ket-PC.html

The problem is:
If the layout from the shell is set to FillLayout, the application has the
functionality more or less (both areas have the same width (upper area is
much too large)). If the application is automatically resized, the upper
tables are correctly scrollable.

Has the shell another layout, the scrollbars are not visible and there is no
possibility to make them visible.

Where can I download the source from SWT/JFace?? I want to compare the
FillLayout with the GridLayout class??

Enclosed I will post the code....

Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new FillLayout());

// RowLayout rowLayout = new RowLayout();
// rowLayout.wrap = false;
// shell.setLayout(rowLayout);

// GridLayout gridLayout = new GridLayout();
// gridLayout.numColumns = 2;
// gridLayout.marginWidth = 1;
// shell.setLayout(gridLayout);

final ScrolledComposite sc1 = new ScrolledComposite (shell,
SWT.H_SCROLL | SWT.V_SCROLL);
// final ScrolledComposite sc2 = new ScrolledComposite (shell,
SWT.H_SCROLL | SWT.V_SCROLL);

Table table1 = new Table(sc1,SWT.SINGLE);
table1.setHeaderVisible(false);
table1.setLinesVisible(true);

TableColumn col1 = new TableColumn(table1,SWT.LEFT);
col1.setWidth(200);
TableColumn col2 = new TableColumn(table1,SWT.LEFT);
col2.setWidth(60);

for (int i = 0; i < 60; i++) {
TableItem item1 = new TableItem(table1,0);
item1.setText(new String[]{"Line " + i,"b"});
}

// Table table2 = new Table(sc2,SWT.SINGLE);
// table2.setHeaderVisible(false);
// table2.setLinesVisible(true);

// for (int i = 0; i < 10; i++) {
// TableColumn col21 = new TableColumn(table2,SWT.LEFT);
// col21.setWidth(80);
// }

// for (int i = 0; i < 60; i++) {
// TableItem item1 = new TableItem(table2,0);
// item1.setText(new String[]{"Line "+i,"c"});
// }

sc1.setContent(table1);
table1.pack();

// sc2.setContent(table2);
// table2.pack();

// sc1.setAlwaysShowScrollBars(true);
// sc1.setExpandVertical(true);

final ScrollBar vBar1 = sc1.getVerticalBar ();
// final ScrollBar vBar2 = sc2.getVerticalBar ();
final ScrollBar hBar1 = sc1.getHorizontalBar ();
// final ScrollBar hBar2 = sc2.getHorizontalBar ();

SelectionListener listener1 = new SelectionAdapter () {
public void widgetSelected (SelectionEvent e) {
int x = hBar1.getSelection() * (hBar2.getMaximum() -
hBar2.getThumb()) / Math.max(1, hBar1.getMaximum() - hBar1.getThumb());
int y = vBar1.getSelection() * (vBar2.getMaximum() -
vBar2.getThumb()) / Math.max(1, vBar1.getMaximum() - vBar1.getThumb());
sc2.setOrigin (x, y);
}
};
SelectionListener listener2 = new SelectionAdapter () {
public void widgetSelected (SelectionEvent e) {
int x = hBar2.getSelection() * (hBar1.getMaximum() -
hBar1.getThumb()) / Math.max(1, hBar2.getMaximum() - hBar2.getThumb());
int y = vBar2.getSelection() * (vBar1.getMaximum() -
vBar1.getThumb()) / Math.max(1, vBar2.getMaximum() - vBar2.getThumb());
sc1.setOrigin (x, y);
}
};
vBar1.addSelectionListener (listener1);
hBar1.addSelectionListener (listener1);
// vBar2.addSelectionListener (listener2);
// hBar2.addSelectionListener (listener2);

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


I hope you can help me!?
Previous Topic:Is it possible to have a ScrolledComposite with width>32767 on Windows 2000
Next Topic:ISelectionProvider and reloading it
Goto Forum:
  


Current Time: Fri Apr 26 06:42:46 GMT 2024

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

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

Back to the top