Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsScrollBar getThumb() inconsistencies between Linux and Windows
https://www.eclipse.org/forums/index.php/mv/msg/144710/455484/#msg_455484
Originally posted by: gtoor.pervasive.com
Running the following snippet shows different behavior on Windows on Linux
OS. On Windows XP, the ScrollBar.getThumb() returns the number of lines in
the table in the viewport. On Linux (SuSE 9.2 prof), the same call seems to
returns the number of pixels visible for a table.
Also the Scrollbar events on Linux always shows a value of 0 for
event.details, while on Windows, the event details reflects the user action
(click on arrow, click for page up/down or drag event). I saw an earlier
posting from a year ago saying this was a bug in GTK. Any progress on that
issue? (See below for previous thread discussion)
[Steve Northover]
Sorry, GTK just doesn't provide the information. We have a bugzilla report
open against them and they said they will be fixing it.
"Oded cohen" <oded.cohen@XXX.XXX> wrote in message
news:c2q6q3$i92$1@eclipse.org...
> first of all - thnx for the quick response...
>
> when I wrote the snippet I notices that when I'm dragging the scroll bar
> I'm getting sevral events in all the platforms. The problem in GTK is that
> the detail member of the event object is always 0 where in other platforms
> I'm getting detail == SWT.DRAG (so I can filter it until I'm getting the
> last event which is different).
>
> another thing I noticed is - if I just click with the mouse one time to
> scroll - in GTK I get 2 different scroll events (for no reason).
>
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
/**
* ADDDOCS
*/
public class TableSnippet
{
private static ScrollBar vsb;
private static Table table;
public static void main(String[] args)
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
shell.setText("Table Scroll Events Snippet");
createTable(shell);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
private static void createTable(Shell shell) {
table = new Table(shell,SWT.SINGLE);
TableColumn col1 =
new TableColumn(table,SWT.LEFT);
col1.setText("Coloumn 1");
col1.setWidth(80);
TableColumn col2 =
new TableColumn(table,SWT.LEFT);
col2.setText("Coloumn 2");
col2.setWidth(80);
for (int i=0; i< 150; i++) {
TableItem item1 = new TableItem(table,0);
item1.setText(new String[]{"a"+ i,"b" + i});
}
table.setHeaderVisible(true);
table.setLinesVisible(true);
vsb = table.getVerticalBar();
vsb.addSelectionListener(new ScrollBarHandler());
}
static class ScrollBarHandler extends SelectionAdapter
}]]>2005-05-16T21:49:49-00:00Re: ScrollBar getThumb() inconsistencies between Linux and Windows
https://www.eclipse.org/forums/index.php/mv/msg/144710/455567/#msg_455567
On Windows it uses lines, on GTK pixels. What are you trying to do?
"Gagan Toor" <gtoor@pervasive.com> wrote in message
news:d6b4hv$19g$1@news.eclipse.org...
> Running the following snippet shows different behavior on Windows on Linux
> OS. On Windows XP, the ScrollBar.getThumb() returns the number of lines
in
> the table in the viewport. On Linux (SuSE 9.2 prof), the same call seems
to
> returns the number of pixels visible for a table.
>
> Also the Scrollbar events on Linux always shows a value of 0 for
> event.details, while on Windows, the event details reflects the user
action
> (click on arrow, click for page up/down or drag event). I saw an earlier
> posting from a year ago saying this was a bug in GTK. Any progress on
that
> issue? (See below for previous thread discussion)
>
>
> [Steve Northover]
> Sorry, GTK just doesn't provide the information. We have a bugzilla
report
> open against them and they said they will be fixing it.
>
> "Oded cohen" <oded.cohen@XXX.XXX> wrote in message
> news:c2q6q3$i92$1@eclipse.org...
> > first of all - thnx for the quick response...
> >
> > when I wrote the snippet I notices that when I'm dragging the scroll bar
> > I'm getting sevral events in all the platforms. The problem in GTK is
that
> > the detail member of the event object is always 0 where in other
platforms
> > I'm getting detail == SWT.DRAG (so I can filter it until I'm getting the
> > last event which is different).
> >
> > another thing I noticed is - if I just click with the mouse one time to
> > scroll - in GTK I get 2 different scroll events (for no reason).
> >
>
>
>
> import org.eclipse.swt.SWT;
>
> import org.eclipse.swt.events.SelectionAdapter;
>
> import org.eclipse.swt.events.SelectionEvent;
>
> import org.eclipse.swt.layout.FillLayout;
>
> import org.eclipse.swt.widgets.Display;
>
> import org.eclipse.swt.widgets.ScrollBar;
>
> import org.eclipse.swt.widgets.Shell;
>
> import org.eclipse.swt.widgets.Table;
>
> import org.eclipse.swt.widgets.TableColumn;
>
> import org.eclipse.swt.widgets.TableItem;
>
>
>
> /**
>
> * ADDDOCS
>
> */
>
> public class TableSnippet
>
> {
>
> private static ScrollBar vsb;
>
> private static Table table;
>
>
> public static void main(String[] args)
>
> {
>
> Display display = new Display();
>
> Shell shell = new Shell(display);
>
> shell.setLayout(new FillLayout());
>
> shell.setText("Table Scroll Events Snippet");
>
> createTable(shell);
>
>
> shell.pack();
>
> shell.open();
>
> while (!shell.isDisposed()) {
>
> if (!display.readAndDispatch())
>
> display.sleep();
>
> }
>
> display.dispose();
>
> }
>
> private static void createTable(Shell shell) {
>
> table = new Table(shell,SWT.SINGLE);
>
> TableColumn col1 =
>
> new TableColumn(table,SWT.LEFT);
>
> col1.setText("Coloumn 1");
>
> col1.setWidth(80);
>
> TableColumn col2 =
>
> new TableColumn(table,SWT.LEFT);
>
> col2.setText("Coloumn 2");
>
> col2.setWidth(80);
>
>
> for (int i=0; i< 150; i++) {
>
> TableItem item1 = new TableItem(table,0);
>
> item1.setText(new String[]{"a"+ i,"b" + i});
>
> }
>
>
> table.setHeaderVisible(true);
>
> table.setLinesVisible(true);
>
> vsb = table.getVerticalBar();
>
> vsb.addSelectionListener(new ScrollBarHandler());
>
> }
>
>
> static class ScrollBarHandler extends SelectionAdapter
>
> {
>
> public void widgetSelected(SelectionEvent ev)
>
> {
>
> System.out.println("Scrollbar Event: " + ev.detail + "- #Lines: "
>
> + vsb.getThumb() + " - " + vsb.getThumb()/(table.getItemHeight() +
>
> table.getGridLineWidth()));
>
>
> switch(ev.detail)
>
> {
>
> case SWT.ARROW_UP:
>
> System.out.println("Arrow Up");
>
> break;
>
>
> case SWT.ARROW_DOWN:
>
> System.out.println("Arrow Down");
>
> break;
>
>
> case SWT.PAGE_UP:
>
> System.out.println("Page Up");
>
> break;
>
>
> case SWT.PAGE_DOWN:
>
> System.out.println("Page Down");
>
> break;
>
>
> case SWT.DRAG:
>
> System.out.println("DRAG Event");
>
> break;
>
> }
>
> }
>
> }
>
> }
>
>]]>Steve Northover2005-05-17T18:10:47-00:00