Views
Foundation Package API Reference Guide
Product Documentation:
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 (const Changer &changer)
 Copy constructor. More...
 
 Changer (IlvPalette *source)
 Initializes a new palette changer for a given palette. 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 (const Builder &builder)
 Copy constructor. More...
 
 Builder (const IlvPalette *palette)
 Initializes a new palette builder, starting with an existing palette. More...
 
 Builder (IlvDisplay *display)
 Initializes a new palette builder, starting with the default palette of the indicated display. 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 (const char *background)
 Sets the new palette background color name. More...
 
Builderbackground (IlvColor *background)
 Sets the new palette background color. 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 (const char *fontName)
 Sets the new palette font by name. More...
 
Builderfont (IlvFont *font)
 Sets the new palette font. More...
 
Builderforeground (const char *foreground)
 Sets the new palette foreground color name. More...
 
Builderforeground (IlvColor *foreground)
 Sets the new palette foreground color. 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 (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...
 
BuilderlineStyle (IlvLineStyle *lineStyle)
 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:

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

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.