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 "render_button.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(std::string const & c) { p_.scanCommand(c); };
48 virtual int latex(Buffer const &, std::ostream &,
49 OutputParams const &) const;
51 int plaintext(Buffer const &, std::ostream &,
52 OutputParams const &) const;
54 virtual int linuxdoc(Buffer const &, std::ostream &,
55 OutputParams const &) const;
57 virtual int docbook(Buffer const &, std::ostream &,
58 OutputParams const & runparams) const;
60 InsetOld::Code lyxCode() const { return InsetOld::NO_CODE; }
63 InsetCommandParams const & params() const { return p_; }
65 std::string const & getContents() const { return p_.getContents(); }
67 void setContents(std::string const & c) { p_.setContents(c); }
69 std::string const & getOptions() const { return p_.getOptions(); }
71 RenderButton & button() const { return button_; }
77 priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
79 std::string const getCommand() const { return p_.getCommand(); }
81 std::string const & getCmdName() const { return p_.getCmdName(); }
83 void setCmdName(std::string const & n) { p_.setCmdName(n); }
85 void setOptions(std::string const & o) { p_.setOptions(o); }
87 void setParams(InsetCommandParams const &);
88 /// This should provide the text for the button
89 virtual std::string const getScreenLabel(Buffer const &) const = 0;
93 InsetCommandParams p_;
94 mutable bool set_label_;
95 mutable RenderButton button_;
99 class InsetCommandMailer : public MailInset {
102 InsetCommandMailer(std::string const & name, InsetCommand & inset);
104 virtual InsetBase & inset() const { return inset_; }
106 virtual std::string const & name() const { return name_; }
108 virtual std::string const inset2string(Buffer const &) const;
110 static void string2params(std::string const &, InsetCommandParams &);
112 static std::string const params2string(std::string const & name,
113 InsetCommandParams const &);
116 std::string const name_;
118 InsetCommand & inset_;