Table doesn't render right on Mac OS X [message #460663] |
Fri, 02 September 2005 16:05  |
Eclipse User |
|
|
|
I'm having two problems when trying to display a table on Mac OS X:
- grid lines are never visible (setLinesVisible(true) has no effect
- the table is much wider than needed (about double) -- calling pack() or
setSize(computeSize()) has no effect.
The same code, when run on a Windows box, behaves as expected.
Running Mac OS 10.4.2, Eclipse 3.1.
Are there known gotchas in table rendering between OS X and Windows?
Anything I can add to the code below to make it display consistently
across both (preferably all) platforms?
Thanks,
Mike
Sample code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
public class MacExample {
public static void main(String[] args) {
Display display = new Display();
GridLayout layout = new GridLayout();
layout.numColumns =1;
Shell shell = new Shell(display);
shell.setLayout(layout);
Table grid = new Table(shell, SWT.SINGLE);
grid.setLinesVisible(true);
int columns = 4;
int rows = 10;
for (int i = 0; i < columns; i++) {
TableColumn tc2 = new TableColumn(grid, SWT.CENTER);
tc2.setWidth(10);
tc2.pack();
}
TableItem[] items = new TableItem[rows];
for (int i = 0; i < rows; i++) {
TableItem item = new TableItem(grid, SWT.NONE);
item.setText(new String[] {"1", "2", "3", "4"});
items[i] = item;
}
for (int i=0; i<columns; i++) {
TableColumn tc = grid.getColumn(i);
tc.pack();
}
grid.pack();
grid.setSize(grid.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
|
|
|
|
Re: Table doesn't render right on Mac OS X [message #460765 is a reply to message #460663] |
Tue, 06 September 2005 20:59  |
Eclipse User |
|
|
|
Try again using the latest code from HEAD. Both problems should be fixed.
If you are running Tiger, then grid lines are supported (otherwise, they are
not supported because the operating system had no such concept). The
computeSize() bugs should also be fixed.
"Mike Yawn" <mike@theYawns.com> wrote in message
news:23d67c8856eba91a12e7c4108b5e8ea9$1@www.eclipse.org...
> I'm having two problems when trying to display a table on Mac OS X:
>
> - grid lines are never visible (setLinesVisible(true) has no effect
> - the table is much wider than needed (about double) -- calling pack() or
> setSize(computeSize()) has no effect.
>
> The same code, when run on a Windows box, behaves as expected.
>
> Running Mac OS 10.4.2, Eclipse 3.1.
>
> Are there known gotchas in table rendering between OS X and Windows?
> Anything I can add to the code below to make it display consistently
> across both (preferably all) platforms?
>
> Thanks,
> Mike
>
> Sample code:
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.GridLayout;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
> import org.eclipse.swt.widgets.Table;
> import org.eclipse.swt.widgets.TableColumn;
> import org.eclipse.swt.widgets.TableItem;
>
>
> public class MacExample {
>
> public static void main(String[] args) {
>
> Display display = new Display();
> GridLayout layout = new GridLayout();
> layout.numColumns =1;
> Shell shell = new Shell(display);
> shell.setLayout(layout);
>
> Table grid = new Table(shell, SWT.SINGLE);
> grid.setLinesVisible(true);
>
> int columns = 4;
> int rows = 10;
>
>
> for (int i = 0; i < columns; i++) {
> TableColumn tc2 = new TableColumn(grid, SWT.CENTER);
> tc2.setWidth(10);
> tc2.pack();
> }
>
>
> TableItem[] items = new TableItem[rows];
> for (int i = 0; i < rows; i++) {
> TableItem item = new TableItem(grid, SWT.NONE);
> item.setText(new String[] {"1", "2", "3", "4"});
> items[i] = item;
> }
>
> for (int i=0; i<columns; i++) {
> TableColumn tc = grid.getColumn(i);
> tc.pack();
> }
> grid.pack();
> grid.setSize(grid.computeSize(SWT.DEFAULT, SWT.DEFAULT, true));
> shell.pack();
>
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch())
> display.sleep();
> }
> display.dispose();
> }
>
> }
>
|
|
|
Powered by
FUDForum. Page generated in 0.05537 seconds