Pages

about my opensource eclipse java applications recently i'm studying GWT and Android

Monday, August 08, 2005

Scroll ScrollPane by MouseWheel [Draw2D]

Create class implement SelectionListener and write that.

public class WheelMove implements SelectionListener{

public void widgetSelected(SelectionEvent arg0) {
ScrollBar bar=scrollpane.getHorizontalScrollBar();
int direction=1;//16777218
if(arg0.detail==16777217){
direction=-1;
}
bar.setValue(bar.getValue()+direction*bar.getStepIncrement());

}
public void widgetDefaultSelected(SelectionEvent arg0) {
}
}

and get Real ScrollBar of FigureCanvas and add a addSelectionListener.

FigureCanvas canvas = new FigureCanvas(shell);
canvas.getVerticalBar().addSelectionListener(new WheelMove());

FullCode
http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/akjrcp/draw2dexample/src/example/draw2d/NonOpaqueViewPort.java?rev=HEAD&content-type=text/vnd.viewcvs-markup

Change isOpaque() of ScrollPane [Draw2D]

Finaly,I upload sample codes to cvs.
see here
http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/akjrcp/draw2dexample/src/example/draw2d/

I'm sorry,I don't have any way to know other platform results.
So I guess sometime on non-windows platrom it's didn't work correctly.

isOpaque methods of Scrollpane return always true.
but if you don't like it,overwrite it.

public class NoOpaqueScrollPane extends ScrollPane{
public boolean isOpaque(){
return false;
}
}


FullCode
http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/akjrcp/draw2dexample/src/example/draw2d/NonOpaqueViewPort.java?rev=HEAD&content-type=text/vnd.viewcvs-markup