From c01de9fd41971f752d9d137f0fd9a7c5254b9c1a Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 15 Sep 2010 12:43:07 +0000 Subject: [PATCH] * 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 --- src/insets/InsetLine.cpp | 21 ++++++++++++--------- src/insets/InsetLine.h | 7 ++++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/insets/InsetLine.cpp b/src/insets/InsetLine.cpp index 255e6a99bf..f9b4662e57 100644 --- a/src/insets/InsetLine.cpp +++ b/src/insets/InsetLine.cpp @@ -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)); diff --git a/src/insets/InsetLine.h b/src/insets/InsetLine.h index 87c1569769..6ee0968ba0 100644 --- a/src/insets/InsetLine.h +++ b/src/insets/InsetLine.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; -- 2.39.2