Rogue Wave Views
Foundation Package API Reference Guide
Product Documentation:

Rogue Wave Views
Documentation Home
List of all members | Public Member Functions
IlvPalette::Builder Class Reference

IlvPalette builder. More...

#include <ilviews/base/resource.h>

Inheritance diagram for IlvPalette::Builder:
IlvPalette::Changer

Public Member Functions

 Builder (IlvDisplay *display)
 Initializes a new palette builder, starting with the default palette of the indicated display. More...
 
 Builder (const IlvPalette *palette)
 Initializes a new palette builder, starting with an existing palette. More...
 
 Builder (const Builder &builder)
 Copy constructor. More...
 
Builderalpha (IlvIntensity alpha)
 Sets the new palette alpha value. More...
 
BuilderantialiasingMode (IlvAntialiasingMode aaMode)
 Sets the new palette antialias setting. More...
 
BuilderarcMode (IlvArcMode arcMode)
 Sets the new palette arc mode. More...
 
Builderbackground (IlvColor *background)
 Sets the new palette background color. More...
 
Builderbackground (const char *background)
 Sets the new palette background color name. More...
 
BuilderbackgroundHSV (IlFloat hue, IlFloat saturation, IlFloat value)
 Sets the new palette background color HSV values. More...
 
BuilderbackgroundRGB (IlvIntensity r, IlvIntensity g, IlvIntensity b)
 Sets the new palette background color RGB values. More...
 
BuildercolorPattern (IlvColorPattern *colorPattern)
 Sets the new palette fill color pattern. More...
 
BuilderfillRule (IlvFillRule fillRule)
 Sets the new palette fill rule. More...
 
BuilderfillStyle (IlvFillStyle fillStyle)
 Sets the new palette fill style. More...
 
Builderfont (IlvFont *font)
 Sets the new palette font. More...
 
Builderfont (const char *fontName)
 Sets the new palette font by name. More...
 
Builderforeground (IlvColor *foreground)
 Sets the new palette foreground color. More...
 
Builderforeground (const char *foreground)
 Sets the new palette foreground color name. More...
 
BuilderforegroundHSV (IlFloat hue, IlFloat saturation, IlFloat value)
 Sets the new palette foreground color HSV values. More...
 
BuilderforegroundRGB (IlvIntensity r, IlvIntensity g, IlvIntensity b)
 Sets the new palette foreground color RGB values. More...
 
virtual IlvPaletteget (IlBoolean shared=IlTrue) const
 Builds and returns the new palette. More...
 
BuildergradientPattern (IlvGradientPattern *gradPat)
 Sets the new palette gradient pattern. More...
 
Builderinvert ()
 Swaps the foreground and the background colors of this palette builder. More...
 
BuilderlineStyle (IlvLineStyle *lineStyle)
 Sets the new palette line style. More...
 
BuilderlineStyle (const char *name)
 Sets the new palette line style. More...
 
BuilderlineStyle (IlUShort count, const unsigned char *dashes, IlUShort offset=0)
 Sets the new palette line style. More...
 
BuilderlineWidth (IlUShort lineWidth)
 Sets the new palette line width. More...
 
 operator IlvPalette * () const
 Cast operator to a pointer to an IlvPalette. More...
 
Builderoperator= (const Builder &builder)
 Assignment operator. More...
 
Builderpattern (IlvPattern *pattern)
 Sets the new palette fill pattern. More...
 

Detailed Description

IlvPalette builder.

Library: xviews or winviews or mviews (mutually exclusive)
This class simplifies the process of building a new IlvPalette, starting from an existing palette, and limiting the parameters that need to be changed to just what the application needs .

Starting with a palette, the palette builder lets you change one or several palette settings, so one does not have to provide the entire set of palette parameters should only a few of them be changed.

If you need to create a new palette that is the exact copy of another one, but where, for example, the background and foreground colors are swapped and where the line width is changed, you can use the following code:

IlvPalette* newPalette = IlvPalette::Builder(initialPalette)
.invert()
.lineWidth(10);
// newPalette is identical to initialPalette, except that its
// background and foreground colors are swapped, and the line
// width is now set to 10.

that is much more readable, less error-prone and shorter than the equivalent code:

IlvPalette* newPalette = initialPalette->getDisplay()
->getPalette(initialPalette->getForeground(),
initialPalette->getBackground(),
initialPalette->getPattern(),
initialPalette->getColorPattern(),
initialPalette->getFont(),
initialPalette->getLineStyle(),
10,
initialPalette->getFillStyle(),
initialPalette->getArcMode(),
initialPalette->getFillRule(),
initialPalette->getAlpha(),
initialPalette->getAntialiasingMode(),
initialPalette->getGradientPattern());

