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 const &, 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 docstring editMessage() const;
63 InsetCode lyxCode() const { return BRANCH_CODE; }
65 void write(std::ostream &) const;
67 void read(Lexer & lex);
69 docstring const buttonLabel(BufferView const & bv) const;
71 ColorCode backgroundColor() const;
73 bool showInsetDialog(BufferView *) const;
75 int latex(odocstream &, OutputParams const &) const;
77 int plaintext(odocstream &, OutputParams const &) const;
79 int docbook(odocstream &, OutputParams const &) const;
81 docstring xhtml(odocstream &, OutputParams const &) const;
83 void tocString(odocstream &) const;
85 void validate(LaTeXFeatures &) const;
87 docstring contextMenu(BufferView const &, int, int) const;
89 void addToToc(DocIterator const &);
91 InsetBranchParams const & params() const { return params_; }
93 void setParams(InsetBranchParams const & params) { params_ = params; }
95 virtual bool usePlainLayout() { return false; }
97 /** \returns true if params_.branch is listed as 'selected' in
98 \c buffer. This handles the case of child documents.
100 bool isBranchSelected() const;
102 * Is the content of this inset part of the output document?
104 * Note that Branch insets are only considered part of the
105 * document when they are selected.
107 bool producesOutput() const { return isBranchSelected(); }
109 bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
111 bool isMacroScope() const;
113 docstring toolTip(BufferView const & bv, int x, int y) const;
115 bool usePlainLayout() const { return false; }
117 void doDispatch(Cursor & cur, FuncRequest & cmd);
119 docstring name() const { return from_ascii("Branch"); }
121 Inset * clone() const { return new InsetBranch(*this); }
124 friend class InsetBranchParams;
126 InsetBranchParams params_;