]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetArgument.cpp
Allow for some argument visual customization
[features.git] / src / insets / InsetArgument.cpp
index d971a16e3a804f3ea7d7e18355acf3ab4daac5cd..b113878f062e9c60eee7c65702ac86daa6fedc5b 100644 (file)
@@ -4,6 +4,7 @@
  * Licence details can be found in the file COPYING.
  *
  * \author Martin Vermeer
+ * \author Jürgen Spitzmüller
  *
  * Full author contact details are available in file CREDITS.
  */
@@ -18,6 +19,7 @@
 #include "InsetList.h"
 #include "Layout.h"
 #include "Lexer.h"
+#include "OutputParams.h"
 #include "ParIterator.h"
 
 #include "support/convert.h"
@@ -32,7 +34,8 @@ namespace lyx {
 
 
 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())
 {}
 
 
@@ -100,6 +103,9 @@ void InsetArgument::updateBuffer(ParIterator const & it, UpdateType utype)
                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.");
@@ -200,13 +206,53 @@ string InsetArgument::contextMenuName() const
        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, docstring const & ldelim,
+               OutputParams const & runparams_in, docstring const & ldelim,
                docstring const & rdelim) const
 {
        TexRow texrow;
        odocstringstream ss;
        otexstream ots(ss, texrow);
+       OutputParams runparams = runparams_in;
+       if (getLayout().isPassThru())
+               runparams.pass_thru = true;
        InsetText::latex(ots, runparams);
        docstring str = ss.str();
        if (ldelim != "{" && support::contains(str, rdelim))