X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiPainter.cpp;h=a3c2b6ccacba1438286b9f6e78c89a2ea834b031;hb=eea79637c78bb9916031924eca7b305cfb8e83df;hp=a3bc70cf7186281b18c5d08f3339eb709ba032a6;hpb=a1cec91afaca91968b46e695533c10ad2a3f73d3;p=lyx.git diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp index a3bc70cf71..a3c2b6ccac 100644 --- a/src/frontends/qt4/GuiPainter.cpp +++ b/src/frontends/qt4/GuiPainter.cpp @@ -22,7 +22,6 @@ #include "debug.h" #include "Language.h" -#include "Color.h" #include "support/unicode.h" @@ -60,24 +59,24 @@ QString generateStringSignature(QString const & str, Font const & f) } // anon namespace -QLPainter::QLPainter(QPaintDevice * device) +GuiPainter::GuiPainter(QPaintDevice * device) : QPainter(device), Painter() { // new QPainter has default QPen: - current_color_ = Color::black; + current_color_ = Color_black; current_ls_ = line_solid; current_lw_ = line_thin; } -QLPainter::~QLPainter() +GuiPainter::~GuiPainter() { QPainter::end(); - //lyxerr << "QLPainter::end()" << endl; + //lyxerr << "GuiPainter::end()" << endl; } -void QLPainter::setQPainterPen(Color_color col, +void GuiPainter::setQPainterPen(ColorCode col, Painter::line_style ls, Painter::line_width lw) { if (col == current_color_ && ls == current_ls_ && lw == current_lw_) @@ -105,7 +104,7 @@ void QLPainter::setQPainterPen(Color_color col, } -void QLPainter::point(int x, int y, Color_color col) +void GuiPainter::point(int x, int y, ColorCode col) { if (!isDrawingEnabled()) return; @@ -115,8 +114,8 @@ void QLPainter::point(int x, int y, Color_color col) } -void QLPainter::line(int x1, int y1, int x2, int y2, - Color_color col, +void GuiPainter::line(int x1, int y1, int x2, int y2, + ColorCode col, line_style ls, line_width lw) { @@ -132,8 +131,8 @@ void QLPainter::line(int x1, int y1, int x2, int y2, } -void QLPainter::lines(int const * xp, int const * yp, int np, - Color_color col, +void GuiPainter::lines(int const * xp, int const * yp, int np, + ColorCode col, line_style ls, line_width lw) { @@ -160,8 +159,8 @@ void QLPainter::lines(int const * xp, int const * yp, int np, } -void QLPainter::rectangle(int x, int y, int w, int h, - Color_color col, +void GuiPainter::rectangle(int x, int y, int w, int h, + ColorCode col, line_style ls, line_width lw) { @@ -173,14 +172,14 @@ void QLPainter::rectangle(int x, int y, int w, int h, } -void QLPainter::fillRectangle(int x, int y, int w, int h, Color_color col) +void GuiPainter::fillRectangle(int x, int y, int w, int h, ColorCode col) { fillRect(x, y, w, h, guiApp->colorCache().get(col)); } -void QLPainter::arc(int x, int y, unsigned int w, unsigned int h, - int a1, int a2, Color_color col) +void GuiPainter::arc(int x, int y, unsigned int w, unsigned int h, + int a1, int a2, ColorCode col) { if (!isDrawingEnabled()) return; @@ -194,12 +193,12 @@ void QLPainter::arc(int x, int y, unsigned int w, unsigned int h, } -void QLPainter::image(int x, int y, int w, int h, graphics::Image const & i) +void GuiPainter::image(int x, int y, int w, int h, graphics::Image const & i) { - graphics::QLImage const & qlimage = - static_cast(i); + graphics::GuiImage const & qlimage = + static_cast(i); - fillRectangle(x, y, w, h, Color::graphicsbg); + fillRectangle(x, y, w, h, Color_graphicsbg); if (!isDrawingEnabled()) return; @@ -208,14 +207,14 @@ void QLPainter::image(int x, int y, int w, int h, graphics::Image const & i) } -int QLPainter::text(int x, int y, char_type c, Font const & f) +int GuiPainter::text(int x, int y, char_type c, Font const & f) { docstring s(1, c); return text(x, y, s, f); } -int QLPainter::smallCapsText(int x, int y, +int GuiPainter::smallCapsText(int x, int y, QString const & s, Font const & f) { Font smallfont(f); @@ -242,9 +241,12 @@ int QLPainter::smallCapsText(int x, int y, } -int QLPainter::text(int x, int y, docstring const & s, +int GuiPainter::text(int x, int y, docstring const & s, Font const & f) { + if (s.empty()) + return 0; + /* Caution: The following ucs4 to QString conversions work for symbol fonts only because they are no real conversions but simple casts in reality. When we want to draw a symbol or calculate the metrics we pass the position @@ -265,7 +267,7 @@ int QLPainter::text(int x, int y, docstring const & s, str = ' ' + str; #endif - QLFontInfo & fi = guiApp->guiFontLoader().fontinfo(f); + GuiFontInfo & fi = guiApp->guiFontLoader().fontinfo(f); int textwidth; @@ -314,8 +316,8 @@ int QLPainter::text(int x, int y, docstring const & s, // We need to draw the text as LTR as we use our own bidi code. setLayoutDirection(Qt::LeftToRight); drawText(x, y, str); - LYXERR(Debug::PAINTING) << "draw " << std::string(str.toUtf8()) - << " at " << x << "," << y << std::endl; + //LYXERR(Debug::PAINTING) << "draw " << std::string(str.toUtf8()) + // << " at " << x << "," << y << std::endl; return textwidth; } @@ -339,7 +341,7 @@ int QLPainter::text(int x, int y, docstring const & s, int const h = mA + mD; pm = QPixmap(w, h); pm.fill(Qt::transparent); - QLPainter p(&pm); + GuiPainter p(&pm); p.setQPainterPen(f.realColor()); if (p.font() != fi.font) p.setFont(fi.font); @@ -347,9 +349,9 @@ int QLPainter::text(int x, int y, docstring const & s, p.setLayoutDirection(Qt::LeftToRight); p.drawText(-lb, mA, str); QPixmapCache::insert(key, pm); - LYXERR(Debug::PAINTING) << "h=" << h << " mA=" << mA << " mD=" << mD - << " w=" << w << " lb=" << lb << " tw=" << textwidth - << " rb=" << rb << endl; + //LYXERR(Debug::PAINTING) << "h=" << h << " mA=" << mA << " mD=" << mD + // << " w=" << w << " lb=" << lb << " tw=" << textwidth + // << " rb=" << rb << endl; } // Draw the cached pixmap. drawPixmap(x + lb, y - mA, pm);