Home » Eclipse Projects » Remote Application Platform (RAP) » Scrollable Canvas(Create a scrollable canvas)
Scrollable Canvas [message #655736] |
Tue, 22 February 2011 14:23 |
|
Hi everybody,
I am working right now on an application that draws intensively to the screen, namely on a Canvas. Whenever the Canvas is scrolled, I redraw large section of the screen based on input from the ScrollBars. This works fine on RCP, but I have had troubles getting it to work on RAP, mainly because the Canvas class is a Scrollable, but does not scroll.
I got some of the scrolling functionality by patching the rwt plugin. I placed a ScrollableComposite inside the Canvas class and routed all calls to it. This solution, I think, is a bit ugly, and, even though this solved some of the problems, it, created others. Before I commit to solving these new issues, I thought I might ask you guys for help.
So, if you know a cleaner way to make a Canvas that can be controlled by ScrollBar objects, please let me know.
Thanks,
Flo.
|
|
|
Re: Scrollable Canvas [message #655774 is a reply to message #655736] |
Tue, 22 February 2011 15:25 |
Ivan Furnadjiev Messages: 2426 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Florian,
you could try to put the Canvas inside a ScrolledComposite. This should
work.
HTH,
Ivan
On 2/22/2011 4:23 PM, Tripon Florian wrote:
> Hi everybody,
>
> I am working right now on an application that draws intensively to the
> screen, namely on a Canvas. Whenever the Canvas is scrolled, I redraw
> large section of the screen based on input from the ScrollBars. This
> works fine on RCP, but I have had troubles getting it to work on RAP,
> mainly because the Canvas class is a Scrollable, but does not scroll.
>
> I got some of the scrolling functionality by patching the rwt plugin.
> I placed a ScrollableComposite inside the Canvas class and routed all
> calls to it. This solution, I think, is a bit ugly, and, even though
> this solved some of the problems, it, created others. Before I commit
> to solving these new issues, I thought I might ask you guys for help.
>
> So, if you know a cleaner way to make a Canvas that can be controlled
> by ScrollBar objects, please let me know.
>
> Thanks,
> Flo.
|
|
|
Re: Scrollable Canvas [message #655790 is a reply to message #655774] |
Tue, 22 February 2011 16:12 |
|
Hi Ivan,
Thanks for the quick reply.
That's what I did in the first place, but it did not work for me. My class extends Canvas and does its own drawing. It relays on the ScrollBar objects provided by the Scrollable class (in RCP) to know what he must draw. Keeping the same source code for both RCP & RAP meant that I must somehow get access to the scrollbar objects so I started playing around with the RWT package.
My current approach scrambles the internal logic of the class that needs to draw. The path, which I do not want to take, is to create a bunch of proxies that translate everything that relates to size and location.
I was hoping that there is a cleaner way of doing this
Thanks,
Flo.
|
|
|
Re: Scrollable Canvas [message #655819 is a reply to message #655790] |
Tue, 22 February 2011 17:43 |
Ivan Furnadjiev Messages: 2426 Registered: July 2009 Location: Sofia, Bulgaria |
Senior Member |
|
|
Hi Florian,
maybe I don't understand what you want to achieve, but if you put your
Canvas inside a ScrolledComposite and add a ControlListener to listen
for controlMoved event, you can get the scrollbar position from your
Canvas location.
HTH,
Ivan
On 2/22/2011 6:13 PM, Tripon Florian wrote:
> Hi Ivan,
>
> Thanks for the quick reply.
> That's what I did in the first place, but it did not work for me. My
> class extends Canvas and does its own drawing. It relays on the
> ScrollBar objects provided by the Scrollable class (in RCP) to know
> what he must draw. Keeping the same source code for both RCP & RAP
> meant that I must somehow get access to the scrollbar objects so I
> started playing around with the RWT package.
> My current approach scrambles the internal logic of the class that
> needs to draw. The path, which I do not want to take, is to create a
> bunch of proxies that translate everything that relates to size and
> location.
>
> I was hoping that there is a cleaner way of doing this :)
> Thanks,
> Flo.
|
|
|
Re: Scrollable Canvas [message #655951 is a reply to message #655819] |
Wed, 23 February 2011 13:50 |
|
Hi Ivan,
Thanks a lot for your input. It worked like a charm. I removed all references to the ScrollBar objects from the Canvas extending class. I'll give it a kick in RCP tomorrow to see if it still works.
This is where you get when the obvious solution is in front of you but you don't look at it because it is way too obvious.
Cheers,
Flo.
|
|
|
Goto Forum:
Current Time: Thu Apr 25 11:54:45 GMT 2024
Powered by FUDForum. Page generated in 0.03333 seconds
|