Jump to content

GpiQueryDefAttrs

From EDM2

This function returns default attribute values for the specified primitive type.

Syntax

GpiQueryDefAttrs(hps, lPrimType, flAttrMask, ppbunAttrs)

Parameters

hps (HPS) - input
Presentation-space handle.
lPrimType (LONG) - input
Primitive type.
This is the type of primitive for which default attribute values are to be queried, as follows:
PRIM_LINE
Line and arc primitives
PRIM_CHAR
Character primitives
PRIM_MARKER
Marker primitives
PRIM_AREA
Area primitives
PRIM_IMAGE
Image primitives.
flAttrMask (ULONG) - input
Attributes mask.
Each flag that is set indicates that the default value of the corresponding attribute is to be returned in the ppbunAttrs buffer. If all flags in flAttrMask are 0, the ppbunAttrs buffer address is not used.
Line attributes:
LBB_COLOR
Line color
LBB_MIX_MODE
Line mix
LBB_WIDTH
Line width
LBB_GEOM_WIDTH
Geometric line width
LBB_TYPE
Line type
LBB_END
Line end
LBB_JOIN
Line join.
Character attributes:
CBB_COLOR
Character color
CBB_BACK_COLOR
Character background color
CBB_MIX_MODE
Character mix
CBB_BACK_MIX_MODE
Character background mix
CBB_SET
Character set
CBB_MODE
Character mode
CBB_BOX
Character box
CBB_ANGLE
Character angle
CBB_SHEAR.
Character shear
CBB_DIRECTION
Character direction
CBB_EXTRA
Character extra
CBB_BREAK_EXTRA
Character break extra
Marker attributes:
MBB_COLOR
Marker color
MBB_BACK_COLOR
Marker background color
MBB_MIX_MODE
Marker mix
MBB_BACK_MIX_MODE
Marker background mix
MBB_SET
Marker set
MBB_SYMBOL
Marker symbol
MBB_BOX
Marker box.
Pattern attributes (areas):
ABB_COLOR
Area color
ABB_BACK_COLOR
Area background color
ABB_MIX_MODE
Area mix
ABB_BACK_MIX_MODE
Area background mix
ABB_SET
Pattern set
ABB_SYMBOL
Pattern symbol
ABB_REF_POINT
Pattern reference point.
Image attributes:
IBB_COLOR
Image color
IBB_BACK_COLOR
Image background color
IBB_MIX_MODE
Image mix
IBB_BACK_MIX_MODE
Image background mix.
ppbunAttrs (PBUNDLE) - output
Attributes.
ppbunAttrs is a buffer in which is returned the default value of each attribute for which the flAttrMask flag is set, in the order specified in GpiSetAttrs for the particular primitive type.
Only data for attributes for which the appropriate flag in flAttrMask is set is updated, so ppbunAttrs need only be large enough for the highest offset attribute to be returned (see GpiSetAttrs).

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_PRIMITIVE_TYPE (0x20B9)
An invalid primitive type parameter was specified with GpiSetAttrs or GpiQueryAttrs.
PMERR_UNSUPPORTED_ATTR (0x2109)
An unsupported attribute was specified in the attrmask with GpiSetAttrs or GpiQueryAttrs.

Remarks

The parameters returned by this function may be used to reinstate exactly the same default attribute values as are queried, using GpiSetDefAttrs.

Example Code

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

HPS        hps;         /*  Presentation-space handle. */
LONG       lPrimType;   /*  Primitive type. */
ULONG      flAttrMask;  /*  Attributes mask. */
PBUNDLE    ppbunAttrs;  /*  Attributes. */
BOOL       rc;          /*  Success indicator. */

rc = GpiQueryDefAttrs(hps, lPrimType, flAttrMask, ppbunAttrs);


This example uses GpiQueryDefAttrs to return the default color and mix attribute values for the primitive line and arc types and, if successful, uses the values to reinstate the default attributes via the DosSetDefAttrs API.

#define INCL_GPIDEFAULTS        /* Default functions           */
#define INCL_GPIPRIMITIVES
#include <os2.h>

BOOL       fSuccess;   /* success indicator                    */
HPS        hps;        /* Presentation-space handle            */
LONG       lPrimType;  /* primitive type                       */
ULONG      flAttrMask; /* attributes mask                      */
LINEBUNDLE ppbunAttrs; /* Attributes                           */

/* request line/arc primitive values */
lPrimType = PRIM_LINE;

/* request values for color, mix attributes */
flAttrMask = LBB_COLOR | LBB_MIX_MODE;

fSuccess = GpiQueryDefAttrs(hps, lPrimType, flAttrMask,
                            &ppbunAttrs);

/* if successful, reinstate default color and mix attributes  */
if (fSuccess == TRUE)
   fSuccess = GpiSetDefAttrs(hps, lPrimType, flAttrMask,
                             &ppbunAttrs);