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 "RenderButton.h"
19 #include "MailInset.h"
26 // Created by Alejandro 970222
27 /** Used to insert a LaTeX command automatically.
31 class InsetCommand : public Inset {
34 InsetCommand(InsetCommandParams const &, std::string const & mailer_name);
38 void metrics(MetricsInfo &, Dimension &) const;
40 Dimension const dimension(BufferView const &) const { return button_.dimension(); }
42 void draw(PainterInfo & pi, int x, int y) const;
44 void write(Buffer const &, std::ostream & os) const
47 virtual void read(Buffer const &, Lexer & lex)
50 int latex(Buffer const &, odocstream &, OutputParams const &) const;
52 int plaintext(Buffer const &, odocstream &, OutputParams const &) const;
54 int docbook(Buffer const &, odocstream &, OutputParams const & runparams) const;
56 InsetCode lyxCode() const { return NO_CODE; }
58 InsetCommandParams const & params() const { return p_; }
60 docstring const getFirstNonOptParam() const { return p_.getFirstNonOptParam(); }
62 /// tell that the button label should be recomputed.
63 void refresh() { updateButtonLabel_ = true; }
65 void setParam(std::string const & name, docstring const & value)
67 updateButtonLabel_ = true;
71 docstring const & getParam(std::string const & name) const
76 void edit(Cursor & cur, bool left);
78 RenderButton & button() const { return button_; }
80 bool setMouseHover(bool mouse_hover);
84 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
86 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
88 docstring const getCommand() const { return p_.getCommand(); }
90 std::string const & getCmdName() const { return p_.getCmdName(); }
92 void setCmdName(std::string const & n)
94 updateButtonLabel_ = true;
98 void setParams(InsetCommandParams const &);
99 /// This should provide the text for the button
100 virtual docstring const getScreenLabel(Buffer const &) const = 0;
104 InsetCommandParams p_;
106 std::string mailer_name_;
107 /// changes color when mouse enters/leaves this inset
110 mutable bool updateButtonLabel_;
112 mutable RenderButton button_;
116 class InsetCommandMailer : public MailInset {
119 InsetCommandMailer(std::string const & name, InsetCommand & inset);
121 virtual Inset & inset() const { return inset_; }
123 virtual std::string const & name() const { return name_; }
125 virtual std::string const inset2string(Buffer const &) const;
126 /// returns true if params are successfully read
127 static bool string2params(std::string const &, std::string const & name,
128 InsetCommandParams &);
130 static std::string const params2string(std::string const & name,
131 InsetCommandParams const &);
134 std::string const name_;
136 InsetCommand & inset_;