2003-10-27 12:41:26 +00:00
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetLine.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.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-10-27 12:41:26 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "InsetLine.h"
|
2003-10-27 12:41:26 +00:00
|
|
|
|
2007-11-01 22:17:22 +00:00
|
|
|
#include "Dimension.h"
|
2007-10-28 18:51:54 +00:00
|
|
|
#include "Font.h"
|
2003-10-27 12:41:26 +00:00
|
|
|
#include "LaTeXFeatures.h"
|
2008-06-18 18:54:31 +00:00
|
|
|
#include "MetricsInfo.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "OutputParams.h"
|
2009-11-25 22:07:17 +00:00
|
|
|
#include "output_xhtml.h"
|
2007-10-28 18:51:54 +00:00
|
|
|
#include "Text.h"
|
2003-10-27 12:41:26 +00:00
|
|
|
|
2008-02-18 07:14:42 +00:00
|
|
|
#include "frontends/Painter.h"
|
|
|
|
|
|
|
|
#include "support/debug.h"
|
2007-11-01 22:17:22 +00:00
|
|
|
#include "support/docstream.h"
|
|
|
|
|
2003-10-27 12:41:26 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
|
|
|
|
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
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
void InsetLine::read(Lexer &)
|
2003-10-27 12:41:26 +00:00
|
|
|
{
|
|
|
|
/* Nothing to read */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
void InsetLine::write(ostream & os) const
|
2003-10-27 12:41:26 +00:00
|
|
|
{
|
2004-08-16 11:27:51 +00:00
|
|
|
os << "\n\\lyxline\n";
|
2003-10-27 12:41:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
|
2003-10-27 12:41:26 +00:00
|
|
|
{
|
|
|
|
dim.asc = 3;
|
|
|
|
dim.des = 3;
|
|
|
|
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 InsetLine::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
{
|
2007-09-25 07:07:11 +00:00
|
|
|
Dimension const dim = dimension(*pi.base.bv);
|
2010-09-05 23:27:55 +00:00
|
|
|
|
|
|
|
FontInfo f = pi.base.font;
|
|
|
|
Color Line_color = f.realColor();
|
|
|
|
|
|
|
|
pi.pain.line(x, y, x + dim.wid, y, Line_color,
|
2010-09-05 17:18:23 +00:00
|
|
|
Painter::line_solid, 1);
|
2003-10-27 12:41:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
int InsetLine::latex(odocstream & os, OutputParams const & runparams) const
|
2003-10-27 12:41:26 +00:00
|
|
|
{
|
2006-10-19 16:51:30 +00:00
|
|
|
os << "\\lyxline{\\"
|
2006-10-21 00:16:43 +00:00
|
|
|
<< from_ascii(runparams.local_font->latexSize()) << '}';
|
2003-10-27 12:41:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
int InsetLine::plaintext(odocstream & os, OutputParams const &) const
|
2003-10-27 12:41:26 +00:00
|
|
|
{
|
2007-02-15 22:27:45 +00:00
|
|
|
os << "\n-------------------------------------------\n";
|
2007-02-20 17:52:41 +00:00
|
|
|
return PLAINTEXT_NEWLINE;
|
2003-10-27 12:41:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
int InsetLine::docbook(odocstream & os, OutputParams const &) const
|
2003-10-27 12:41:26 +00:00
|
|
|
{
|
|
|
|
os << '\n';
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-11-25 22:07:17 +00:00
|
|
|
docstring InsetLine::xhtml(XHTMLStream & xs, OutputParams const &) const
|
2009-06-05 17:48:14 +00:00
|
|
|
{
|
2010-01-19 22:08:04 +00:00
|
|
|
xs << html::CompTag("hr");
|
2009-11-25 22:07:17 +00:00
|
|
|
xs.cr();
|
2009-06-12 17:23:17 +00:00
|
|
|
return docstring();
|
2009-06-05 17:48:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-10-27 12:41:26 +00:00
|
|
|
void InsetLine::validate(LaTeXFeatures & features) const
|
|
|
|
{
|
|
|
|
features.require("lyxline");
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|