* add InsetLine::dimension() to avoid calling InsetCommand::dimension()

* InsetLine::draw() bit of code shuffling.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@35384 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Abdelrazak Younes 2010-09-15 12:43:07 +00:00
parent 7966756340
commit c01de9fd41
2 changed files with 16 additions and 12 deletions

View File

@ -14,8 +14,6 @@
#include "InsetLine.h"
#include "Buffer.h"
#include "BufferView.h"
#include "CoordCache.h"
#include "Dimension.h"
#include "DispatchResult.h"
#include "FuncRequest.h"
@ -127,19 +125,21 @@ void InsetLine::metrics(MetricsInfo & mi, Dimension & dim) const
}
Dimension const InsetLine::dimension(BufferView const & bv) const
{
// We cannot use InsetCommand::dimension() as this returns the dimension
// of the button, which is not used here.
return Inset::dimension(bv);
}
void InsetLine::draw(PainterInfo & pi, int x, int y) const
{
// FIXME: We cannot use InsetCommand::dimension() as this returns the dimension
// of the button, which is not used here!
Dimension const dim = pi.base.bv->coordCache().getInsets().dim(this);
Dimension const dim = dimension(*pi.base.bv);
int const max_width = dim.width();
frontend::FontMetrics const & fm = theFontMetrics(pi.base.font);
// get the surrounding text color
FontInfo f = pi.base.font;
Color Line_color = f.realColor();
Length height = Length(to_ascii(getParam("height")));
int const h = height.inPixels(dim.height(), fm.width(char_type('M')));
@ -151,6 +151,9 @@ void InsetLine::draw(PainterInfo & pi, int x, int y) const
if (y - o - h/2 < 0)
o = y - h/2 - 2;
// get the surrounding text color
Color Line_color = pi.base.font.realColor();
// the offset is a vertical one
pi.pain.line(x + 1, y - o - h/2, x + dim.wid - 2, y - o - h/2,
Line_color, Painter::line_solid, float(h));

View File

@ -14,7 +14,6 @@
#define INSET_LINE_H
#include "Inset.h"
#include "InsetCommand.h"
@ -43,6 +42,8 @@ public:
///
static bool isCompatibleCommand(std::string const & s)
{ return s == "rule"; }
///
Dimension const dimension(BufferView const &) const;
private:
///