43.1 Overview

Scrollcanvas class derives from Area class and creates a canvas with scrollbars attached. You can draw custom graphics to this canvas via a paint callback that is automatically invoked whenever content needs to be drawn. You just need to set up a notification on the Scrollcanvas.Paint attribute and your event handler will be called whenever content needs to be drawn. The same thing can be achieved by embedding a widget derived from Hollywood class inside a scrollgroup or connecting such a Hollywood widget to scrollbars but Scrollcanvas class is preferable in some cases because it is optimized especially for scrolled content, i.e. it tries to minimize painting by using OS widgets which are specifically designed for displaying scrolled content. Thus, it is usually faster than the two solutions outlined above.

You can set the canvas dimensions by using the Scrollcanvas.VirtWidth and Scrollcanvas.VirtHeight. Since Scrollcanvas class uses scrollbars, the dimensions of the canvas can obviously be much bigger than the physical dimensions of the scrollcanvas widget. As with all other classes, you can set those physical dimensions using the generic Area.Width and Area.Height attributes.

To force a complete redraw of your widget, just run the Area.Redraw method on your object. Running Area.Redraw on your object will result in your paint function being called so that you can update the canvas accordingly.

With Scrollcanvas class the dimensions you specify in Scrollcanvas.VirtWidth and Scrollcanvas.VirtHeight are in device-independent pixels by default and RapaGUI will automatically apply the system's scale factor to the contents drawn by the Scrollcanvas.Paint function. If you want to have fine-tuned control, you can set the Scrollcanvas.AutoScale attribute to False. In that case, Scrollcanvas.VirtWidth and Scrollcanvas.VirtHeight are interpreted as physical pixels and no auto scaling will be done so that your paint function can draw high resolutions graphics without any quality loss due to scaling. See High-DPI support for details.


Show TOC