mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-21 23:51:25 +00:00
00edcc582f
Basically, I replaced all methods in the font_metrics namespace by a proper virtual interface FontMetrics. The FontLoader is _the_ container for FontMetrics. This patch should also bring some optimizations in a number of place in the code. This is because we do not need any more to search for the LyXFont at each font_metrics call. In effect, the speed advantage is not as sensible and this is a bit deceiving considering that this was my primary motivation behind the patch. But I like the patch anyway as it cleans up the relation and interfacing between fonts, metrics and frontends. * frontends/FontMetrics.h: new virtual interface. Renamed from font_metrics.h * qt4/GuiFontMetrics: corresponding qt4 implememtation. Renamed from qfont_metrics.C. The smallCaps particular case treatment has been transfered here as well as the width cache for MacOSX and Windows. * qt4/QLPainter.C: the smallCapsText has been reworked to return the width of the drawn text.C all other files: replace font_metric helper function call with corresponding FontMetrics method calls. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15265 a592a061-630c-0410-9148-cb99ea01b6c8
102 lines
1.9 KiB
C
102 lines
1.9 KiB
C
/**
|
|
* \file insetpagebreak.C
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author André Pönitz
|
|
*
|
|
* Full author contact details are available in file CREDITS.
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#include "insetpagebreak.h"
|
|
|
|
#include "debug.h"
|
|
#include "LColor.h"
|
|
#include "lyxtext.h"
|
|
#include "metricsinfo.h"
|
|
#include "gettext.h"
|
|
|
|
#include "frontends/Application.h"
|
|
#include "frontends/FontLoader.h"
|
|
#include "frontends/FontMetrics.h"
|
|
#include "frontends/Painter.h"
|
|
|
|
using lyx::docstring;
|
|
using lyx::frontend::Painter;
|
|
|
|
using std::endl;
|
|
using std::ostream;
|
|
|
|
|
|
void InsetPagebreak::read(Buffer const &, LyXLex &)
|
|
{
|
|
/* Nothing to read */
|
|
}
|
|
|
|
|
|
void InsetPagebreak::write(Buffer const &, ostream & os) const
|
|
{
|
|
os << "\n\\newpage\n";
|
|
}
|
|
|
|
|
|
void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
{
|
|
dim.asc = defaultRowHeight();
|
|
dim.des = defaultRowHeight();
|
|
dim.wid = mi.base.textwidth;
|
|
dim_ = dim;
|
|
}
|
|
|
|
|
|
void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
|
|
{
|
|
static docstring const label = _("Page Break");
|
|
|
|
LyXFont font;
|
|
font.setColor(LColor::pagebreak);
|
|
font.decSize();
|
|
|
|
int w = 0;
|
|
int a = 0;
|
|
int d = 0;
|
|
theApp->fontLoader().metrics(font).rectText(label, w, a, d);
|
|
|
|
int const text_start = int(x + (dim_.wid - w) / 2);
|
|
int const text_end = text_start + w;
|
|
|
|
pi.pain.rectText(text_start, y + d, label, font,
|
|
LColor::none, LColor::none);
|
|
|
|
pi.pain.line(x, y, text_start, y,
|
|
LColor::pagebreak, Painter::line_onoffdash);
|
|
pi.pain.line(text_end, y, int(x + dim_.wid), y,
|
|
LColor::pagebreak, Painter::line_onoffdash);
|
|
}
|
|
|
|
|
|
int InsetPagebreak::latex(Buffer const &, ostream & os,
|
|
OutputParams const &) const
|
|
{
|
|
os << "\\newpage{}";
|
|
return 0;
|
|
}
|
|
|
|
|
|
int InsetPagebreak::plaintext(Buffer const &, ostream & os,
|
|
OutputParams const &) const
|
|
{
|
|
os << '\n';
|
|
return 0;
|
|
}
|
|
|
|
|
|
int InsetPagebreak::docbook(Buffer const &, std::ostream & os,
|
|
OutputParams const &) const
|
|
{
|
|
os << '\n';
|
|
return 0;
|
|
}
|