#include "GuiApplication.h"
#include "GuiFontMetrics.h"
-#include "GuiWorkArea.h"
#include "QLImage.h"
#include "GuiApplication.h"
#include "language.h"
#include "LColor.h"
-
#include "support/unicode.h"
-#include <QPainter>
-#include <QPicture>
-#include <QPixmap>
-#include <QImage>
-
-
using std::endl;
using std::string;
namespace lyx {
namespace frontend {
-QLPainter::QLPainter(QWidget * qwa)
- : qwa_(qwa)
+QLPainter::QLPainter(QPaintDevice * device)
+ : QPainter(device), Painter()
{
- //lyxerr << "QLPainter::start()" << endl;
- QPainter::begin(qwa_);
- setRenderHint(QPainter::TextAntialiasing);
// new QPainter has default QPen:
current_color_ = LColor::black;
current_ls_ = line_solid;
}
-int QLPainter::paperWidth() const
-{
- return qwa_->width();
-}
-
-
-int QLPainter::paperHeight() const
-{
- return qwa_->height();
-}
-
-
void QLPainter::setQPainterPen(LColor_color col,
Painter::line_style ls, Painter::line_width lw)
{
void QLPainter::point(int x, int y, LColor_color col)
{
+ if (!isDrawingEnabled())
+ return;
+
setQPainterPen(col);
drawPoint(x, y);
}
line_style ls,
line_width lw)
{
+ if (!isDrawingEnabled())
+ return;
+
setQPainterPen(col, ls, lw);
drawLine(x1, y1, x2, y2);
}
points[i].setY(yp[i]);
}
+ if (!isDrawingEnabled())
+ return;
+
setQPainterPen(col, ls, lw);
drawPolyline(points.get(), np);
}
line_style ls,
line_width lw)
{
+ if (!isDrawingEnabled())
+ return;
+
setQPainterPen(col, ls, lw);
drawRect(x, y, w, h);
}
void QLPainter::arc(int x, int y, unsigned int w, unsigned int h,
int a1, int a2, LColor_color col)
{
+ if (!isDrawingEnabled())
+ return;
+
// LyX usings 1/64ths degree, Qt usings 1/16th
setQPainterPen(col);
drawArc(x, y, w, h, a1 / 4, a2 / 4);
fillRectangle(x, y, w, h, LColor::graphicsbg);
+ if (!isDrawingEnabled())
+ return;
+
drawImage(x, y, qlimage.qimage(), 0, 0, w, h);
}
} else {
setFont(qfont);
}
- drawText(x + textwidth, y, c);
+ if (isDrawingEnabled())
+ drawText(x + textwidth, y, c);
textwidth += fontMetrics().width(c);
}
return textwidth;
int QLPainter::text(int x, int y, char_type const * s, size_t ls,
LyXFont const & f)
{
-#if 0
- Encoding const * encoding = f.language()->encoding();
- if (f.isSymbolFont())
- encoding = encodings.symbol_encoding();
-#endif
-
QString str;
ucs4_to_qstring(s, ls, str);
setFont(fi.font);
// We need to draw the text as LTR as we use our own bidi code.
setLayoutDirection(Qt::LeftToRight);
- drawText(x, y, str);
+ if (isDrawingEnabled()) {
+ lyxerr[Debug::PAINTING] << "draw " << std::string(str.toUtf8())
+ << " at " << x << "," << y << std::endl;
+ drawText(x, y, str);
+ }
// Here we use the font width cache instead of
// textwidth = fontMetrics().width(str);
// because the above is awfully expensive on MacOSX