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 // vim: expandtab 11 12 #ifndef QWT_PLOT_CANVAS_H 13 #define QWT_PLOT_CANVAS_H 14 15 #include <qframe.h> 16 #include <qpen.h> 17 #include "qwt_global.h" 18 19 class QwtPlot; 20 class QPixmap; 21 22 /*! 23 \brief Canvas of a QwtPlot. 24 \sa QwtPlot 25 */ 26 class QWT_EXPORT QwtPlotCanvas : public QFrame 27 { 28 Q_OBJECT 29 30 public: 31 32 /*! 33 \brief Paint attributes 34 35 - PaintCached\n 36 Paint double buffered and reuse the content of the pixmap buffer 37 for some spontaneous repaints that happen when a plot gets unhidden, 38 deiconified or changes the focus. 39 Disabling the cache will improve the performance for 40 incremental paints (using QwtPlotCurve::draw). 41 42 - PaintPacked\n 43 Suppress system background repaints and paint it together with 44 the canvas contents. 45 Painting packed might avoid flickering for expensive repaints, 46 when there is a notable gap between painting the background 47 and the plot contents. 48 49 The default setting enables PaintCached and PaintPacked 50 51 \sa setPaintAttribute(), testPaintAttribute(), paintCache() 52 */ 53 enum PaintAttribute 54 { 55 PaintCached = 1, 56 PaintPacked = 2 57 }; 58 59 /*! 60 \brief Focus indicator 61 62 - NoFocusIndicator\n 63 Don't paint a focus indicator 64 65 - CanvasFocusIndicator\n 66 The focus is related to the complete canvas. 67 Paint the focus indicator using paintFocus() 68 69 - ItemFocusIndicator\n 70 The focus is related to an item (curve, point, ...) on 71 the canvas. It is up to the application to display a 72 focus indication using f.e. highlighting. 73 74 \sa setFocusIndicator(), focusIndicator(), paintFocus() 75 */ 76 77 enum FocusIndicator 78 { 79 NoFocusIndicator, 80 CanvasFocusIndicator, 81 ItemFocusIndicator 82 }; 83 84 explicit QwtPlotCanvas(QwtPlot *); 85 virtual ~QwtPlotCanvas(); 86 87 QwtPlot *plot(); 88 const QwtPlot *plot() const; 89 90 void setFocusIndicator(FocusIndicator); 91 FocusIndicator focusIndicator() const; 92 93 void setPaintAttribute(PaintAttribute, bool on = true); 94 bool testPaintAttribute(PaintAttribute) const; 95 96 QPixmap *paintCache(); 97 const QPixmap *paintCache() const; 98 void invalidatePaintCache(); 99 100 void replot(); 101 102 protected: 103 virtual void hideEvent(QHideEvent *); 104 105 virtual void paintEvent(QPaintEvent *); 106 107 virtual void drawContents(QPainter *); 108 virtual void drawFocusIndicator(QPainter *); 109 110 void drawCanvas(QPainter *painter = NULL); 111 112 private: 113 void setSystemBackground(bool); 114 115 class PrivateData; 116 PrivateData *d_data; 117 }; 118 119 #endif 120