]> git.lyx.org Git - lyx.git/blobdiff - src/MetricsInfo.cpp
Clarify that the Dialog::lyxview_ pointer is in fact a reference
[lyx.git] / src / MetricsInfo.cpp
index 3808da6a2457f6fce1fd774b67c86ab8130e028d..589e9241a955be42378551383955df099f23875e 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "BufferView.h"
 #include "ColorSet.h"
+#include "LyXRC.h"
 #include "MetricsInfo.h"
 
 #include "insets/Inset.h"
@@ -35,27 +36,37 @@ namespace lyx {
 //
 /////////////////////////////////////////////////////////////////////////
 
-MetricsBase::MetricsBase()
-       : bv(0), font(), style(LM_ST_TEXT), fontname("mathnormal"),
-         textwidth(0)
-{}
-
-
-MetricsBase::MetricsBase(BufferView * b, FontInfo const & f, int w)
-       : bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"),
-         textwidth(w)
-{}
+MetricsBase::MetricsBase(BufferView * b, FontInfo f, int w)
+       : bv(b), font(move(f)), style(LM_ST_TEXT), fontname("mathnormal"),
+         textwidth(w), solid_line_thickness_(1), solid_line_offset_(1),
+         dotted_line_thickness_(1)
+{
+       if (lyxrc.zoom >= 200) {
+               // derive the line thickness from zoom factor
+               // the zoom is given in percent
+               // (increase thickness at 250%, 450% etc.)
+               solid_line_thickness_ = (lyxrc.zoom + 150) / 200;
+               // adjust line_offset_ too
+               solid_line_offset_ = 1 + solid_line_thickness_ / 2;
+       }
+       if (lyxrc.zoom >= 100) {
+               // derive the line thickness from zoom factor
+               // the zoom is given in percent
+               // (increase thickness at 150%, 250% etc.)
+               dotted_line_thickness_ = (lyxrc.zoom + 50) / 100;
+       }
+}
 
 
-Changer MetricsBase::changeFontSet(docstring const & name, bool cond)
+Changer MetricsBase::changeFontSet(string const & name, bool cond)
 {
        RefChanger<MetricsBase> rc = make_save(*this);
        if (!cond)
                rc->keep();
        else {
                ColorCode oldcolor = font.color();
-               docstring const oldname = from_ascii(fontname);
-               fontname = to_utf8(name);
+               string const oldname = fontname;
+               fontname = name;
                font = sane_font;
                augmentFont(font, name);
                font.setSize(rc->old.font.size());
@@ -68,20 +79,14 @@ Changer MetricsBase::changeFontSet(docstring const & name, bool cond)
 }
 
 
-Changer MetricsBase::changeFontSet(char const * name, bool cond)
-{
-       return changeFontSet(from_ascii(name), cond);
-}
-
-
 /////////////////////////////////////////////////////////////////////////
 //
 // MetricsInfo
 //
 /////////////////////////////////////////////////////////////////////////
 
-MetricsInfo::MetricsInfo(BufferView * bv, FontInfo const & font, int textwidth, 
-       MacroContext const & mc)
+MetricsInfo::MetricsInfo(BufferView * bv, FontInfo font, int textwidth,
+                         MacroContext const & mc)
        : base(bv, font, textwidth), macrocontext(mc)
 {}