Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

TQPalette Class Reference

The TQPalette class contains color groups for each widget state. More...

#include <qpalette.h>

List of all member functions.

Public Members

Related Functions


Detailed Description

The TQPalette class contains color groups for each widget state.

A palette consists of three color groups: active, disabled, and inactive. All widgets contain a palette, and all widgets in TQt use their palette to draw themselves. This makes the user interface easily configurable and easier to keep consistent.

If you create a new widget we strongly recommend that you use the colors in the palette rather than hard-coding specific colors.

The color groups:

Both active and inactive windows can contain disabled widgets. (Disabled widgets are often called inaccessible or grayed out.)

In Motif style, active() and inactive() look the same. In Windows 2000 style and Macintosh Platinum style, the two styles look slightly different.

There are setActive(), setInactive(), and setDisabled() functions to modify the palette. (TQt also supports a normal() group; this is an obsolete alias for active(), supported for backwards compatibility.)

Colors and brushes can be set for particular roles in any of a palette's color groups with setColor() and setBrush().

You can copy a palette using the copy constructor and test to see if two palettes are identical using isCopyOf().

See also TQApplication::setPalette(), TQWidget::palette, TQColorGroup, TQColor, Widget Appearance and Style, Graphics Classes, Image Processing Classes, and Implicitly and Explicitly Shared Classes.


Member Type Documentation

TQPalette::ColorGroup


Member Function Documentation

TQPalette::TQPalette ()

Constructs a palette that consists of color groups with only black colors.

TQPalette::TQPalette ( const TQColor & button )

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Constructs a palette from the button color. The other colors are automatically calculated, based on this color. Background will be the button color as well.

TQPalette::TQPalette ( const TQColor & button, const TQColor & background )

Constructs a palette from a button color and a background. The other colors are automatically calculated, based on these colors.

TQPalette::TQPalette ( const TQColorGroup & active, const TQColorGroup & disabled, const TQColorGroup & inactive )

Constructs a palette that consists of the three color groups active, disabled and inactive. See the Detailed Description for definitions of the color groups and TQColorGroup::ColorRole for definitions of each color role in the three groups.

See also TQColorGroup and TQColorGroup::ColorRole.

TQPalette::TQPalette ( const TQPalette & p )

Constructs a copy of p.

This constructor is fast (it uses copy-on-write).

TQPalette::~TQPalette ()

Destroys the palette.

const TQColorGroup & TQPalette::active () const

Returns the active color group of this palette.

See also TQColorGroup, setActive(), inactive(), and disabled().

Examples: themes/metal.cpp and themes/wood.cpp.

const TQBrush & TQPalette::brush ( ColorGroup gr, TQColorGroup::ColorRole r ) const

Returns the brush in color group gr, used for color role r.

See also color(), setBrush(), and TQColorGroup::ColorRole.

const TQColor & TQPalette::color ( ColorGroup gr, TQColorGroup::ColorRole r ) const

Returns the color in color group gr, used for color role r.

See also brush(), setColor(), and TQColorGroup::ColorRole.

TQPalette TQPalette::copy () const

Returns a deep copy of this palette.

Warning: This is slower than the copy constructor and assignment operator and offers no benefits.

const TQColorGroup & TQPalette::disabled () const

Returns the disabled color group of this palette.

See also TQColorGroup, setDisabled(), active(), and inactive().

Examples: themes/metal.cpp and themes/wood.cpp.

const TQColorGroup & TQPalette::inactive () const

Returns the inactive color group of this palette.

See also TQColorGroup, setInactive(), active(), and disabled().

bool TQPalette::isCopyOf ( const TQPalette & p )

Returns TRUE if this palette and p are copies of each other, i.e. one of them was created as a copy of the other and neither was subsequently modified; otherwise returns FALSE. This is much stricter than equality.

See also operator=() and operator==().

const TQColorGroup & TQPalette::normal () const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Returns the active color group. Use active() instead.

See also setActive() and active().

bool TQPalette::operator!= ( const TQPalette & p ) const

Returns TRUE (slowly) if this palette is different from p; otherwise returns FALSE (usually tquickly).

TQPalette & TQPalette::operator= ( const TQPalette & p )

Assigns p to this palette and returns a reference to this palette.

This is fast (it uses copy-on-write).

See also copy().

bool TQPalette::operator== ( const TQPalette & p ) const

Returns TRUE (usually tquickly) if this palette is equal to p; otherwise returns FALSE (slowly).

int TQPalette::serialNumber () const

Returns a number that uniquely identifies this TQPalette object. The serial number is intended for caching. Its value may not be used for anything other than equality testing.

Note that TQPalette uses copy-on-write, and the serial number changes during the lazy copy operation (detach()), not during a shallow copy (copy constructor or assignment).

See also TQPixmap, TQPixmapCache, and TQCache.

void TQPalette::setActive ( const TQColorGroup & g )

Sets the Active color group to g.

See also active(), setDisabled(), setInactive(), and TQColorGroup.

void TQPalette::setBrush ( ColorGroup gr, TQColorGroup::ColorRole r, const TQBrush & b )

Sets the brush in color group gr, used for color role r, to b.

See also brush(), setColor(), and TQColorGroup::ColorRole.

void TQPalette::setBrush ( TQColorGroup::ColorRole r, const TQBrush & b )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the brush in for color role r in all three color groups to b.

See also brush(), setColor(), TQColorGroup::ColorRole, active(), inactive(), and disabled().

void TQPalette::setColor ( ColorGroup gr, TQColorGroup::ColorRole r, const TQColor & c )

Sets the brush in color group gr, used for color role r, to the solid color c.

See also setBrush(), color(), and TQColorGroup::ColorRole.

Example: themes/themes.cpp.

void TQPalette::setColor ( TQColorGroup::ColorRole r, const TQColor & c )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the brush color used for color role r to color c in all three color groups.

See also color(), setBrush(), and TQColorGroup::ColorRole.

void TQPalette::setDisabled ( const TQColorGroup & g )

Sets the Disabled color group to g.

See also disabled(), setActive(), and setInactive().

void TQPalette::setInactive ( const TQColorGroup & g )

Sets the Inactive color group to g.

See also active(), setDisabled(), setActive(), and TQColorGroup.

void TQPalette::setNormal ( const TQColorGroup & cg )

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Sets the active color group to cg. Use setActive() instead.

See also setActive() and active().


Related Functions

TQDataStream & operator<< ( TQDataStream & s, const TQPalette & p )

Writes the palette, p to the stream s and returns a reference to the stream.

See also Format of the TQDataStream operators.

TQDataStream & operator>> ( TQDataStream & s, TQPalette & p )

Reads a palette from the stream, s into the palette p, and returns a reference to the stream.

See also Format of the TQDataStream operators.


This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8