Jump to content

GpiSetBackMix: Difference between revisions

From EDM2
Created page with "This function sets the current background mix attribute for each individual primitive type. ==Syntax== GpiSetBackMix(hps, lMixMode); ==Parameters== ;hps (HPS) - input :Presentation-space handle. ;lMixMode (LONG) - input :Background-mix mode. :Background mixes marked with an asterisk (*) are mandatory for all devices. :The currently associated device supports any of the mixes specified as supported in DevQueryCaps (CAPS_BACKGROUND_MIX_SUPPORT) Any other valid mixes..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 1: Line 1:
This function sets the current background mix attribute for each individual primitive type.  
This function sets the current background mix attribute for each individual primitive type.
 
==Syntax==
==Syntax==
  GpiSetBackMix(hps, lMixMode);
  GpiSetBackMix(hps, lMixMode)
 


==Parameters==
==Parameters==
;hps (HPS) - input
;hps (HPS) - input:Presentation-space handle.  
:Presentation-space handle.  
;lMixMode (LONG) - input:Background-mix mode.
 
;lMixMode (LONG) - input
:Background-mix mode.
:Background mixes marked with an asterisk (*) are mandatory for all devices.
:Background mixes marked with an asterisk (*) are mandatory for all devices.
:The currently associated device supports any of the mixes specified as supported in DevQueryCaps (CAPS_BACKGROUND_MIX_SUPPORT) Any other valid mixes can be supported for some primitive types but otherwise result in BM_LEAVEALONE. An error is raised only if the value specified is not one of those listed.
:The currently associated device supports any of the mixes specified as supported in DevQueryCaps (CAPS_BACKGROUND_MIX_SUPPORT) Any other valid mixes can be supported for some primitive types but otherwise result in BM_LEAVEALONE. An error is raised only if the value specified is not one of those listed.
:For more information on mixing, see [[GpiSetMix]].
:For more information on mixing, see [[GpiSetMix]].
 
::BM_DEFAULT - The default value (BM_LEAVEALONE unless changed with GpiSetDefAttrs).  
:;BM_DEFAULT
::BM_OR - Logical-OR.
::The default value (BM_LEAVEALONE unless changed with GpiSetDefAttrs).  
::BM_OVERPAINT - The background of the primitive takes precedence over whatever is underneath. (*)  
:;BM_OR
::BM_XOR - Exclusive-OR.
::Logical-OR.  
::BM_LEAVEALONE - The background of the primitive has no effect on what is underneath. (*)
:;BM_OVERPAINT
::The background of the primitive takes precedence over whatever is underneath. (*)  
:;BM_XOR
::Exclusive-OR.  
:;BM_LEAVEALONE
::The background of the primitive has no effect on what is underneath. (*)  
 
 


==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_BACKGROUND_COL_ATTR (0x2044):An invalid background color attribute value was specified or the default value was explicitly specified with GpiSetAttrs instead of using the defaults mask.
:An attempt was made to access the presentation space from more than one thread simultaneously.  
;PMERR_INV_BACKGROUND_COL_ATTR (0x2044)
:An invalid background color attribute value was specified or the default value was explicitly specified with GpiSetAttrs instead of using the defaults mask.  


==Remarks==
==Remarks==
Line 51: Line 32:
These primitives are affected by the background mix attribute:
These primitives are affected by the background mix attribute:


;Areas
;Areas:The background of an area is defined to be every pel within the area that is not set by the shading pattern.  
The background of an area is defined to be every pel within the area that is not set by the shading pattern.  
;Text:The background of a character is the complete character box.  
;Text
;Images:For an image, the background is every pel within the image that is not set.  
The background of a character is the complete character box.  
;Markers:The background of a marker is the complete marker box.
;Images
For an image, the background is every pel within the image that is not set.  
;Markers
The background of a marker is the complete marker box.  


Note: When the background mix is BM_LEAVEALONE (initial default) the background color is not seen.
Note: When the background mix is BM_LEAVEALONE (initial default) the background color is not seen.
Line 80: Line 57:
</pre>
</pre>
This is an example of a function used to repaint the window when a WM_PAINT message is issued.
This is an example of a function used to repaint the window when a WM_PAINT message is issued.
 
