drawGrid

drawGrid(x1:     Integer;
         y1:     Integer;
         x2:     Integer;
         y2:     Integer;
         style:  Integer;
         width:  Integer;
         height: Integer;
         color:  Integer) updating;

The drawGrid method of the Printer class draws a grid into the specified rectangle, by using the Printer class grid style constants listed in the following table.

Printer Class Constant Value Description
DrawGrid_Crosses 1 Small crosses drawn at the grid line intersection
DrawGrid_Dots 2 Dots drawn at the grid line intersections
DrawGrid_Lines 0 Horizontal and vertical grid lines

The drawGrid method parameters are listed in the following table.

Parameter Description
x1, y1 Horizontal and vertical left and top points of the rectangle, respectively
x2, y2 Horizontal and vertical right and bottom points of the rectangle, respectively
style DrawGrid_Lines (0), DrawGrid_Crosses (1), or DrawGrid_Dots (2)
width Increment in pixels between each vertical grid line
height Increment in pixels between each horizontal grid line
color Color of the pen used to draw the grid

Grid lines for the left and top edges of the rectangle are not drawn.

The grid lines are drawn by using the Printer::drawWidth and Printer::drawStyle properties. For the line style drawWidth = 1, drawWindow = 0 (client area), and scaleMode=0 (pixels), the result is the same as if you wrote the following code.

vars
    x : Integer;
    y : Integer;
begin
    foreach x in self.width to self.clientWidth - 1 step 5 do
        window.drawLine(x, 0, x, self.clientHeight, self.color);
    endforeach;
    foreach y in self.height to self.clientHeight - 1 step 5 do
        window.drawLine(0, y, self.clientWidth, y, self.color);
    endforeach;
end;