2003-03-12 19:16:42 +00:00
|
|
|
/**
|
|
|
|
* \file insetnewline.C
|
|
|
|
* 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>
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
#include "insetnewline.h"
|
2003-03-12 19:16:42 +00:00
|
|
|
|
|
|
|
#include "BufferView.h"
|
2003-05-19 17:03:12 +00:00
|
|
|
#include "debug.h"
|
2003-09-16 09:44:34 +00:00
|
|
|
#include "LColor.h"
|
2003-03-12 19:16:42 +00:00
|
|
|
#include "lyxtext.h"
|
2003-05-30 06:48:24 +00:00
|
|
|
#include "metricsinfo.h"
|
2003-09-06 17:23:08 +00:00
|
|
|
#include "paragraph.h"
|
2003-08-26 16:36:53 +00:00
|
|
|
#include "paragraph_funcs.h"
|
|
|
|
|
2003-03-12 19:16:42 +00:00
|
|
|
#include "frontends/font_metrics.h"
|
2003-09-05 09:01:27 +00:00
|
|
|
#include "frontends/Painter.h"
|
2003-03-12 19:16:42 +00:00
|
|
|
|
|
|
|
using std::endl;
|
2003-09-05 09:01:27 +00:00
|
|
|
using std::ostream;
|
2003-03-12 19:16:42 +00:00
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
void InsetNewline::read(Buffer const &, LyXLex &)
|
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
|
|
|
{
|
2004-08-16 11:27:51 +00:00
|
|
|
os << "\n\\newline\n";
|
2003-03-12 19:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
void InsetNewline::metrics(MetricsInfo & mi, Dimension & dim) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
2003-06-02 10:03:27 +00:00
|
|
|
LyXFont & font = mi.base.font;
|
2003-05-27 13:55:03 +00:00
|
|
|
dim.asc = font_metrics::maxAscent(font);
|
|
|
|
dim.des = font_metrics::maxDescent(font);
|
|
|
|
dim.wid = font_metrics::width('n', font);
|
2003-07-18 07:47:07 +00:00
|
|
|
dim_ = dim;
|
2003-03-12 19:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-08-28 07:41:31 +00:00
|
|
|
int InsetNewline::latex(Buffer const &, ostream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
OutputParams const &) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
|
|
|
lyxerr << "Eek, calling InsetNewline::latex !" << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
int InsetNewline::plaintext(Buffer const &, ostream & os,
|
|
|
|
OutputParams const &) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
|
|
|
os << '\n';
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-31 18:45:43 +00:00
|
|
|
int InsetNewline::linuxdoc(Buffer const &, std::ostream & 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-10-31 18:45:43 +00:00
|
|
|
int InsetNewline::docbook(Buffer const &, std::ostream & 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
|
|
|
{
|
2003-05-30 06:48:24 +00:00
|
|
|
int const wid = font_metrics::width('n', pi.base.font);
|
|
|
|
int const asc = font_metrics::maxAscent(pi.base.font);
|
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);
|
|
|
|
}
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
pi.pain.lines(xp, yp, 3, LColor::eolmarker);
|
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);
|
|
|
|
}
|
|
|
|
|
2003-05-30 06:48:24 +00:00
|
|
|
pi.pain.lines(xp, yp, 3, LColor::eolmarker);
|
2003-03-12 19:16:42 +00:00
|
|
|
}
|
2004-02-20 10:32:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
bool InsetNewline::isSpace() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|