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"
19 class InsetBranchParams {
22 explicit InsetBranchParams(docstring const & b = docstring())
25 void write(std::ostream & os) const;
27 void read(Lexer & lex);
33 /////////////////////////////////////////////////////////////////////////
37 /////////////////////////////////////////////////////////////////////////
39 /// The Branch inset for alternative, conditional output.
41 class InsetBranch : public InsetCollapsable
45 InsetBranch(Buffer *, InsetBranchParams const &);
48 static std::string params2string(InsetBranchParams const &);
50 static void string2params(std::string const &, InsetBranchParams &);
52 docstring branch() const { return params_.branch; }
54 void rename(docstring const & newname) { params_.branch = newname; }
58 InsetCode lyxCode() const { return BRANCH_CODE; }
60 void write(std::ostream &) const;
62 void read(Lexer & lex);
64 docstring const buttonLabel(BufferView const & bv) const;
66 ColorCode backgroundColor(PainterInfo const &) const;
68 int latex(odocstream &, OutputParams const &) const;
70 int plaintext(odocstream &, OutputParams const &) const;
72 int docbook(odocstream &, OutputParams const &) const;
74 docstring xhtml(XHTMLStream &, OutputParams const &) const;
76 void tocString(odocstream &) const;
78 void validate(LaTeXFeatures &) const;
80 docstring contextMenu(BufferView const &, int, int) const;
82 void addToToc(DocIterator const &);
84 InsetBranchParams const & params() const { return params_; }
86 void setParams(InsetBranchParams const & params) { params_ = params; }
88 /** \returns true if params_.branch is listed as 'selected' in
89 \c buffer. This handles the case of child documents.
91 bool isBranchSelected() const;
93 * Is the content of this inset part of the output document?
95 * Note that Branch insets are only considered part of the
96 * document when they are selected.
98 bool producesOutput() const { return isBranchSelected(); }
100 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
102 bool isMacroScope() const;
104 docstring toolTip(BufferView const & bv, int x, int y) const;
106 bool usePlainLayout() const { return false; }
108 void doDispatch(Cursor & cur, FuncRequest & cmd);
110 docstring name() const { return from_ascii("Branch"); }
112 Inset * clone() const { return new InsetBranch(*this); }
115 friend class InsetBranchParams;
117 InsetBranchParams params_;