]> git.lyx.org Git - lyx.git/blob - src/insets/insetcommand.h
drop linuxdoc support (part 1)
[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 docbook(Buffer const &, std::ostream &,
57                             OutputParams const & runparams) const;
58         ///
59         InsetBase::Code lyxCode() const { return InsetBase::NO_CODE; }
60
61         ///
62         InsetCommandParams const & params() const { return p_; }
63         ///
64         std::string const & getContents() const { return p_.getContents(); }
65         ///
66         void setContents(std::string const & c)
67         {
68                 updateButtonLabel_ = true;
69                 p_.setContents(c);
70         }
71         ///
72         std::string const & getOptions() const { return p_.getOptions(); }
73         ///
74         std::string const & getSecOptions() const { return p_.getSecOptions(); }
75         ///
76         RenderButton & button() const { return button_; }
77
78 protected:
79         ///
80         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
81         ///
82         bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
83         ///
84         std::string const getCommand() const { return p_.getCommand(); }
85         ///
86         std::string const & getCmdName() const { return p_.getCmdName(); }
87         ///
88         void setCmdName(std::string const & n)
89         {
90                 updateButtonLabel_ = true;
91                 p_.setCmdName(n);
92         }
93         ///
94         void setOptions(std::string const & o)
95         {
96                 updateButtonLabel_ = true;
97                 p_.setOptions(o);
98         }
99         ///
100         void setSecOptions(std::string const & s)
101         {
102                 updateButtonLabel_ = true;
103                 p_.setSecOptions(s);
104         }
105         ///
106         void setParams(InsetCommandParams const &);
107         /// This should provide the text for the button
108         virtual std::string const getScreenLabel(Buffer const &) const = 0;
109
110 private:
111         ///
112         InsetCommandParams p_;
113         std::string mailer_name_;
114         mutable bool updateButtonLabel_;
115         mutable RenderButton button_;
116 };
117
118
119 class InsetCommandMailer : public MailInset {
120 public:
121         ///
122         InsetCommandMailer(std::string const & name, InsetCommand & inset);
123         ///
124         virtual InsetBase & inset() const { return inset_; }
125         ///
126         virtual std::string const & name() const { return name_; }
127         ///
128         virtual std::string const inset2string(Buffer const &) const;
129         ///
130         static void string2params(std::string const &, std::string const & name,
131                                   InsetCommandParams &);
132         ///
133         static std::string const params2string(std::string const & name,
134                                                InsetCommandParams const &);
135 private:
136         ///
137         std::string const name_;
138         ///
139         InsetCommand & inset_;
140 };
141
142
143 #endif