mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
* 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:
parent
7966756340
commit
c01de9fd41
@ -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));
|
||||
|
@ -14,7 +14,6 @@
|
||||
#define INSET_LINE_H
|
||||
|
||||
|
||||
#include "Inset.h"
|
||||
#include "InsetCommand.h"
|
||||
|
||||
|
||||
@ -41,9 +40,11 @@ public:
|
||||
///
|
||||
static std::string defaultCommand() { return "rule"; };
|
||||
///
|
||||
static bool isCompatibleCommand(std::string const & s)
|
||||
static bool isCompatibleCommand(std::string const & s)
|
||||
{ return s == "rule"; }
|
||||
|
||||
///
|
||||
Dimension const dimension(BufferView const &) const;
|
||||
|
||||
private:
|
||||
///
|
||||
void metrics(MetricsInfo &, Dimension &) const;
|
||||
|
Loading…
Reference in New Issue
Block a user