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
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*/
|
|
|
|
|
|
|
|
#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"
|
|
|
|
#include "dimension.h"
|
2003-03-12 19:16:42 +00:00
|
|
|
#include "paragraph.h"
|
|
|
|
#include "lyxtext.h"
|
|
|
|
#include "support/LOstream.h"
|
|
|
|
#include "frontends/Painter.h"
|
|
|
|
#include "frontends/font_metrics.h"
|
|
|
|
|
|
|
|
using std::ostream;
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNewline::read(Buffer const *, LyXLex &)
|
|
|
|
{
|
|
|
|
/* Nothing to read */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNewline::write(Buffer const *, ostream & os) const
|
|
|
|
{
|
|
|
|
os << "\n\\newline \n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-19 17:03:12 +00:00
|
|
|
void InsetNewline::dimension(BufferView *, LyXFont const & font,
|
|
|
|
Dimension & dim) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
2003-05-19 17:03:12 +00:00
|
|
|
dim.a = font_metrics::maxAscent(font);
|
|
|
|
dim.d = font_metrics::maxDescent(font);
|
|
|
|
dim.w = font_metrics::width('n', font);
|
2003-03-12 19:16:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-23 08:59:47 +00:00
|
|
|
int InsetNewline::latex(Buffer const *, ostream &,
|
|
|
|
LatexRunParams const &) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
|
|
|
lyxerr << "Eek, calling InsetNewline::latex !" << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int InsetNewline::ascii(Buffer const *, ostream & os, int) const
|
|
|
|
{
|
|
|
|
os << '\n';
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int InsetNewline::linuxdoc(Buffer const *, std::ostream &) const
|
|
|
|
{
|
|
|
|
/* FIXME */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int InsetNewline::docbook(Buffer const *, std::ostream &, bool) const
|
|
|
|
{
|
|
|
|
/* FIXME */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetNewline::draw(BufferView * bv, LyXFont const & font,
|
2003-03-17 01:34:36 +00:00
|
|
|
int baseline, float & x) const
|
2003-03-12 19:16:42 +00:00
|
|
|
{
|
|
|
|
Painter & pain(bv->painter());
|
|
|
|
|
|
|
|
int const wid = font_metrics::width('n', font);
|
|
|
|
int const asc = font_metrics::maxAscent(font);
|
|
|
|
int const y = baseline;
|
|
|
|
|
|
|
|
// hack, and highly dubious
|
|
|
|
lyx::pos_type pos = parOwner()->getPositionOfInset(this);
|
|
|
|
bool const ltr_pos = (bv->text->bidi_level(pos) % 2 == 0);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (ltr_pos) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
pain.lines(xp, yp, 3, LColor::eolmarker);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
if (ltr_pos) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
pain.lines(xp, yp, 3, LColor::eolmarker);
|
|
|
|
|
|
|
|
x += wid;
|
|
|
|
}
|