]> git.lyx.org Git - lyx.git/blob - src/insets/insetinclude.h
The speed patch: redraw only rows that have changed
[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 class 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();
32
33         /// Override these InsetButton methods if Previewing
34         void metrics(MetricsInfo & mi, Dimension & dim) const;
35         ///
36         void draw(PainterInfo & pi, int x, int y) const;
37         ///
38         virtual bool display() const;
39
40         /// get the parameters
41         InsetCommandParams const & params(void) const;
42
43         ///
44         InsetBase::Code lyxCode() const { return InsetBase::INCLUDE_CODE; }
45         /** Fills \c list
46          *  \param buffer the Buffer containing this inset.
47          *  \param list the list of labels in the child buffer.
48          */
49         void getLabelList(Buffer const & buffer,
50                           std::vector<std::string> & list) const;
51         /** Fills \c keys
52          *  \param buffer the Buffer containing this inset.
53          *  \param keys the list of bibkeys in the child buffer.
54          */
55         ///
56         void fillWithBibKeys(Buffer const & buffer,
57                 std::vector<std::pair<std::string,std::string> > & keys) const;
58         ///
59         EDITABLE editable() const { return IS_EDITABLE; }
60         ///
61         void write(Buffer const &, std::ostream &) const;
62         ///
63         void read(Buffer const &, LyXLex &);
64         ///
65         int latex(Buffer const &, std::ostream &,
66                   OutputParams const &) const;
67         ///
68         int plaintext(Buffer const &, std::ostream &,
69                   OutputParams const &) const;
70         ///
71         int linuxdoc(Buffer const &, std::ostream &,
72                      OutputParams const &) const;
73         ///
74         int docbook(Buffer const &, std::ostream &,
75                     OutputParams const &) const;
76         ///
77         void validate(LaTeXFeatures &) const;
78         ///
79         void addPreview(lyx::graphics::PreviewLoader &) const;
80         ///
81         bool getStatus(LCursor &, FuncRequest const &, FuncStatus &) const;
82 protected:
83         InsetInclude(InsetInclude const &);
84         ///
85         virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
86 private:
87         virtual std::auto_ptr<InsetBase> doClone() const;
88
89         /** Slot receiving a signal that the external file has changed
90          *  and the preview should be regenerated.
91          */
92         void fileChanged() const;
93
94         friend class InsetIncludeMailer;
95
96         /// set the parameters
97         void set(InsetCommandParams const & params, Buffer const &);
98         /// get the text displayed on the button
99         std::string const getScreenLabel(Buffer const &) const;
100         ///
101         void write(std::ostream &) const;
102         ///
103         void read(LyXLex &);
104
105         /// the parameters
106         InsetCommandParams params_;
107         /// holds the entity name that defines the file location (SGML)
108         std::string const include_label;
109
110         /// The pointer never changes although *preview_'s contents may.
111         boost::scoped_ptr<RenderMonitoredPreview> const preview_;
112
113         /// cache
114         mutable bool set_label_;
115         mutable RenderButton button_;
116 };
117
118
119 #include "mailinset.h"
120
121 class InsetIncludeMailer : public MailInset {
122 public:
123         ///
124         InsetIncludeMailer(InsetInclude & inset);
125         ///
126         virtual InsetBase & inset() const { return inset_; }
127         ///
128         virtual std::string const & name() const { return name_; }
129         ///
130         virtual std::string const inset2string(Buffer const &) const;
131         ///
132         static void string2params(std::string const &, InsetCommandParams &);
133         ///
134         static std::string const params2string(InsetCommandParams const &);
135 private:
136         ///
137         static std::string const name_;
138         ///
139         InsetInclude & inset_;
140 };
141
142 #endif // INSETINCLUDE_H