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"
20 class InsetBranchParams {
23 explicit InsetBranchParams(docstring const & b = docstring())
26 void write(std::ostream & os) const;
28 void read(Lexer & lex);
34 /////////////////////////////////////////////////////////////////////////
38 /////////////////////////////////////////////////////////////////////////
40 /// The Branch inset for alternative, conditional output.
42 class InsetBranch : public InsetCollapsable
46 InsetBranch(Buffer *, InsetBranchParams const &);
51 static std::string params2string(InsetBranchParams const &);
53 static void string2params(std::string const &, InsetBranchParams &);
55 docstring branch() const { return params_.branch; }
57 void rename(docstring const & newname) { params_.branch = newname; }
61 InsetCode lyxCode() const { return BRANCH_CODE; }
63 void write(std::ostream &) const;
65 void read(Lexer & lex);
67 docstring const buttonLabel(BufferView const & bv) const;
69 ColorCode backgroundColor() const;
71 bool showInsetDialog(BufferView *) const;
73 int latex(odocstream &, OutputParams const &) const;
75 int plaintext(odocstream &, OutputParams const &) const;
77 int docbook(odocstream &, OutputParams const &) const;
79 docstring xhtml(XHTMLStream &, OutputParams const &) const;
81 void tocString(odocstream &) const;
83 void validate(LaTeXFeatures &) const;
85 docstring contextMenu(BufferView const &, int, int) const;
87 void addToToc(DocIterator const &);
89 InsetBranchParams const & params() const { return params_; }
91 void setParams(InsetBranchParams const & params) { params_ = params; }
93 /** \returns true if params_.branch is listed as 'selected' in
94 \c buffer. This handles the case of child documents.
96 bool isBranchSelected() const;
98 * Is the content of this inset part of the output document?
100 * Note that Branch insets are only considered part of the
101 * document when they are selected.
103 bool producesOutput() const { return isBranchSelected(); }
105 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
107 bool isMacroScope() const;
109 docstring toolTip(BufferView const & bv, int x, int y) const;
111 bool usePlainLayout() const { return false; }
113 void doDispatch(Cursor & cur, FuncRequest & cmd);
115 docstring name() const { return from_ascii("Branch"); }
117 Inset * clone() const { return new InsetBranch(*this); }
120 friend class InsetBranchParams;
122 InsetBranchParams params_;