lyx_mirror/src/insets/InsetLine.cpp
Abdelrazak Younes 237c132c1e * Inset:
- get rid of the cached Dimension. Text inset dimensions are saved in ParagraphMetrics and mathed maintain their own dimension where needed.
- width(), ascent(), descent(): deleted.
- dimension(): now needs a valid BufferView.
- metrics(): now void.

* BufferView::getCoveringInset(): simplify.

* ParagraphMetrics(): now cache inset dimensions.




git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20420 a592a061-630c-0410-9148-cb99ea01b6c8
2007-09-21 20:39:47 +00:00

91 lines
1.5 KiB
C++

/**
* \file InsetLine.cpp
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "InsetLine.h"
#include "debug.h"
#include "Color.h"
#include "Text.h"
#include "MetricsInfo.h"
#include "LaTeXFeatures.h"
#include "OutputParams.h"
#include "frontends/Painter.h"
namespace lyx {
using frontend::Painter;
using std::ostream;
void InsetLine::read(Buffer const &, Lexer &)
{
/* Nothing to read */
}
void InsetLine::write(Buffer const &, ostream & os) const
{
os << "\n\\lyxline\n";
}
void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
{
dim.asc = 3;
dim.des = 3;
dim.wid = mi.base.textwidth;
}
void InsetLine::draw(PainterInfo & pi, int x, int y) const
{
pi.pain.line(x, y, x + pi.base.textwidth, y, Color::topline,
Painter::line_solid, Painter::line_thick);
}
int InsetLine::latex(Buffer const &, odocstream & os,
OutputParams const & runparams) const
{
os << "\\lyxline{\\"
<< from_ascii(runparams.local_font->latexSize()) << '}';
return 0;
}
int InsetLine::plaintext(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << "\n-------------------------------------------\n";
return PLAINTEXT_NEWLINE;
}
int InsetLine::docbook(Buffer const &, odocstream & os,
OutputParams const &) const
{
os << '\n';
return 0;
}
void InsetLine::validate(LaTeXFeatures & features) const
{
features.require("lyxline");
}
} // namespace lyx