]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetCharStyle.cpp
Fix text frame drawing.
[lyx.git] / src / insets / InsetCharStyle.cpp
index 3e38f8796e8109493c76a971060e5231ec039ab2..079d872299e85d07855392320456a3bd208f2d10 100644 (file)
@@ -22,7 +22,6 @@
 #include "FuncStatus.h"
 #include "Cursor.h"
 #include "gettext.h"
-#include "LaTeXFeatures.h"
 #include "Color.h"
 #include "Lexer.h"
 #include "Text.h"
 namespace lyx {
 
 using std::string;
-using std::auto_ptr;
-using std::istringstream;
-using std::max;
 using std::ostream;
-using std::ostringstream;
-
-
-void InsetCharStyle::init()
-{}
 
 
 InsetCharStyle::InsetCharStyle(BufferParams const & bp, string const s)
        : InsetCollapsable(bp, Collapsed)
 {
        params_.name = s;
-       setUndefined();
-       init();
 }
 
 
 InsetCharStyle::InsetCharStyle(BufferParams const & bp,
-                               CharStyles::iterator cs)
+                               InsetLayout il)
        : InsetCollapsable(bp, Collapsed)
 {
-       params_.name = cs->name;
-       setDefined(cs);
-       init();
+       params_.name = il.name;
+       setLayout(il);
 }
 
 
 InsetCharStyle::InsetCharStyle(InsetCharStyle const & in)
        : InsetCollapsable(in), params_(in.params_)
-{
-       init();
-}
+{}
 
 
-auto_ptr<Inset> InsetCharStyle::doClone() const
+Inset * InsetCharStyle::clone() const
 {
-       return auto_ptr<Inset>(new InsetCharStyle(*this));
+       return new InsetCharStyle(*this);
 }
 
 
 bool InsetCharStyle::undefined() const
 {
-       return layout_.latexname.empty();
-}
-
-
-void InsetCharStyle::setUndefined()
-{
-       layout_.latextype.clear();
-       layout_.latexname.clear();
-       layout_.latexparam.clear();
-       layout_.font = Font(Font::ALL_INHERIT);
-       layout_.labelfont = Font(Font::ALL_INHERIT);
-       layout_.labelfont.setColor(Color::error);
+       return layout_.labelstring == from_utf8("UNDEFINED");
 }
 
 
-void InsetCharStyle::setDefined(CharStyles::iterator cs)
+void InsetCharStyle::setLayout(InsetLayout il)
 {
-       layout_ = *cs;
+       layout_ = il;
 }
 
 
@@ -136,16 +111,6 @@ bool InsetCharStyle::metrics(MetricsInfo & mi, Dimension & dim) const
        mi.base.font.realize(tmpfont);
        bool changed = InsetCollapsable::metrics(mi, dim);
        mi.base.font = tmpfont;
-       if (status() == Open) {
-               // FIXME UNICODE
-               docstring s(from_utf8(params_.name));
-               if (undefined())
-                       s = _("Undef: ") + s;
-               // Chop off prefix:
-               if (s.find(':') != string::npos)
-                       s = s.substr(s.find(':'));
-               layout_.labelstring = s;
-       }
        return changed;
 }
 
@@ -160,18 +125,6 @@ void InsetCharStyle::draw(PainterInfo & pi, int x, int y) const
        //needed, or even wanted, here. It just works. -- MV 10.04.2005
        InsetCollapsable::draw(pi, x, y);
        pi.base.font = tmpfont;
-
-       // the name of the charstyle. Can be toggled.
-       if (status() == Open) {
-               // FIXME UNICODE
-               docstring s(from_utf8(params_.name));
-               if (undefined())
-                       s = _("Undef: ") + s;
-               // Chop off prefix:
-               if (s.find(':') != string::npos)
-                       s = s.substr(s.find(':'));
-               layout_.labelstring = s;
-       }
 }
 
 
@@ -242,14 +195,6 @@ void InsetCharStyle::textString(Buffer const & buf, odocstream & os) const
 }
 
 
-void InsetCharStyle::validate(LaTeXFeatures & features) const
-{
-       // Force inclusion of preamble snippet in layout file
-       features.require(layout_.latexname);
-       InsetText::validate(features);
-}
-
-
 void InsetCharStyleParams::write(ostream & os) const
 {
        os << "CharStyle " << name << "\n";