2003-10-27 12:41:26 +00:00
|
|
|
|
/**
|
2007-04-25 16:11:45 +00:00
|
|
|
|
* \file InsetPagebreak.cpp
|
2003-10-27 12:41:26 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-25 16:11:45 +00:00
|
|
|
|
#include "InsetPagebreak.h"
|
2003-10-27 12:41:26 +00:00
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
2006-12-29 23:54:48 +00:00
|
|
|
|
#include "gettext.h"
|
2007-04-29 23:33:02 +00:00
|
|
|
|
#include "Text.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "MetricsInfo.h"
|
|
|
|
|
#include "OutputParams.h"
|
2006-12-29 23:54:48 +00:00
|
|
|
|
#include "TextMetrics.h"
|
2003-10-27 12:41:26 +00:00
|
|
|
|
|
2006-10-07 16:15:06 +00:00
|
|
|
|
#include "frontends/FontMetrics.h"
|
2003-10-27 12:41:26 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
using frontend::Painter;
|
2006-06-20 08:39:16 +00:00
|
|
|
|
|
2003-10-27 12:41:26 +00:00
|
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
|
void InsetPagebreak::read(Buffer const &, Lexer &)
|
2003-10-27 12:41:26 +00:00
|
|
|
|
{
|
|
|
|
|
/* Nothing to read */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
void InsetPagebreak::write(Buffer const &, std::ostream & os) const
|
2003-10-27 12:41:26 +00:00
|
|
|
|
{
|
2006-11-25 15:09:01 +00:00
|
|
|
|
os << "\n" << getCmdName() << '\n';
|
2003-10-27 12:41:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
|
void InsetPagebreak::metrics(MetricsInfo & mi, Dimension & dim) const
|
2003-10-27 12:41:26 +00:00
|
|
|
|
{
|
|
|
|
|
dim.asc = defaultRowHeight();
|
|
|
|
|
dim.des = defaultRowHeight();
|
|
|
|
|
dim.wid = mi.base.textwidth;
|
2007-09-25 07:07:11 +00:00
|
|
|
|
// Cache the inset dimension.
|
|
|
|
|
setDimCache(mi, dim);
|
2003-10-27 12:41:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetPagebreak::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
|
{
|
2007-10-28 18:51:54 +00:00
|
|
|
|
FontInfo font;
|
2007-10-25 12:41:02 +00:00
|
|
|
|
font.setColor(Color_pagebreak);
|
2003-10-27 12:41:26 +00:00
|
|
|
|
font.decSize();
|
|
|
|
|
|
2007-09-25 07:07:11 +00:00
|
|
|
|
Dimension const dim = dimension(*pi.base.bv);
|
|
|
|
|
|
2003-10-27 12:41:26 +00:00
|
|
|
|
int w = 0;
|
|
|
|
|
int a = 0;
|
|
|
|
|
int d = 0;
|
2006-11-25 16:52:09 +00:00
|
|
|
|
theFontMetrics(font).rectText(insetLabel(), w, a, d);
|
2003-10-27 12:41:26 +00:00
|
|
|
|
|
2007-09-25 07:07:11 +00:00
|
|
|
|
int const text_start = int(x + (dim.wid - w) / 2);
|
2003-10-27 12:41:26 +00:00
|
|
|
|
int const text_end = text_start + w;
|
|
|
|
|
|
2006-11-25 16:52:09 +00:00
|
|
|
|
pi.pain.rectText(text_start, y + d, insetLabel(), font,
|
2007-10-25 12:41:02 +00:00
|
|
|
|
Color_none, Color_none);
|
2003-10-27 12:41:26 +00:00
|
|
|
|
|
|
|
|
|
pi.pain.line(x, y, text_start, y,
|
2007-10-25 12:41:02 +00:00
|
|
|
|
Color_pagebreak, Painter::line_onoffdash);
|
2007-09-25 07:07:11 +00:00
|
|
|
|
pi.pain.line(text_end, y, int(x + dim.wid), y,
|
2007-10-25 12:41:02 +00:00
|
|
|
|
Color_pagebreak, Painter::line_onoffdash);
|
2003-10-27 12:41:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int InsetPagebreak::latex(Buffer const &, odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
|
OutputParams const &) const
|
2003-10-27 12:41:26 +00:00
|
|
|
|
{
|
2006-11-25 15:09:01 +00:00
|
|
|
|
os << from_ascii(getCmdName()) << "{}";
|
2003-10-27 12:41:26 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
int InsetPagebreak::plaintext(Buffer const &, odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
|
OutputParams const &) const
|
2003-10-27 12:41:26 +00:00
|
|
|
|
{
|
2003-11-01 14:09:35 +00:00
|
|
|
|
os << '\n';
|
2007-02-20 17:52:41 +00:00
|
|
|
|
return PLAINTEXT_NEWLINE;
|
2003-10-27 12:41:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-19 21:00:33 +00:00
|
|
|
|
int InsetPagebreak::docbook(Buffer const &, odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
|
OutputParams const &) const
|
2003-10-27 12:41:26 +00:00
|
|
|
|
{
|
|
|
|
|
os << '\n';
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|