]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBranch.h
Remove all BufferParam arguments in InsetXXX methods (since insets know about their...
[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         docstring branch() const { return params_.branch; }
56         ///
57         void rename(docstring const & newname) { params_.branch = newname; }
58
59 private:
60         ///
61         docstring editMessage() const;
62         ///
63         InsetCode lyxCode() const { return BRANCH_CODE; }
64         ///
65         void write(std::ostream &) const;
66         ///
67         void read(Lexer & lex);
68         ///
69         docstring const buttonLabel(BufferView const & bv) const;
70         ///
71         ColorCode backgroundColor() const;
72         ///
73         bool showInsetDialog(BufferView *) const;
74         ///
75         int latex(odocstream &, OutputParams const &) const;
76         ///
77         int plaintext(odocstream &, OutputParams const &) const;
78         ///
79         int docbook(odocstream &, OutputParams const &) const;
80         ///
81         docstring xhtml(odocstream &, OutputParams const &) const;
82         ///
83         void tocString(odocstream &) const;
84         ///
85         void validate(LaTeXFeatures &) const;
86         ///
87         docstring contextMenu(BufferView const &, int, int) const;
88         ///
89         void addToToc(DocIterator const &);
90         ///
91         InsetBranchParams const & params() const { return params_; }
92         ///
93         void setParams(InsetBranchParams const & params) { params_ = params; }
94         ///
95         virtual bool usePlainLayout() { return false; }
96
97         /** \returns true if params_.branch is listed as 'selected' in
98             \c buffer. This handles the case of child documents.
99          */
100         bool isBranchSelected() const;
101         /*!
102          * Is the content of this inset part of the output document?
103          *
104          * Note that Branch insets are only considered part of the
105          * document when they are selected.
106          */
107         bool producesOutput() const { return isBranchSelected(); }
108         ///
109         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
110         ///
111         bool isMacroScope() const;
112         ///
113         docstring toolTip(BufferView const & bv, int x, int y) const;
114         ///
115         bool usePlainLayout() const { return false; }
116         ///
117         void doDispatch(Cursor & cur, FuncRequest & cmd);
118         ///
119         docstring name() const { return from_ascii("Branch"); }
120         ///
121         Inset * clone() const { return new InsetBranch(*this); }
122
123         ///
124         friend class InsetBranchParams;
125         ///
126         InsetBranchParams params_;
127 };
128
129 } // namespace lyx
130
131 #endif