]> git.lyx.org Git - lyx.git/blob - src/insets/InsetWrap.h
This should be the last of the commits refactoring the InsetLayout code.
[lyx.git] / src / insets / InsetWrap.h
1 // -*- C++ -*-
2 /**
3  * \file InsetWrap.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Dekel Tsur
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETWRAP_H
13 #define INSETWRAP_H
14
15 #include "InsetCollapsable.h"
16 #include "Length.h"
17 #include "MailInset.h"
18
19
20 namespace lyx {
21
22
23 class InsetWrapParams {
24 public:
25         ///
26         void write(std::ostream &) const;
27         ///
28         void read(Lexer &);
29
30         ///
31         std::string type;
32         ///
33         int lines;
34         ///
35         std::string placement;
36         ///
37         Length overhang;
38         ///
39         Length width;
40 };
41
42
43 /** The wrap inset
44  */
45 class InsetWrap : public InsetCollapsable {
46 public:
47         ///
48         InsetWrap(BufferParams const &, std::string const &);
49         ///
50         ~InsetWrap();
51         ///
52         void write(Buffer const & buf, std::ostream & os) const;
53         ///
54         void read(Buffer const & buf, Lexer & lex);
55         ///
56         void validate(LaTeXFeatures & features) const;
57         ///
58         InsetCode lyxCode() const { return WRAP_CODE; }
59         ///
60         bool isMacroScope(Buffer const &) const { return true; }
61         ///
62         int latex(Buffer const &, odocstream &,
63                   OutputParams const &) const;
64         ///
65         int plaintext(Buffer const &, odocstream &,
66                       OutputParams const &) const;
67         ///
68         int docbook(Buffer const &, odocstream &,
69                     OutputParams const &) const;
70         ///
71         virtual docstring const editMessage() const;
72         ///
73         bool insetAllowed(InsetCode) const;
74         ///
75         bool showInsetDialog(BufferView *) const;
76         ///
77         InsetWrapParams const & params() const { return params_; }
78         ///
79         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
80         // Update the counters of this inset and of its contents
81         virtual void updateLabels(Buffer const &, ParIterator const &);
82 protected:
83         ///
84         virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
85         ///
86         virtual docstring name() const { return name_; }
87 private:
88         virtual Inset * clone() const;
89
90         ///
91         InsetWrapParams params_;
92         ///
93         docstring name_;
94 };
95
96
97 class InsetWrapMailer : public MailInset {
98 public:
99         ///
100         InsetWrapMailer(InsetWrap & inset);
101         ///
102         virtual Inset & inset() const { return inset_; }
103         ///
104         virtual std::string const & name() const { return name_; }
105         ///
106         virtual std::string const inset2string(Buffer const &) const;
107         ///
108         static void string2params(std::string const &, InsetWrapParams &);
109         ///
110         static std::string const params2string(InsetWrapParams const &);
111 private:
112         ///
113         static std::string const name_;
114         ///
115         InsetWrap & inset_;
116 };
117
118
119 } // namespace lyx
120
121 #endif