}
QLPainter::QLPainter(QWorkArea * qwa)
- : Painter(), paint_check_(0), qwa_(qwa)
+ : Painter(), qwa_(qwa)
{
}
-void QLPainter::start()
-{
-}
-
-
-void QLPainter::end()
-{
-// if (qp_->isActive())
-// qp_->end();
-}
-
int QLPainter::paperWidth() const
{
return qwa_->viewport()->height();
}
-/*
-QPainter & QLPainter::setPen(LColor_color c,
- Painter::line_style ls, Painter::line_width lw)
-{
- QPen pen = qp_->pen();
-
- pen.setColor(lcolorcache.get(c));
-
- switch (ls) {
- case line_solid: pen.setStyle(Qt::SolidLine); break;
- case line_onoffdash: pen.setStyle(Qt::DotLine); break;
- }
-
- switch (lw) {
- case line_thin: pen.setWidth(0); break;
- case line_thick: pen.setWidth(3); break;
- }
-
- qp_->setPen(pen);
-
- return *qp_;
-}
-*/
QPainter & QLPainter::setQPainterPen(QPainter & qp, LColor_color c,
Painter::line_style ls, Painter::line_width lw)
{
void QLPainter::point(int x, int y, LColor_color c)
{
- QPainter qp(qwa_->pixmap());
+ QPainter qp(qwa_->paintDevice());
setQPainterPen(qp, c).drawPoint(x, y);
}
line_style ls,
line_width lw)
{
- QPainter qp(qwa_->pixmap());
+ QPainter qp(qwa_->paintDevice());
setQPainterPen(qp, col, ls, lw).drawLine(x1, y1, x2, y2);
}
points[i].setY(yp[i]);
}
- QPainter qp(qwa_->pixmap());
+ QPainter qp(qwa_->paintDevice());
setQPainterPen(qp, col, ls, lw).drawPolyline(points.get(), np);
}
line_style ls,
line_width lw)
{
- QPainter qp(qwa_->pixmap());
+ QPainter qp(qwa_->paintDevice());
setQPainterPen(qp, col, ls, lw).drawRect(x, y, w, h);
}
void QLPainter::fillRectangle(int x, int y, int w, int h, LColor_color col)
{
-// lyxerr[Debug::GRAPHICS] << BOOST_CURRENT_FUNCTION
-// << "\nx=" << x << " y=" << y << " w=" << w << " h=" << h
-// << " LColor " << col << endl;
-
- QPainter qp(qwa_->pixmap());
+ QPainter qp(qwa_->paintDevice());
qp.fillRect(x, y, w, h, lcolorcache.get(col));
}
points[i].setY(yp[i]);
}
- QPainter qp(qwa_->pixmap());
+ QPainter qp(qwa_->paintDevice());
setQPainterPen(qp, col);
qp.setBrush(lcolorcache.get(col));
qp.drawPolygon(points.get(), np);
int a1, int a2, LColor_color col)
{
// LyX usings 1/64ths degree, Qt usings 1/16th
- QPainter qp(qwa_->pixmap());
+ QPainter qp(qwa_->paintDevice());
setQPainterPen(qp, col).drawArc(x, y, w, h, a1 / 4, a2 / 4);
}
fillRectangle(x, y, w, h, LColor::graphicsbg);
- QPainter qp(qwa_->pixmap());
+ QPainter qp(qwa_->paintDevice());
qp.drawImage(x, y, qlimage.qimage(), 0, 0, w, h);
}
QFontMetrics const & qfontm = QFontMetrics(qfont);
QFontMetrics const & qsmallfontm = QFontMetrics(qsmallfont);
- QPainter qp(qwa_->pixmap());
+ QPainter qp(qwa_->paintDevice());
int tmpx = x;
size_t ls = s.length();
for (size_t i = 0; i < ls; ++i) {
void QLPainter::text(int x, int y, char const * s, size_t ls,
LyXFont const & f)
{
- QPainter qp(qwa_->pixmap());
+ QPainter qp(qwa_->paintDevice());
setQPainterPen(qp, f.realColor());
Encoding const * encoding = f.language()->encoding();
}
/// draw a pixmap from the image cache
-void QLPainter::pixmap(int x, int y, QPixmap const & pixmap)
+void QLPainter::drawPixmap(int x, int y, QPixmap const & pixmap)
{
- QPainter qp(qwa_->pixmap());
+ QPainter qp(qwa_->paintDevice());
qp.drawPixmap(x, y, pixmap);
}
+\r
+void QLPainter::drawImage(int x, int y, QImage const & image)\r
+{\r
+ QPainter qp(qwa_->paintDevice());\r
+ qp.drawImage(x, y, image);\r
+}\r
class QPaintDevice;
class QPainter;
class QString;
-class QPixmap;
+class QPixmap;\r
+class QImage;\r
class QWorkArea;
/**
~QLPainter();
- /// begin painting
- virtual void start();
+ /// begin painting\r
+ /**\r
+ Not used in the the Qt4 frontend.\r
+ */
+ virtual void start() {}
/// end painting
- virtual void end();
+ /**\r
+ Not used in the the Qt4 frontend.\r
+ */\r
+ virtual void end() {}
/// return the width of the work area in pixels
virtual int paperWidth() const;
char c, LyXFont const & f);
/// draw a pixmap from the image cache
- virtual void pixmap(int x, int y, QPixmap const & pixmap);
+ virtual void drawPixmap(int x, int y, QPixmap const & pixmap);
+ /// draw a pixmap from the image cache\r
+ virtual void drawImage(int x, int y, QImage const & image);\r
+\r
private:
/// draw small caps text
void smallCapsText(int x, int y,
/// our qt painter
boost::scoped_ptr<QPainter> qp_;
- /// recursion check
- int paint_check_;
-
/// the working area
QWorkArea * qwa_;
};
verticalScrollBar()->setPageStep(viewport()->height());
- pixmap_.reset(new QPixmap(viewport()->width(), viewport()->height()));
+ screen_device_ = QPixmap(viewport()->width(), viewport()->height());
+ paint_device_ = QImage(viewport()->width(), viewport()->height(), QImage::Format_RGB32);\r
this->workAreaResize();
-
+\r
+ /*
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
<< "\n QWidget width\t" << this->QWidget::width()
<< "\n QWidget height\t" << this->QWidget::height()
<< "\n viewport height\t" << viewport()->height()
<< "\n QResizeEvent rect left\t" << rect().left()
<< "\n QResizeEvent rect right\t" << rect().right()
- << endl;
+ << endl;\r
+ */
}
+void QWorkArea::update(int x, int y, int w, int h)\r
+{\r
+ //screen_device_.fromImage(paint_device_);\r
+ QPainter q(&screen_device_);\r
+ q.drawImage(x, y, paint_device_.copy(x, y, w, h));\r
+ \r
+ viewport()->update(x, y, w, h);\r
+}\r
+\r
void QWorkArea::paintEvent(QPaintEvent * e)
-{
+{\r
+ /*
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
<< "\n QWidget width\t" << this->width()
<< "\n QWidget height\t" << this->height()
<< "\n QPaintEvent y\t" << e->rect().y()
<< "\n QPaintEvent w\t" << e->rect().width()
<< "\n QPaintEvent h\t" << e->rect().height()
- << endl;
-
+ << endl;\r
+ */
QPainter q(viewport());
- q.drawPixmap(e->rect(), *pixmap_.get(), e->rect());
+ q.drawPixmap(e->rect(), screen_device_, e->rect());
}
+\r
+QPixmap QWorkArea::copyScreen(int x, int y, int w, int h) const\r
+{\r
+ return screen_device_.copy(x, y, w, h);\r
+}\r
+\r
+void QWorkArea::drawScreen(int x, int y, QPixmap pixmap)\r
+{\r
+ QPainter q(&screen_device_);\r
+ q.drawPixmap(x, y, pixmap);\r
+ viewport()->update(x, y, pixmap.width(), pixmap.height());\r
+}\r
///////////////////////////////////////////////////////////////
#undef emit
#endif
-#include "funcrequest.h"
-#include "frontends/Timeout.h"
-
#include "WorkArea.h"
#include "QLPainter.h"
#include "LyXView.h"
+#include "funcrequest.h"\r
+#include "frontends/Timeout.h"\r
+\r
#include <QAbstractScrollArea>
#include <QMouseEvent>
#include <QWheelEvent>
#include <QKeyEvent>
#include <QPaintEvent>
#include <QTimer>
-
-#include <boost/scoped_ptr.hpp>
+#include <QImage>\r
+#include <QPixmap>\r
#include <queue>
/// return the widget's painter
virtual Painter & getPainter() { return (Painter &) painter_; }
- ///
- //virtual QPaintDevice & paintDevice() { return content_->pixmap(); }
-
/// return the backing pixmap
- QPixmap * pixmap() const { return pixmap_.get(); }
-
- /// return the widget's painter
- //virtual QLPainter & getQLPainter() const { return painter_; }
+ QPaintDevice * paintDevice() { return &paint_device_; }
+\r
+ /// update the passed area.
+ void update(int x, int y, int w, int h);\r
- /// get the content pane widget
- QWidget * getContent() const { return viewport(); }
+ /// return a screen copy of the defined area.\r
+ QPixmap copyScreen(int x, int y, int w, int h) const;
+ /// Draw a pixmap onto the backing pixmap.\r
+ /**\r
+ QPixmap is implicitely shared so no need to pass by reference.\r
+ */\r
+ void drawScreen(int x, int y, QPixmap pixmap);\r
+\r
protected:
/// repaint part of the widget
///\r
SyntheticMouseEvent synthetic_mouse_event_;
- /// the double buffered pixmap
- boost::scoped_ptr<QPixmap> pixmap_;
+ /// Our client side painting device.
+ QImage paint_device_;
+ /// Our server side painting device.\r
+ QPixmap screen_device_;\r
+\r
/// \todo remove\r
QTimer step_timer_;
\r
* Full author contact details are available in file CREDITS.
*/
-#include <config.h>
-
-#include "QWorkArea.h"
-#include "qscreen.h"
-//Added by qt3to4:
-#include <QPixmap>
-#include <QPainter>
-
-#include "debug.h"
-#include "lcolorcache.h"
+#include <config.h>\r
+#include "QWorkArea.h"\r
+#include "qscreen.h"\r
+\r
+#include <QColor>\r
+#include <QPainter>\r
#include <QApplication>
+#include "debug.h"\r
+#include "lcolorcache.h"\r
+\r
namespace {
QScreen::QScreen(QWorkArea & o)
- : LyXScreen(), owner_(o), nocursor_pixmap_(0,0)
+ : LyXScreen(), owner_(o), nocursor_(0,0)
{
}
void QScreen::expose(int x, int y, int w, int h)
{
- lyxerr[Debug::GUI] << "expose " << w << 'x' << h << '+' << x << '+' << y << std::endl;
+ lyxerr[Debug::GUI] << "expose " << w << 'x' << h\r
+ << '+' << x << '+' << y << std::endl;
- owner_.viewport()->update(x, y, w, h);
-// owner_.update();
+ owner_.update(x, y, w, h);
}
-
void QScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
{
if (!qApp->focusWidget())
if (x==cursor_x_ && y==cursor_y_ && h==cursor_h_) {
// Draw the new (vertical) cursor using the cached store.
- QLPainter * lp = (QLPainter *) &(owner_.getPainter());
- lp->pixmap(cursor_x_, cursor_y_, vcursor_pixmap_);
- owner_.viewport()->update(
- cursor_x_, cursor_y_,
- cursor_w_, cursor_h_);
+ owner_.drawScreen(cursor_x_, cursor_y_, vcursor_);
return;
}
// 1 the rectangle of the original screen.
// 2 the vertical line of the cursor.
// 3 the horizontal line of the L-shaped cursor (if necessary).
-
- // Initialise storage for these pixmaps as necessary.
- if (cursor_w_ != nocursor_pixmap_.width() ||
- cursor_h_ != nocursor_pixmap_.height()) {
- nocursor_pixmap_.resize(cursor_w_, cursor_h_);
- }
-
+\r
QColor const & required_color = lcolorcache.get(LColor::cursor);
bool const cursor_color_changed = required_color != cursor_color_;
if (cursor_color_changed)
- cursor_color_ = required_color;
-
-// if (cursor_h_ != vcursor_pixmap_.height() || cursor_color_changed) {
-// if (cursor_h_ != vcursor_pixmap_.height())
- vcursor_pixmap_.resize(cursor_w_, cursor_h_);
- vcursor_pixmap_.fill(cursor_color_);
-// }
+ cursor_color_ = required_color;\r
+\r
+ vcursor_ = QPixmap(cursor_w_, cursor_h_);\r
+ vcursor_ .fill(cursor_color_);\r
switch (shape) {
case BAR_SHAPE:
break;
case REVERSED_L_SHAPE:
case L_SHAPE:
- if (cursor_w_ != hcursor_pixmap_.width() ||
+ if (cursor_w_ != hcursor_.width() ||
cursor_color_changed) {
- if (cursor_w_ != hcursor_pixmap_.width())
- hcursor_pixmap_.resize(cursor_w_, 1);
- hcursor_pixmap_.fill(cursor_color_);
+ if (cursor_w_ != hcursor_.width())
+ hcursor_ = QPixmap(cursor_w_, 1);\r
+ hcursor_.fill(cursor_color_);\r
}
break;
}
- // Save the old area (no cursor).
- QPainter qp(&nocursor_pixmap_);
- qp.drawPixmap(0, 0, *owner_.pixmap(),
- cursor_x_, cursor_y_, cursor_w_, cursor_h_);
+ // Save the old area (no cursor).\r
+ nocursor_ = owner_.copyScreen(cursor_x_, cursor_y_, cursor_w_, cursor_h_);\r
// Draw the new (vertical) cursor using the cached store.
- QLPainter * lp = (QLPainter *) &(owner_.getPainter());
- lp->pixmap(cursor_x_, cursor_y_, vcursor_pixmap_);
+ owner_.drawScreen(cursor_x_, cursor_y_, vcursor_);
// Draw the new (horizontal) cursor if necessary.
switch (shape) {
break;
case REVERSED_L_SHAPE:
case L_SHAPE:
- lp->pixmap(cursor_x_, y + h - 1, hcursor_pixmap_);
+ owner_.drawScreen(cursor_x_, y + h - 1, hcursor_);
break;
}
-
- owner_.viewport()->update(
- cursor_x_, cursor_y_,
- cursor_w_, cursor_h_);
}
void QScreen::removeCursor()
{
// before first showCursor
- if (nocursor_pixmap_.isNull())
+ if (nocursor_.isNull())
return;
- QLPainter * lp = (QLPainter *) &(owner_.getPainter());
- lp->pixmap(cursor_x_, cursor_y_, nocursor_pixmap_);
-
- owner_.viewport()->update(
- cursor_x_, cursor_y_,
- cursor_w_, cursor_h_);
+ owner_.drawScreen(cursor_x_, cursor_y_, nocursor_);
}
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author John Levon
+ * \author John Levon\r
*
* Full author contact details are available in file CREDITS.
*/
#ifndef QSCREEN_H
#define QSCREEN_H
-#include "screen.h"
-#include <qcolor.h>
+\r
+#include "screen.h"\r
-#include <QPixmap>
+#include <QPixmap>\r
+\r
+class QColor;\r
class QWorkArea;
class WorkArea;
/// our owning widget
QWorkArea & owner_;
-// QRegion nocursor_region_;
-// QRegion hcursor_region_;
-// QRegion vcursor_region_;
-
- QPixmap nocursor_pixmap_;
- QPixmap hcursor_pixmap_;
- QPixmap vcursor_pixmap_;
+ QPixmap nocursor_;
+ QPixmap hcursor_;
+ QPixmap vcursor_;
//@{ the cursor pixmap position/size
int cursor_x_;