Jump to content

GpiQueryRegionRects: Difference between revisions

From EDM2
Created page with "This function determines what rectangles that, when ORed together, define the specified region and then returns either the number of rectangles or the rectangles themselves. ==Syntax== GpiQueryRegionRects(hps, hrgn, prclBound, prgnrcControl, prclRect); ==Parameters== ;hps (HPS) - input :Presentation-space handle. :The region must be owned by the device identified by the currently associated device context. ;hrgn (HRGN) - input :Region handle. ;prclBound (PRECTL)..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
This function determines what rectangles that, when ORed together, define the specified region and then returns either the number of rectangles or the rectangles themselves.  
This function determines what rectangles that, when ORed together, define the specified region and then returns either the number of rectangles or the rectangles themselves.


==Syntax==
==Syntax==
  GpiQueryRegionRects(hps, hrgn, prclBound, prgnrcControl, prclRect);
  GpiQueryRegionRects(hps, hrgn, prclBound, prgnrcControl, prclRect)


==Parameters==
==Parameters==
;hps (HPS) - input
;hps (HPS) - input:Presentation-space handle.
:Presentation-space handle.
:The region must be owned by the device identified by the currently associated device context.
:The region must be owned by the device identified by the currently associated device context.  
;hrgn (HRGN) - input:Region handle.
 
;prclBound ([[PRECTL]]) - input:Bounding rectangle.
;hrgn (HRGN) - input
::NULL - Return all the rectangles in the region.
:Region handle.  
::Other - Return only rectangles that intersect with the bounding rectangle. Each rectangle returned is the intersection of the bounding rectangle with a rectangle in the region.
 
;prgnrcControl (PRGNRECT) - in/out:Processing-control structure.
;prclBound (PRECTL) - input
;prclRect (PRECTL) - output:Pointer to an array of rectangle structures or NULL
:Bounding rectangle.
::NULL - Return the number of rectangles in the region.
:;NULL
::Return all the rectangles in the region.  
:;Other
::Return only rectangles that intersect with the bounding rectangle. Each rectangle returned is the intersection of the bounding rectangle with a rectangle in the region.  
 
;prgnrcControl (PRGNRECT) - in/out
:Processing-control structure.  
 
;prclRect (PRECTL) - output
:Pointer to an array of rectangle structures or NULL
:;NULL
::Return the number of rectangles in the region.
 
::The number of rectanges is returned in the crcReturned field of the RGNRECT structure identified by the prgnrcControl parameter. The ircStart field will always be 1. If a bounding rectangle is specified, the crc and crcReturned fields will be set as follows:
::The number of rectanges is returned in the crcReturned field of the RGNRECT structure identified by the prgnrcControl parameter. The ircStart field will always be 1. If a bounding rectangle is specified, the crc and crcReturned fields will be set as follows:
 
:::{|
            ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄ¿
|If the given rectangle is:||crc||crcReturned
            ³If the given   ³crc        ³crcReturned ³
|-
            ³rectangle is: ³            ³            ³
|Completely inside.||RRGN_INSIDE||1
            ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄ´
|-
            ³Completely    ³RRGN_INSIDE ³1          ³
|Completely outside.||RRGN_OUTSIDE||0
            ³inside.       ³            ³            ³
|-
            ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄ´
|Partially inside.||RRGN_PARTIAL||Number of rectangles
            ³Completely    ³RRGN_OUTSIDE³0          ³
|}
            ³outside.       ³            ³            ³
::Other - Return only rectangles that intersect with the bounding rectangle. Each rectangle returned is the intersection of the bounding rectangle with a rectangle in the region.
            ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄ´
            ³Partially      ³RRGN_PARTIAL³Number of   ³
            ³inside.        ³            ³rectangles  ³
            ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÙ
 
:;Other
::Return only rectangles that intersect with the bounding rectangle. Each rectangle returned is the intersection of the bounding rectangle with a rectangle in the region.
 
::Pointer to an array of rectangle structures in which the rectangles are returned.
::Pointer to an array of rectangle structures in which the rectangles are returned.
::The maximum number of rectangles that can be returned is specified by the crc parameter of the RGNRECT structure identified by the prgnrcControl parameter.  
::The maximum number of rectangles that can be returned is specified by the crc parameter of the RGNRECT structure identified by the prgnrcControl parameter.
 
       


==Returns==
==Returns==
;rc (BOOL) - returns
;rc (BOOL) - returns:Success indicator.
:Success indicator.
::TRUE - Successful completion
 
