4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
8 * \author Lars Gullik Bjønnes
10 * Full author contact details are available in file CREDITS.
13 #ifndef INSET_LATEXCOMMAND_H
14 #define INSET_LATEXCOMMAND_H
18 #include "insetcommandparams.h"
19 #include "renderers.h"
20 #include "mailinset.h"
22 // Created by Alejandro 970222
23 /** Used to insert a LaTeX command automatically
25 * Similar to InsetLaTeX but having control of the basic structure of a
26 * LaTeX command: \name[options]{contents}.
30 class InsetCommand : public InsetOld {
34 InsetCommand(InsetCommandParams const &);
36 void metrics(MetricsInfo &, Dimension &) const;
38 void draw(PainterInfo & pi, int x, int y) const;
40 void write(Buffer const &, std::ostream & os) const
43 virtual void read(Buffer const &, LyXLex & lex)
45 /// Can remove one InsetBibKey is modified
46 void scanCommand(string const & c) { p_.scanCommand(c); };
48 virtual int latex(Buffer const &, std::ostream &,
49 LatexRunParams const &) const;
51 int ascii(Buffer const &, std::ostream &, int linelen) const;
53 virtual int linuxdoc(Buffer const &, std::ostream &) const;
55 virtual int docbook(Buffer const &, std::ostream &, bool) const;
57 InsetOld::Code lyxCode() const { return InsetOld::NO_CODE; }
60 InsetCommandParams const & params() const { return p_; }
62 virtual dispatch_result localDispatch(FuncRequest const & cmd);
64 string const & getContents() const { return p_.getContents(); }
66 void setContents(string const & c) { p_.setContents(c); }
68 string const & getOptions() const { return p_.getOptions(); }
72 string const getCommand() const { return p_.getCommand(); }
74 string const & getCmdName() const { return p_.getCmdName(); }
76 void setCmdName(string const & n) { p_.setCmdName(n); }
78 void setOptions(string const & o) { p_.setOptions(o); }
80 void setParams(InsetCommandParams const &);
82 virtual BufferView * view() const;
83 /// This should provide the text for the button
84 virtual string const getScreenLabel(Buffer const &) const = 0;
88 InsetCommandParams p_;
89 mutable bool set_label_;
90 mutable ButtonRenderer button_;
94 class InsetCommandMailer : public MailInset {
97 InsetCommandMailer(string const & name, InsetCommand & inset);
99 virtual InsetBase & inset() const { return inset_; }
101 virtual string const & name() const { return name_; }
103 virtual string const inset2string(Buffer const &) const;
105 static void string2params(string const &, InsetCommandParams &);
107 static string const params2string(string const & name,
108 InsetCommandParams const &);
113 InsetCommand & inset_;