class KPalette

# class KPalette | Class for handling Palettes. More...
Definition | `#include <kpalette.h>`
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum Editable { Yes, No, Ask }

#### Public Methods

- KPalette (const QString &name=QString::null)
- KPalette (const KPalette &)
- virtual ~KPalette ()
- KPalette& operator= ( const KPalette &)
- bool save ()
- QString description () const
- void setDescription (const QString &desc)
- QString name () const
- void setName (const QString &name)
- Editable editable () const
- void setEditable (Editable editable)
- int nrColors () const
- QColor color (int index)
- int findColor (const QColor &color) const
- QString colorName (int index)
- QString colorName (const QColor &color)
- int addColor (const QColor &newColor, const QString &newColorName = QString::null)
- int changeColor (int index, const QColor &newColor, const QString &newColorName = QString::null)
- int changeColor (const QColor &oldColor, const QColor &newColor, const QString &newColorName = QString::null)

#### Public Static Methods

- static QStringList getPaletteList ()

## Detailed Description

Class for handling Palettes.

This class makes it easy to handle palettes. A palette is a set of colors. This class can read and write palettes from and to a file.

This class uses the "GIMP" palette file format.

This class is totally unrelated to QPalette.

QStringList getPaletteList () | ### getPaletteList

[static]

Query which KDE palettes are installed.

Returns: A list with a palette names.

KPalette (const QString &name=QString::null) | ### KPalette

KPalette constructor. Creates a KPalette from a file the filename is derived from the name.

Parameters:

name | The name of palette as returned by getPaletteList()

KPalette (const KPalette &) | ### KPalette

KPalette copy constructor.

~KPalette () | ### ~KPalette

[virtual]

KPalette destructor.

KPalette& operator= ( const KPalette &) | ### operator=

KPalette assignment operator

bool save () | ### save

Save the palette

Returns: 'true' if successful

QString description () | ### description

[const]

Get the description of the palette.

Returns: the description of the palette.

void setDescription (const QString &desc) | ### setDescription

Set the description of the palette.

Parameters:

desc | the new description

QString name () | ### name

[const]

Get the name of the palette.

Returns: the name of the palette

void setName (const QString &name) | ### setName

Set the name of the palette.

Parameters:

name | the name of the palette

enum Editable { Yes, No, Ask } | ### Editable

Used to specify whether a palette may be edited.

See also: editable(), setEditable()

Editable editable () | ### editable

[const]

Returns whether the palette may be edited.

Returns: the state of the palette

void setEditable (Editable editable) | ### setEditable

Change whether the palette may be edited.

Parameters:

editable | the state of the palette

int nrColors () | ### nrColors

[const]

Return the number of colors in the palette.

Returns: the number of colors

QColor color (int index) | ### color

Find color by index.

Parameters:

index | the index of the desired color

Returns: The `index` -th color of the palette, null if not found.

int findColor (const QColor &color) | ### findColor

[const]

Find index by `color`.

Parameters:

color | the color to find

Returns: The index of the color in the palette or -1 if the color is not found.

QString colorName (int index) | ### colorName

Find color name by `index`.

Parameters:

the | index of the color

Returns: The name of the `index` -th color. Note that not all palettes have named the colors. Null is returned if the color does not exist or has no name.

QString colorName (const QColor &color) | ### colorName

Find color name by `color`.

Returns: The name of color according to this palette. Note that not all palettes have named the colors. Note also that each palette can give the same color a different name.

int addColor (const QColor &newColor, const QString &newColorName = QString::null) | ### addColor

Add a color.

Parameters:

newColor | The color to add.
newColorName | The name of the color, null to remove the name.

Returns: The index of the added color.

int changeColor (int index, const QColor &newColor, const QString &newColorName = QString::null) | ### changeColor

Change a color.

Parameters:

index | Index of the color to change
newColor | The new color.
newColorName | The new color name, null to remove the name.

Returns: The index of the new color or -1 if the color couldn't be changed.

int changeColor (const QColor &oldColor, const QColor &newColor, const QString &newColorName = QString::null) | ### changeColor

Change a color.

Parameters:

oldColor | The original color
newColor | The new color.
newColorName | The new color name, null to remove the name.

Returns: The index of the new color or -1 if the color couldn't be changed.

- Version: $Id: kpalette.h,v 1.8 2002/09/19 19:39:49 tjansen Exp $
- Author: Waldo Bastian (bastian@kde.org)
- Generated: root on macppc.ports.openbsd.org on Sat Sep 6 10:36:15 2003, using kdoc 2.0a54.