]> git.lyx.org Git - lyx.git/blob - src/insets/InsetBranch.h
Fix GRAPHICS_EDIT of InsetGraphics
[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 protected:
85         ///
86         void doDispatch(Cursor & cur, FuncRequest & cmd);
87         ///
88         docstring name() const { return from_ascii("Branch"); }
89 private:
90         ///
91         friend class InsetBranchParams;
92         ///
93         Inset * clone() const { return new InsetBranch(*this); }
94         ///
95         InsetBranchParams params_;
96 };
97
98
99 class InsetBranchMailer : public MailInset {
100 public:
101         ///
102         InsetBranchMailer(InsetBranch & inset);
103         ///
104         virtual Inset & inset() const { return inset_; }
105         ///
106         virtual std::string const & name() const { return name_; }
107         ///
108         virtual std::string const inset2string(Buffer const &) const;
109         ///
110         static std::string const params2string(InsetBranchParams const &);
111         ///
112         static void string2params(std::string const &, InsetBranchParams &);
113
114 private:
115         ///
116         static std::string const name_;
117         ///
118         InsetBranch & inset_;
119 };
120
121 } // namespace lyx
122
123 #endif