Vault  4.1
Public Member Functions | Static Public Member Functions | Friends
VColorPair Class Reference

VColorPair holds a foreground and background color as a single object for ease of management and use in the other APIs. More...

#include <vcolor.h>

List of all members.

Public Member Functions

 VColorPair (const VColor &bg)
 VColorPair (const VColor &bg, const VColor &fg)
const VColorgetBg () const
const VColorgetFg () const
const VColorgetColor (bool isBg) const
VString getCSSColor () const

Static Public Member Functions

static VColor generateContrastingForeground (const VColor &bg)
 Returns white if the specified background is "dark", and black if the specified background is "light".
static VColorPair safeConstructColorPair (const VString &bgCssColor, const VString &fgCssColor)
 This function returns a VColorPair based on the supplied bg/fg colors, which may be empty if not applicable.

Friends

bool operator== (const VColorPair &c1, const VColorPair &c2)
bool operator!= (const VColorPair &c1, const VColorPair &c2)

Detailed Description

VColorPair holds a foreground and background color as a single object for ease of management and use in the other APIs.

For consistency, we always reference the background as the first element, and the foreground as the second element. Also for consistency and brevity, we abbreviate using "bg" and "fg" everywhere. For efficiency, thoughout the color palette classes we provide flexible APIs that can return a color pair, a particular color, or a fg/bg color as asked for.

Definition at line 164 of file vcolor.h.


Member Function Documentation

VColor VColorPair::generateContrastingForeground ( const VColor bg) [static]

Returns white if the specified background is "dark", and black if the specified background is "light".

Parameters:
bga background color value
Returns:
white or black, to best contrast with the background

Definition at line 230 of file vcolor.cpp.

References VColor::getLightness().

VColorPair VColorPair::safeConstructColorPair ( const VString bgCssColor,
const VString fgCssColor 
) [static]

This function returns a VColorPair based on the supplied bg/fg colors, which may be empty if not applicable.

This function also catches malformed color values skips them.

Parameters:
bgCssColorbackground color as a CSS color string (see VColor); if empty, the result is constructed with white bg color
fgCssColorforeground color as a CSS color string (see VColor); if empty, the result is constructed with no fg color (a contrasting color will be generated)

Definition at line 235 of file vcolor.cpp.

References VString::isNotEmpty(), and VColor::setCSSColor().


The documentation for this class was generated from the following files:

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.