]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBranch.h
InsetInfo: enable inset dissolve
[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 "InsetCollapsible.h"
16
17 namespace lyx {
18
19 class InsetBranchParams {
20 public:
21         ///
22         explicit InsetBranchParams(docstring const & b = docstring())
23                 : branch(b), inverted(false) {}
24         InsetBranchParams(docstring const & b, bool i)
25                 : branch(b), inverted(i) {}
26         ///
27         void write(std::ostream & os) const;
28         ///
29         void read(Lexer & lex);
30         ///
31         docstring branch;
32         ///
33         bool inverted;
34 };
35
36
37 /////////////////////////////////////////////////////////////////////////
38 //
39 // InsetBranch
40 //
41 /////////////////////////////////////////////////////////////////////////
42
43 /// The Branch inset for alternative, conditional output.
44
45 class InsetBranch : public InsetCollapsible
46 {
47 public:
48         ///
49         InsetBranch(Buffer *, InsetBranchParams const &);
50
51         ///
52         static std::string params2string(InsetBranchParams const &);
53         ///
54         static void string2params(std::string const &, InsetBranchParams &);
55         ///
56         docstring branch() const { return params_.branch; }
57         ///
58         void rename(docstring const & newname) { params_.branch = newname; }
59         ///
60         InsetBranchParams const & params() const { return params_; }
61
62 private:
63         ///
64         InsetCode lyxCode() const { return BRANCH_CODE; }
65         ///
66         void write(std::ostream &) const;
67         ///
68         void read(Lexer & lex);
69         ///
70         docstring const buttonLabel(BufferView const &) const;
71         ///
72         ColorCode backgroundColor(PainterInfo const &) const;
73         ///
74         void latex(otexstream &, OutputParams const &) const;
75         ///
76         int plaintext(odocstringstream & ods, OutputParams const & op,
77                       size_t max_length = INT_MAX) const;
78         ///
79         int docbook(odocstream &, OutputParams const &) const;
80         ///
81         docstring xhtml(XHTMLStream &, OutputParams const &) const;
82         ///
83         void toString(odocstream &) const;
84         ///
85         void forOutliner(docstring &, size_t const, bool const) const;
86         ///
87         void validate(LaTeXFeatures &) const;
88         ///
89         std::string contextMenuName() const;
90         ///
91         void updateBuffer(ParIterator const & it, UpdateType utype);
92         ///
93         void setParams(InsetBranchParams const & params) { params_ = params; }
94
95         /** \returns true if params_.branch is listed as 'selected' in
96                 \c buffer. \p child only checks within child documents.
97          */
98         bool isBranchSelected(bool const child = false) const;
99         /*!
100          * Is the content of this inset part of the output document?
101          *
102          * Note that Branch insets are considered part of the
103          * document when they are selected XOR inverted.
104          */
105         bool producesOutput() const;
106         ///
107         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
108         ///
109         bool isMacroScope() const;
110         ///
111         docstring toolTip(BufferView const & bv, int x, int y) const;
112         ///
113         bool usePlainLayout() const { return false; }
114         ///
115         void doDispatch(Cursor & cur, FuncRequest & cmd);
116         ///
117         docstring layoutName() const { return from_ascii("Branch:") + branch(); }
118         ///
119         Inset * clone() const { return new InsetBranch(*this); }
120
121         ///
122         friend class InsetBranchParams;
123         ///
124         InsetBranchParams params_;
125 };
126
127 } // namespace lyx
128
129 #endif