<pre>
<pre>  
VOID cdecl ClientPaint( HWND hwnd )
VOID cdecl ClientPaint( HWND hwnd )
{
{
Line 88: Line 64:
   RECTL  rcl;                      /* Window rectangle          */
   RECTL  rcl;                      /* Window rectangle          */


   /* Obtain a cache PS and set color
   /* Obtain a cache PS and set color and background mix attributes */
    and background mix attributes   */
   hps = WinBeginPaint( hwnd, (HPS)NULLHANDLE, (PRECTL)&rcl );
   hps = WinBeginPaint( hwnd, (HPS)NULLHANDLE, (PRECTL)&rcl );
   GpiSetColor( hps, clrText );
   GpiSetColor( hps, clrText );
   GpiSetBackColor( hps, CLR_BACKGROUND ); /* set background
   GpiSetBackColor( hps, CLR_BACKGROUND ); /* set background to white. */
                                                to white.       */
   GpiSetBackMix( hps, BM_OVERPAINT );
   GpiSetBackMix( hps, BM_OVERPAINT );
                       /* the background of the primitive takes
                       /* the background of the primitive takes
                           over whatever is underneath.          */
                           over whatever is underneath.          */
}
}
</pre>
</pre>



Latest revision as of 15:47, 3 April 2025

This function sets the current background mix attribute for each individual primitive type.

Syntax

GpiSetBackMix(hps, lMixMode)

Parameters

hps (HPS) - input
Presentation-space handle.
lMixMode (LONG) - input
Background-mix mode.
Background mixes marked with an asterisk (*) are mandatory for all devices.
The currently associated device supports any of the mixes specified as supported in DevQueryCaps (CAPS_BACKGROUND_MIX_SUPPORT) Any other valid mixes can be supported for some primitive types but otherwise result in BM_LEAVEALONE. An error is raised only if the value specified is not one of those listed.
For more information on mixing, see GpiSetMix.
BM_DEFAULT - The default value (BM_LEAVEALONE unless changed with GpiSetDefAttrs).
BM_OR - Logical-OR.
BM_OVERPAINT - The background of the primitive takes precedence over whatever is underneath. (*)
BM_XOR - Exclusive-OR.
BM_LEAVEALONE - The background of the primitive has no effect on what is underneath. (*)

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_BACKGROUND_COL_ATTR (0x2044)
An invalid background color attribute value was specified or the default value was explicitly specified with GpiSetAttrs instead of using the defaults mask.

Remarks

The background mix attribute controls the way that the background color of a primitive is combined with the color of any primitive that it overlaps.

These primitives are affected by the background mix attribute:

Areas
The background of an area is defined to be every pel within the area that is not set by the shading pattern.
Text
The background of a character is the complete character box.
Images
For an image, the background is every pel within the image that is not set.
Markers
The background of a marker is the complete marker box.

Note: When the background mix is BM_LEAVEALONE (initial default) the background color is not seen.

The attribute mode determines whether the current value of the background mix attribute is preserved. If it is, the values of the background mix attribute for each primitive type are preserved, and a single GpiPop function restores them.

This function should not be used within a path or area bracket.

Note: There are restrictions on the use of this function when creating SAA-conforming metafiles; see "MetaFile Resolutions" in the Presentation Manager Programming Reference for more information.

Example Code

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

HPS     hps;       /*  Presentation-space handle. */
LONG    lMixMode;  /*  Background-mix mode. */
BOOL    rc;        /*  Success indicator. */

rc = GpiSetBackMix(hps, lMixMode);

This is an example of a function used to repaint the window when a WM_PAINT message is issued.

VOID cdecl ClientPaint( HWND hwnd )
{
  POINTL  pt;
  HPS     hps;                      /* Presentation space handle */
  RECTL   rcl;                      /* Window rectangle          */

  /* Obtain a cache PS and set color and background mix attributes */
  hps = WinBeginPaint( hwnd, (HPS)NULLHANDLE, (PRECTL)&rcl );
  GpiSetColor( hps, clrText );
  GpiSetBackColor( hps, CLR_BACKGROUND ); /* set background to white. */
  GpiSetBackMix( hps, BM_OVERPAINT );
                       /* the background of the primitive takes
                          over whatever is underneath.           */
}

Related Functions

  • GpiBox
  • GpiBeginArea
  • GpiCharString
  • GpiCharStringAt
  • GpiCharStringPos
  • GpiCharStringPosAt
  • GpiEndArea
  • GpiFullArc
  • GpiMarker
  • GpiPolyMarker
  • GpiQueryBackMix
  • GpiSetBackColor
  • GpiSetColor
  • GpiSetMix
  • GpiQueryCharStringPos
  • GpiQueryCharStringPosAt
  • GpiSetAttrMode
  • GpiSetAttrs
  • GpiSetDefAttrs

Graphic Elements and Orders

Element Type: OCODE_GSBMX

This element type is generated if the attribute mode (see GpiSetAttrMode) is set to AM_NOPRESERVE.

Order: Set Background Mix

Element Type: OCODE_GPSBMX

This element type is generated if the attribute mode is set to AM_PRESERVE.

Order: Set Background Mix