2003-08-17 11:28:23 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
2007-04-25 01:24:38 +00:00
|
|
|
* \file InsetBranch.h
|
2003-08-17 11:28:23 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Martin Vermeer
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-08-17 11:28:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INSETBRANCH_H
|
|
|
|
#define INSETBRANCH_H
|
|
|
|
|
2017-10-16 08:12:21 +00:00
|
|
|
#include "InsetCollapsible.h"
|
2003-08-17 11:28:23 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
2005-01-19 15:03:31 +00:00
|
|
|
class InsetBranchParams {
|
|
|
|
public:
|
2008-03-27 22:26:24 +00:00
|
|
|
///
|
2006-11-03 15:16:45 +00:00
|
|
|
explicit InsetBranchParams(docstring const & b = docstring())
|
2016-07-12 03:56:32 +00:00
|
|
|
: branch(b), inverted(false) {}
|
|
|
|
InsetBranchParams(docstring const & b, bool i)
|
|
|
|
: branch(b), inverted(i) {}
|
2003-08-28 07:41:31 +00:00
|
|
|
///
|
|
|
|
void write(std::ostream & os) const;
|
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void read(Lexer & lex);
|
2003-08-28 07:41:31 +00:00
|
|
|
///
|
2006-11-03 15:16:45 +00:00
|
|
|
docstring branch;
|
2016-07-12 03:56:32 +00:00
|
|
|
///
|
|
|
|
bool inverted;
|
2003-12-14 16:33:56 +00:00
|
|
|
};
|
2003-08-28 07:41:31 +00:00
|
|
|
|
|
|
|
|
2008-03-27 22:26:24 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// InsetBranch
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/// The Branch inset for alternative, conditional output.
|
2003-08-17 11:28:23 +00:00
|
|
|
|
2017-10-16 08:12:21 +00:00
|
|
|
class InsetBranch : public InsetCollapsible
|
2008-03-27 22:26:24 +00:00
|
|
|
{
|
2003-08-17 11:28:23 +00:00
|
|
|
public:
|
|
|
|
///
|
2009-11-08 15:53:21 +00:00
|
|
|
InsetBranch(Buffer *, InsetBranchParams const &);
|
2008-03-27 22:26:24 +00:00
|
|
|
|
|
|
|
///
|
|
|
|
static std::string params2string(InsetBranchParams const &);
|
|
|
|
///
|
|
|
|
static void string2params(std::string const &, InsetBranchParams &);
|
2009-07-09 09:48:34 +00:00
|
|
|
///
|
|
|
|
docstring branch() const { return params_.branch; }
|
2009-07-10 06:49:51 +00:00
|
|
|
///
|
|
|
|
void rename(docstring const & newname) { params_.branch = newname; }
|
2016-07-12 03:56:32 +00:00
|
|
|
///
|
|
|
|
InsetBranchParams const & params() const { return params_; }
|
2008-03-27 22:26:24 +00:00
|
|
|
|
|
|
|
private:
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetCode lyxCode() const override { return BRANCH_CODE; }
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void write(std::ostream &) const override;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void read(Lexer & lex) override;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring const buttonLabel(BufferView const &) const override;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
ColorCode backgroundColor(PainterInfo const &) const override;
|
2007-06-12 13:45:49 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void latex(otexstream &, OutputParams const &) const override;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2013-03-08 19:52:18 +00:00
|
|
|
int plaintext(odocstringstream & ods, OutputParams const & op,
|
2020-10-01 07:42:11 +00:00
|
|
|
size_t max_length = INT_MAX) const override;
|
2007-02-16 09:28:25 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void docbook(XMLStream &, OutputParams const &) const override;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring xhtml(XMLStream &, OutputParams const &) const override;
|
2009-06-05 17:48:14 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void toString(odocstream &) const override;
|
2007-01-19 16:23:47 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void forOutliner(docstring &, size_t const, bool const) const override;
|
2010-12-20 21:55:09 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void validate(LaTeXFeatures &) const override;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
std::string contextMenuName() const override;
|
2009-03-31 09:38:07 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void updateBuffer(ParIterator const & it, UpdateType utype, bool const deleted = false) override;
|
2003-12-14 16:33:56 +00:00
|
|
|
|
|
|
|
/** \returns true if params_.branch is listed as 'selected' in
|
2012-09-30 12:59:24 +00:00
|
|
|
\c buffer. \p child only checks within child documents.
|
2003-12-14 16:33:56 +00:00
|
|
|
*/
|
2012-09-30 12:59:24 +00:00
|
|
|
bool isBranchSelected(bool const child = false) const;
|
2008-04-23 10:55:51 +00:00
|
|
|
/*!
|
|
|
|
* Is the content of this inset part of the output document?
|
|
|
|
*
|
2016-07-12 13:28:12 +00:00
|
|
|
* Note that Branch insets are considered part of the
|
|
|
|
* document when they are selected XOR inverted.
|
2008-04-23 10:55:51 +00:00
|
|
|
*/
|
2020-10-01 07:42:11 +00:00
|
|
|
bool producesOutput() const override;
|
2005-04-22 08:57:22 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const override;
|
2007-12-21 20:42:46 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool isMacroScope() const override;
|
2008-02-12 09:11:06 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring toolTip(BufferView const & bv, int x, int y) const override;
|
2008-03-24 19:18:18 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool usePlainLayout() const override { return false; }
|
2007-04-29 12:32:14 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void doDispatch(Cursor & cur, FuncRequest & cmd) override;
|
2007-04-29 12:32:14 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring layoutName() const override { return from_ascii("Branch:") + branch(); }
|
2008-03-04 22:28:18 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
Inset * clone() const override { return new InsetBranch(*this); }
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
|
|
///
|
2008-03-27 22:26:24 +00:00
|
|
|
friend class InsetBranchParams;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2008-03-27 22:26:24 +00:00
|
|
|
InsetBranchParams params_;
|
2003-08-17 11:28:23 +00:00
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
|
|
#endif
|