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
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "InsetCollapsable.h"
|
|
|
|
#include "MailInset.h"
|
2003-08-17 11:28:23 +00:00
|
|
|
|
2003-12-14 16:33:56 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
class Buffer;
|
2003-12-14 16:33:56 +00:00
|
|
|
|
2005-01-19 15:03:31 +00:00
|
|
|
class InsetBranchParams {
|
|
|
|
public:
|
2006-11-03 15:16:45 +00:00
|
|
|
explicit InsetBranchParams(docstring const & b = docstring())
|
2003-12-14 16:33:56 +00:00
|
|
|
: branch(b) {}
|
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;
|
2003-12-14 16:33:56 +00:00
|
|
|
};
|
2003-08-28 07:41:31 +00:00
|
|
|
|
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
/** The Branch inset for alternative, conditional output.
|
|
|
|
|
|
|
|
*/
|
|
|
|
class InsetBranch : public InsetCollapsable {
|
|
|
|
public:
|
|
|
|
///
|
2003-12-14 16:33:56 +00:00
|
|
|
InsetBranch(BufferParams const &, InsetBranchParams const &);
|
2003-08-28 07:41:31 +00:00
|
|
|
///
|
2003-08-17 11:28:23 +00:00
|
|
|
~InsetBranch();
|
2003-08-28 07:41:31 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
virtual docstring const editMessage() const;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
Inset::Code lyxCode() const { return Inset::BRANCH_CODE; }
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
void write(Buffer const &, std::ostream &) const;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2007-04-26 11:30:54 +00:00
|
|
|
void read(Buffer const & buf, Lexer & lex);
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
|
|
|
void setButtonLabel();
|
|
|
|
///
|
2007-06-12 13:45:49 +00:00
|
|
|
virtual Color_color backgroundColor() const;
|
|
|
|
///
|
2003-08-17 11:28:23 +00:00
|
|
|
bool showInsetDialog(BufferView *) const;
|
|
|
|
///
|
2007-02-16 09:28:25 +00:00
|
|
|
int latex(Buffer const &, odocstream &,
|
2007-05-28 22:27:45 +00:00
|
|
|
OutputParams const &) const;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
int plaintext(Buffer const &, odocstream &,
|
2007-05-28 22:27:45 +00:00
|
|
|
OutputParams const &) const;
|
2007-02-16 09:28:25 +00:00
|
|
|
///
|
|
|
|
int docbook(Buffer const &, odocstream &,
|
2007-05-28 22:27:45 +00:00
|
|
|
OutputParams const &) const;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2007-01-19 16:23:47 +00:00
|
|
|
void textString(Buffer const & buf, odocstream &) const;
|
|
|
|
///
|
2003-08-17 11:28:23 +00:00
|
|
|
void validate(LaTeXFeatures &) const;
|
|
|
|
///
|
|
|
|
InsetBranchParams const & params() const { return params_; }
|
|
|
|
///
|
|
|
|
void setParams(InsetBranchParams const & params) { params_ = params; }
|
2003-12-14 16:33:56 +00:00
|
|
|
|
|
|
|
/** \returns true if params_.branch is listed as 'selected' in
|
2005-10-25 15:21:49 +00:00
|
|
|
\c buffer. This handles the case of child documents.
|
2003-12-14 16:33:56 +00:00
|
|
|
*/
|
2005-10-25 15:21:49 +00:00
|
|
|
bool isBranchSelected(Buffer const & buffer) const;
|
2005-04-22 08:57:22 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
bool getStatus(Cursor &, FuncRequest const &, FuncStatus &) const;
|
2007-08-12 21:43:58 +00:00
|
|
|
//
|
|
|
|
virtual void updateLabels(Buffer const &, ParIterator const &);
|
2003-10-17 18:01:15 +00:00
|
|
|
protected:
|
2007-04-29 12:32:14 +00:00
|
|
|
///
|
2004-11-23 23:04:52 +00:00
|
|
|
InsetBranch(InsetBranch const &);
|
2007-04-29 12:32:14 +00:00
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
2007-04-29 12:32:14 +00:00
|
|
|
///
|
2007-04-30 14:39:09 +00:00
|
|
|
docstring name() const { return from_ascii("Branch"); }
|
2003-08-17 11:28:23 +00:00
|
|
|
private:
|
|
|
|
friend class InsetBranchParams;
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
virtual std::auto_ptr<Inset> doClone() const;
|
2004-11-23 23:04:52 +00:00
|
|
|
|
2003-08-17 11:28:23 +00:00
|
|
|
/// used by the constructors
|
|
|
|
void init();
|
|
|
|
///
|
|
|
|
InsetBranchParams params_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class InsetBranchMailer : public MailInset {
|
|
|
|
public:
|
|
|
|
///
|
2003-12-10 14:49:51 +00:00
|
|
|
InsetBranchMailer(InsetBranch & inset);
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
virtual Inset & inset() const { return inset_; }
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
virtual std::string const & name() const { return name_; }
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
virtual std::string const inset2string(Buffer const &) const;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2003-12-10 14:49:51 +00:00
|
|
|
static std::string const params2string(InsetBranchParams const &);
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
static void string2params(std::string const &, InsetBranchParams &);
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
///
|
2003-12-10 14:49:51 +00:00
|
|
|
static std::string const name_;
|
2003-08-17 11:28:23 +00:00
|
|
|
///
|
|
|
|
InsetBranch & inset_;
|
|
|
|
};
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
2003-08-17 11:28:23 +00:00
|
|
|
|
|
|
|
#endif
|