|
Re: Any way to draw on Browser object? [message #533542 is a reply to message #533461] |
Fri, 14 May 2010 14:01 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi Misha,
There isn't currently support for this. I could not find an existing bug
report for it, so if you want you can log one at
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform &component=SWT .
The closest that you can currently get is to open a Shell on top with a
region set according to the content to be painted. Depending on how much
you want to paint on top, this may or may not be a reasonable thing to do.
A basic example of this follows:
public class Main0 {
static Region region;
public static void main(String[] args) {
final Display display = new Display();
final Shell shell = new Shell(display);
shell.setBounds(10, 10, 400, 400);
shell.setLayout(new FillLayout());
final Browser browser = new Browser(shell, SWT.NONE);
browser.setUrl("eclipse.org");
shell.open();
display.timerExec(3333, new Runnable() {
public void run() {
Rectangle bounds = display.map(shell, null,
browser.getBounds());
Shell shell2 = new Shell(display, SWT.NO_TRIM | SWT.ON_TOP);
shell2.setBounds(bounds);
final int width = bounds.width;
region = new Region();
Rectangle pixel = new Rectangle(0, 0, 1, 1);
for (int i = 0; i < width; i++) {
pixel.x = pixel.y = i;
region.add(pixel);
}
shell2.setRegion(region);
shell2.addListener(SWT.Paint, new Listener() {
public void handleEvent(Event event) {
event.gc.drawLine(0, 0, width, width);
}
});
shell2.open();
}
});
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
region.dispose();
shell.dispose();
display.dispose();
}
}
HTH,
Grant
"Misha Koshelev" <misha680@gmail.com> wrote in message
news:hsii2v$ooh$1@build.eclipse.org...
> SWT.Paint seems not to be called/supported (works fine on Shell).
>
> Thank you
> Misha
|
|
|
|
Re: Any way to draw on Browser object? [message #533642 is a reply to message #533562] |
Fri, 14 May 2010 21:10 |
Misha Koshelev Messages: 31 Registered: May 2010 |
Member |
|
|
Thank you. My code looks something like:
Object[] coords=(Object[])result;
Rectangle rectangle=new Rectangle(((Double)coords[0]).intValue(),((Double)coords[1]).intValue(),((Double)coords[2]).intValue(),((Double)coords[3]).intValue());
rectangle.intersect(gui.getBrowser().getClientArea());
rectangle=display.map(gui.getBrowser(),null,rectangle);
if (rectangleShell!=null) {
rectangleShell.dispose();
}
rectangleShell=new Shell(display,SWT.NO_TRIM|SWT.ON_TOP);
rectangleShell.setBounds(rectangle);
rectangleShell.setBackground(display.getSystemColor(SWT.COLOR_RED));
final Region region=new Region();
Rectangle point=new Rectangle(0,0,1,1);
for (int x=0;x<rectangle.width;x++) {
point.x=x;
point.y=0;
region.add(point);
point.y=rectangle.height-1;
region.add(point);
}
for (int y=0;y<rectangle.height;y++) {
point.x=0;
point.y=y;
region.add(point);
point.x=rectangle.width-1;
region.add(point);
}
rectangleShell.setRegion(region);
rectangleShell.addListener(SWT.Dispose,new Listener() {
public void handleEvent(Event event) {
region.dispose();
}
});
rectangleShell.open();
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03962 seconds