The textwidth value that was returned is not used anymore. Now in some
cases we can avoid to compute it at all.
virtual void image(int x, int y, int w, int h,
graphics::Image const & image) = 0;
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.
/** 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.
/** 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.
/** 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; }
void setDrawingEnabled(bool drawing_enabled)
{ drawing_enabled_ = drawing_enabled; }
double pixelRatio() const { return pixel_ratio_; }
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;
/// 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);
{
//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.
/* 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;
// 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_) {
textDecoration(f, x, y, textwidth);
if (use_pixmap_cache_) {
if (QPixmapCache::find(key, pm)) {
// Draw the cached pixmap.
drawPixmap(x + lb, y - mA, pm);
if (QPixmapCache::find(key, pm)) {
// Draw the cached pixmap.
drawPixmap(x + lb, y - mA, pm);
}
// Only the right bearing of the last character is
}
// Only the right bearing of the last character is
drawPixmap(x + lb, y - mA, pm);
//rectangle(x-lb, y-mA, w, h, Color_green);
}
drawPixmap(x + lb, y - mA, pm);
//rectangle(x-lb, y-mA, w, h, Color_green);
}
}
// don't use the pixmap cache,
do_drawText(x, y, str, rtl, f, ff);
//LYXERR(Debug::PAINTING, "draw " << string(str.toUtf8())
// << " at " << x << "," << y);
}
// don't use the pixmap cache,
do_drawText(x, y, str, rtl, f, ff);
//LYXERR(Debug::PAINTING, "draw " << string(str.toUtf8())
// << " at " << x << "," << y);
-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();
{
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);
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,
// 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);
setClipRegion(region - clip);
text(x, y, str, fi, rtl, wordspacing);
setClipping(false);
/** draw a string at position x, y (y is the baseline). The
* text direction is given by \c rtl.
/** 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.
/** 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.
/** 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)
/// 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);
///
virtual void textDecoration(FontInfo const & f, int x, int y, int width);