ScrollBar.setIncrement() no effect on Linux? [message #557715] |
Wed, 08 September 2010 11:16  |
Eclipse User |
|
|
|
Hey!
Is there a known issue with the setIncrement Method? what i'm trying to do ist the following:
final ScrollBar vBar2 = table.getVerticalBar();
if (vBar2 != null) {
vBar2.setIncrement(table.getItemHeight());
}
that seems to work on windows, and have no effect on linux. the plan is, that the table scrolls only one items height at a time (so i can guarantee, that the topmost item is always shown completely). linux is off by one or two pixels per item, resulting in what i don't want: half shown items.
completely removeing the above code, the scrolling behaviour stays exactly the same, and setting the increment to 100 also has no effect at all...?!
any insights?
Thanks!
Rgards, Markus
|
|
|
|
Re: ScrollBar.setIncrement() no effect on Linux? [message #557989 is a reply to message #557730] |
Thu, 09 September 2010 13:03   |
Eclipse User |
|
|
|
Hi Markus,
For scrollbars like these that are created and owned by native controls you
cannot count on being able to control them like this. It may work on some
platforms/situations but is not guaranteed to always do so.
For the specific problem that you describe, an approach like the snippet
below should ensure that partial items are never shown as a result of
clicking on the scrollbar's up or down arrow, which is what setIncrement()
controls for Scrollbars in other contexts.
public class Main {
static int lastTopIndex = 0;
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,600,600);
final Table table = new Table(shell, SWT.V_SCROLL);
table.setBounds(10,10,500,500);
for (int i = 0; i < 99; i++) {
new TableItem(table, SWT.NONE).setText("item " + i);
}
table.getVerticalBar().addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
int topIndex = table.getTopIndex();
if (topIndex != lastTopIndex) {
lastTopIndex = topIndex;
table.setTopIndex(topIndex);
}
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
}
HTH,
Grant
"Markus Duft" <markus.duft@salomon.at> wrote in message
news:i68avn$hg1$1@build.eclipse.org...
> hm... playing some more on a windows 7 host - it doesn't work there
> either. independently of what i set the value to (and, yes, the
> setIncrement get's called, i breakpointed it ;)), scrolling behaviour
> never changes...
|
|
|
|
Powered by
FUDForum. Page generated in 0.03902 seconds