AlignPossible Block, Left, Right, Center
End
+Input stdinsets.inc
Input stdlists.inc
Input stdcounters.inc
Input stdfloats.inc
End
+Input stdinsets.inc
Input stdlists.inc
Input stdsections.inc
Input stdstarsections.inc
--- /dev/null
+# Textclass definition file for LaTeX.
+# Author : Martin vermeer <amrtin.vermeer@hut.fi>
+# Inset layouts definition
+
+Format 2
+
+InsetLayout Marginal
+ LabelString margin
+ LatexType command
+ LatexName marginpar
+ LabelFont
+ Color Red
+ Size Small
+ EndFont
+End
+
+InsetLayout Foot
+ LabelString foot
+ LatexType command
+ LatexName footnote
+ LabelFont
+ Color Green
+ Size Small
+ EndFont
+End
+
+InsetLayout Note:Comment
+ LabelString comment
+ LatexType environment
+ LatexName comment
+ LabelFont
+ Color Magenta
+ Size Small
+ EndFont
+End
+
+
+InsetLayout Note:Note
+ LabelString note
+ LatexType command
+ LatexName note
+ LabelFont
+ Color Blue
+ Size Small
+ EndFont
+End
+
+InsetLayout Note:Greyedout
+ LabelString greyedout
+ LatexType command
+ LatexName greyedout
+ LabelFont
+ Color Red
+ Size Small
+ EndFont
+End
+
+InsetLayout Note:Framed
+ LabelString framed
+ LatexType command
+ LatexName framed
+ LabelFont
+ Color Red
+ Size Small
+ EndFont
+End
+
+InsetLayout Note:Shaded
+ LabelString shaded
+ LatexType command
+ LatexName shaded
+ LabelFont
+ Color Red
+ Size Small
+ EndFont
+End
+
+
TC_STYLE,
TC_DEFAULTSTYLE,
TC_CHARSTYLE,
+ TC_INSETLAYOUT,
TC_ENVIRONMENT,
TC_NOSTYLE,
TC_COLUMNS,
{ "float", TC_FLOAT },
{ "format", TC_FORMAT },
{ "input", TC_INPUT },
+ { "insetlayout", TC_INSETLAYOUT },
{ "leftmargin", TC_LEFTMARGIN },
{ "nofloat", TC_NOFLOAT },
{ "nostyle", TC_NOSTYLE },
readCharStyle(lexrc, name);
}
break;
+ case TC_INSETLAYOUT:
+ if (lexrc.next()) {
+ docstring const name = subst(lexrc.getDocString(), '_', ' ');
+ readInsetLayout(lexrc, name);
+ }
+ break;
case TC_FLOAT:
readFloat(lexrc);
break;
};
+enum InsetLayoutTags {
+ IL_FONT = 1,
+ IL_LABELFONT,
+ IL_LABELSTRING,
+ IL_LATEXTYPE,
+ IL_LATEXNAME,
+ IL_LATEXPARAM,
+ IL_PREAMBLE,
+ IL_END
+};
+
+
+
void TextClass::readCharStyle(Lexer & lexrc, string const & name)
{
keyword_item elementTags[] = {
}
+void TextClass::readInsetLayout(Lexer & lexrc, docstring const & name)
+{
+ keyword_item elementTags[] = {
+ { "end", IL_END },
+ { "font", IL_FONT },
+ { "labelfont", IL_LABELFONT },
+ { "labelstring", IL_LABELSTRING },
+ { "latexname", IL_LATEXNAME },
+ { "latexparam", IL_LATEXPARAM },
+ { "latextype", IL_LATEXTYPE },
+ { "preamble", IL_PREAMBLE}
+ };
+
+ lexrc.pushTable(elementTags, IL_END);
+
+ docstring labelstring;
+ string latextype;
+ string latexname;
+ string latexparam;
+ Font font(Font::ALL_INHERIT);
+ Font labelfont(Font::ALL_INHERIT);
+ string preamble;
+
+ bool getout = false;
+ while (!getout && lexrc.isOK()) {
+ int le = lexrc.lex();
+ switch (le) {
+ case Lexer::LEX_UNDEF:
+ lexrc.printError("Unknown ClassOption tag `$$Token'");
+ continue;
+ default: break;
+ }
+ switch (static_cast<InsetLayoutTags>(le)) {
+ case IL_LATEXTYPE:
+ lexrc.next();
+ latextype = lexrc.getString();
+ break;
+ case IL_LABELSTRING:
+ lexrc.next();
+ labelstring = lexrc.getDocString();
+ break;
+ case IL_LATEXNAME:
+ lexrc.next();
+ latexname = lexrc.getString();
+ break;
+ case IL_LATEXPARAM:
+ lexrc.next();
+ latexparam = subst(lexrc.getString(), """, "\"");
+ break;
+ case IL_LABELFONT:
+ labelfont.lyxRead(lexrc);
+ labelfont.realize(defaultfont());
+ break;
+ case IL_FONT:
+ font.lyxRead(lexrc);
+ font.realize(defaultfont());
+ labelfont = font;
+ break;
+ case IL_PREAMBLE:
+ preamble = lexrc.getLongString("EndPreamble");
+ break;
+ case IL_END:
+ getout = true;
+ break;
+ }
+ }
+
+ //
+ // Here add element to list if getout == true
+ if (getout) {
+ InsetLayout il;
+ il.labelstring = labelstring;
+ il.latextype = latextype;
+ il.latexname = latexname;
+ il.latexparam = latexparam;
+ il.font = font;
+ il.labelfont = labelfont;
+ il.preamble = from_utf8(preamble);
+ insetlayoutlist_[name] = il;
+ }
+
+ lexrc.popTable();
+}
+
+
+
enum FloatTags {
FT_TYPE = 1,
FT_NAME,
return *ctrs_.get();
}
+InsetLayout const & TextClass::insetlayout(docstring const & name) const
+{
+ return insetlayoutlist_[name];
+}
+
CharStyles::iterator TextClass::charstyle(string const & s) const
{
#include <vector>
#include <set>
+#include <map>
namespace lyx {
};
+class InsetLayout {
+public:
+ docstring labelstring;
+ std::string latextype;
+ std::string latexname;
+ std::string latexparam;
+ Font font;
+ Font labelfont;
+ docstring preamble;
+};
+
+
/// List of semantically defined character style insets
typedef std::vector<CharStyle> CharStyles;
+/// List of inset layouts
+typedef std::map<docstring, InsetLayout> InsetLayouts;
/// Stores the layout specification of a LyX document class.
class TextClass {
///
void readCharStyle(Lexer &, std::string const &);
///
+ void readInsetLayout(Lexer &, docstring const &);
+ ///
void readFloat(Lexer &);
///
void readCounter(Lexer &);
Counters & counters() const;
/// CharStyles of this doc class
CharStyles & charstyles() const { return charstylelist_; };
+ /// Inset layouts of this doc class
+ InsetLayout const & insetlayout(docstring const & name) const;
/// Retrieve element of name s:
CharStyles::iterator charstyle(std::string const & s) const;
///
///
std::string const & name() const;
///
+ docstring const & labelstring() const;
+ ///
std::string const & latexname() const;
///
std::string const & description() const;
/// CharStyles available to this layout
mutable CharStyles charstylelist_;
+ /// Input layouts available to this layout
+ mutable InsetLayouts insetlayoutlist_;
+
/// available types of float, eg. figure, algorithm.
boost::shared_ptr<FloatList> floatlist_;
#include "Inset.h"
#include "Buffer.h"
+#include "BufferParams.h"
#include "BufferView.h"
#include "Color.h"
#include "CoordCache.h"
#include "FuncStatus.h"
#include "gettext.h"
#include "Text.h"
+#include "TextClass.h"
#include "MetricsInfo.h"
#include "MetricsInfo.h"
}
+InsetLayout const & Inset::getLayout(BufferParams const & bp) const
+{
+ return bp.getTextClass().insetlayout(name());
+}
+
+
void Inset::dump() const
{
Buffer buf("foo", 1);
class CursorSlice;
class FuncRequest;
class FuncStatus;
+class InsetLayout;
class InsetMath;
class InsetText;
class LaTeXFeatures;
///
virtual docstring name() const { return from_ascii("unknown"); }
+ ///
+ virtual InsetLayout const & getLayout(BufferParams const & bp) const;
/// used to toggle insets
/// is the inset open?
/// should this inset be handled like a normal charater
InsetCollapsable::InsetCollapsable(InsetCollapsable const & rhs)
: InsetText(rhs),
- labelfont_(rhs.labelfont_),
+ layout_(rhs.layout_),
button_dim(rhs.button_dim),
topx(rhs.topx),
topbaseline(rhs.topbaseline),
}
+void InsetCollapsable::setLayout(BufferParams const & bp)
+{
+ setLabelFont(getLayout(bp).labelfont);
+ setLabel(getLayout(bp).labelstring);
+}
+
+
void InsetCollapsable::write(Buffer const & buf, ostream & os) const
{
os << "status ";
Dimension InsetCollapsable::dimensionCollapsed() const
{
Dimension dim;
- theFontMetrics(labelfont_).buttonText(
+ theFontMetrics(layout_.labelfont).buttonText(
label, dim.wid, dim.asc, dim.des);
return dim;
}
button_dim.y1 = top;
button_dim.y2 = top + dimc.height();
- pi.pain.buttonText(xx, top + dimc.asc, label, labelfont_, mouse_hover_);
+ pi.pain.buttonText(xx, top + dimc.asc, label, layout_.labelfont, mouse_hover_);
if (status() == Open) {
int textx, texty;
}
-void InsetCollapsable::setLabelFont(Font & font)
+void InsetCollapsable::setLabelFont(Font const & font)
{
- labelfont_ = font;
+ layout_.labelfont = font;
}
docstring InsetCollapsable::floatName(string const & type, BufferParams const & bp) const
#include "Inset.h"
#include "InsetText.h"
+#include "TextClass.h"
#include "Box.h"
#include "Font.h"
class Text;
class Paragraph;
class CursorSlice;
+class InsetLayout;
namespace frontend { class Painter; }
///
docstring name() const { return from_ascii("Collapsable"); }
///
+ void setLayout(BufferParams const &);
+ ///
void read(Buffer const &, Lexer &);
///
void write(Buffer const &, std::ostream &) const;
///
virtual void setButtonLabel() {}
///
- void setLabelFont(Font & f);
+ void setLabelFont(Font const & f);
///
bool isOpen() const { return status_ == Open || status_ == Inlined; }
///
docstring floatName(std::string const & type, BufferParams const &) const;
protected:
- ///
- Font labelfont_;
///
mutable Box button_dim;
///
mutable int topbaseline;
///
mutable docstring label;
+ ///
+ mutable InsetLayout layout_;
private:
///
mutable CollapseStatus status_;
InsetFoot::InsetFoot(BufferParams const & bp)
: InsetFootlike(bp)
{
- setLabel(_("foot"));
+ setLayout(bp);
}
InsetFoot::InsetFoot(InsetFoot const & in)
: InsetFootlike(in)
-{
- setLabel(_("foot"));
-}
+{}
auto_ptr<Inset> InsetFoot::doClone() const
#include "BufferParams.h"
#include "MetricsInfo.h"
-
namespace lyx {
InsetFootlike::InsetFootlike(BufferParams const & bp)
: InsetCollapsable(bp)
-{
- Font font(Font::ALL_SANE);
- font.decSize();
- font.decSize();
- font.setColor(Color::collapsable);
- setLabelFont(font);
-}
+{}
InsetFootlike::InsetFootlike(InsetFootlike const & in)
: InsetCollapsable(in)
-{
- Font font(Font::ALL_SANE);
- font.decSize();
- font.decSize();
- font.setColor(Color::collapsable);
- setLabelFont(font);
-}
+{}
bool InsetFootlike::metrics(MetricsInfo & mi, Dimension & dim) const
InsetMarginal::InsetMarginal(BufferParams const & bp)
: InsetFootlike(bp)
{
- setLabel(_("margin"));
+ setLayout(bp);
}
InsetMarginal::InsetMarginal(InsetMarginal const & in)
: InsetFootlike(in)
-{
- setLabel(_("margin"));
-}
+{}
auto_ptr<Inset> InsetMarginal::doClone() const
#include "Buffer.h"
#include "BufferParams.h"
#include "BufferView.h"
+<<<<<<< .mine
+#include "BufferParams.h"
+=======
#include "Counters.h"
+>>>>>>> .r19497
#include "Cursor.h"
#include "debug.h"
#include "DispatchResult.h"
}
-void InsetNote::init()
-{
- setButtonLabel();
-}
-
-
InsetNote::InsetNote(BufferParams const & bp, string const & label)
: InsetCollapsable(bp)
{
params_.type = notetranslator().find(label);
- init();
+ setLayout(bp);
+ setButtonLabel();
}
InsetNote::InsetNote(InsetNote const & in)
: InsetCollapsable(in), params_(in.params_)
{
- init();
+ setButtonLabel();
}
}
+docstring InsetNote::name() const
+{
+ return from_ascii(string("Note") + string(":") + string(notetranslator().find(params_.type)));
+}
+
+
Inset::DisplayType InsetNote::display() const
{
switch (params_.type) {
{
params_.read(lex);
InsetCollapsable::read(buf, lex);
+ setLayout(buf.params());
setButtonLabel();
}
{
docstring const label = notetranslator_loc().find(params_.type);
setLabel(label);
-
- Font font(Font::ALL_SANE);
- font.decSize();
- font.decSize();
-
- Color_color c;
- switch (params_.type) {
- case InsetNoteParams::Note:
- c = Color::note;
- break;
- case InsetNoteParams::Comment:
- c = Color::comment;
- break;
- case InsetNoteParams::Greyedout:
- c = Color::greyedout;
- break;
- case InsetNoteParams::Framed:
- c = Color::greyedout;
- break;
- case InsetNoteParams::Shaded:
- c = Color::greyedout;
- break;
- }
- font.setColor(c);
- setLabelFont(font);
+ setLabelFont(layout_.labelfont);
}
case LFUN_INSET_MODIFY:
InsetNoteMailer::string2params(to_utf8(cmd.argument()), params_);
+ // get a bp from cur:
+ setLayout(cur.buffer().params());
setButtonLabel();
break;
///
Inset::Code lyxCode() const { return Inset::NOTE_CODE; }
///
- docstring name() const { return from_ascii("Note"); }
+ docstring name() const;
/// framed and shaded notes are displayed
virtual DisplayType display() const;
///