]> git.lyx.org Git - lyx.git/blobdiff - src/metricsinfo.C
Add GTK bibitem dialog
[lyx.git] / src / metricsinfo.C
index b715e14535b54dc867e01d524a09aa7638944fe3..9d6568640c1a1cea9dca85f3aa48e2a0a741b219 100644 (file)
 
 #include <config.h>
 
+#include "BufferView.h"
+#include "LColor.h"
 #include "metricsinfo.h"
+
 #include "mathed/math_support.h"
+
 #include "frontends/Painter.h"
-#include "BufferView.h"
-#include "LColor.h"
 
+#include <boost/assert.hpp>
+
+using std::string;
 
 
 MetricsBase::MetricsBase()
@@ -24,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)
@@ -42,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), erased_(false)
 {
        base.bv = bv;
 }
@@ -55,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) {
@@ -117,10 +127,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)
@@ -144,8 +155,11 @@ 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);
 }
 
 
@@ -159,7 +173,7 @@ WidthChanger::WidthChanger(MetricsBase & mb, int w)
        :       Changer<MetricsBase>(mb)
 {
        save_ = mb;
-       mb.textwidth     = w;
+       mb.textwidth = w;
 }
 
 
@@ -174,14 +188,12 @@ WidthChanger::~WidthChanger()
 ColorChanger::ColorChanger(LyXFont & font, string const & color)
        : Changer<LyXFont, string>(font)
 {
-       save_ = lcolor.getFromGUIName(color);
-       font.setColor(lcolor.getFromGUIName(color));
+       save_ = lcolor.getFromLyXName(color);
+       font.setColor(lcolor.getFromLyXName(color));
 }
 
 
 ColorChanger::~ColorChanger()
 {
-       orig_.setColor(lcolor.getFromGUIName(save_));
+       orig_.setColor(lcolor.getFromLyXName(save_));
 }
-
-