#include "GuiPainter.h"
+#include "ColorCache.h"
#include "GuiApplication.h"
+#include "GuiFontLoader.h"
#include "GuiFontMetrics.h"
#include "GuiImage.h"
-
-#include "GuiApplication.h"
#include "qt_helpers.h"
-#include "support/debug.h"
+#include "FontInfo.h"
#include "Language.h"
#include "LyXRC.h"
+#include "insets/Inset.h"
+
+#include "support/lassert.h"
+#include "support/debug.h"
+
#include <QPixmapCache>
#include <QTextLayout>
void GuiPainter::leaveMonochromeMode()
{
- BOOST_ASSERT(!monochrome_min_.empty());
+ LASSERT(!monochrome_min_.empty(), /**/);
monochrome_min_.pop();
monochrome_max_.pop();
}
FontInfo smallfont(f);
smallfont.decSize().decSize().setShape(UP_SHAPE);
- QFont const & qfont = guiApp->guiFontLoader().get(f);
- QFont const & qsmallfont = guiApp->guiFontLoader().get(smallfont);
+ QFont const & qfont = getFont(f);
+ QFont const & qsmallfont = getFont(smallfont);
setQPainterPen(computeColor(f.realColor()));
int textwidth = 0;
str = ' ' + str;
#endif
- GuiFontInfo & fi = guiApp->guiFontLoader().fontinfo(f);
+ QFont const & ff = getFont(f);
+ GuiFontMetrics const & fm = getFontMetrics(f);
int textwidth;
// Here we use the font width cache instead of
// textwidth = fontMetrics().width(str);
// because the above is awfully expensive on MacOSX
- textwidth = fi.metrics.width(s);
+ textwidth = fm.width(s);
if (f.underbar() == FONT_ON)
underline(f, x, y, textwidth);
if (s.size() == 1 && str[0].unicode() == 0x00ad) {
setQPainterPen(computeColor(f.realColor()));
QTextLayout adsymbol(str);
- adsymbol.setFont(fi.font);
+ adsymbol.setFont(ff);
adsymbol.beginLayout();
QTextLine line = adsymbol.createLine();
line.setNumColumns(1);
// don't use the pixmap cache,
// draw directly onto the painting device
setQPainterPen(computeColor(f.realColor()));
- if (font() != fi.font)
- setFont(fi.font);
- // We need to draw the text as LTR as we use our own bidi code.
- setLayoutDirection(Qt::LeftToRight);
+ if (font() != ff)
+ setFont(ff);
// We need to draw the text as LTR as we use our own bidi code.
setLayoutDirection(Qt::LeftToRight);
drawText(x, y, str);
// Only the left bearing of the first character is important
// as we always write from left to right, even for
// right-to-left languages.
- int const lb = min(fi.metrics.lbearing(s[0]), 0);
- int const mA = fi.metrics.maxAscent();
+ int const lb = min(fm.lbearing(s[0]), 0);
+ int const mA = fm.maxAscent();
if (!QPixmapCache::find(key, pm)) {
// Only the right bearing of the last character is
// important as we always write from left to right,
// even for right-to-left languages.
- int const rb = fi.metrics.rbearing(s[s.size()-1]);
+ int const rb = fm.rbearing(s[s.size()-1]);
int const w = textwidth + rb - lb;
- int const mD = fi.metrics.maxDescent();
+ int const mD = fm.maxDescent();
int const h = mA + mD;
pm = QPixmap(w, h);
pm.fill(Qt::transparent);
GuiPainter p(&pm);
p.setQPainterPen(computeColor(f.realColor()));
- if (p.font() != fi.font)
- p.setFont(fi.font);
+ if (p.font() != ff)
+ p.setFont(ff);
// We need to draw the text as LTR as we use our own bidi code.
p.setLayoutDirection(Qt::LeftToRight);
p.drawText(-lb, mA, str);
FontMetrics const & fm = theFontMetrics(font);
fm.buttonText(str, width, ascent, descent);
- button(x + 1, y - ascent, width - 2, descent + ascent, mouseHover);
- text(x + 4, y - 1, str, font);
+ static int const d = Inset::TEXT_TO_INSET_OFFSET / 2;
+
+ button(x + d, y - ascent, width - d, descent + ascent, mouseHover);
+ text(x + Inset::TEXT_TO_INSET_OFFSET, y, str, font);
}