]> git.lyx.org Git - lyx.git/blob - src/insets/InsetSeparator.h
b824214ae7914e3e2e1b8fcfbab91d90cee39139
[lyx.git] / src / insets / InsetSeparator.h
1 // -*- C++ -*-
2 /**
3  * \file InsetSeparator.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Enrico Forestieri
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSET_SEPARATOR_H
13 #define INSET_SEPARATOR_H
14
15 #include "Inset.h"
16
17
18 namespace lyx {
19
20 class InsetSeparatorParams
21 {
22 public:
23         /// The different kinds of separators we support
24         enum Kind {
25                 PLAIN,
26                 PARBREAK,
27                 LATEXPAR
28         };
29         ///
30         InsetSeparatorParams() : kind(PLAIN) {}
31         ///
32         void write(std::ostream & os) const;
33         ///
34         void read(Lexer & lex);
35         ///
36         Kind kind;
37 };
38
39
40 class InsetSeparator : public Inset
41 {
42 public:
43         ///
44         InsetSeparator();
45         ///
46         explicit InsetSeparator(InsetSeparatorParams const & params);
47         ///
48         static void string2params(std::string const &, InsetSeparatorParams &);
49         ///
50         static std::string params2string(InsetSeparatorParams const &);
51         /// To be used in combination with inset-forall
52         /// Here's a command that removes every latexpar separator:
53         ///   inset-forall Separator:latexpar char-delete-forward
54         docstring layoutName() const override
55         {
56                 switch (params_.kind) {
57                 case InsetSeparatorParams::PLAIN:
58                         return from_ascii("Separator:plain");
59                 case InsetSeparatorParams::PARBREAK:
60                         return from_ascii("Separator:parbreak");
61                 case InsetSeparatorParams::LATEXPAR:
62                         return from_ascii("Separator:latexpar");
63                 }
64                 // remove warning
65                 return docstring();
66         }
67         ///
68         int rowFlags() const override { return BreakAfter | Flush; }
69         ///
70         bool nextnoindent() const { return params_.kind == InsetSeparatorParams::PLAIN; }
71 private:
72         ///
73         InsetCode lyxCode() const override { return SEPARATOR_CODE; }
74         ///
75         void metrics(MetricsInfo &, Dimension &) const override;
76         ///
77         void draw(PainterInfo & pi, int x, int y) const override;
78         ///
79         void latex(otexstream &, OutputParams const &) const override;
80         ///
81         int plaintext(odocstringstream & ods, OutputParams const & op,
82                       size_t max_length = INT_MAX) const override;
83         ///
84         void docbook(XMLStream &, OutputParams const &) const override;
85         ///
86         docstring xhtml(XMLStream &, OutputParams const &) const override;
87         ///
88         void read(Lexer & lex) override;
89         ///
90         void write(std::ostream & os) const override;
91         /// is this equivalent to a space (which is BTW different from
92         /// a line separator)?
93         bool isSpace() const override { return true; }
94         ///
95         ColorCode ColorName() const;
96         ///
97         std::string contextMenuName() const override;
98         ///
99         Inset * clone() const override { return new InsetSeparator(*this); }
100         ///
101         void doDispatch(Cursor & cur, FuncRequest & cmd) override;
102         ///
103         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const override;
104
105         ///
106         InsetSeparatorParams params_;
107 };
108
109
110 } // namespace lyx
111
112 #endif // INSET_SEPARATOR_H