canvas - scroll [message #449954] |
Tue, 01 February 2005 13:26 |
Eclipse User |
|
|
|
Originally posted by: bm.gmail.com
Hi
I am very new to doing anything with swt
I need to draw a fairly simple diagram, rectangles with labels, and arrows
from x number of these pointing back to a center rect.
For now i have done this in a view by adding a paint listener
in createPartControl(Composite parent) for my view i have:
Canvas canvas = new Canvas(parent,SWT.BORDER);
canvas.setVisible(true);
CPaintListener paintListener = new CPaintListener();
canvas.addPaintListener(paintListener);
then in the paint listener
paintControl(PaintEvent event) {
GC gc = event.gc;
gc.drawRectangle(x,y,width,height);
}
is there a better way to go about drawing these in the first place?
my main question is though, once i maximize my view, some of the
rectangles
are out of view, and i cannot set the view so that i can scroll
how do i go about this?
any help regarding either is much appreciated
|
|
|
Re: canvas - scroll [message #450000 is a reply to message #449954] |
Thu, 03 February 2005 16:29 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
You need to implement scrollbar support similar to what is done in the
following Snippet:
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet48.java?rev=HEAD&a mp;content-type=text/vnd.viewcvs-markup
"BM" <bm@gmail.com> wrote in message news:cto02n$uoc$1@www.eclipse.org...
> Hi
> I am very new to doing anything with swt
> I need to draw a fairly simple diagram, rectangles with labels, and arrows
> from x number of these pointing back to a center rect.
> For now i have done this in a view by adding a paint listener
> in createPartControl(Composite parent) for my view i have:
>
> Canvas canvas = new Canvas(parent,SWT.BORDER);
> canvas.setVisible(true);
> CPaintListener paintListener = new CPaintListener();
> canvas.addPaintListener(paintListener);
>
> then in the paint listener
> paintControl(PaintEvent event) {
> GC gc = event.gc;
> gc.drawRectangle(x,y,width,height);
> }
>
> is there a better way to go about drawing these in the first place?
>
> my main question is though, once i maximize my view, some of the
> rectangles are out of view, and i cannot set the view so that i can scroll
> how do i go about this?
> any help regarding either is much appreciated
>
>
>
|
|
|
Re: canvas - scroll [message #450029 is a reply to message #450000] |
Sun, 06 February 2005 17:23 |
Eclipse User |
|
|
|
Originally posted by: bm.gmail.com
I tried this and scroll does work
however it does not draw the image properly on all the area
when i create the canvas what is currently visible is ok,
but once i scroll outside the area nothing is drawn, and if
i scroll back to the start some of the image has been wiped
how can i fix this?
Veronika Irvine wrote:
> You need to implement scrollbar support similar to what is done in the
> following Snippet:
>
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet48.java?rev=HEAD&a mp;content-type=text/vnd.viewcvs-markup
> "BM" <bm@gmail.com> wrote in message news:cto02n$uoc$1@www.eclipse.org...
>> Hi
>> I am very new to doing anything with swt
>> I need to draw a fairly simple diagram, rectangles with labels, and arrows
>> from x number of these pointing back to a center rect.
>> For now i have done this in a view by adding a paint listener
>> in createPartControl(Composite parent) for my view i have:
>>
>> Canvas canvas = new Canvas(parent,SWT.BORDER);
>> canvas.setVisible(true);
>> CPaintListener paintListener = new CPaintListener();
>> canvas.addPaintListener(paintListener);
>>
>> then in the paint listener
>> paintControl(PaintEvent event) {
>> GC gc = event.gc;
>> gc.drawRectangle(x,y,width,height);
>> }
>>
>> is there a better way to go about drawing these in the first place?
>>
>> my main question is though, once i maximize my view, some of the
>> rectangles are out of view, and i cannot set the view so that i can scroll
>> how do i go about this?
>> any help regarding either is much appreciated
>>
>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03354 seconds