]> git.lyx.org Git - lyx.git/blobdiff - src/metricsinfo.C
Fix bug 886 and others not reported related with the document paper size.
[lyx.git] / src / metricsinfo.C
index 1202520b80e97eb7b2e2c62739aa6f4397408962..efe237dc703daf9b32cd4768c46100b02a3358e3 100644 (file)
@@ -1,12 +1,26 @@
+/**
+ * \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 <config.h>
 
+#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 <boost/assert.hpp>
+
+using std::string;
 
 
 MetricsBase::MetricsBase()
@@ -15,7 +29,6 @@ MetricsBase::MetricsBase()
 {}
 
 
-
 MetricsBase::MetricsBase(BufferView * b, LyXFont const & f, int w)
        : bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"),
          textwidth(w)
@@ -33,8 +46,8 @@ MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth)
 
 
 
-PainterInfo::PainterInfo(BufferView * bv)
-       : pain(bv->painter())
+PainterInfo::PainterInfo(BufferView * bv, Painter & painter)
+       : pain(painter), ltr_pos(false)
 {
        base.bv = bv;
 }
@@ -108,10 +121,11 @@ ShapeChanger::~ShapeChanger()
 StyleChanger::StyleChanger(MetricsBase & mb, Styles style)
        :       Changer<MetricsBase>(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 +149,14 @@ FontSetChanger::FontSetChanger(MetricsBase & mb, char const * name)
        :       Changer<MetricsBase>(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_;
@@ -149,7 +167,7 @@ WidthChanger::WidthChanger(MetricsBase & mb, int w)
        :       Changer<MetricsBase>(mb)
 {
        save_ = mb;
-       mb.textwidth     = w;
+       mb.textwidth = w;
 }
 
 
@@ -157,3 +175,19 @@ WidthChanger::~WidthChanger()
 {
        orig_ = save_;
 }
+
+
+
+
+ColorChanger::ColorChanger(LyXFont & font, string const & color)
+       : Changer<LyXFont, string>(font)
+{
+       save_ = lcolor.getFromLyXName(color);
+       font.setColor(lcolor.getFromLyXName(color));
+}
+
+
+ColorChanger::~ColorChanger()
+{
+       orig_.setColor(lcolor.getFromLyXName(save_));
+}