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