::FALSE - Error occurred
:;TRUE
::Successful completion  
:;FALSE
::Error occurred.


==Errors==
==Errors==
Possible returns from WinGetLastError
Possible returns from WinGetLastError:
;PMERR_INV_HPS (0x207F)
;PMERR_INV_HPS (0x207F):An invalid presentation-space handle was specified.  
        An invalid presentation-space handle was specified.  
;PMERR_PS_BUSY (0x20F4):An attempt was made to access the presentation space from more than one thread simultaneously.  
;PMERR_PS_BUSY (0x20F4)
;PMERR_INV_HRGN (0x2080):An invalid region handle was specified.  
        An attempt was made to access the presentation space from more than one thread simultaneously.  
;PMERR_INV_REGION_CONTROL (0x20BE):An invalid control parameter was specified with GpiQueryRegionRects.  
;PMERR_INV_HRGN (0x2080)
;PMERR_INV_COORDINATE (0x205B):An invalid coordinate value was specified.  
        An invalid region handle was specified.  
;PMERR_INV_RECT (0x20BD):An invalid rectangle parameter was specified.  
;PMERR_INV_REGION_CONTROL (0x20BE)
;PMERR_REGION_IS_CLIP_REGION (0x20F8):An attempt was made to perform a region operation on a region that is selected as a clip region.  
        An invalid control parameter was specified with GpiQueryRegionRects.  
;PMERR_HRGN_BUSY (0x2034):An internal region busy error was detected. The region was locked by one thread during an attempt to access it from another thread.
;PMERR_INV_COORDINATE (0x205B)
        An invalid coordinate value was specified.  
;PMERR_INV_RECT (0x20BD)
        An invalid rectangle parameter was specified.  
;PMERR_REGION_IS_CLIP_REGION (0x20F8)
        An attempt was made to perform a region operation on a region that is selected as a clip region.  
;PMERR_HRGN_BUSY (0x2034)
        An internal region busy error was detected. The region was locked by one thread during an attempt to access it from another thread.
 


==Remarks==
==Remarks==
Line 99: Line 63:
</pre>
</pre>
In this example we determine the rectangles that can be OR'ed together to determine the specified region.
In this example we determine the rectangles that can be OR'ed together to determine the specified region.
<pre>  
<pre>
#define INCL_GPIREGIONS
#define INCL_GPIREGIONS
#include <OS2.H>
#include <OS2.H>
Line 110: Line 74:
RGNRECT rgnrcControl;  /* processing control      */
RGNRECT rgnrcControl;  /* processing control      */
RECTL arclRect[MAXRECTS];  /* array of rectangle structures */
RECTL arclRect[MAXRECTS];  /* array of rectangle structures */
                           /* in which the rectangles are   */
                           /* in which the rectangles are returned. */
                          /* returned.                     */


rgnrcControl.ircStart = 1;    /* start numbering rectangles */
rgnrcControl.ircStart = 1;    /* start numbering rectangles from 1.                 */
                              /* from 1.                   */
rgnrcControl.crc = MAXRECTS;  /* maximum number of rectangles that can be returned. */
rgnrcControl.crc = MAXRECTS;  /* maximum number of rectangles */
                              /* that can be returned.       */
rgnrcControl.usDirection = RECTDIR_LFRT_TOPBOT;
rgnrcControl.usDirection = RECTDIR_LFRT_TOPBOT;
                               /* order rectangles left-to-right */
                               /* order rectangles left-to-right and top-to-bottom. */
                              /* and top-to-bottom.             */
flResult =  GpiQueryRegionRects(hps,
flResult =  GpiQueryRegionRects(hps,
                                 hrgn,
                                 hrgn,
                                 &rclBound,      /* output */
                                 &rclBound,      /* output */
                                 &rgnrcControl,
                                 &rgnrcControl, /* rgnrcControl.crcReturned is the */
                              /* rgnrcControl.crcReturned is the */
                                                /* number of rectangles returned.  */
                              /* number of rectangles returned.  */
                                 &arclRect[0]);
                                 &arclRect[0]);
</pre>
</pre>


[[Category:Gpi]]
[[Category:Gpi]]

Latest revision as of 11:10, 4 April 2025

This function determines what rectangles that, when ORed together, define the specified region and then returns either the number of rectangles or the rectangles themselves.

Syntax

GpiQueryRegionRects(hps, hrgn, prclBound, prgnrcControl, prclRect)

