2000-02-25 12:06:15 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insetert.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
*
|
2002-09-25 14:26:13 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2000-02-25 12:06:15 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2000-02-25 12:06:15 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef INSETERT_H
|
|
|
|
|
#define INSETERT_H
|
|
|
|
|
|
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
#include "insetcollapsable.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
|
2001-07-24 22:08:49 +00:00
|
|
|
|
/** A collapsable text inset for LaTeX insertions.
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
|
To write full ert (including styles and other insets) in a given
|
2001-10-31 15:19:49 +00:00
|
|
|
|
space.
|
|
|
|
|
|
|
|
|
|
Note that collapsed_ encompasses both the inline and collapsed button
|
2002-03-21 17:09:55 +00:00
|
|
|
|
versions of this inset.
|
2000-02-25 12:06:15 +00:00
|
|
|
|
*/
|
2002-02-20 14:55:17 +00:00
|
|
|
|
|
|
|
|
|
class Language;
|
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
class InsetERT : public InsetCollapsable {
|
2000-02-25 12:06:15 +00:00
|
|
|
|
public:
|
2000-06-28 13:35:52 +00:00
|
|
|
|
///
|
2001-08-06 14:55:02 +00:00
|
|
|
|
enum ERTStatus {
|
|
|
|
|
Open,
|
|
|
|
|
Collapsed,
|
|
|
|
|
Inlined
|
|
|
|
|
};
|
|
|
|
|
///
|
2002-03-03 20:25:07 +00:00
|
|
|
|
InsetERT(BufferParams const &, bool collapsed = false);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
///
|
2003-05-26 09:13:55 +00:00
|
|
|
|
InsetERT(InsetERT const &);
|
2001-07-27 12:03:36 +00:00
|
|
|
|
///
|
2003-07-25 17:11:25 +00:00
|
|
|
|
virtual std::auto_ptr<InsetBase> clone() const;
|
2003-05-26 09:13:55 +00:00
|
|
|
|
///
|
2002-03-03 20:25:07 +00:00
|
|
|
|
InsetERT(BufferParams const &,
|
2003-10-06 15:43:21 +00:00
|
|
|
|
Language const *, std::string const & contents, bool collapsed);
|
2001-07-08 12:52:16 +00:00
|
|
|
|
///
|
2001-08-06 14:55:02 +00:00
|
|
|
|
~InsetERT();
|
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld::Code lyxCode() const { return InsetOld::ERT_CODE; }
|
2001-07-27 12:03:36 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void read(Buffer const & buf, LyXLex & lex);
|
2001-07-24 22:08:49 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void write(Buffer const & buf, std::ostream & os) const;
|
2000-06-28 13:35:52 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const editMessage() const;
|
2000-06-28 13:35:52 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
bool insertInset(BufferView *, InsetOld *);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
bool insetAllowed(InsetOld::Code code) const { return code == InsetOld::NEWLINE_CODE; }
|
2000-06-28 13:35:52 +00:00
|
|
|
|
///
|
2001-07-24 15:07:09 +00:00
|
|
|
|
void setFont(BufferView *, LyXFont const &,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
bool toggleall = false, bool selectall = false);
|
2000-06-28 13:35:52 +00:00
|
|
|
|
///
|
2001-08-06 14:55:02 +00:00
|
|
|
|
EDITABLE editable() const;
|
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int latex(Buffer const &, std::ostream &,
|
2003-05-23 08:59:47 +00:00
|
|
|
|
LatexRunParams const &) const;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
///
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int ascii(Buffer const &, std::ostream &,
|
|
|
|
|
LatexRunParams const & runparams) const;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
///
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int linuxdoc(Buffer const &, std::ostream &,
|
|
|
|
|
LatexRunParams const &) const;
|
2001-07-24 15:07:09 +00:00
|
|
|
|
///
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int docbook(Buffer const &, std::ostream &,
|
|
|
|
|
LatexRunParams const & runparams) const;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
///
|
2001-08-18 15:01:09 +00:00
|
|
|
|
void validate(LaTeXFeatures &) const {}
|
|
|
|
|
///
|
2001-07-27 12:03:36 +00:00
|
|
|
|
bool checkInsertChar(LyXFont &);
|
2001-07-31 09:53:40 +00:00
|
|
|
|
///
|
2003-08-26 10:33:59 +00:00
|
|
|
|
// these are needed here because of the label/inlined functionallity
|
2001-08-06 14:55:02 +00:00
|
|
|
|
///
|
|
|
|
|
bool isOpen() const { return status_ == Open || status_ == Inlined; }
|
|
|
|
|
///
|
2001-10-31 15:19:49 +00:00
|
|
|
|
bool inlined() const { return status_ == Inlined; }
|
|
|
|
|
///
|
|
|
|
|
ERTStatus status() const { return status_; }
|
|
|
|
|
///
|
2001-08-06 14:55:02 +00:00
|
|
|
|
void open(BufferView *);
|
|
|
|
|
///
|
2001-08-07 15:07:36 +00:00
|
|
|
|
void close(BufferView *) const;
|
2001-07-31 09:53:40 +00:00
|
|
|
|
///
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void metrics(MetricsInfo &, Dimension &) const;
|
2001-07-31 09:53:40 +00:00
|
|
|
|
///
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2001-10-31 15:19:49 +00:00
|
|
|
|
/// set the status of the inset
|
2001-08-07 15:07:36 +00:00
|
|
|
|
void status(BufferView *, ERTStatus const st) const;
|
2001-08-06 14:55:02 +00:00
|
|
|
|
///
|
|
|
|
|
bool showInsetDialog(BufferView *) const;
|
2002-01-20 16:49:37 +00:00
|
|
|
|
///
|
2002-02-20 14:55:17 +00:00
|
|
|
|
void getDrawFont(LyXFont &) const;
|
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
bool forceDefaultParagraphs(InsetOld const *) const {
|
2002-01-20 16:49:37 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2003-10-17 18:01:15 +00:00
|
|
|
|
protected:
|
|
|
|
|
///
|
|
|
|
|
virtual
|
2003-10-29 10:47:21 +00:00
|
|
|
|
DispatchResult
|
2003-10-17 18:01:15 +00:00
|
|
|
|
priv_dispatch(FuncRequest const &, idx_type &, pos_type &);
|
2001-07-24 10:13:19 +00:00
|
|
|
|
private:
|
2002-08-19 10:11:13 +00:00
|
|
|
|
///
|
|
|
|
|
void lfunMousePress(FuncRequest const &);
|
|
|
|
|
///
|
|
|
|
|
// the bool return is used to see if we opened a dialog so that we can
|
|
|
|
|
// check this from an outer inset and open the dialog of the outer inset
|
|
|
|
|
// if that one has one!
|
|
|
|
|
///
|
|
|
|
|
bool lfunMouseRelease(FuncRequest const &);
|
|
|
|
|
///
|
|
|
|
|
void lfunMouseMotion(FuncRequest const &);
|
2001-07-24 10:13:19 +00:00
|
|
|
|
///
|
|
|
|
|
void init();
|
2001-07-24 22:08:49 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const get_new_label() const;
|
2001-07-25 19:45:21 +00:00
|
|
|
|
///
|
2001-08-07 15:07:36 +00:00
|
|
|
|
void setButtonLabel() const;
|
2001-07-31 09:53:40 +00:00
|
|
|
|
///
|
|
|
|
|
void set_latex_font(BufferView *);
|
2001-10-31 15:19:49 +00:00
|
|
|
|
/// update status on button
|
|
|
|
|
void updateStatus(BufferView *, bool = false) const;
|
2003-11-04 12:36:59 +00:00
|
|
|
|
///
|
|
|
|
|
void edit(BufferView * bv, bool left);
|
2001-08-06 14:55:02 +00:00
|
|
|
|
|
|
|
|
|
///
|
2001-08-07 15:07:36 +00:00
|
|
|
|
mutable ERTStatus status_;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-02-25 14:51:38 +00:00
|
|
|
|
|
|
|
|
|
#include "mailinset.h"
|
|
|
|
|
|
|
|
|
|
class InsetERTMailer : public MailInset {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
InsetERTMailer(InsetERT & inset);
|
|
|
|
|
///
|
2003-03-10 13:33:39 +00:00
|
|
|
|
virtual InsetBase & inset() const { return inset_; }
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const & name() const { return name_; }
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const inset2string(Buffer const &) const;
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static void string2params(std::string const &, InsetERT::ERTStatus &);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static std::string const params2string(InsetERT::ERTStatus);
|
2003-02-25 14:51:38 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
static std::string const name_;
|
2003-02-25 14:51:38 +00:00
|
|
|
|
///
|
|
|
|
|
InsetERT & inset_;
|
|
|
|
|
};
|
|
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
|
#endif
|