Coordinate system and view port Foundation
This section covers the most important aspect of a presentation space: the coordinate system. The presentation space determines the unit of measure for the coordinate system used to output graphics. The unit can be pixel, centimeter, inch or an arbitrary unit.
The presentation space determines the origin of the coordinate system (the point {0,0}) along with the unit of measurement for the output. All graphic output is in relation to the coordinate system of the presentation space and this in return relates to the coordinate system of the output device. When graphic elements are output, two coordinate systems are to be considered: the coordinate systems of the presentation space and the coordinate system of the device context.
The coordinate system of the presentation space is predetermined by the page size. The page determines the available space where graphic output can occur. Since all graphic output occurs in the presentation space, the output uses the page coordinates of the presentation space.
A presentation space displays the page in the device context. It uses what is called a "viewport". The entire page of a presentation space is completely displayed in the viewport. The viewport relates to the coordinates of the output device, meaning the size of the viewport determines what is visible on the output device. The size of the page, however, determines what can be displayed in the presentation space.
The page size of a presentation space as well as the size of the viewport can be set for a presentation space. The size of the page is determined using the method :setPageSize() and the size of the viewport is set using the method :setViewPort(). The page determines the display in the presentation space and the viewport determines the display on the output device (in the device context). The following illustration shows the effect of different size viewports with two pages of equal size and equal size output devices in two windows:

The illustration shows two equal size windows with a drawing area of approximately 260 * 200 pixels (excluding the title bar) which both display the same image. The only difference between the windows is the size of the viewport of their respective presentation spaces. The gray area in the illustration represents the viewport. In the left window the viewport is smaller than the window. In the right window the image spills out over the window border, because the viewport is larger than the window. Everything that is outside the window border of the right window would not be visible on the screen. The following program code shows how the viewport can be influenced:
oPS1 := oWindowA:presSpace()
oPS1:setViewPort( {20, 20, 240, 180} ) // viewport < window
DisplayGraphic( oPS1 ) // draw image
oPS2 := oWindowB:presSpace()
oPS2:setViewPort( {-20, -20, 280, 240} ) // viewport > window
DisplayGraphic( oPS2 )
In both windows, the image is drawn with the same coordinates. However, in the left window the viewport of the presentation space is smaller than the output device (the window). Correspondingly, the image is reduced. In the right window, the viewport is larger than the output device. The display in the window is enlarged and parts of the image are cut off. The gray area corresponds to the viewport. This program code illustrates that the coordinates of the viewport are specified as coordinates of the window. Thus, the viewport in the left window begins with the point {20,20}, which lies within the window. The viewport in the right window, however, lies outside the window because it begins at the point {-20,-20}.
A presentation space transfers graphic output through the viewport into the device context. The viewport of a presentation space always relates to the coordinate system of the output device. In the example, the output device is 260*200 pixels large and two different size viewports are defined. In this way images can be scaled in any way in the display, because the viewport determines the coordinates in the output device where the graphic output occurs. If the viewport does not have the same size as the output device, a graphic transformation is automatically performed during the output of the image to the device context.
Along with the viewport, the size of the abstract drawing area which represents the presentation space can be set for a presentation space. This occurs using the method :setPageSize() to define the size of the "page" in a presentation space. The page size affects the dimensions of the coordinate system in a presentation space.

The illustration again shows two equal size windows with a drawing area of 260*200 pixels, and in both windows the same image is displayed. Here the page sizes of the two presentation spaces are different:
oPS1 := oWindowA:presSpace()
oPS1:setViewPort( {0, 0, 260, 200} ) // viewport = window
oPS1:setPageSize( {260, 200} ) // page size = window
DisplayGraphic( oPS1 ) // draw image
oPS2 := oWindowB:presSpace()
oPS2:setViewPort( {0, 0, 260, 200} ) // viewport = window
oPS2:setPageSize( {520, 400} ) // page size > window
DisplayGraphic( oPS2 )
In both cases, the viewport is the same size as the window. This means that everything drawn in the presentation space also appears in the window. But the page size for the presentation space in the right window is four times larger than in the left window. In the left window the coordinate system of the presentation space extends from 0 to 260 in the x direction (horizontal) and from 0 to 200 in the y direction (vertical), meaning the page is 260*200 pixels large. In the right window the x axis of the presentation space extends from 0 to 520 and the y axis from 0 to 400. Since the image in both cases is displayed at the same coordinates in the presentation space, it is four times smaller in the presentation space of the right window than in the left window.
The method :setPageSize() defines the size of the page or the dimensions of the coordinate system in a presentation space. The method :setViewPort(), on the other hand, specifies the device coordinates of the device context where output occurs. Both methods cause an automatic transformation when the page size of the presentation space does not match the size of the output device or when the viewport does not match the dimensions of the coordinate system of the device context.
The two methods :setPageSize() and :setViewPort() offer two ways to scale a graphic. Both methods can be used for output in a window. The method :setViewPort() can only be used for screen output in a window and is limited to graphic output containing vector images. No automatic scaling is performed in the display of raster images (bitmaps) or raster operations (the function GraBitBlt()). The display of bitmaps or bitmap fonts always occurs in the coordinates of the device context. Characters which are displayed with a bitmap font cannot be scaled and bitmaps must be explicitly scaled using GraBitBlt().
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.