Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » canvas - scroll
canvas - scroll [message #449954] Tue, 01 February 2005 13:26 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Veronika Irvine is currently offline Veronika IrvineFriend
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 Go to previous message
Eclipse UserFriend
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
>>
>>
>>
Previous Topic:TreeViewer - getting selection on right click
Next Topic:problem with TextViewer
Goto Forum:
  


Current Time: Sat Apr 20 05:42:14 GMT 2024

Powered by FUDForum. Page generated in 0.03110 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top