Images on forms [message #454112] |
Mon, 18 April 2005 09:18 |
Daniel Krügler Messages: 853 Registered: July 2009 |
Senior Member |
|
|
Hello community,
I would like to present an image (JPG) on a form (org.eclipse.ui.forms).
My idea was to use an org.eclipse.swt.widgets.Canvas widget (was that a
reasonable idea?), which is a Composite. So I tried:
Composite sectionClient =
getToolkit().createComposite(getSection()); // getSection returns a
// formerly created Section instance
....
fCanvas = new Canvas(sectionClient, SWT.NONE);
getToolkit().adapt(fCanvas);
fCanvas.addPaintListener(new PaintListener() {
public void paintControl(PaintEvent e) {
if (fImage != null && !fImage.isDisposed()) {
e.gc.drawImage(fImage, 0, 0);
}
}
});
GridLayout rightPartLayout = new GridLayout();
rightPartLayout.numColumns = 1;
fCanvas.setLayout(rightPartLayout);
getToolkit().paintBordersFor(fCanvas);
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
Should the call of adapt be sufficient for proper presentation?
The reasoning for my questions are due to the fact that in the
end my image is presented "clipped off" on the right and bottom side.
Please note that I have to assign the actual image during run-time
**after** creation of the composite. At this event I simply do:
public void setImage(Image img) {
fImage = img;
//fCanvas.layout(true, true); // Does actually not help
//fCanvas.redraw(); //Does not help either
}
Interestingly I could not get rid of the clipping problem by adding
SWT.V_SCROLL | SWT.H_SCROLL to the creation flags of the Canvas: The
bars are shown but any scrolling does not cause a corresponding
scrolling of the contained image.
Thank you for any ideas,
Daniel Krügler
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04001 seconds