virtual void image(int x, int y, int w, int h,
graphics::Image const & image) = 0;
+ /** draw a character at position x, y (y is the baseline)
+ */
+ virtual void text(int x, int y, char_type c, FontInfo const & f) = 0;
+
/** draw a string at position x, y (y is the baseline). The
* text direction is given by \c rtl.
- * \return the width of the drawn text.
*/
- virtual int text(int x, int y, docstring const & str, FontInfo const & f,
- bool rtl = false, double wordspacing = 0.0) = 0;
+ virtual void text(int x, int y, docstring const & str, FontInfo const & f,
+ bool rtl = false, double wordspacing = 0.0) = 0;
/** draw a string at position x, y (y is the baseline). The
* text direction is enforced by the \c Font.
- * \return the width of the drawn text.
*/
- virtual int text(int x, int y, docstring const & str, Font const & f,
- double wordspacing = 0.0) = 0;
+ virtual void text(int x, int y, docstring const & str, Font const & f,
+ double wordspacing = 0.0) = 0;
/** draw a string at position x, y (y is the baseline), but
* make sure that the part between \c from and \c to is in
* \c other color. The text direction is enforced by the \c Font.
- * \return the width of the drawn text.
*/
- virtual int text(int x, int y, docstring const & str, Font const & f,
- Color other, size_type from, size_type to,
- double const wordspacing) = 0;
+ virtual void text(int x, int y, docstring const & str, Font const & f,
+ Color other, size_type from, size_type to,
+ double const wordspacing) = 0;
void setDrawingEnabled(bool drawing_enabled)
{ drawing_enabled_ = drawing_enabled; }
double pixelRatio() const { return pixel_ratio_; }
- /// draw a char at position x, y (y is the baseline)
- /**
- * \return the width of the drawn text.
- */
- virtual int text(int x, int y, char_type c, FontInfo const & f) = 0;
-
/// draw the underbar, strikeout, uuline and uwave font attributes
virtual void textDecoration(FontInfo const & f, int x, int y, int width) = 0;
}
-int GuiPainter::text(int x, int y, char_type c, FontInfo const & f)
+void GuiPainter::text(int x, int y, char_type c, FontInfo const & f)
{
- return text(x, y, docstring(1, c), f);
+ text(x, y, docstring(1, c), f);
}
}
-int GuiPainter::text(int x, int y, docstring const & s,
- FontInfo const & f, bool const rtl,
- double const wordspacing)
+void GuiPainter::text(int x, int y, docstring const & s,
+ FontInfo const & f, bool const rtl,
+ double const wordspacing)
{
//LYXERR0("text: x=" << x << ", s=" << s);
- if (s.empty())
- return 0;
+ if (s.empty() || !isDrawingEnabled())
+ return;
/* Caution: The following ucs4 to QString conversions work for symbol fonts
only because they are no real conversions but simple casts in reality.
// Note that we have to take in account space stretching (word spacing)
int const textwidth = fm.width(s) + count(s.begin(), s.end(), ' ') * wordspacing;
- if (!isDrawingEnabled())
- return textwidth;
-
textDecoration(f, x, y, textwidth);
if (use_pixmap_cache_) {
if (QPixmapCache::find(key, pm)) {
// Draw the cached pixmap.
drawPixmap(x + lb, y - mA, pm);
- return textwidth;
+ return;
}
// Only the right bearing of the last character is
drawPixmap(x + lb, y - mA, pm);
//rectangle(x-lb, y-mA, w, h, Color_green);
}
- return textwidth;
+ return;
}
// don't use the pixmap cache,
do_drawText(x, y, str, rtl, f, ff);
//LYXERR(Debug::PAINTING, "draw " << string(str.toUtf8())
// << " at " << x << "," << y);
- return textwidth;
}
-int GuiPainter::text(int x, int y, docstring const & str, Font const & f,
- double const wordspacing)
+void GuiPainter::text(int x, int y, docstring const & str, Font const & f,
+ double const wordspacing)
{
- return text(x, y, str, f.fontInfo(), f.isVisibleRightToLeft(), wordspacing);
+ text(x, y, str, f.fontInfo(), f.isVisibleRightToLeft(), wordspacing);
}
-int GuiPainter::text(int x, int y, docstring const & str, Font const & f,
- Color other, size_type const from, size_type const to,
- double const wordspacing)
+void GuiPainter::text(int x, int y, docstring const & str, Font const & f,
+ Color other, size_type const from, size_type const to,
+ double const wordspacing)
{
GuiFontMetrics const & fm = getFontMetrics(f.fontInfo());
FontInfo fi = f.fontInfo();
fi.setPaintColor(other);
QRegion const clip(x + xmin, y - ascent, xmax - xmin, height);
setClipRegion(clip);
- int const textwidth = text(x, y, str, fi, rtl, wordspacing);
+ text(x, y, str, fi, rtl, wordspacing);
// Then the part in normal color
// Note that in Qt5, it is not possible to use Qt::UniteClip,
setClipRegion(region - clip);
text(x, y, str, fi, rtl, wordspacing);
setClipping(false);
-
- return textwidth;
}
/** draw a string at position x, y (y is the baseline). The
* text direction is given by \c rtl.
- * \return the width of the drawn text.
*/
- virtual int text(int x, int y, docstring const & str, FontInfo const & f,
- bool rtl = false, double wordspacing = 0.0);
+ virtual void text(int x, int y, docstring const & str, FontInfo const & f,
+ bool rtl = false, double wordspacing = 0.0);
/** draw a string at position x, y (y is the baseline). The
* text direction is enforced by the \c Font.
- * \return the width of the drawn text.
*/
- virtual int text(int x, int y, docstring const & str, Font const & f,
- double wordspacing = 0.0);
+ virtual void text(int x, int y, docstring const & str, Font const & f,
+ double wordspacing = 0.0);
/** draw a string at position x, y (y is the baseline), but
* make sure that the part between \c from and \c to is in
* \c other color. The text direction is enforced by the \c Font.
- * \return the width of the drawn text.
*/
- virtual int text(int x, int y, docstring const & str, Font const & f,
- Color other, size_type from, size_type to,
- double const wordspacing);
+ virtual void text(int x, int y, docstring const & str, Font const & f,
+ Color other, size_type from, size_type to,
+ double const wordspacing);
/// draw a char at position x, y (y is the baseline)
- virtual int text(int x, int y, char_type c, FontInfo const & f);
+ virtual void text(int x, int y, char_type c, FontInfo const & f);
///
virtual void textDecoration(FontInfo const & f, int x, int y, int width);