Qwt User's Guide  6.0.2
qwt_plot_canvas.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #ifndef QWT_PLOT_CANVAS_H
11 #define QWT_PLOT_CANVAS_H
12 
13 #include "qwt_global.h"
14 #include <qframe.h>
15 #include <qpen.h>
16 #include <qpainterpath.h>
17 #include <qbitmap.h>
18 
19 class QwtPlot;
20 class QPixmap;
21 
29 class QWT_EXPORT QwtPlotCanvas : public QFrame
30 {
31  Q_OBJECT
32 
33 public:
34 
43  {
55  BackingStore = 1,
56 
72  Opaque = 2,
73 
89  HackStyledBackground = 4,
90 
97  ImmediatePaint = 8
98  };
99 
101  typedef QFlags<PaintAttribute> PaintAttributes;
102 
110  {
113 
119 
125  ItemFocusIndicator
126  };
127 
128  explicit QwtPlotCanvas( QwtPlot * );
129  virtual ~QwtPlotCanvas();
130 
131  QwtPlot *plot();
132  const QwtPlot *plot() const;
133 
134  void setFocusIndicator( FocusIndicator );
135  FocusIndicator focusIndicator() const;
136 
137  void setBorderRadius( double );
138  double borderRadius() const;
139 
140  QPainterPath borderPath( const QRect &rect ) const;
141  QBitmap borderMask( const QSize & ) const;
142 
143  void setPaintAttribute( PaintAttribute, bool on = true );
144  bool testPaintAttribute( PaintAttribute ) const;
145 
146  const QPixmap *backingStore() const;
147  void invalidateBackingStore();
148 
149  void replot();
150 
151  virtual bool event( QEvent * );
152 
153 protected:
154  virtual void paintEvent( QPaintEvent * );
155  virtual void resizeEvent( QResizeEvent * );
156 
157  virtual void drawFocusIndicator( QPainter * );
158  virtual void drawBorder( QPainter * );
159 
160  void updateStyleSheetInfo();
161 
162 private:
163  void drawCanvas( QPainter *, bool withBackground );
164 
165  class PrivateData;
166  PrivateData *d_data;
167 };
168 
169 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotCanvas::PaintAttributes )
170 
171 #endif