Function GraBox() Foundation

Draws rectangle.

Syntax
GraBox( [<oPS>], [<aLeftBottom>], <aRightTop>, ;
        [<nFill>], [<nHRadius>], [<nVRadius>] ) --> lSuccess
Parameters
<oPS>
The argument <oPS> specifies the presentation space in which a rectangle is drawn. If the current window is an XbpCrt window, <oPS>is optional. If it is NIL, the return value of SetAppWindow():presSpace() is used. In all other cases <oPS> is not optional. It must be created either using XbpPresSpace():new() or a "Micro PS" must be requested from an Xbase Part using the method:lockPS(). After graphic output the Micro PS must be released with :unlockPS().
<aLeftBottom> := { <nX1>, <nY1> }
<aLeftBottom> is an array of two elements which determines the coordinates for the lower left corner of the rectangle. The first element <nX1> designates the x coordinate and the second element <nY1> the y coordinate. The unit for the coordinates depends on the coordinate system defined for the presentation space. If no presentation space is specified, the values for the coordinates are given in pixels, which is the unit for a window. The origin for the coordinates (point {0,0}) is at the lower left. If <aLeftBottom> is not specified, the lower left corner of the rectangle is the current pen position.
<aRightTop> := { <nX2>, <nY2> }
<aRightTop> is an array of two elements which contains the coordinates for the upper right corner of the rectangle.
<nFill>
The optional argument <nFill> specifies whether the rectangle is drawn as an outline or is filled. The following table shows the #define constants from the GRA.CH file to use for<nFill>:
Fill attributes for GraBox()
Constant Description
GRA_FILL Fills rectangle
GRA_OUTLINE *) Only draws rectangle border
GRA_OUTLINEFILL Draws rectangle border and fills
  1. Default value
<nHRadius>
The parameters <nHRadius> and <nVRadius> determine how much to round the corners of the rectangle. Both are positive integers which, taken together, determine the distance (radius of curvature) from a corner to the middle of the rectangle. This distance provides the measure from which the corners are rounded. <nHRadius> indicates the horizontal distance. When <nHRadius> is equal to <nVRadius>, the corners are rounded by a 90 arc.
<nVRadius>
<nVRadius> determines the vertical curvature radius for rounding the corners. For rounded corners, both parameters <nHRadius> and <nVRadius> must be greater than 0.
Return

The return value of GraBox() is .T. (true) if the rectangle was drawn, otherwise it is .F. (false). If the return value equals .F., the cause of error can be determined using GraError().

Description

Rectangles are drawn with the function GraBox(). By default, output is an outline, with the color and line width set by the function GraSetAttrLine(). For a filled rectangle, the fill pattern and the fill color are determined by GraSetAttrArea(). The default pattern corresponds to the #define constant GRA_SYM_SOLID.

The pen position does not change when drawing a rectangle since a closed figure is drawn.

Examples
Drawing rectangles
// The example draws three rectangles which 
// demonstrate different variations of GraBox(). 

#include "Gra.ch" 

PROCEDURE Main 
   LOCAL aAttr 

   SetColor("N/W")                     // fill window with pale gray 
   CLS 

   aAttr := Array( GRA_AA_COUNT )      // determine fill attributes 
   aAttr [ GRA_AA_SYMBOL ] := GRA_SYM_DIAG2 
   GraSetAttrArea( NIL, aAttr ) 

   graBox( NIL, { 70,230}, {200,350}  ) // outlined rectangle 
   graBox( NIL, {300,230}, {550,350}, ; // filled rectangle 
                             GRA_FILL ) 

   graBox( NIL, {150, 70}, {460,200}, ; // rectangle outlined, 
              GRA_OUTLINEFILL, 20, 20 ) // filled and rounded 

   Inkey(0) 
RETURN 
Feedback

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.