2003-03-12 19:16:42 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetNewline.cpp
|
2003-03-12 19:16:42 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-03-12 19:16:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "InsetNewline.h"
|
2003-03-12 19:16:42 +00:00
|
|
|
|
2007-11-01 22:17:22 +00:00
|
|
|
#include "Dimension.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "MetricsInfo.h"
|
|
|
|
#include "OutputParams.h"
|
2003-08-26 16:36:53 +00:00
|
|
|
|
2006-10-07 16:15:06 +00:00
|
|
|
#include "frontends/FontMetrics.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
#include "frontends/Painter.h"
|
2003-03-12 19:16:42 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "support/debug.h"
|
2007-11-25 18:34:37 +00:00
|
|
|
#include "support/docstring.h"
|
2007-11-28 22:12:03 +00:00
|
|
|
#include "support/docstream.h"
|
2007-11-25 18:34:37 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
2006-10-19 16:51:30 +00:00
|
|
|
|
2003-03-12 19:16:42 +00:00
|
|
|
|
2007-04-26 11:30:54 +00:00
|
|
|
void InsetNewline::read(Buffer const &, Lexer &)
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
|
|
|
/* Nothing to read */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
void InsetNewline::write(Buffer const &, ostream & os) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
2007-11-25 18:34:37 +00:00
|
|
|
os << "\n" << getLyXName() << '\n';
|
2003-03-12 19:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
2006-10-21 00:16:43 +00:00
|
|
|
frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
|
2006-10-07 16:15:06 +00:00
|
|
|
dim.asc = fm.maxAscent();
|
|
|
|
dim.des = fm.maxDescent();
|
|
|
|
dim.wid = fm.width('n');
|
2003-03-12 19:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-25 18:34:37 +00:00
|
|
|
int InsetNewline::latex(Buffer const &, odocstream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const &) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
2007-11-25 18:34:37 +00:00
|
|
|
os << from_ascii(getCmdName()) << '\n';
|
2003-03-12 19:16:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
int InsetNewline::plaintext(Buffer const &, odocstream & os,
|
2007-05-28 22:27:45 +00:00
|
|
|
OutputParams const &) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
|
|
|
os << '\n';
|
2007-02-20 17:52:41 +00:00
|
|
|
return PLAINTEXT_NEWLINE;
|
2003-03-12 19:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-10-19 21:00:33 +00:00
|
|
|
int InsetNewline::docbook(Buffer const &, odocstream & os,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const &) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
2003-06-06 18:35:03 +00:00
|
|
|
os << '\n';
|
2003-03-12 19:16:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
void InsetNewline::draw(PainterInfo & pi, int x, int y) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
2007-11-25 18:34:37 +00:00
|
|
|
FontInfo font;
|
|
|
|
font.setColor(ColorName());
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
frontend::FontMetrics const & fm = theFontMetrics(pi.base.font);
|
2006-10-07 16:15:06 +00:00
|
|
|
int const wid = fm.width('n');
|
|
|
|
int const asc = fm.maxAscent();
|
2003-03-12 19:16:42 +00:00
|
|
|
|
|
|
|
int xp[3];
|
|
|
|
int yp[3];
|
|
|
|
|
|
|
|
yp[0] = int(y - 0.875 * asc * 0.75);
|
|
|
|
yp[1] = int(y - 0.500 * asc * 0.75);
|
|
|
|
yp[2] = int(y - 0.125 * asc * 0.75);
|
|
|
|
|
2004-08-14 23:57:29 +00:00
|
|
|
if (pi.ltr_pos) {
|
2003-03-12 19:16:42 +00:00
|
|
|
xp[0] = int(x + wid * 0.375);
|
|
|
|
xp[1] = int(x);
|
|
|
|
xp[2] = int(x + wid * 0.375);
|
|
|
|
} else {
|
|
|
|
xp[0] = int(x + wid * 0.625);
|
|
|
|
xp[1] = int(x + wid);
|
|
|
|
xp[2] = int(x + wid * 0.625);
|
|
|
|
}
|
|
|
|
|
2007-11-25 18:34:37 +00:00
|
|
|
pi.pain.lines(xp, yp, 3, ColorName());
|
2003-03-12 19:16:42 +00:00
|
|
|
|
|
|
|
yp[0] = int(y - 0.500 * asc * 0.75);
|
|
|
|
yp[1] = int(y - 0.500 * asc * 0.75);
|
|
|
|
yp[2] = int(y - asc * 0.75);
|
|
|
|
|
2004-08-14 23:57:29 +00:00
|
|
|
if (pi.ltr_pos) {
|
2003-03-12 19:16:42 +00:00
|
|
|
xp[0] = int(x);
|
|
|
|
xp[1] = int(x + wid);
|
|
|
|
xp[2] = int(x + wid);
|
|
|
|
} else {
|
|
|
|
xp[0] = int(x + wid);
|
|
|
|
xp[1] = int(x);
|
|
|
|
xp[2] = int(x);
|
|
|
|
}
|
|
|
|
|
2007-11-25 18:34:37 +00:00
|
|
|
pi.pain.lines(xp, yp, 3, ColorName());
|
|
|
|
|
|
|
|
// add label text behind the newline marker to divide from \newline
|
|
|
|
int w = 0;
|
|
|
|
int a = 0;
|
|
|
|
int d = 0;
|
|
|
|
theFontMetrics(font).rectText(insetLabel(), w, a, d);
|
|
|
|
|
|
|
|
int const text_start = int(x + 2 * wid);
|
|
|
|
|
|
|
|
pi.pain.rectText(text_start, yp[0] + d, insetLabel(), font,
|
|
|
|
Color_none, Color_none);
|
2003-03-12 19:16:42 +00:00
|
|
|
}
|
2004-02-20 10:32:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool InsetNewline::isSpace() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|