arg.mandatory = false;
bool error = false;
bool finished = false;
+ arg.font = inherit_font;
+ arg.labelfont = inherit_font;
unsigned int nr;
lex >> nr;
while (!finished && lex.isOK() && !error) {
} else if (tok == "requires") {
lex.next();
arg.requires = lex.getString();
+ } else if (tok == "decoration") {
+ lex.next();
+ arg.decoration = lex.getString();
+ } else if (tok == "font") {
+ arg.font = lyxRead(lex, arg.font);
+ } else if (tok == "labelfont") {
+ arg.labelfont = lyxRead(lex, arg.labelfont);
} else {
lex.printError("Unknown tag");
error = true;
docstring rdelim;
docstring tooltip;
std::string requires;
+ std::string decoration;
+ FontInfo font;
+ FontInfo labelfont;
};
///
typedef std::map<unsigned int, latexarg> LaTeXArgMap;
InsetArgument::InsetArgument(Buffer * buf, string const & name)
- : InsetCollapsable(buf), name_(name), labelstring_(docstring())
+ : InsetCollapsable(buf), name_(name), labelstring_(docstring()),
+ font_(inherit_font), labelfont_(inherit_font), decoration_(string())
{}
support::rsplit(label, striplabel, '|');
labelstring_ = striplabel.empty() ? label: striplabel;
tooltip_ = translateIfPossible((*lait).second.tooltip);
+ font_ = (*lait).second.font;
+ labelfont_ = (*lait).second.labelfont;
+ decoration_ = (*lait).second.decoration;
} else {
labelstring_ = _("Unknown Argument");
tooltip_ = _("Argument not known in this Layout. Will be supressed in the output.");
return "context-argument";
}
+FontInfo InsetArgument::getFont() const
+{
+ if (font_ != inherit_font)
+ return font_;
+ return getLayout().font();
+}
+
+FontInfo InsetArgument::getLabelfont() const
+{
+ if (labelfont_ != inherit_font)
+ return labelfont_;
+ return getLayout().labelfont();
+}
+
+namespace {
+
+InsetLayout::InsetDecoration translateDecoration(std::string const & str)
+{
+ if (support::compare_ascii_no_case(str, "classic") == 0)
+ return InsetLayout::CLASSIC;
+ if (support::compare_ascii_no_case(str, "minimalistic") == 0)
+ return InsetLayout::MINIMALISTIC;
+ if (support::compare_ascii_no_case(str, "conglomerate") == 0)
+ return InsetLayout::CONGLOMERATE;
+ return InsetLayout::DEFAULT;
+}
+
+}// namespace anon
+
+InsetLayout::InsetDecoration InsetArgument::decoration() const
+{
+ InsetLayout::InsetDecoration dec = getLayout().decoration();
+ if (!decoration_.empty())
+ dec = translateDecoration(decoration_);
+ return dec == InsetLayout::DEFAULT ? InsetLayout::CLASSIC : dec;
+}
+
void InsetArgument::latexArgument(otexstream & os,
OutputParams const & runparams_in, docstring const & ldelim,
docstring const & rdelim) const
/// \name Public functions inherited from InsetCollapsable class
//@{
///
+ InsetLayout::InsetDecoration decoration() const;
+ ///
+ FontInfo getFont() const;
+ ///
+ FontInfo getLabelfont() const;
+ ///
void setButtonLabel();
//@}
docstring labelstring_;
///
docstring tooltip_;
+ ///
+ FontInfo font_;
+ ///
+ FontInfo labelfont_;
+ ///
+ std::string decoration_;
protected:
/// \name Protected functions inherited from Inset class
Dimension InsetCollapsable::dimensionCollapsed(BufferView const & bv) const
{
Dimension dim;
- theFontMetrics(getLayout().labelfont()).buttonText(
+ FontInfo labelfont(getLabelfont());
+ labelfont.realize(sane_font);
+ theFontMetrics(labelfont).buttonText(
buttonLabel(bv), dim.wid, dim.asc, dim.des);
return dim;
}
auto_open_[mi.base.bv] = mi.base.bv->cursor().isInside(this);
FontInfo tmpfont = mi.base.font;
- mi.base.font = getLayout().font();
+ mi.base.font = getFont();
mi.base.font.realize(tmpfont);
BufferView const & bv = *mi.base.bv;
case SubLabel: {
InsetText::metrics(mi, dim);
// consider width of the inset label
- FontInfo font(getLayout().labelfont());
+ FontInfo font(getLabelfont());
font.realize(sane_font);
font.decSize();
font.decSize();
auto_open_[&bv] = bv.cursor().isInside(this);
FontInfo tmpfont = pi.base.font;
- pi.base.font = getLayout().font();
+ pi.base.font = getFont();
pi.base.font.realize(tmpfont);
// Draw button first -- top, left or only
button_dim.y1 = y - dimc.asc;
button_dim.y2 = y + dimc.des;
- FontInfo labelfont = getLayout().labelfont();
+ FontInfo labelfont = getLabelfont();
labelfont.setColor(labelColor());
pi.pain.buttonText(x, y, buttonLabel(bv), labelfont,
mouse_hover_[&bv]);
// the label below the text. Can be toggled.
if (geometry(bv) == SubLabel) {
- FontInfo font(getLayout().labelfont());
+ FontInfo font(getLabelfont());
font.realize(sane_font);
font.decSize();
font.decSize();
/// Default looks
virtual InsetLayout::InsetDecoration decoration() const;
+ /// Inset font
+ virtual FontInfo getFont() const { return getLayout().font(); }
+ /// Label font
+ virtual FontInfo getLabelfont() const { return getLayout().labelfont(); }
///
enum Geometry {
TopButton,
arg.mandatory = false;
bool error = false;
bool finished = false;
+ arg.font = inherit_font;
+ arg.labelfont = inherit_font;
unsigned int nr;
lex >> nr;
while (!finished && lex.isOK() && !error) {
} else if (tok == "requires") {
lex.next();
arg.requires = lex.getString();
+ } else if (tok == "decoration") {
+ lex.next();
+ arg.decoration = lex.getString();
+ } else if (tok == "font") {
+ arg.font = lyxRead(lex, arg.font);
+ } else if (tok == "labelfont") {
+ arg.labelfont = lyxRead(lex, arg.labelfont);
} else {
lex.printError("Unknown tag");
error = true;