1 // This may look like C code, but it's really -*- C++ -*-
2 /*
3  * Copyright (C) 2008 Emweb bv, Herent, Belgium.
4  *
5  * See the LICENSE file for terms of use.
6  */
7 #ifndef CHART_WCHART_PALETTE_H_
8 #define CHART_WCHART_PALETTE_H_
9 
10 #include <Wt/WDllDefs.h>
11 
12 namespace Wt {
13 
14 class WBrush;
15 class WColor;
16 class WPen;
17 
18   namespace Chart {
19 
20 /*! \class WChartPalette Wt/Chart/WChartPalette.h Wt/Chart/WChartPalette.h
21  *  \brief Abstract base class for styling rendered data series in charts.
22  *
23  * This class provides an interface for a palette which sets strokes
24  * and fill strokes for data in a \link WAbstractChart
25  * chart\endlink. A palette is an ordered list of styles, which is
26  * indexed by the chart to get a suitable style for a particular
27  * series (in case of WCartesianChart) or data row (in case of
28  * WPieChart). Each style is defined by a brush, two pen styles (one
29  * for borders, and one for plain lines), and a font color that is
30  * appropriate for drawing text within the brushed area.
31  *
32  * To use a custom palette, you should reimplement this class, and then
33  * use WAbstractChart::setPalette() to use an instance of the palette.
34  *
35  * \ingroup charts
36  */
37 class WT_API WChartPalette
38 {
39 public:
40   /*! \brief Destructor.
41    */
42   virtual ~WChartPalette();
43 
44   /*! \brief Returns a brush from the palette.
45    *
46    * Returns the brush for the style with given <i>index</i>.
47    */
48   virtual WBrush brush(int index) const = 0;
49 
50   /*! \brief Returns a border pen from the palette.
51    *
52    * Returns the pen for stroking borders around an area filled using the
53    * brush at the same <i>index</i>.
54    *
55    * \sa strokePen(), brush()
56    */
57   virtual WPen borderPen(int index) const = 0;
58 
59   /*! \brief Returns a stroke pen from the palette.
60    *
61    * Returns the pen for stroking lines for the style with given <i>index</i>.
62    *
63    * \sa strokePen()
64    */
65   virtual WPen strokePen(int index) const = 0;
66 
67   /*! \brief Returns a font color from the palette.
68    *
69    * Returns a font color suitable for rendering text in the area filled
70    * with the brush at the same <i>index</i>.
71    *
72    * \sa brush()
73    */
74   virtual WColor fontColor(int index) const = 0;
75 };
76 
77   }
78 }
79 
80 #endif // CHART_WCHART_PALETTE_H_
81