Parameters

hps (HPS) - input
Presentation-space handle.
The region must be owned by the device identified by the currently associated device context.
hrgn (HRGN) - input
Region handle.
prclBound (PRECTL) - input
Bounding rectangle.
NULL - Return all the rectangles in the region.
Other - Return only rectangles that intersect with the bounding rectangle. Each rectangle returned is the intersection of the bounding rectangle with a rectangle in the region.
prgnrcControl (PRGNRECT) - in/out
Processing-control structure.
prclRect (PRECTL) - output
Pointer to an array of rectangle structures or NULL
NULL - Return the number of rectangles in the region.
The number of rectanges is returned in the crcReturned field of the RGNRECT structure identified by the prgnrcControl parameter. The ircStart field will always be 1. If a bounding rectangle is specified, the crc and crcReturned fields will be set as follows:
If the given rectangle is: crc crcReturned
Completely inside. RRGN_INSIDE 1
Completely outside. RRGN_OUTSIDE 0
Partially inside. RRGN_PARTIAL Number of rectangles
Other - Return only rectangles that intersect with the bounding rectangle. Each rectangle returned is the intersection of the bounding rectangle with a rectangle in the region.
Pointer to an array of rectangle structures in which the rectangles are returned.
The maximum number of rectangles that can be returned is specified by the crc parameter of the RGNRECT structure identified by the prgnrcControl parameter.

Returns

rc (BOOL) - returns
Success indicator.
TRUE - Successful completion
FALSE - Error occurred

Errors

Possible returns from WinGetLastError:

PMERR_INV_HPS (0x207F)
An invalid presentation-space handle was specified.
PMERR_PS_BUSY (0x20F4)
An attempt was made to access the presentation space from more than one thread simultaneously.
PMERR_INV_HRGN (0x2080)
An invalid region handle was specified.
PMERR_INV_REGION_CONTROL (0x20BE)
An invalid control parameter was specified with GpiQueryRegionRects.
PMERR_INV_COORDINATE (0x205B)
An invalid coordinate value was specified.
PMERR_INV_RECT (0x20BD)
An invalid rectangle parameter was specified.
PMERR_REGION_IS_CLIP_REGION (0x20F8)
An attempt was made to perform a region operation on a region that is selected as a clip region.
PMERR_HRGN_BUSY (0x2034)
An internal region busy error was detected. The region was locked by one thread during an attempt to access it from another thread.

Remarks

Points on the right-hand and top boundaries are not included in the region. Points on the left-hand and bottom boundaries, that are not also on the right-hand or top boundaries (that is, the top-left and bottom-right corner points), are included.

It is invalid if the specified region is currently selected as the clip region (by GpiSetClipRegion).

Example Code

#define INCL_GPIREGIONS /* Or use INCL_GPI, INCL_PM, */
#include <os2.h>

HPS         hps;            /*  Presentation-space handle. */
HRGN        hrgn;           /*  Region handle. */
PRECTL      prclBound;      /*  Bounding rectangle. */
PRGNRECT    prgnrcControl;  /*  Processing-control structure. */
PRECTL      prclRect;       /*  Pointer to an array of rectangle structures. */
BOOL        rc;             /*  Success indicator. */

rc = GpiQueryRegionRects(hps, hrgn, prclBound, prgnrcControl, prclRect);

In this example we determine the rectangles that can be OR'ed together to determine the specified region.

#define INCL_GPIREGIONS
#include <OS2.H>
#define MAXRECTS 12

BOOL flResult;      /* success indicator.         */
HPS hps;            /* presentation space handle. */
HRGN hrgn;          /* region handle.             */
RECTL rclBound;     /* bounding rectangle         */
RGNRECT rgnrcControl;  /* processing control      */
RECTL arclRect[MAXRECTS];  /* array of rectangle structures */
                           /* in which the rectangles are returned. */

rgnrcControl.ircStart = 1;    /* start numbering rectangles from 1.                 */
rgnrcControl.crc = MAXRECTS;  /* maximum number of rectangles that can be returned. */
rgnrcControl.usDirection = RECTDIR_LFRT_TOPBOT;
                               /* order rectangles left-to-right and top-to-bottom. */
flResult =  GpiQueryRegionRects(hps,
                                hrgn,
                                &rclBound,      /* output */
                                &rgnrcControl,  /* rgnrcControl.crcReturned is the */
                                                /* number of rectangles returned.  */
                                &arclRect[0]);