2003-03-11 13:33:14 +00:00
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
|
* \file InsetHFill.cpp
|
2003-03-11 13:33:14 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-03-11 13:33:14 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "InsetHFill.h"
|
2007-12-05 22:25:07 +00:00
|
|
|
|
|
|
|
|
|
#include "MetricsInfo.h"
|
|
|
|
|
|
|
|
|
|
#include "frontends/Painter.h"
|
|
|
|
|
|
2007-11-29 07:04:28 +00:00
|
|
|
|
#include "support/gettext.h"
|
2006-10-20 16:12:49 +00:00
|
|
|
|
|
2007-11-06 21:45:24 +00:00
|
|
|
|
#include <ostream>
|
2003-10-10 21:08:55 +00:00
|
|
|
|
|
2007-12-12 19:28:07 +00:00
|
|
|
|
using namespace std;
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
2006-10-11 19:40:50 +00:00
|
|
|
|
|
2003-09-05 09:01:27 +00:00
|
|
|
|
|
2003-03-11 13:33:14 +00:00
|
|
|
|
InsetHFill::InsetHFill()
|
2007-12-12 19:28:07 +00:00
|
|
|
|
: InsetCommand(InsetCommandParams(HFILL_CODE), string())
|
2003-03-11 13:33:14 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2008-02-23 22:01:02 +00:00
|
|
|
|
ParamInfo const & InsetHFill::findInfo(string const & /* cmdName */)
|
2007-10-25 04:13:56 +00:00
|
|
|
|
{
|
2008-02-23 22:01:02 +00:00
|
|
|
|
static ParamInfo param_info_;
|
|
|
|
|
return param_info_;
|
2007-10-25 04:13:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
|
void InsetHFill::metrics(MetricsInfo &, Dimension & dim) const
|
2003-10-28 11:18:40 +00:00
|
|
|
|
{
|
2007-12-05 22:25:07 +00:00
|
|
|
|
// The metrics for this inset are calculated externally in
|
|
|
|
|
// \c TextMetrics::computeRowMetrics. Those are dummy value:
|
|
|
|
|
dim = Dimension(10, 10, 10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void InsetHFill::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
|
{
|
|
|
|
|
Dimension const dim = Inset::dimension(*pi.base.bv);
|
2007-12-05 23:10:11 +00:00
|
|
|
|
int const x0 = x + 1;
|
|
|
|
|
int const x1 = x + dim.wid - 2;
|
2007-12-06 08:51:56 +00:00
|
|
|
|
int const y0 = y + dim.des - 1;
|
|
|
|
|
int const y1 = y - dim.asc + 1;
|
2007-12-05 22:25:07 +00:00
|
|
|
|
|
2007-12-05 23:10:11 +00:00
|
|
|
|
pi.pain.line(x0, y1, x0, y0, Color_added_space);
|
|
|
|
|
pi.pain.line(x0, y, x1, y, Color_added_space,
|
2007-12-05 22:25:07 +00:00
|
|
|
|
frontend::Painter::line_onoffdash);
|
|
|
|
|
pi.pain.line(x1, y1, x1, y0, Color_added_space);
|
2003-10-28 11:18:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
docstring InsetHFill::screenLabel() const
|
2003-10-28 11:18:40 +00:00
|
|
|
|
{
|
2006-10-20 16:12:49 +00:00
|
|
|
|
return _("Horizontal Fill");
|
2003-10-28 11:18:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetHFill::plaintext(odocstream & os, OutputParams const &) const
|
2003-03-11 13:33:14 +00:00
|
|
|
|
{
|
2007-02-15 16:07:36 +00:00
|
|
|
|
os << " ";
|
2007-05-28 22:27:45 +00:00
|
|
|
|
return 5;
|
2003-03-11 13:33:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
int InsetHFill::docbook(odocstream & os, OutputParams const &) const
|
2003-06-07 09:48:11 +00:00
|
|
|
|
{
|
|
|
|
|
os << '\n';
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-10-28 11:18:40 +00:00
|
|
|
|
|
2008-02-27 20:43:16 +00:00
|
|
|
|
void InsetHFill::write(ostream & os) const
|
2003-03-11 13:33:14 +00:00
|
|
|
|
{
|
2004-08-16 11:27:51 +00:00
|
|
|
|
os << "\n\\hfill\n";
|
2003-03-11 13:33:14 +00:00
|
|
|
|
}
|
2004-02-20 10:32:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool InsetHFill::isSpace() const
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|