Login  Register

Re: Drawing graphs iin Dolphin

Posted by Stefan Schmiedl on Jul 11, 2004; 10:51pm
URL: https://forum.world.st/Drawing-graphs-iin-Dolphin-tp3370875p3370960.html

On Tue, 6 Jul 2004 11:45:37 +0100,
Peter Kenny <[hidden email]> wrote:

>
> b. I have obviously got to learn more about views and canvases than I really
> want to know if I am going to crack this. One thing bugs me at the moment.
> Almost all the #onPaintRequired; methods I have found begin:
>     onPaintRequired: aPaintEvent
>     |canvas|
>     canvas := aPaintEvent canvas
> and this provides the canvas for the #drawOn: method. But inside the method
> the canvas has extent = 1280@1024 (i.e. the whole screen) and windowExtent =
> viewportExtent = 1@1. Nothing bears any  relationship to the actual extent
> of the graph window I am trying to draw on.

Don't let yourself become confused by the way Windows names concepts.

Viewport coordinates refer to "device units", commonly known as pixels.
Window coordinates refer to "logical units" used by your program.

The relationship between those two is governed by a concept called
MapMode. Your data point windowExtent = viewportExtent = 1@1 only means
that you're working with pixel based coordinates and that the y-axis
points down.

You should also find a viewportOrigin and a windowOrigin.
The viewportOrigin contains the "absolute" position of the origin in
device units and is useful if you want to put the origin into the lower
left corner of the window.
The windowOrigin determines where your "logical" origin lies in
relationship to this point.

As long as you have GDI-friendly coordinates, you can exchange the
headache caused by manual scaling and shifting for the headache
necessary to understand how MM_ANISOTROPIC et al. work.

BTW: There is almost no difference between drawing into a window and
drawing into a WMF or EMF file. You won't need ActiveX components to
display those, either, as Windows has builtin functions for handling
this kind of tasks.

I found the Win32-API help file (old version, available for download)
enormously helpful. And much more useable than that modern HTML-help
monstrosity.

s.