]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBranch.h
more border tweaks
[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 #include "MailInset.h"
17
18
19 namespace lyx {
20
21 class InsetBranchParams {
22 public:
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 /** The Branch inset for alternative, conditional output.
35
36 */
37 class InsetBranch : public InsetCollapsable {
38 public:
39         ///
40         InsetBranch(Buffer const &, InsetBranchParams const &);
41         ///
42         ~InsetBranch();
43         ///
44         docstring editMessage() const;
45         ///
46         InsetCode lyxCode() const { return BRANCH_CODE; }
47         ///
48         void write(std::ostream &) const;
49         ///
50         void read(Lexer & lex);
51         ///
52         void setButtonLabel();
53         ///
54         virtual ColorCode backgroundColor() const;
55         ///
56         bool showInsetDialog(BufferView *) const;
57         ///
58         int latex(odocstream &, OutputParams const &) const;
59         ///
60         int plaintext(odocstream &, OutputParams const &) const;
61         ///
62         int docbook(odocstream &, OutputParams const &) const;
63         ///
64         void textString(odocstream &) const;
65         ///
66         void validate(LaTeXFeatures &) const;
67         ///
68         InsetBranchParams const & params() const { return params_; }
69         ///
70         void setParams(InsetBranchParams const & params) { params_ = params; }
71
72         /** \returns true if params_.branch is listed as 'selected' in
73             \c buffer. This handles the case of child documents.
74          */
75         bool isBranchSelected() const;
76         ///
77         bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
78         ///
79         virtual void updateLabels(ParIterator const &);
80         ///
81         bool isMacroScope() const;
82         ///
83         docstring toolTip(BufferView const & bv, int x, int y) const;
84         ///
85         virtual bool useEmptyLayout() const { return false; }
86 protected:
87         ///
88         void doDispatch(Cursor & cur, FuncRequest & cmd);
89         ///
90         docstring name() const { return from_ascii("Branch"); }
91 private:
92         ///
93         friend class InsetBranchParams;
94         ///
95         Inset * clone() const { return new InsetBranch(*this); }
96         ///
97         InsetBranchParams params_;
98 };
99
100
101 class InsetBranchMailer : public MailInset {
102 public:
103         ///
104         InsetBranchMailer(InsetBranch & inset);
105         ///
106         virtual Inset & inset() const { return inset_; }
107         ///
108         virtual std::string const & name() const { return name_; }
109         ///
110         virtual std::string const inset2string(Buffer const &) const;
111         ///
112         static std::string const params2string(InsetBranchParams const &);
113         ///
114         static void string2params(std::string const &, InsetBranchParams &);
115
116 private:
117         ///
118         static std::string const name_;
119         ///
120         InsetBranch & inset_;
121 };
122
123 } // namespace lyx
124
125 #endif