]> git.lyx.org Git - lyx.git/blob - src/insets/insetcommand.h
implement missing getStatus methods
[lyx.git] / src / insets / insetcommand.h
1 // -*- C++ -*-
2 /**
3  * \file insetcommand.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  * \author Lars Gullik Bjønnes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef INSET_LATEXCOMMAND_H
14 #define INSET_LATEXCOMMAND_H
15
16 #include "inset.h"
17 #include "insetcommandparams.h"
18 #include "render_button.h"
19 #include "mailinset.h"
20 #include "cursor.h"
21
22
23 // Created by Alejandro 970222
24 /** Used to insert a LaTeX command automatically
25  *
26  * Similar to InsetLaTeX but having control of the basic structure of a
27  *   LaTeX command: \name[options]{contents}.
28  */
29
30 ///
31 class InsetCommand : public InsetOld {
32 public:
33         ///
34         InsetCommand(InsetCommandParams const &, std::string const & mailer_name);
35         ///
36         ~InsetCommand();
37         ///
38         void metrics(MetricsInfo &, Dimension &) const;
39         ///
40         void draw(PainterInfo & pi, int x, int y) const;
41         ///
42         void write(Buffer const &, std::ostream & os) const
43                 { p_.write(os); }
44         ///
45         virtual void read(Buffer const &, LyXLex & lex)
46                 { p_.read(lex); }
47         /// Can remove one InsetBibKey is modified
48         void scanCommand(std::string const & c) { p_.scanCommand(c); };
49         ///
50         virtual int latex(Buffer const &, std::ostream &,
51                           OutputParams const &) const;
52         ///
53         int plaintext(Buffer const &, std::ostream &,
54                   OutputParams const &) const;
55         ///
56         virtual int linuxdoc(Buffer const &, std::ostream &,
57                              OutputParams const &) const;
58         ///
59         virtual int docbook(Buffer const &, std::ostream &,
60                             OutputParams const & runparams) const;
61         ///
62         InsetBase::Code lyxCode() const { return InsetBase::NO_CODE; }
63
64         ///
65         InsetCommandParams const & params() const { return p_; }
66         ///
67         std::string const & getContents() const { return p_.getContents(); }
68         ///
69         void setContents(std::string const & c) { p_.setContents(c); }
70         ///
71         std::string const & getOptions() const { return p_.getOptions(); }
72         ///
73         std::string const & getSecOptions() const { return p_.getSecOptions(); }
74         ///
75         RenderButton & button() const { return button_; }
76
77 protected:
78         ///
79         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
80         ///
81         bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
82         ///
83         std::string const getCommand() const { return p_.getCommand(); }
84         ///
85         std::string const & getCmdName() const { return p_.getCmdName(); }
86         ///
87         void setCmdName(std::string const & n) { p_.setCmdName(n); }
88         ///
89         void setOptions(std::string const & o) { p_.setOptions(o); }
90         ///
91         void setSecOptions(std::string const & s) { p_.setSecOptions(s); }
92         ///
93         void setParams(InsetCommandParams const &);
94         /// This should provide the text for the button
95         virtual std::string const getScreenLabel(Buffer const &) const = 0;
96
97 private:
98         ///
99         InsetCommandParams p_;
100         std::string mailer_name_;
101         mutable bool set_label_;
102         mutable RenderButton button_;
103 };
104
105
106 class InsetCommandMailer : public MailInset {
107 public:
108         ///
109         InsetCommandMailer(std::string const & name, InsetCommand & inset);
110         ///
111         virtual InsetBase & inset() const { return inset_; }
112         ///
113         virtual std::string const & name() const { return name_; }
114         ///
115         virtual std::string const inset2string(Buffer const &) const;
116         ///
117         static void string2params(std::string const &, std::string const & name,
118                                   InsetCommandParams &);
119         ///
120         static std::string const params2string(std::string const & name,
121                                                InsetCommandParams const &);
122 private:
123         ///
124         std::string const name_;
125         ///
126         InsetCommand & inset_;
127 };
128
129
130 #endif