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 INSETCOMMAND_H
14 #define INSETCOMMAND_H
17 #include "InsetCommandParams.h"
18 #include "RenderButton.h"
25 /////////////////////////////////////////////////////////////////////////
29 /////////////////////////////////////////////////////////////////////////
31 // Created by Alejandro 970222
32 // Used to insert a LaTeX command automatically.
34 class InsetCommand : public Inset
38 InsetCommand(InsetCommandParams const &, std::string const & mailer_name);
42 /// returns true if params are successfully read
43 static bool string2params(std::string const &, std::string const & name,
44 InsetCommandParams &);
46 static std::string params2string(std::string const & name,
47 InsetCommandParams const &);
49 InsetCommandParams const & params() const { return p_; }
51 void setParams(InsetCommandParams const &);
53 void setParam(std::string const & name, docstring const & value);
55 docstring const & getParam(std::string const & name) const;
57 docstring const getFirstNonOptParam() const { return p_.getFirstNonOptParam(); }
58 /// update label and references.
59 virtual void updateCommand(docstring const &, bool) {}
63 void write(std::ostream & os) const { p_.write(os); }
65 void read(Lexer & lex) { p_.read(lex); }
67 void doDispatch(Cursor & cur, FuncRequest & cmd);
69 docstring const getCommand() const { return p_.getCommand(); }
71 std::string const & getCmdName() const { return p_.getCmdName(); }
73 void setCmdName(std::string const & n) { p_.setCmdName(n); }
77 void metrics(MetricsInfo &, Dimension &) const;
79 Dimension const dimension(BufferView const &) const { return button_.dimension(); }
81 void draw(PainterInfo & pi, int x, int y) const;
83 int latex(odocstream &, OutputParams const &) const;
85 int plaintext(odocstream &, OutputParams const &) const;
87 int docbook(odocstream &, OutputParams const & runparams) const;
89 InsetCode lyxCode() const { return NO_CODE; }
91 void edit(Cursor & cur, bool front,
92 EntryDirection entry_from = ENTRY_DIRECTION_IGNORE);
94 RenderButton & button() const { return button_; }
96 bool setMouseHover(bool mouse_hover);
97 /// Return parameter information for command cmdName.
98 /// Not implemented here. Must be implemented in derived class.
99 static ParamInfo const & findInfo(std::string const & cmdName);
100 /// Return default command for this inset.
101 /// Not implemented here. Must be implemented in derived class.
102 static std::string defaultCommand();
103 /// Whether this is a command this inset can represent.
104 /// Not implemented here. Must be implemented in derived class.
105 static bool isCompatibleCommand(std::string const & cmd);
107 docstring contextMenu(BufferView const & bv, int x, int y) const;
109 bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
110 /// This should provide the text for the button
111 virtual docstring screenLabel() const = 0;
115 InsetCommandParams p_;
117 std::string mailer_name_;
118 /// changes color when mouse enters/leaves this inset
121 mutable RenderButton button_;