#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;
}
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;
}
//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;
- }
}
}
-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";