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
17 #include "insetcommandparams.h"
18 #include "render_button.h"
19 #include "mailinset.h"
23 // Created by Alejandro 970222
24 /** Used to insert a LaTeX command automatically
26 * Similar to InsetLaTeX but having control of the basic structure of a
27 * LaTeX command: \name[options]{contents}.
31 class InsetCommand : public InsetOld {
34 InsetCommand(InsetCommandParams const &, std::string const & mailer_name);
38 void metrics(MetricsInfo &, Dimension &) const;
40 void draw(PainterInfo & pi, int x, int y) const;
42 void write(Buffer const &, std::ostream & os) const
45 virtual void read(Buffer const &, LyXLex & lex)
47 /// Can remove one InsetBibKey is modified
48 void scanCommand(std::string const & c) { p_.scanCommand(c); };
50 virtual int latex(Buffer const &, std::ostream &,
51 OutputParams const &) const;
53 int plaintext(Buffer const &, std::ostream &,
54 OutputParams const &) const;
56 virtual int docbook(Buffer const &, std::ostream &,
57 OutputParams const & runparams) const;
59 InsetBase::Code lyxCode() const { return InsetBase::NO_CODE; }
62 InsetCommandParams const & params() const { return p_; }
64 std::string const & getContents() const { return p_.getContents(); }
66 void setContents(std::string const & c)
68 updateButtonLabel_ = true;
72 std::string const & getOptions() const { return p_.getOptions(); }
74 std::string const & getSecOptions() const { return p_.getSecOptions(); }
76 RenderButton & button() const { return button_; }
80 virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
82 bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
84 std::string const getCommand() const { return p_.getCommand(); }
86 std::string const & getCmdName() const { return p_.getCmdName(); }
88 void setCmdName(std::string const & n)
90 updateButtonLabel_ = true;
94 void setOptions(std::string const & o)
96 updateButtonLabel_ = true;
100 void setSecOptions(std::string const & s)
102 updateButtonLabel_ = true;
106 void setParams(InsetCommandParams const &);
107 /// This should provide the text for the button
108 virtual std::string const getScreenLabel(Buffer const &) const = 0;
112 InsetCommandParams p_;
113 std::string mailer_name_;
114 mutable bool updateButtonLabel_;
115 mutable RenderButton button_;
119 class InsetCommandMailer : public MailInset {
122 InsetCommandMailer(std::string const & name, InsetCommand & inset);
124 virtual InsetBase & inset() const { return inset_; }
126 virtual std::string const & name() const { return name_; }
128 virtual std::string const inset2string(Buffer const &) const;
130 static void string2params(std::string const &, std::string const & name,
131 InsetCommandParams &);
133 static std::string const params2string(std::string const & name,
134 InsetCommandParams const &);
137 std::string const name_;
139 InsetCommand & inset_;