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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Qwt User's Guide: qwt_paint_buffer.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.8 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div>
<h1>qwt_paint_buffer.cpp</h1><pre class="fragment"><div>00001 <span class="comment">/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************</span>
00002 <span class="comment"> * Qwt Widget Library</span>
00003 <span class="comment"> * Copyright (C) 1997 Josef Wilgen</span>
00004 <span class="comment"> * Copyright (C) 2002 Uwe Rathmann</span>
00005 <span class="comment"> *</span>
00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span>
00008 <span class="comment"> *****************************************************************************/</span>
00009
00010 <span class="preprocessor">#include <qwidget.h></span>
00011 <span class="preprocessor">#include <qpainter.h></span>
00012 <span class="preprocessor">#include "qwt_paint_buffer.h"</span>
00013
00014 <span class="keywordtype">bool</span> QwtPaintBuffer::d_enabled = TRUE;
00015
<a name="l00017"></a><a class="code" href="class_qwt_paint_buffer.html#a0">00017</a> <a class="code" href="class_qwt_paint_buffer.html#a0">QwtPaintBuffer::QwtPaintBuffer</a>():
00018 d_device(0),
00019 d_painter(0),
00020 d_devicePainter(0)
00021 {
00022 }
00023
<a name="l00034"></a><a class="code" href="class_qwt_paint_buffer.html#a1">00034</a> <a class="code" href="class_qwt_paint_buffer.html#a0">QwtPaintBuffer::QwtPaintBuffer</a>(QPaintDevice *device,
00035 <span class="keyword">const</span> QRect &rect, QPainter *painter):
00036 d_device(0),
00037 d_painter(0),
00038 d_devicePainter(0)
00039 {
00040 <a class="code" href="class_qwt_paint_buffer.html#a3">open</a>(device, rect, painter);
00041 }
00042
<a name="l00047"></a><a class="code" href="class_qwt_paint_buffer.html#a2">00047</a> <a class="code" href="class_qwt_paint_buffer.html#a2">QwtPaintBuffer::~QwtPaintBuffer</a>()
00048 {
00049 <a class="code" href="class_qwt_paint_buffer.html#a4">close</a>();
00050 }
00051
<a name="l00058"></a><a class="code" href="class_qwt_paint_buffer.html#a5">00058</a> QPainter *<a class="code" href="class_qwt_paint_buffer.html#a5">QwtPaintBuffer::painter</a>()
00059 {
00060 <span class="keywordflow">return</span> d_painter;
00061 }
00062
<a name="l00066"></a><a class="code" href="class_qwt_paint_buffer.html#a6">00066</a> <span class="keyword">const</span> QPaintDevice *<a class="code" href="class_qwt_paint_buffer.html#a6">QwtPaintBuffer::device</a>()
00067 {
00068 <span class="keywordflow">return</span> d_device;
00069 }
00070
<a name="l00076"></a><a class="code" href="class_qwt_paint_buffer.html#e0">00076</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_paint_buffer.html#e0">QwtPaintBuffer::setEnabled</a>(<span class="keywordtype">bool</span> enable)
00077 {
00078 d_enabled = enable;
00079 }
00080
<a name="l00084"></a><a class="code" href="class_qwt_paint_buffer.html#e1">00084</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_paint_buffer.html#e1">QwtPaintBuffer::isEnabled</a>()
00085 {
00086 <span class="keywordflow">return</span> d_enabled;
00087 }
00088
<a name="l00097"></a><a class="code" href="class_qwt_paint_buffer.html#a3">00097</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_paint_buffer.html#a3">QwtPaintBuffer::open</a>(QPaintDevice *device,
00098 <span class="keyword">const</span> QRect &rect, QPainter *painter)
00099 {
00100 <a class="code" href="class_qwt_paint_buffer.html#a4">close</a>();
00101
00102 <span class="keywordflow">if</span> ( device == 0 || !rect.isValid() )
00103 <span class="keywordflow">return</span>;
00104
00105 d_device = device;
00106 d_devicePainter = painter;
00107 d_rect = rect;
00108
00109 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_paint_buffer.html#e1">isEnabled</a>() )
00110 {
00111 <span class="preprocessor">#if QT_VERSION >= 300</span>
00112 <span class="preprocessor"></span><span class="preprocessor">#ifdef Q_WS_X11</span>
00113 <span class="preprocessor"></span> <span class="keywordflow">if</span> ( d_pixBuffer.x11Screen() != d_device->x11Screen() )
00114 d_pixBuffer.x11SetScreen(d_device->x11Screen());
00115 <span class="preprocessor">#endif</span>
00116 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
00117 <span class="preprocessor"></span> d_pixBuffer.resize(d_rect.size());
00118
00119 d_painter = <span class="keyword">new</span> QPainter();
00120 <span class="keywordflow">if</span> ( d_device->devType() == QInternal::Widget )
00121 {
00122 QWidget *w = (QWidget *)d_device;
00123 d_pixBuffer.fill(w, d_rect.topLeft());
00124 d_painter->begin(&d_pixBuffer, w);
00125 d_painter->translate(-d_rect.x(), -d_rect.y());
00126 }
00127 <span class="keywordflow">else</span>
00128 {
00129 d_painter->begin(&d_pixBuffer);
00130 }
00131 }
00132 <span class="keywordflow">else</span>
00133 {
00134 <span class="keywordflow">if</span> ( d_devicePainter )
00135 d_painter = d_devicePainter;
00136 <span class="keywordflow">else</span>
00137 d_painter = <span class="keyword">new</span> QPainter(d_device);
00138
00139 <span class="keywordflow">if</span> ( d_device->devType() == QInternal::Widget )
00140 {
00141 QWidget *w = (QWidget *)d_device;
00142 <span class="keywordflow">if</span> ( w->testWFlags( Qt::WRepaintNoErase | Qt::WResizeNoErase) )
00143 d_painter->eraseRect(d_rect);
00144 }
00145 }
00146 }
00147
<a name="l00151"></a><a class="code" href="class_qwt_paint_buffer.html#b0">00151</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_paint_buffer.html#b0">QwtPaintBuffer::flush</a>()
00152 {
00153 <span class="keywordflow">if</span> ( d_enabled && d_device != 0 && d_rect.isValid())
00154 {
00155 <span class="comment">// We need a painter to find out if</span>
00156 <span class="comment">// there is a painter redirection for d_device.</span>
00157
00158 QPainter *p;
00159 <span class="keywordflow">if</span> ( d_devicePainter == 0 )
00160 p = <span class="keyword">new</span> QPainter(d_device);
00161 <span class="keywordflow">else</span>
00162 p = d_devicePainter;
00163
00164 QPaintDevice *<a class="code" href="class_qwt_paint_buffer.html#a6">device</a> = p->device();
00165 <span class="keywordflow">if</span> ( device->isExtDev() )
00166 d_devicePainter->drawPixmap(d_rect.topLeft(), d_pixBuffer);
00167 <span class="keywordflow">else</span>
00168 bitBlt(device, d_rect.topLeft(), &d_pixBuffer );
00169
00170 <span class="keywordflow">if</span> ( d_devicePainter == 0 )
00171 <span class="keyword">delete</span> p;
00172 }
00173 }
00174
<a name="l00178"></a><a class="code" href="class_qwt_paint_buffer.html#a4">00178</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_paint_buffer.html#a4">QwtPaintBuffer::close</a>()
00179 {
00180 <a class="code" href="class_qwt_paint_buffer.html#b0">flush</a>();
00181
00182 <span class="keywordflow">if</span> ( d_painter )
00183 {
00184 <span class="keywordflow">if</span> ( d_painter->isActive() )
00185 d_painter->end();
00186
00187 <span class="keywordflow">if</span> ( d_painter != d_devicePainter )
00188 <span class="keyword">delete</span> d_painter;
00189 }
00190
00191 <span class="keywordflow">if</span> ( !d_pixBuffer.isNull() )
00192 d_pixBuffer = QPixmap();
00193
00194 d_device = 0;
00195 d_painter = 0;
00196 d_devicePainter = 0;
00197 }
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Tue Nov 16 21:12:20 2004 for Qwt User's Guide by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address>
</body>
</html>
|