A handy use case is when you want to create a set of IlvPalette objects that are based on a reference one:

IlvPalette::Builder builder(display);
builder.background("black").foreground("white").lineWidth(1);
IlvPalette* normal = builder.get();
IlvPalette* warning = builder.foreground("orange").lineWidth(3);
IlvPalette* error = builder.foreground("red").lineWidth(7);
// 'warning' and 'error' are similar to 'normal', where only the
// foreground color and the line width were changed.

Without the Builder, you would have to repeat a large number of parameters when invoking IlvDisplay::getPalette().

Constructor & Destructor Documentation

§ Builder() [1/3]

IlvPalette::Builder::Builder ( IlvDisplay display)

Initializes a new palette builder, starting with the default palette of the indicated display.

Parameters
displayThe display instance to query the default palette from, that initializes the builder state.

§ Builder() [2/3]

IlvPalette::Builder::Builder ( const IlvPalette palette)

Initializes a new palette builder, starting with an existing palette.

Parameters
paletteThe palette to initialize the builder from.

§ Builder() [3/3]

IlvPalette::Builder::Builder ( const Builder builder)

Copy constructor.

Constructs a copy of builder.

Parameters
builderThe builder that is copied to this object.

Member Function Documentation

§ alpha()

Builder& IlvPalette::Builder::alpha ( IlvIntensity  alpha)

Sets the new palette alpha value.

Parameters
alphaThe new palette alpha value.
Returns
The Builder object (*this).

§ antialiasingMode()

Builder& IlvPalette::Builder::antialiasingMode ( IlvAntialiasingMode  aaMode)

Sets the new palette antialias setting.

Parameters
aaModeThe new palette antialias setting.
Returns
The Builder object (*this).

§ arcMode()

Builder& IlvPalette::Builder::arcMode ( IlvArcMode  arcMode)

Sets the new palette arc mode.

Parameters
arcModeThe new palette arc mode.
Returns
The Builder object (*this).

§ background() [1/2]

Builder& IlvPalette::Builder::background ( IlvColor background)

Sets the new palette background color.

Parameters
backgroundThe new palette background color. This color is locked.
Returns
The Builder object (*this).

§ background() [2/2]

Builder& IlvPalette::Builder::background ( const char *  background)

Sets the new palette background color name.

Parameters
backgroundThe name of the new palette background color. If this name does not correspond to an actual color, this function does nothing.
Returns
The Builder object (*this).
See also
IlvDisplay::getColor(const char*, IlBoolean).

§ backgroundHSV()

Builder& IlvPalette::Builder::backgroundHSV ( IlFloat  hue,
IlFloat  saturation,
IlFloat  value 
)

Sets the new palette background color HSV values.

Parameters
hueThe hue value value of the new palette background color.
saturationThe saturation value of the new palette background color.
valueThe The luminosity value of the new palette background color.
Returns
The Builder object (*this).
See also
IlvDisplay::getColor(IlFloat, IlFloat, IlFloat, IlBoolean).

§ backgroundRGB()

Builder& IlvPalette::Builder::backgroundRGB ( IlvIntensity  r,
IlvIntensity  g,
IlvIntensity  b 
)

Sets the new palette background color RGB values.

Parameters
rThe red component value of the new palette background color.
gThe green component value of the new palette background color.
bThe red component value of the new palette background color.
Returns
The Builder object (*this).
See also
IlvDisplay::getColor(IlvIntensity, IlvIntensity, IlvIntensity, IlBoolean).

§ colorPattern()

Builder& IlvPalette::Builder::colorPattern ( IlvColorPattern colorPattern)

Sets the new palette fill color pattern.

Parameters
colorPatternThe new palette fill color pattern. This pattern is locked.
Returns
The Builder object (*this).

§ fillRule()

Builder& IlvPalette::Builder::fillRule ( IlvFillRule  fillRule)

Sets the new palette fill rule.

Parameters
fillRuleThe new palette fill rule.
Returns
The Builder object (*this).

§ fillStyle()

Builder& IlvPalette::Builder::fillStyle ( IlvFillStyle  fillStyle)

Sets the new palette fill style.

Parameters
fillStyleThe new palette fill style.
Returns
The Builder object (*this).

§ font() [1/2]

Builder& IlvPalette::Builder::font ( IlvFont font)

Sets the new palette font.

Parameters
fontThe new palette font. This font is locked.
Returns
The Builder object (*this).

§ font() [2/2]

Builder& IlvPalette::Builder::font ( const char *  fontName)

