X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmetricsinfo.C;h=9544e68883c464c85566db05bda984a00992a269;hb=8765ab59cdddad67284007813ef25934ea0042ce;hp=78c251b7d7912a8974c57dde436ee28d758c6c14;hpb=b853229344b1a336a82c39126410802ad50d308e;p=lyx.git diff --git a/src/metricsinfo.C b/src/metricsinfo.C index 78c251b7d7..9544e68883 100644 --- a/src/metricsinfo.C +++ b/src/metricsinfo.C @@ -1,24 +1,40 @@ +/** + * \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 "mathed/MathSupport.h" + #include "frontends/Painter.h" -#include "debug.h" -#include "BufferView.h" + +#include +namespace lyx { + +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) +MetricsBase::MetricsBase(BufferView * b, LyXFont const & f, int w) : bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"), - restrictwidth(false), textwidth(0) + textwidth(w) {} @@ -27,25 +43,31 @@ MetricsInfo::MetricsInfo() {} -MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font) - : base(bv, font) +MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth) + : base(bv, font, textwidth) {} -PainterInfo::PainterInfo(BufferView * bv) - : pain(bv->painter()) +PainterInfo::PainterInfo(BufferView * bv, lyx::frontend::Painter & painter) + : pain(painter), ltr_pos(false), erased_(false) { base.bv = bv; } -void PainterInfo::draw(int x, int y, char c) +void PainterInfo::draw(int x, int y, char_type c) { pain.text(x, y, c, base.font); } +void PainterInfo::draw(int x, int y, docstring const & str) +{ + pain.text(x, y, str, base.font); +} + + Styles smallerScriptStyle(Styles st) { switch (st) { @@ -91,6 +113,7 @@ ArrayChanger::ArrayChanger(MetricsBase & mb) {} + ShapeChanger::ShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape) : Changer(font) { @@ -98,6 +121,7 @@ ShapeChanger::ShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape) orig_.setShape(shape); } + ShapeChanger::~ShapeChanger() { orig_.setShape(save_); @@ -108,10 +132,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) @@ -135,10 +160,26 @@ 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, from_ascii(name)); + mb.font.setSize(oldsize); +} + + +FontSetChanger::FontSetChanger(MetricsBase & mb, docstring const & name) + : Changer(mb) +{ + save_ = mb; + LyXFont::FONT_SIZE oldsize = save_.font.size(); + mb.fontname = to_utf8(name); + mb.font = LyXFont(); augmentFont(mb.font, name); + mb.font.setSize(oldsize); } + FontSetChanger::~FontSetChanger() { orig_ = save_; @@ -149,8 +190,7 @@ WidthChanger::WidthChanger(MetricsBase & mb, int w) : Changer(mb) { save_ = mb; - mb.restrictwidth = true; - mb.textwidth = w; + mb.textwidth = w; } @@ -158,3 +198,22 @@ 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_)); +} + + +} // namespace lyx