cdCanvasSetForeground

Definition: include pGUI.e

cdCanvasSetForeground(cdCanvas hCdCanvas, integer colour)
-- or --
[integer colour =] cd[Canvas](Set|Get)(Back|Fore)ground() variations, as detailed below.
Description: Configures a new current foreground color.

This color is used in all primitives (lines, areas, marks and text). Default value: CD_BLACK.
Comments: To retrieve the current value, use integer colour = cdCanvasGetForeground(cdCanvas hCdCanvas).

In C, cdCanvasForeground performs a get/set with a conflict over CD_QUERY(/WHITE), and it is suggested to use cdCanvasSetForeground to avoid that conflict (nb there is no C function named cdCanvasGetForground). In pGUI, the procedure cdCanvasSetForeground and the function cdCanvasGetForeground are used in the obvious and non-conflicting way, though (not that I can imagine why) you might (occasionally) need to replace one C call with a Get followed by a Set in pGUI.

The C function cdForeground(c) is shorthand for cdCanvasForeground(cdActiveCanvas(),c), except for CD_QUERY, which it does not handle.
While technically the same issue might not be present, it seems prudent to keep things consistent, hence when translating from C (or for that matter any other language binding) replace cdForeground() with cdSetForeground(), cdGetForegound(), or both.

The routines cdCanvasSetBackground, cdCanvasGetBackground, cdSetBackground, and cdGetBackground are practically identical, and not separately documented, and likewise pGUI does not define cdBackround and cdCanvasBackground, instead there must always be either "Get" or "Set" in the routine name.
The cd[Canvas]SetBackground() routine only affects cd[Canvas]Clear().
See Also: DEV See also Color Coding.