Sets the new palette font by name.

Parameters
fontNameThe new palette font name. This font is locked. If this name does not correspond to an actual font, this function does nothing.
Returns
The Builder object (*this).

§ foreground() [1/2]

Builder& IlvPalette::Builder::foreground ( IlvColor foreground)

Sets the new palette foreground color.

Parameters
foregroundThe new palette foreground color. This color is locked.
Returns
The Builder object (*this).

§ foreground() [2/2]

Builder& IlvPalette::Builder::foreground ( const char *  foreground)

Sets the new palette foreground color name.

Parameters
foregroundThe name of the new palette foreground color. If this name does not correspond to an actual color, this function does nothing.
Returns
The Builder object (*this).
See also
IlvDisplay::getColor(const char*, IlBoolean).

§ foregroundHSV()

Builder& IlvPalette::Builder::foregroundHSV ( IlFloat  hue,
IlFloat  saturation,
IlFloat  value 
)

Sets the new palette foreground color HSV values.

Parameters
hueThe hue value value of the new palette foreground color.
saturationThe saturation value of the new palette foreground color.
valueThe The luminosity value of the new palette foreground color.
Returns
The Builder object (*this).
See also
IlvDisplay::getColor(IlFloat, IlFloat, IlFloat, IlBoolean).

§ foregroundRGB()

Builder& IlvPalette::Builder::foregroundRGB ( IlvIntensity  r,
IlvIntensity  g,
IlvIntensity  b 
)

Sets the new palette foreground color RGB values.

Parameters
rThe red component value of the new palette foreground color.
gThe green component value of the new palette foreground color.
bThe red component value of the new palette foreground color.
Returns
The Builder object (*this).
See also
IlvDisplay::getColor(IlvIntensity, IlvIntensity, IlvIntensity, IlBoolean).

§ get()

virtual IlvPalette* IlvPalette::Builder::get ( IlBoolean  shared = IlTrue) const
virtual

Builds and returns the new palette.

Parameters
sharedIf IlTrue, the palette that is built is shared (that is, allocated using IlvDisplay::getPalette()), and not locked.
If IlFalse, the new palette is not shared (allocated using the IlvPalette constructor).
Returns
The new palette that was just build.
See also
operator IlvPalette*().

Reimplemented in IlvPalette::Changer.

§ gradientPattern()

Builder& IlvPalette::Builder::gradientPattern ( IlvGradientPattern gradPat)

Sets the new palette gradient pattern.

Parameters
gradPatThe new gradient pattern. This gradient pattern is locked.
Returns
The Builder object (*this).

§ invert()

Builder& IlvPalette::Builder::invert ( )

Swaps the foreground and the background colors of this palette builder.

Returns
The Builder object (*this).
See also
foreground(), background().

§ lineStyle() [1/3]

Builder& IlvPalette::Builder::lineStyle ( IlvLineStyle lineStyle)

Sets the new palette line style.

Parameters
lineStyleThe new palette line style. This line style is locked.
Returns
The Builder object (*this).

§ lineStyle() [2/3]

Builder& IlvPalette::Builder::lineStyle ( const char *  name)

Sets the new palette line style.

Parameters
nameThe new palette line style name if the style has been previously defined.
Returns
The Builder object (*this).

§ lineStyle() [3/3]

Builder& IlvPalette::Builder::lineStyle ( IlUShort  count,
const unsigned char *  dashes,
IlUShort  offset = 0 
)

Sets the new palette line style.

Parameters
countThe length of the line style array.
dashesThe number of foreground-colored pixels in a dash.
offsetThe number of pixels to be skipped before the next dash.
Returns
The Builder object (*this).

§ lineWidth()

Builder& IlvPalette::Builder::lineWidth ( IlUShort  lineWidth)

Sets the new palette line width.

Parameters
lineWidthThe new palette line width.
Returns
The Builder object (*this).

§ operator IlvPalette *()

IlvPalette::Builder::operator IlvPalette * ( ) const

Cast operator to a pointer to an IlvPalette.

The palette that is returned is a shared palette that is not locked.

Returns
The new palette, as returned by get(IlTrue).

§ operator=()

Builder& IlvPalette::Builder::operator= ( const Builder builder)

Assignment operator.

This operator assigns builder to this object.

Parameters
builderThe builder that is copied to this object.

§ pattern()

Builder& IlvPalette::Builder::pattern ( IlvPattern pattern)

Sets the new palette fill pattern.

Parameters
patternThe new palette fill pattern. This pattern is locked.
Returns
The Builder object (*this).

© Copyright 2018, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.