X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmetricsinfo.C;h=9d6568640c1a1cea9dca85f3aa48e2a0a741b219;hb=6c2e78e12855d8661eb289ded3dc8722748863b8;hp=1a66b53eb014d1bc1e0017416897bb214374a156;hpb=38fce2feaced45d99f3e78ee8e877f2c37aa6bd1;p=lyx.git diff --git a/src/metricsinfo.C b/src/metricsinfo.C index 1a66b53eb0..9d6568640c 100644 --- a/src/metricsinfo.C +++ b/src/metricsinfo.C @@ -1,30 +1,53 @@ +/** + * \file metricsinfo.C + * 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 +#include "BufferView.h" +#include "LColor.h" #include "metricsinfo.h" + #include "mathed/math_support.h" + #include "frontends/Painter.h" -#include "debug.h" -#include "BufferView.h" +#include + +using std::string; MetricsBase::MetricsBase() : bv(0), font(), style(LM_ST_TEXT), fontname("mathnormal"), - restrictwidth(false), textwidth(0) + textwidth(0) {} +MetricsBase::MetricsBase(BufferView * b, LyXFont const & f, int w) + : bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"), + textwidth(w) +{} + MetricsInfo::MetricsInfo() {} +MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth) + : base(bv, font, textwidth) +{} + -PainterInfo::PainterInfo(BufferView * bv) - : pain(bv->painter()) +PainterInfo::PainterInfo(BufferView * bv, Painter & painter) + : pain(painter), ltr_pos(false), erased_(false) { base.bv = bv; } @@ -36,6 +59,12 @@ void PainterInfo::draw(int x, int y, char c) } +void PainterInfo::draw(int x, int y, std::string const & str) +{ + pain.text(x, y, str, base.font); +} + + Styles smallerScriptStyle(Styles st) { switch (st) { @@ -98,10 +127,11 @@ ShapeChanger::~ShapeChanger() StyleChanger::StyleChanger(MetricsBase & mb, Styles style) : Changer(mb) { - static const int diff[4][4] = { { 0, 0, -3, -5 }, - { 0, 0, -3, -5 }, - { 3, 3, 0, -2 }, - { 5, 5, 2, 0 } }; + static const int diff[4][4] = + { { 0, 0, -3, -5 }, + { 0, 0, -3, -5 }, + { 3, 3, 0, -2 }, + { 5, 5, 2, 0 } }; save_ = mb; int t = diff[mb.style][style]; if (t > 0) @@ -125,10 +155,14 @@ FontSetChanger::FontSetChanger(MetricsBase & mb, char const * name) : Changer(mb) { save_ = mb; + LyXFont::FONT_SIZE oldsize = save_.font.size(); mb.fontname = name; + mb.font = LyXFont(); augmentFont(mb.font, name); + mb.font.setSize(oldsize); } + FontSetChanger::~FontSetChanger() { orig_ = save_; @@ -139,8 +173,7 @@ WidthChanger::WidthChanger(MetricsBase & mb, int w) : Changer(mb) { save_ = mb; - mb.restrictwidth = true; - mb.textwidth = w; + mb.textwidth = w; } @@ -148,3 +181,19 @@ WidthChanger::~WidthChanger() { orig_ = save_; } + + + + +ColorChanger::ColorChanger(LyXFont & font, string const & color) + : Changer(font) +{ + save_ = lcolor.getFromLyXName(color); + font.setColor(lcolor.getFromLyXName(color)); +} + + +ColorChanger::~ColorChanger() +{ + orig_.setColor(lcolor.getFromLyXName(save_)); +}