KChart

KChartPalette.h
1/*
2 * SPDX-FileCopyrightText: 2001-2015 Klaralvdalens Datakonsult AB. All rights reserved.
3 *
4 * This file is part of the KD Chart library.
5 *
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#ifndef __KCHART_PALETTE_H__
10#define __KCHART_PALETTE_H__
11
12#include <QObject>
13#include <QBrush>
14#include "KChartGlobal.h"
15
16namespace KChart {
17
18 /**
19 * \brief A Palette is a set of brushes (or colors) to be used
20 * for painting data sets.
21 *
22 * The palette class encapsulates a collection of brushes, which in
23 * the simplest case are colors, to be used for painting a series of
24 * data sets. When asked for the m-th color, a palette of size n will
25 * wrap around and thus cycle through the available colors.
26 *
27 * Three builtin palettes are provided for convenience, one with a default
28 * set of colors, one with a subdued color selection, one with rainbow
29 * colors.
30 *
31 * When a palette changes, it emits a changed() signal. Hook up to it, if
32 * you want to repaint when the color selection changes.
33 */
34
35class KCHART_EXPORT Palette: public QObject
36{
37 Q_OBJECT
38public:
39 explicit Palette( QObject *parent = nullptr );
40 Palette( const Palette& );
41 Palette &operator= ( const Palette & );
42
43 ~Palette() override;
44
45 /** Provide access to the three builtin palettes, one with standard bright
46 * colors, one with more subdued colors, and one with rainbow colors. */
47 static const Palette& defaultPalette();
48 static const Palette& subduedPalette();
49 static const Palette& rainbowPalette();
50
51 /** @return whether this represents a valid palette. For a palette to be
52 * valid it needs to have at least one brush associated. */
53 bool isValid() const;
54
55 /** @return the number of brushed in the palette. */
56 int size() const;
57
58 /** Adds \a brush to the palette. If no \a position is specified, the
59 * brush is appended.
60 */
61 void addBrush( const QBrush & brush, int position = -1 );
62
63 /**
64 * Query the palette for a brush at the specified position. If the
65 * position exceeds the size of the palette, it wraps around.
66 */
67 QBrush getBrush( int position ) const;
68
69 /** Remove the brush at position \a position, if there is one. */
70 void removeBrush( int position );
71
72Q_SIGNALS:
73 /** Emitted whenever the palette changes. Views listen to this and repaints. */
74 void changed();
75
76private:
77 KCHART_DECLARE_PRIVATE_BASE_VALUE( Palette )
78};
79
80}
81
82KCHART_DECLARE_SWAP_SPECIALISATION( KChart::Palette )
83
84#endif
Contains KChart macros.
A Palette is a set of brushes (or colors) to be used for painting data sets.
void changed()
Emitted whenever the palette changes.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:54:44 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.