/usr/include/Wt/Chart/WAbstractChart is in libwt-dev 3.1.10-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef CHART_WABSTRACT_CHART_H_
#define CHART_WABSTRACT_CHART_H_
#include <Wt/WBrush>
#include <Wt/WFont>
#include <Wt/WPaintedWidget>
#include <Wt/WRectF>
namespace Wt {
class WAbstractItemModel;
class WModelIndex;
class WPainter;
class WRectF;
/*! \brief Namespace for the \ref charts
*/
namespace Chart {
class WChartPalette;
/*! \defgroup charts Charts
* \brief A charting library implemented using the %Wt \ref painting
*
* The charting library contains two main chart widget classes,
* WCartesianChart and WPieChart, and a number of utility classes
* for drawing simple to complex charts.
*/
/*! \class WAbstractChart Wt/Chart/WAbstractChart Wt/Chart/WAbstractChart
* \brief Abstract base class for MVC-based charts.
*
* This is an abstract class and should not be used directly.
*
* As an abstract base for MVC-based charts, this class manages the
* model setModel() and provides virtual methods that listen to
* model changes. In addition, it gives access to generic chart
* properties such as the title setTitle() and title font
* setTitleFont(), the chart palette setPalette(), plot area
* padding setPlotAreaPadding(), and the background fill color
* setBackground().
*
* <h3>CSS</h3>
*
* Styling through CSS is not applicable.
*
* \sa WCartesianChart, WPieChart
*
* \ingroup charts modelview
*/
class WT_API WAbstractChart : public WPaintedWidget
{
public:
/*! \brief Destructor.
*/
virtual ~WAbstractChart();
/*! \brief Set the model.
*
* The model is used by the chart to get its data. Ownership of the
* model is not transferred, and if a previous model was set it is
* not deleted.
*
* The default model is a 0 model.
*
* \sa model()
*/
void setModel(WAbstractItemModel *model);
/*! \brief Returns the model.
*
* \sa setModel(WAbstractItemModel *)
*/
WAbstractItemModel *model() const { return model_; }
/*! \brief Sets a background for the chart.
*
* Set the background color for the main plot area.
*
* The default is a completely transparent background.
*
* \sa background()
*/
void setBackground(const WBrush& background);
/*! \brief Returns the background of the chart.
*
* \sa setBackground(const WBrush&)
*/
const WBrush& background() const { return background_; }
/*! \brief Set a palette for the chart.
*
* A palette is used to provide the style information to render the
* chart series. Ownership of the palette is transferred to the chart.
*
* The default palette is dependent on the chart type.
*
* \sa palette()
*/
void setPalette(WChartPalette *palette);
/*! \brief Returns the palette for the chart.
*
* \sa setPalette(WChartPalette *palette)
*/
WChartPalette *palette() const { return palette_; }
/*! \brief Set an internal margin for the main plot area.
*
* This configures the area (in pixels) around the plot area that is
* available for axes, labels, and titles. You need to set this
* appropriately so that labels fit inside these margins.
*
* The default is dependent on the chart type.
*/
void setPlotAreaPadding(int padding, WFlags<Side> sides = All);
/*! \brief Returns the internal margin for the main plot area.
*
* \sa setPlotAreaPadding(int, WFlags<Side>)
*/
int plotAreaPadding(Side side) const;
/*! \brief Set a chart title.
*
* The title is displayed on top of the chart, using the titleFont().
*
* The default title is an empty title ("").
*
* \sa title()
*/
void setTitle(const WString& title);
/*! \brief Return the chart title.
*
* \sa title()
*/
const WString& title() const { return title_; }
/*! \brief Set the font for the chart title.
*
* Changes the font for the chart title.
*
* The default title font is a 15 point Sans Serif font.
*
* \sa titleFont(), setTitle(const WString&)
*/
void setTitleFont(const WFont& titleFont);
/*! \brief Returns the font for the chart title.
*
* \sa setTitleFont(const WFont&)
*/
const WFont& titleFont() const { return titleFont_; }
void setAxisTitleFont(const WFont& titleFont);
const WFont& axisTitleFont() const { return titleFont_; }
/*! \brief Paint the chart in a rectangle of the given painter.
*
* Paints the chart inside the <i>painter</i>, in the area indicated
* by <i>rectangle</i>. When <i>rectangle</i> is a null rectangle,
* the entire painter \link WPainter::window() window\endlink is
* used.
*/
virtual void paint(WPainter& painter, const WRectF& rectangle = WRectF())
const = 0;
protected:
WAbstractChart(WContainerWidget *parent);
private:
WAbstractItemModel *model_;
WBrush background_;
WChartPalette *palette_;
int padding_[4];
WString title_;
WFont titleFont_;
WFont axisTitleFont_;
// connections with the current model, used to disconnect from a model
// when the model changes.
std::vector<boost::signals::connection> modelConnections_;
/*! \brief Method called whenever the entire model was changed.
*
* \sa setModel(WAbstractItemModel *)
*/
virtual void modelChanged();
/*! \brief Method called whenever the entire model was reset.
*
* Bound to the WAbstractItemModel::modelReset() and
* WAbstractItemModel::layoutChanged() signals.
*/
virtual void modelReset();
/*! \brief Method called when colums have been inserted in the model.
*
* \sa WAbstractItemModel::columnsInserted
*/
virtual void modelColumnsInserted(const WModelIndex& parent,
int start, int end) = 0;
/*! \brief Method called when colums have been removed from the model.
*
* \sa WAbstractItemModel::columnsRemoved
*/
virtual void modelColumnsRemoved(const WModelIndex& parent,
int start, int end) = 0;
/*! \brief Method called when rows have been inserted from the model.
*
* \sa WAbstractItemModel::rowsInserted
*/
virtual void modelRowsInserted(const WModelIndex& parent,
int start, int end) = 0;
/*! \brief Method called when rows have been removed from the model.
*
* \sa WAbstractItemModel::rowsRemoved
*/
virtual void modelRowsRemoved(const WModelIndex& parent,
int start, int end) = 0;
/*! \brief Method called when data has been changed in the model.
*
* \sa WAbstractItemModel::dataChanged
*/
virtual void modelDataChanged(const WModelIndex& topLeft,
const WModelIndex& bottomRight) = 0;
template <typename T>
void set(T& m, const T& v);
};
template <typename T>
void WAbstractChart::set(T& m, const T& v)
{
if (m != v) {
m = v;
update();
}
}
}
}
#endif // CHART_WABSTRACT_CHART_H_
|