Scrollable Canvas Control - Extended

Here is a demo (encrypted) of a scrollable canvas control

  • It includes ability to scroll over large images
  • the ability to zoom in or out
  • the ability to auto fit the image to the viewport space
  • picture data is stored independent of the source, allowing it to be drawn on etc
  • all exposed MouseEvents use actual coordinates regardless of zoom level, so external code doesn’t have to normalize things

This demo is 100% functional.
It has a watermark indicating when the demo will expire, which should give anyone plenty of time to decide if it is worthwhile for them
Of course, any suggestions, comments or fixes required are welcome

www.rdS.com/scrollCanvas.xojo_xml_project.zip

Note : it has been tested on OSX, but not yet on Windows, but since it is all XOJO code it should work :slight_smile:

Source code can be made available (unencrypted) for $75.00
the encrypted version is for evaluation purposes only.

Hi Dave,

The description of this program sounds great. I tried to run it on Windows 10 and received the following error:

[quote]An exception of class PlatformNotSupportedException was not handled. The application must shut down.

Exception Message: Creating a picture with alpha channels only works if App.UseGDIPlus is enabled.[/quote]

I added the following code in App.Open and the program works well:

App.UseGDIPlus = True

Thanks!

Thanks… I’ll add that into the code… it already has a Windows specific pragma for EraseBackGround

Hi Dave,

I can’t scroll with the mousewheel. Is this not supported ?
Can you outline the advantages a bit more comparing with standard solution(s) ?

MouseWheel scrolling is an external event.
I left it that way, because some wish to scroll using the Wheel, others might what to control the Zoom.

For example… MY mouse only has a vertical wheel… while others like the Magic Mouse have a “track wheel”

But that being said… I’m not sure I allowed a way to set the scroll positon externally :slight_smile:
Give me a few hours and I’ll address that and post a new version… It won’t be hard to implement

Ok… Control has been updated, and a new demo version posted :slight_smile:

This has the GDI fix the Eugene suggested for Windows
And added support for MouseWheel.

Contrary to what I said above, the MouseWheel events are now INTERNAL (but the developer can override)

Added the following properties

  • wheelMode : can be wheelIGNORE, wheelSCROLL or wheelZOOM, developer still gets the MouseWheel event back, wheelIgnore skips all internal processing and its up to the developer to do ANY manipulations based on the wheel
  • ScrollX - set/get the current horizontal scroll value… input is clamped to the current scrollbar min/max values
  • ScrollY - set/get the current vertical scroll value … same clamping rules
  • fixed a minor bug that didn’t immediatiely refresh the display when you loaded a new image

As an anti-celebration of April Fools day… Any one that wants a copy of the source code can get it from me for a 50% discount until 6am (Pacific Time) on Monday April 4th. That is Friday, Sat, Sun.

Just post a donation of $37.50 (or more :slight_smile: ) at www.rdS.com/donate.html and I will email you a copy of the demo code with the encryption removed.

THIS IS NOT AN APRIL FOOLS JOKE…

Hi Dave,

With all respect but isn’t scrolling/zooming an image on a canvas pretty much a one-line DrawPicture function? Can you explain a bit why your control is easier or better than g.DrawPicture?
I think I’m missing something.

It IS a drawpicture function… but the issue is… integrating the scrollbars, keeping track of where everything is, managing all the events so that the right information gets to the at the right time, in the right format. This control consists of 6 custom methods (5 of which are private to the control), 8 event handlers, and 10 Computed Properties each which contain code in their Setters.

This control is NOT just a “canvas” object. It is a container control with a canvas, 2 scrollbars, and a few hundred lines of code.

So yes, can you scroll and zoom an image using nothing more than DrawPicture, depends on your point of view… No matter what, something has to figure out what those eight parameters to drawpicture need to be. Something needs to manage the scrollbars. Something needs to be an interface between the real and normalized coordinate systems (which are the same when zoom factor is 1.0, but change radically as the zoom factor changes)

If this control as I offer it has no interest to you, I’m fine with that…

I think it was a valid and respectful question. I just don’t understand and thought I was missing the point.
But I apologize if I offended you.

I vaguely remember reading an announcement about a similar product. What are the advantages of Scrollable Canvas Control ? Have you compared ?

You probably mean http://www.pidog.com/piDogScrollingCanvas/

[quote=257003:@Marco Hof]I think it was a valid and respectful question. I just don’t understand and thought I was missing the point.
But I apologize if I offended you.[/quote]
I am sorry if you felt the tone or content of my response was inappropriate, I was just attempting to explain what it was/did

Yes, there is piDog, and it actually does a few things more, and is much more expensive…

Thank you to those who have made a donation, and/or pointed out improvements (all of which so far have been implemented)

Special offer expires in 16 hours… Thanks to all of you have made a donation

make that 10 hrs…

based on response. decided to extend this offer for a while longer after all

If anyone was still interested in the class, there is another evaluation copy available that expires 31-Dec-2015
I have been asked if this works on Web projects, and the answer is , I don’t know as I have never set up the resources to play with Xojo Webapps…

www.rdS.com/scrollCanvas.xojo_xml_project.zip

What is the use of working with a class that’s already expired? :wink:
I assume you meant 31-Dec-2016.

Den Haag ?

[quote=279018:@Paul Sondervan]What is the use of working with a class that’s already expired? :wink:
I assume you meant 31-Dec-2016.[/quote]
not sure what you are saying… the expire is 31-Dec-2016…