Paint buffer for Qwt widgets. More...
#include <qwt_paint_buffer.h>
Public Member Functions | |
| QwtPaintBuffer () | |
| Default constructor. | |
| QwtPaintBuffer (QPaintDevice *, const QRect &, QPainter *p=NULL) | |
| virtual | ~QwtPaintBuffer () |
| void | open (QPaintDevice *, const QRect &, QPainter *p=NULL) |
| void | close () |
| QPainter * | painter () |
| const QPaintDevice * | device () |
| const QPixmap & | buffer () const |
| Return Buffer used for double buffering. | |
Static Public Member Functions | |
| static void | setEnabled (bool enable) |
| static bool | isEnabled () |
Protected Member Functions | |
| void | flush () |
Paint buffer for Qwt widgets.
QwtPaintBuffer offers a simple way to en/disable double buffering. Double buffering is enabled as default and in general there will be no reason to change this.
Definition at line 29 of file qwt_paint_buffer.h.
| QwtPaintBuffer::QwtPaintBuffer | ( | ) | [explicit] |
Default constructor.
Definition at line 21 of file qwt_paint_buffer.cpp.
:
d_device(0),
d_painter(0),
d_devicePainter(0)
{
}
| QwtPaintBuffer::QwtPaintBuffer | ( | QPaintDevice * | device, |
| const QRect & | rect, | ||
| QPainter * | painter = NULL |
||
| ) | [explicit] |
Create an open paint buffer
| device | Device to paint on |
| rect | Rect to paint on |
| painter | Painter to paint on device. In case of 0 QwtPaintBuffer uses an internal painter |
Definition at line 38 of file qwt_paint_buffer.cpp.
References open().
| QwtPaintBuffer::~QwtPaintBuffer | ( | ) | [virtual] |
Closes the buffer
Definition at line 51 of file qwt_paint_buffer.cpp.
References close().
{
close();
}
| const QPixmap& QwtPaintBuffer::buffer | ( | ) | const [inline] |
Return Buffer used for double buffering.
Definition at line 47 of file qwt_paint_buffer.h.
{ return d_pixBuffer; }
| void QwtPaintBuffer::close | ( | ) |
Flush the internal pixmap buffer to the device and close the buffer.
Definition at line 180 of file qwt_paint_buffer.cpp.
References flush().
Referenced by open(), and ~QwtPaintBuffer().
{
flush();
if ( d_painter )
{
if ( d_painter->isActive() )
d_painter->end();
if ( d_painter != d_devicePainter )
delete d_painter;
}
if ( !d_pixBuffer.isNull() )
d_pixBuffer = QPixmap();
d_device = 0;
d_painter = 0;
d_devicePainter = 0;
}
| const QPaintDevice * QwtPaintBuffer::device | ( | ) |
Definition at line 70 of file qwt_paint_buffer.cpp.
Referenced by flush(), and open().
{
return d_device;
}
| void QwtPaintBuffer::flush | ( | ) | [protected] |
Flush the internal pixmap buffer to the device.
Definition at line 153 of file qwt_paint_buffer.cpp.
References device().
Referenced by close().
{
if ( d_enabled && d_device != 0 && d_rect.isValid())
{
// We need a painter to find out if
// there is a painter redirection for d_device.
QPainter *p;
if ( d_devicePainter == 0 )
p = new QPainter(d_device);
else
p = d_devicePainter;
QPaintDevice *device = p->device();
if ( device->isExtDev() )
d_devicePainter->drawPixmap(d_rect.topLeft(), d_pixBuffer);
else
bitBlt(device, d_rect.topLeft(), &d_pixBuffer );
if ( d_devicePainter == 0 )
delete p;
}
}
| bool QwtPaintBuffer::isEnabled | ( | ) | [static] |
Definition at line 88 of file qwt_paint_buffer.cpp.
Referenced by open().
{
return d_enabled;
}
| void QwtPaintBuffer::open | ( | QPaintDevice * | device, |
| const QRect & | rect, | ||
| QPainter * | painter = NULL |
||
| ) |
Open the buffer
| device | Device to paint on |
| rect | Rect to paint on |
| painter | Painter to paint on device. In case of 0 QwtPaintBuffer uses an internal painter |
Definition at line 101 of file qwt_paint_buffer.cpp.
References close(), device(), isEnabled(), and painter().
Referenced by QwtPaintBuffer().
{
close();
if ( device == 0 || !rect.isValid() )
return;
d_device = device;
d_devicePainter = painter;
d_rect = rect;
if ( isEnabled() )
{
#ifdef Q_WS_X11
if ( d_pixBuffer.x11Screen() != d_device->x11Screen() )
d_pixBuffer.x11SetScreen(d_device->x11Screen());
#endif
d_pixBuffer.resize(d_rect.size());
d_painter = new QPainter();
if ( d_device->devType() == QInternal::Widget )
{
QWidget *w = (QWidget *)d_device;
d_pixBuffer.fill(w, d_rect.topLeft());
d_painter->begin(&d_pixBuffer, w);
d_painter->translate(-d_rect.x(), -d_rect.y());
}
else
{
d_painter->begin(&d_pixBuffer);
}
}
else
{
if ( d_devicePainter )
d_painter = d_devicePainter;
else
d_painter = new QPainter(d_device);
if ( d_device->devType() == QInternal::Widget )
{
QWidget *w = (QWidget *)d_device;
if ( w->testWFlags( Qt::WNoAutoErase ) )
d_painter->eraseRect(d_rect);
}
}
}
| QPainter * QwtPaintBuffer::painter | ( | ) |
Definition at line 62 of file qwt_paint_buffer.cpp.
Referenced by open(), QwtWheel::paintEvent(), QwtThermo::paintEvent(), QwtSlider::paintEvent(), QwtScaleWidget::paintEvent(), QwtKnob::paintEvent(), and QwtDial::paintEvent().
{
return d_painter;
}
| void QwtPaintBuffer::setEnabled | ( | bool | enable ) | [static] |
Enable/Disable double buffering. Please note that this is a global switch for all QwtPaintBuffers, but won't change opened buffers.
Definition at line 80 of file qwt_paint_buffer.cpp.
{
d_enabled = enable;
}
1.7.2