Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Table layout on Linux/GTK
Table layout on Linux/GTK [message #460069] Mon, 22 August 2005 00:31 Go to next message
Vladimir Grishchenko is currently offline Vladimir GrishchenkoFriend
Messages: 7
Registered: July 2009
Junior Member
For the purposes of my application I'm implementing a mechanism that
persists selected table column widths across platform restarts. For this
purpose I wrote a custom table layout manager (I couldn't use the supplied
TableLayout for reasons not relevant to this problem) and I have a control
listener on each table column that saves the new width whenever a column is
resized by the user. That saved width is then used by my layout manager to
size the columns whenever it is asked to layout the table. The problem is
this works fine on win32, but when running on Linux/GTK some internal
mechanism sets column sizes initially to some default values, looks like it
is 10 pixels for each column, and the last column is made to occupy the rest
of the available space on the right. This happens even if no layout manager
was set and prior to layout() is called on the manager if it is set. As a
result I'm stuck with these values as my layout manager will use them when
its layout() method is called.

When run, the following snippet will print nothing on win32 but will print 2
resize and 1 move event on GTK. Any Ideas?

Thanks,
Vladimir.

------------------------------------------------------------ -------

Display display = new Display ();
Shell shell = new Shell (display);
shell.setSize (200, 200);
shell.setLayout(new FillLayout());
shell.open ();

Table table = new Table (shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
table.setLinesVisible(true);
table.setHeaderVisible(true);
TableColumn col1 = new TableColumn(table, SWT.NONE);
col1.setResizable(true);
col1.setText("col1");
TableColumn col2 = new TableColumn(table, SWT.NONE);
col2.setResizable(true);
col2.setText("col2");
ControlListener listener = new ControlListener() {

public void controlMoved(ControlEvent e) {
System.out.println("moved");
}

public void controlResized(ControlEvent e) {
System.out.println("resized " + ((TableColumn)e.widget).getWidth());
}
};
col1.addControlListener(listener);
col2.addControlListener(listener);

for (int i=0; i<12; i++) {
TableItem item = new TableItem (table, 0);
item.setText (0, "Item " + i);
item.setText (1, "Item_ " + i);
}
shell.layout();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
Re: Table layout on Linux/GTK [message #460074 is a reply to message #460069] Mon, 22 August 2005 01:28 Go to previous messageGo to next message
Vladimir Grishchenko is currently offline Vladimir GrishchenkoFriend
Messages: 7
Registered: July 2009
Junior Member
Seems that the workaround for this problem is to set the column width
initially to the value would
be set by the layout manager in its layout() method. This will still
generate the initial resize
events but the new width will be what was explicitly set instead of the
default length values
(coming from GTK???).

"Vladimir Grishchenko" <vgrishchenko@serena.com> wrote in message
news:deb6b4$9m3$1@news.eclipse.org...
> For the purposes of my application I'm implementing a mechanism that
> persists selected table column widths across platform restarts. For this
> purpose I wrote a custom table layout manager (I couldn't use the supplied
> TableLayout for reasons not relevant to this problem) and I have a control
> listener on each table column that saves the new width whenever a column
is
> resized by the user. That saved width is then used by my layout manager to
> size the columns whenever it is asked to layout the table. The problem is
> this works fine on win32, but when running on Linux/GTK some internal
> mechanism sets column sizes initially to some default values, looks like
it
> is 10 pixels for each column, and the last column is made to occupy the
rest
> of the available space on the right. This happens even if no layout
manager
> was set and prior to layout() is called on the manager if it is set. As a
> result I'm stuck with these values as my layout manager will use them when
> its layout() method is called.
>
> When run, the following snippet will print nothing on win32 but will print
2
> resize and 1 move event on GTK. Any Ideas?
>
> Thanks,
> Vladimir.
>
> ------------------------------------------------------------ -------
>
> Display display = new Display ();
> Shell shell = new Shell (display);
> shell.setSize (200, 200);
> shell.setLayout(new FillLayout());
> shell.open ();
>
> Table table = new Table (shell, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
> table.setLinesVisible(true);
> table.setHeaderVisible(true);
> TableColumn col1 = new TableColumn(table, SWT.NONE);
> col1.setResizable(true);
> col1.setText("col1");
> TableColumn col2 = new TableColumn(table, SWT.NONE);
> col2.setResizable(true);
> col2.setText("col2");
> ControlListener listener = new ControlListener() {
>
> public void controlMoved(ControlEvent e) {
> System.out.println("moved");
> }
>
> public void controlResized(ControlEvent e) {
> System.out.println("resized " + ((TableColumn)e.widget).getWidth());
> }
> };
> col1.addControlListener(listener);
> col2.addControlListener(listener);
>
> for (int i=0; i<12; i++) {
> TableItem item = new TableItem (table, 0);
> item.setText (0, "Item " + i);
> item.setText (1, "Item_ " + i);
> }
> shell.layout();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch ()) display.sleep ();
> }
> display.dispose ();
>
>
Re: Table layout on Linux/GTK [message #460250 is a reply to message #460069] Tue, 23 August 2005 13:40 Go to previous messageGo to next message
Billy Biggs is currently offline Billy BiggsFriend
Messages: 94
Registered: July 2009
Member
Vladimir Grishchenko wrote:
> When run, the following snippet will print nothing on win32 but will print 2
> resize and 1 move event on GTK. Any Ideas?

Please post a bug to bugs.eclipse.org/bugs/ against Platform > SWT
along with the code snippet.

Thanks,
-Billy
Re: Table layout on Linux/GTK [message #460289 is a reply to message #460250] Tue, 23 August 2005 17:45 Go to previous message
Vladimir Grishchenko is currently offline Vladimir GrishchenkoFriend
Messages: 7
Registered: July 2009
Junior Member
see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=107758

"Billy Biggs" <bbiggs@ca.ibm.com> wrote in message
news:def914$7k7$2@news.eclipse.org...
> Vladimir Grishchenko wrote:
> > When run, the following snippet will print nothing on win32 but will
print 2
> > resize and 1 move event on GTK. Any Ideas?
>
> Please post a bug to bugs.eclipse.org/bugs/ against Platform > SWT
> along with the code snippet.
>
> Thanks,
> -Billy
Previous Topic:Problems with Table and tableViewer
Next Topic:Firefox browser on Linux
Goto Forum:
  


Current Time: Tue Apr 16 18:05:26 GMT 2024

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

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

Back to the top