Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » ScrollBar getThumb() inconsistencies between Linux and Windows
ScrollBar getThumb() inconsistencies between Linux and Windows [message #455484] Mon, 16 May 2005 21:49 Go to next message
Eclipse User
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

{

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;

}

}

}

}
Re: ScrollBar getThumb() inconsistencies between Linux and Windows [message #455567 is a reply to message #455484] Tue, 17 May 2005 18:10 Go to previous message
Steve Northover is currently offline Steve Northover
Messages: 1636
Registered: July 2009
Senior Member
The operating system scrolling policy can be different between platforms.
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;
>
> }
>
> }
>
> }
>
> }
>
>
Previous Topic:VerifyListener in a TextCellEditor... bug?
Next Topic:Soft vertical scrolling in Table?
Goto Forum:
  


Current Time: Sun Oct 26 08:32:28 GMT 2014

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

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