Use Draw2D on top of a StyledText [message #249454] |
Tue, 30 June 2009 06:46  |
Eclipse User |
|
|
|
Hi.
I want to use Draw2D on top of a StyledText. It should be possible as StyledText implements Canvas.
But I have two problems.
1) When adding a Figure the text is not visible anymore as the background gets white.
2) When using the scrollbars the drawn figures get corrupted.
Any suggestions how to solve the above issues?
Here is the simple test code I use to draw on the StyledText:
LightweightSystem system = new LightweightSystem(textViewer.getTextWidget());
Figure figure = new Figure();
XYLayout layout = new XYLayout();
figure.setLayoutManager(layout);
system.setContents(figure);
PolylineConnection conn = new PolylineConnection();
figure.add(conn);
conn.setLineWidth(10);
conn.setForegroundColor(ColorConstants.black);
conn.setBackgroundColor(ColorConstants.black);
conn.setStart(new Point(10, 10));
conn.setEnd(new Point(40, 40));
Regards,
Kai
|
|
|
Re: Use Draw2D on top of a StyledText [message #512892 is a reply to message #249454] |
Mon, 08 February 2010 05:07  |
Eclipse User |
|
|
|
Hi Kai,
this is what I found out: When defining a LightweightSystem, the constructor builds internally a Rootfigure with opaque = true!
Here is a way, that worked for me:
public void createControl(final Composite parent) {
...
cc = (StyledText) sourceviewer.getControl();
...
Canvas canvas = new Canvas(parent, SWT.TRANSPARENT);
canvas.moveAbove(cc);
// you'll have to add a way to set the bounds of your canvas
//e.g. PaintListener or so
canvas.setBounds(0,0,200,200);
LightweightSystem myLWS = new LightweightSystem();
IFigure root = myLWS.getRootFigure();
root.setOpaque(false);
root.setLayoutManager(new BorderLayout());
myLWS.setControl(canvas);
//now add your shapes here
...
}
Of course, there is still a lot to do (synchro Canvas and StyledText, etc.) this makes it possible to use Draw2d on StyledText!
Best regards,
David
|
|
|
Powered by
FUDForum. Page generated in 0.06115 seconds