]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.h
Rename ascii to plaintext and LatexRunParams to OutputParams.
[lyx.git] / src / insets / insetinclude.h
1 // -*- C++ -*-
2 /**
3  * \file insetinclude.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_INCLUDE_H
13 #define INSET_INCLUDE_H
14
15 #include "inset.h"
16 #include "insetcommandparams.h"
17 #include "render_button.h"
18 #include <boost/scoped_ptr.hpp>
19
20 class Buffer;
21 class Dimension;
22 struct LaTeXFeatures;
23 class RenderMonitoredPreview;
24
25
26 /// for including tex/lyx files
27 class InsetInclude: public InsetOld {
28 public:
29         ///
30         InsetInclude(InsetCommandParams const &);
31         InsetInclude(InsetInclude const &);
32         ~InsetInclude();
33
34         ///
35         virtual std::auto_ptr<InsetBase> clone() const;
36
37         /// Override these InsetButton methods if Previewing
38         void metrics(MetricsInfo & mi, Dimension & dim) const;
39         ///
40         void draw(PainterInfo & pi, int x, int y) const;
41         ///
42         virtual bool display() const { return true; }
43
44         /// get the parameters
45         InsetCommandParams const & params(void) const;
46
47         ///
48         InsetOld::Code lyxCode() const { return InsetOld::INCLUDE_CODE; }
49         /** Fills \c list
50          *  \param buffer the Buffer containing this inset.
51          *  \param list the list of labels in the child buffer.
52          */
53         void getLabelList(Buffer const & buffer,
54                           std::vector<std::string> & list) const;
55         /** Fills \c keys
56          *  \param buffer the Buffer containing this inset.
57          *  \param keys the list of bibkeys in the child buffer.
58          */
59         ///
60         void fillWithBibKeys(Buffer const & buffer,
61                 std::vector<std::pair<std::string,std::string> > & keys) const;
62         ///
63         EDITABLE editable() const { return IS_EDITABLE; }
64         ///
65         void write(Buffer const &, std::ostream &) const;
66         ///
67         void read(Buffer const &, LyXLex &);
68         ///
69         int latex(Buffer const &, std::ostream &,
70                   OutputParams const &) const;
71         ///
72         int plaintext(Buffer const &, std::ostream &,
73                   OutputParams const &) const;
74         ///
75         int linuxdoc(Buffer const &, std::ostream &,
76                      OutputParams const &) const;
77         ///
78         int docbook(Buffer const &, std::ostream &,
79                     OutputParams const &) const;
80         ///
81         void validate(LaTeXFeatures &) const;
82         ///
83         void addPreview(lyx::graphics::PreviewLoader &) const;
84 protected:
85         ///
86         virtual
87         DispatchResult
88         priv_dispatch(FuncRequest const & cmd, idx_type &, pos_type &);
89 private:
90         /// Slot receiving a signal that the preview is ready to display.
91         void statusChanged() const;
92         /** Slot receiving a signal that the external file has changed
93          *  and the preview should be regenerated.
94          */
95         void fileChanged() const;
96
97         friend class InsetIncludeMailer;
98
99         /// set the parameters
100         void set(InsetCommandParams const & params, Buffer const &);
101         /// get the text displayed on the button
102         std::string const getScreenLabel(Buffer const &) const;
103         ///
104         void write(std::ostream &) const;
105         ///
106         void read(LyXLex &);
107
108         /// the parameters
109         InsetCommandParams params_;
110         /// holds the entity name that defines the file location (SGML)
111         std::string const include_label;
112
113         /// The pointer never changes although *preview_'s contents may.
114         boost::scoped_ptr<RenderMonitoredPreview> const preview_;
115
116         /// cache
117         mutable bool set_label_;
118         mutable RenderButton button_;
119 };
120
121
122 #include "mailinset.h"
123
124 class InsetIncludeMailer : public MailInset {
125 public:
126         ///
127         InsetIncludeMailer(InsetInclude & inset);
128         ///
129         virtual InsetBase & inset() const { return inset_; }
130         ///
131         virtual std::string const & name() const { return name_; }
132         ///
133         virtual std::string const inset2string(Buffer const &) const;
134         ///
135         static void string2params(std::string const &, InsetCommandParams &);
136         ///
137         static std::string const params2string(InsetCommandParams const &);
138 private:
139         ///
140         static std::string const name_;
141         ///
142         InsetInclude & inset_;
143 };
144
145 #endif // INSETINCLUDE_H