]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBranch.h
Get rid of regex_constants::match_partial
[lyx.git] / src / insets / InsetBranch.h
1 // -*- C++ -*-
2 /**
3  * \file InsetBranch.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Martin Vermeer
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef INSETBRANCH_H
13 #define INSETBRANCH_H
14
15 #include "InsetCollapsable.h"
16
17 namespace lyx {
18
19 class InsetBranchParams {
20 public:
21         ///
22         explicit InsetBranchParams(docstring const & b = docstring())
23                 : branch(b) {}
24         ///
25         void write(std::ostream & os) const;
26         ///
27         void read(Lexer & lex);
28         ///
29         docstring branch;
30 };
31
32
33 /////////////////////////////////////////////////////////////////////////
34 //
35 // InsetBranch
36 //
37 /////////////////////////////////////////////////////////////////////////
38
39 /// The Branch inset for alternative, conditional output.
40
41 class InsetBranch : public InsetCollapsable
42 {
43 public:
44         ///
45         InsetBranch(Buffer *, InsetBranchParams const &);
46
47         ///
48         static std::string params2string(InsetBranchParams const &);
49         ///
50         static void string2params(std::string const &, InsetBranchParams &);
51         ///
52         docstring branch() const { return params_.branch; }
53         ///
54         void rename(docstring const & newname) { params_.branch = newname; }
55
56 private:
57         ///
58         InsetCode lyxCode() const { return BRANCH_CODE; }
59         ///
60         void write(std::ostream &) const;
61         ///
62         void read(Lexer & lex);
63         ///
64         docstring const buttonLabel(BufferView const & bv) const;
65         ///
66         ColorCode backgroundColor(PainterInfo const &) const;
67         ///
68         void latex(otexstream &, OutputParams const &) const;
69         ///
70         int plaintext(odocstringstream & ods, OutputParams const & op,
71                       size_t max_length = INT_MAX) const;
72         ///
73         int docbook(odocstream &, OutputParams const &) const;
74         ///
75         docstring xhtml(XHTMLStream &, OutputParams const &) const;
76         ///
77         void toString(odocstream &) const;
78         ///
79         void forOutliner(docstring &, size_t) const;
80         ///
81         void validate(LaTeXFeatures &) const;
82         ///
83         std::string contextMenuName() const;
84         ///
85         void addToToc(DocIterator const & di, bool output_active) const;
86         ///
87         InsetBranchParams const & params() const { return params_; }
88         ///
89         void setParams(InsetBranchParams const & params) { params_ = params; }
90
91         /** \returns true if params_.branch is listed as 'selected' in
92                 \c buffer. \p child only checks within child documents.
93          */
94         bool isBranchSelected(bool const child = false) const;
95         /*!
96          * Is the content of this inset part of the output document?
97          *
98          * Note that Branch insets are only considered part of the
99          * document when they are selected.
100          */
101         bool producesOutput() const { return isBranchSelected(); }
102         ///
103         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
104         ///
105         bool isMacroScope() const;
106         ///
107         docstring toolTip(BufferView const & bv, int x, int y) const;
108         ///
109         bool usePlainLayout() const { return false; }
110         ///
111         void doDispatch(Cursor & cur, FuncRequest & cmd);
112         ///
113         docstring layoutName() const { return from_ascii("Branch:") + branch(); }
114         ///
115         Inset * clone() const { return new InsetBranch(*this); }
116
117         ///
118         friend class InsetBranchParams;
119         ///
120         InsetBranchParams params_;
121 };
122
123 } // namespace lyx
124
125 #endif