4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Martin Vermeer
9 * Full author contact details are available in file CREDITS.
15 #include "InsetCollapsable.h"
16 #include "MailInset.h"
23 class InsetBranchParams {
25 explicit InsetBranchParams(docstring const & b = docstring())
28 void write(std::ostream & os) const;
30 void read(Lexer & lex);
36 /** The Branch inset for alternative, conditional output.
39 class InsetBranch : public InsetCollapsable {
42 InsetBranch(BufferParams const &, InsetBranchParams const &);
46 virtual docstring const editMessage() const;
48 InsetCode lyxCode() const { return BRANCH_CODE; }
50 void write(Buffer const &, std::ostream &) const;
52 void read(Buffer const & buf, Lexer & lex);
54 void setButtonLabel();
56 virtual Color_color backgroundColor() const;
58 bool showInsetDialog(BufferView *) const;
60 int latex(Buffer const &, odocstream &,
61 OutputParams const &) const;
63 int plaintext(Buffer const &, odocstream &,
64 OutputParams const &) const;
66 int docbook(Buffer const &, odocstream &,
67 OutputParams const &) const;
69 void textString(Buffer const & buf, odocstream &) const;
71 void validate(LaTeXFeatures &) const;
73 InsetBranchParams const & params() const { return params_; }
75 void setParams(InsetBranchParams const & params) { params_ = params; }
77 /** \returns true if params_.branch is listed as 'selected' in
78 \c buffer. This handles the case of child documents.
80 bool isBranchSelected(Buffer const & buffer) const;
82 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
84 virtual void updateLabels(Buffer const &, ParIterator const &);
87 InsetBranch(InsetBranch const &);
89 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
91 docstring name() const { return from_ascii("Branch"); }
93 friend class InsetBranchParams;
95 virtual Inset * clone() const;
97 /// used by the constructors
100 InsetBranchParams params_;
104 class InsetBranchMailer : public MailInset {
107 InsetBranchMailer(InsetBranch & inset);
109 virtual Inset & inset() const { return inset_; }
111 virtual std::string const & name() const { return name_; }
113 virtual std::string const inset2string(Buffer const &) const;
115 static std::string const params2string(InsetBranchParams const &);
117 static void string2params(std::string const &, InsetBranchParams &);
121 static std::string const name_;
123 InsetBranch & inset_;