Rogue Wave Views
Foundation Package API Reference Guide
Product Documentation:

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

IlvPalette changer. More...

#include <ilviews/base/resource.h>

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

Public Member Functions

 Changer (IlvPalette *source)
 Initializes a new palette changer for a given palette. More...
 
 Changer (const Changer &changer)
 Copy constructor. More...
 
virtual IlvPaletteget (IlBoolean shared=IlTrue) const
 Builds and returns the new palette. More...
 
Changeroperator= (const Changer &changer)
 Assignment operator. More...
 
- Public Member Functions inherited from IlvPalette::Builder
 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...
 
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 changer.

Library: xviews or winviews or mviews (mutually exclusive)
This class simplifies the process of modifying an IlvPalette, by allowing to indicate just the parameters that you want to modify.

If you need to modify a new palette so that, for example, the background and foreground colors are swapped and where the line width is changed, you can use the following code:

palette = IlvPalette::Changer(palette)
.invert()
.lineWidth(10);
// 'palette' was changed so that its foreground and background
// colors are swapped, and its lineWidth was changed.
// Note that the original palette (that is shared) was unlocked,
// then a new palette was created with the new settings and
// finally this new palette was locked.
// Because we are using the same variable 'palette', the result
// is that 'palette' was actually changed to point to a new palette,
// initialized with the indicated settings.

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

IlvPalette* newPalette = palette->getDisplay()
->getPalette(palette->getForeground(),
palette->getBackground(),
palette->getPattern(),
palette->getColorPattern(),
palette->getFont(),
palette->getLineStyle(),
10,
palette->getFillStyle(),
palette->getArcMode(),
palette->getFillRule(),
palette->getAlpha(),
palette->getAntialiasingMode(),
palette->getGradientPattern());
newPalette->lock();
palette->unLock();
palette= newPalette;
See also
IlvDisplay::getPalette().
Warning
Special care must be taken with respect to the resource locking and locking mecanism: the IlvPalette that is used in the Changer constructor is considered not to be used anymore, because it is changed the to the IlvPalette that is returned by the get() member function. See get() for a full explanation of the different use cases.

Constructor & Destructor Documentation

§ Changer() [1/2]

IlvPalette::Changer::Changer ( IlvPalette source)

Initializes a new palette changer for a given palette.

Parameters
sourceThe palette to initialize the changer from. This palette, if shared, may potentially be unlocked when get() is invoked.

§ Changer() [2/2]

IlvPalette::Changer::Changer ( const Changer changer)

Copy constructor.

Constructs a copy of changer.

Parameters
changerThe changer that is copied to this object.

Member Function Documentation

§ get()

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

Builds and returns the new palette.

This member function does the following, succesively:

  • Create a new IlvPalette, based on this Changer attribute values:
    • if shared is IlTrue, this palette is queried to the display using IlvDisplay::getPalette(), then this palette is locked.
    • if shared is IlFalse, this palette is a new palette, initialized by the IlvPalette constructor.
  • Get rid of the legacy palette, the one that was provided in the Changer constructor:
    • if this palette was shared, it is unlocked.
    • if this palette was not shared, it is deleted.

Typically, you would assign the returned palette to the variable that holds the pointer that was provided in the constructor.

Because the original palette (the one provided in the constructor) may be deleted (because it is not shared, or its reference count drops to 0), you must make sure that you are not keeping a pointer to this palette unintentionally.

Parameters
sharedIf IlTrue, the returned palette is shared and locked.
If IlFalse, the returned palette is not shared.
Returns
The new palette that was build, using this Changer attribute values.
See also
operator IlvPalette*().

Reimplemented from IlvPalette::Builder.

§ operator=()

Changer& IlvPalette::Changer::operator= ( const Changer changer)

Assignment operator.

This operator assigns changer to this object.

Parameters
changerThe changer that is copied to this object.

© 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.