]> git.lyx.org Git - lyx.git/blob - src/insets/InsetNewline.h
50a08face72a839fb31cf4bd139afe6ae4ebc538
[lyx.git] / src / insets / InsetNewline.h
1 // -*- C++ -*-
2 /**
3  * \file InsetNewline.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_NEWLINE_H
13 #define INSET_NEWLINE_H
14
15 #include "Inset.h"
16 #include "MailInset.h"
17
18 #include "support/docstring.h"
19 #include "support/gettext.h"
20
21
22 namespace lyx {
23
24 class InsetNewlineParams {
25 public:
26         /// The different kinds of spaces we support
27         enum Kind {
28                 ///
29                 NEWLINE,
30                 ///
31                 LINEBREAK
32         };
33         ///
34         InsetNewlineParams() : kind(NEWLINE) {}
35         ///
36         void write(std::ostream & os) const;
37         ///
38         void read(Lexer & lex);
39         ///
40         Kind kind;
41 };
42
43
44 class InsetNewline : public Inset
45 {
46 public:
47         ///
48         InsetNewline();
49         ///
50         InsetNewline(InsetNewlineParams par) { params_.kind = par.kind; }
51         ///
52         InsetNewlineParams params() const { return params_; }
53         ///
54         InsetCode lyxCode() const { return NEWLINE_CODE; }
55         ///
56         void metrics(MetricsInfo &, Dimension &) const;
57         ///
58         void draw(PainterInfo & pi, int x, int y) const;
59         ///
60         int latex(odocstream &, OutputParams const &) const;
61         ///
62         int plaintext(odocstream &, OutputParams const &) const;
63         ///
64         int docbook(odocstream &, OutputParams const &) const;
65         ///
66         void read(Lexer & lex);
67         ///
68         void write(std::ostream & os) const;
69         /// is this equivalent to a space (which is BTW different from
70         /// a line separator)?
71         bool isSpace() const { return true; }
72         ///
73         ColorCode ColorName() const;
74         ///
75         virtual docstring contextMenu(BufferView const & bv, int x, int y) const;
76
77 private:
78         ///
79         Inset * clone() const { return new InsetNewline(*this); }
80         ///
81         void doDispatch(Cursor & cur, FuncRequest & cmd);
82         ///
83         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
84         ///
85         InsetNewlineParams params_;
86 };
87
88
89 class InsetNewlineMailer : public MailInset {
90 public:
91         ///
92         InsetNewlineMailer(InsetNewline & inset);
93         ///
94         virtual Inset & inset() const { return inset_; }
95         ///
96         virtual std::string const & name() const { return name_; }
97         ///
98         virtual std::string const inset2string(Buffer const &) const;
99         ///
100         static void string2params(std::string const &, InsetNewlineParams &);
101         ///
102         static std::string const params2string(InsetNewlineParams const &);
103 private:
104         ///
105         static std::string const name_;
106         ///
107         InsetNewline & inset_;
108 };
109
110
111 } // namespace lyx
112
113 #endif // INSET_NEWLINE_H