]> git.lyx.org Git - lyx.git/blob - src/insets/InsetSeparator.h
Fix indentation
[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 & par);
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
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 private:
68         ///
69         InsetCode lyxCode() const { return SEPARATOR_CODE; }
70         ///
71         void metrics(MetricsInfo &, Dimension &) const;
72         ///
73         void draw(PainterInfo & pi, int x, int y) const;
74         ///
75         void latex(otexstream &, OutputParams const &) const;
76         ///
77         int plaintext(odocstringstream & ods, OutputParams const & op,
78                       size_t max_length = INT_MAX) const;
79         ///
80         int docbook(odocstream &, OutputParams const &) const;
81         ///
82         docstring xhtml(XHTMLStream &, OutputParams const &) const;
83         ///
84         void read(Lexer & lex);
85         ///
86         void write(std::ostream & os) const;
87         /// is this equivalent to a space (which is BTW different from
88         /// a line separator)?
89         bool isSpace() const { return true; }
90         ///
91         ColorCode ColorName() const;
92         ///
93         std::string contextMenuName() const;
94         ///
95         Inset * clone() const { return new InsetSeparator(*this); }
96         ///
97         void doDispatch(Cursor & cur, FuncRequest & cmd);
98         ///
99         bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
100
101         ///
102         InsetSeparatorParams params_;
103 };
104
105
106 } // namespace lyx
107
108 #endif // INSET_SEPARATOR_H