]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBranch.h
Fix the fix for bug 4346: http://bugzilla.lyx.org/show_bug.cgi?id=4346.
[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
18 namespace lyx {
19
20 class InsetBranchParams {
21 public:
22         ///
23         explicit InsetBranchParams(docstring const & b = docstring())
24                 : branch(b) {}
25         ///
26         void write(std::ostream & os) const;
27         ///
28         void read(Lexer & lex);
29         ///
30         docstring branch;
31 };
32
33
34 /////////////////////////////////////////////////////////////////////////
35 //
36 // InsetBranch
37 //
38 /////////////////////////////////////////////////////////////////////////
39
40 /// The Branch inset for alternative, conditional output.
41
42 class InsetBranch : public InsetCollapsable
43 {
44 public:
45         ///
46         InsetBranch(Buffer const &, InsetBranchParams const &);
47         ///
48         ~InsetBranch();
49
50         ///
51         static std::string params2string(InsetBranchParams const &);
52         ///
53         static void string2params(std::string const &, InsetBranchParams &);
54
55 private:
56         ///
57         docstring editMessage() const;
58         ///
59         InsetCode lyxCode() const { return BRANCH_CODE; }
60         ///
61         void write(std::ostream &) const;
62         ///
63         void read(Lexer & lex);
64         ///
65         docstring const buttonLabel(BufferView const & bv) const;
66         ///
67         ColorCode backgroundColor() const;
68         ///
69         bool showInsetDialog(BufferView *) const;
70         ///
71         int latex(odocstream &, OutputParams const &) const;
72         ///
73         int plaintext(odocstream &, OutputParams const &) const;
74         ///
75         int docbook(odocstream &, OutputParams const &) const;
76         ///
77         void tocString(odocstream &) const;
78         ///
79         void validate(LaTeXFeatures &) const;
80         ///
81         void addToToc(DocIterator const &);
82         ///
83         InsetBranchParams const & params() const { return params_; }
84         ///
85         void setParams(InsetBranchParams const & params) { params_ = params; }
86         ///
87         virtual bool usePlainLayout() { return false; }
88
89         /** \returns true if params_.branch is listed as 'selected' in
90             \c buffer. This handles the case of child documents.
91          */
92         bool isBranchSelected() const;
93         /*!
94          * Is the content of this inset part of the output document?
95          *
96          * Note that Branch insets are only considered part of the
97          * document when they are selected.
98          */
99         bool producesOutput() const { return isBranchSelected(); }
100         ///
101         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
102         ///
103         bool isMacroScope() const;
104         ///
105         docstring toolTip(BufferView const & bv, int x, int y) const;
106         ///
107         bool usePlainLayout() const { return false; }
108         ///
109         void doDispatch(Cursor & cur, FuncRequest & cmd);
110         ///
111         docstring name() const { return from_ascii("Branch"); }
112         ///
113         Inset * clone() const { return new InsetBranch(*this); }
114
115         ///
116         friend class InsetBranchParams;
117         ///
118         InsetBranchParams params_;
119 };
120
121 } // namespace lyx
122
123 #endif