2000-02-25 12:06:15 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
|
|
|
* ======================================================
|
2002-03-21 17:09:55 +00:00
|
|
|
*
|
2000-02-25 12:06:15 +00:00
|
|
|
* LyX, The Document Processor
|
|
|
|
*
|
2000-02-25 13:35:38 +00:00
|
|
|
* Copyright 1998 The LyX Team.
|
2000-02-25 12:06:15 +00:00
|
|
|
*
|
|
|
|
*======================================================
|
|
|
|
*/
|
|
|
|
// The pristine updatable inset: Text
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef INSETERT_H
|
|
|
|
#define INSETERT_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
#include "insetcollapsable.h"
|
2002-05-29 16:21:03 +00:00
|
|
|
|
|
|
|
#include <boost/signals/signal0.hpp>
|
2000-02-25 12:06:15 +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
|
|
|
///
|
2001-07-27 12:03:36 +00:00
|
|
|
InsetERT(InsetERT const &, bool same_id = false);
|
|
|
|
///
|
|
|
|
Inset * clone(Buffer const &, bool same_id = false) const;
|
|
|
|
///
|
2002-03-03 20:25:07 +00:00
|
|
|
InsetERT(BufferParams const &,
|
|
|
|
Language const *, string const & contents, bool collapsed);
|
2001-07-08 12:52:16 +00:00
|
|
|
///
|
2001-08-06 14:55:02 +00:00
|
|
|
~InsetERT();
|
|
|
|
///
|
2001-07-27 12:03:36 +00:00
|
|
|
Inset::Code lyxCode() const { return Inset::ERT_CODE; }
|
|
|
|
///
|
2001-07-24 22:08:49 +00:00
|
|
|
void read(Buffer const * buf, LyXLex & lex);
|
|
|
|
///
|
2001-07-24 15:07:09 +00:00
|
|
|
void write(Buffer const * buf, std::ostream & os) const;
|
2000-06-28 13:35:52 +00:00
|
|
|
///
|
2001-07-24 15:07:09 +00:00
|
|
|
string const editMessage() const;
|
2000-06-28 13:35:52 +00:00
|
|
|
///
|
2001-07-24 15:07:09 +00:00
|
|
|
bool insertInset(BufferView *, Inset *);
|
2000-06-28 13:35:52 +00:00
|
|
|
///
|
2001-07-24 15:07:09 +00:00
|
|
|
bool insetAllowed(Inset::Code) const { return false; }
|
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
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
void edit(BufferView *, int, int, mouse_button::state);
|
2001-06-27 14:10:35 +00:00
|
|
|
///
|
2001-07-24 15:07:09 +00:00
|
|
|
void edit(BufferView * bv, bool front = true);
|
2001-07-20 14:18:48 +00:00
|
|
|
///
|
2001-08-06 14:55:02 +00:00
|
|
|
EDITABLE editable() const;
|
|
|
|
///
|
2002-05-29 16:21:03 +00:00
|
|
|
boost::signal0<void> hideDialog;
|
2001-08-06 14:55:02 +00:00
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
void insetButtonPress(BufferView *, int x, int y, mouse_button::state button);
|
2001-12-04 16:10:19 +00:00
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
bool insetButtonRelease(BufferView * bv, int x, int y, mouse_button::state button);
|
2001-07-24 22:08:49 +00:00
|
|
|
///
|
2002-05-26 17:33:14 +00:00
|
|
|
void insetMotionNotify(BufferView *, int x, int y, mouse_button::state state);
|
2001-12-04 16:10:19 +00:00
|
|
|
///
|
2001-07-24 15:07:09 +00:00
|
|
|
int latex(Buffer const *, std::ostream &, bool fragile,
|
2001-07-24 22:08:49 +00:00
|
|
|
bool free_spc) const;
|
2001-06-27 14:10:35 +00:00
|
|
|
///
|
2001-07-24 15:07:09 +00:00
|
|
|
int ascii(Buffer const *,
|
2002-03-21 17:09:55 +00:00
|
|
|
std::ostream &, int linelen = 0) const;
|
2001-06-27 14:10:35 +00:00
|
|
|
///
|
2001-07-24 15:07:09 +00:00
|
|
|
int linuxdoc(Buffer const *, std::ostream &) const;
|
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
int docbook(Buffer const *, std::ostream &, bool mixcont) const;
|
2001-06-27 14:10:35 +00:00
|
|
|
///
|
2001-08-18 15:01:09 +00:00
|
|
|
void validate(LaTeXFeatures &) const {}
|
|
|
|
///
|
2002-08-13 17:43:40 +00:00
|
|
|
RESULT localDispatch(FuncRequest const &);
|
2001-07-27 12:03:36 +00:00
|
|
|
///
|
|
|
|
bool checkInsertChar(LyXFont &);
|
2001-07-31 09:53:40 +00:00
|
|
|
///
|
|
|
|
// this are needed here because of the label/inlined functionallity
|
|
|
|
///
|
2001-08-06 14:55:02 +00:00
|
|
|
bool needFullRow() const { return status_ == Open; }
|
|
|
|
///
|
|
|
|
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
|
|
|
///
|
2001-10-19 15:40:01 +00:00
|
|
|
bool allowSpellcheck() { return false; }
|
2002-08-06 22:38:44 +00:00
|
|
|
|
2002-08-13 14:40:38 +00:00
|
|
|
WordLangTuple const
|
|
|
|
selectNextWordToSpellcheck(BufferView *, float &) const;
|
2001-09-24 14:29:27 +00:00
|
|
|
///
|
2001-08-06 14:55:02 +00:00
|
|
|
int ascent(BufferView *, LyXFont const &) const;
|
2001-07-31 09:53:40 +00:00
|
|
|
///
|
2001-08-06 14:55:02 +00:00
|
|
|
int descent(BufferView *, LyXFont const &) const;
|
|
|
|
///
|
|
|
|
int width(BufferView *, LyXFont const &) const;
|
2001-07-31 09:53:40 +00:00
|
|
|
///
|
|
|
|
void draw(BufferView *, const LyXFont &, int , float &, bool) 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;
|
|
|
|
///
|
2002-01-20 16:49:37 +00:00
|
|
|
bool forceDefaultParagraphs(Inset const *) const {
|
|
|
|
return true;
|
|
|
|
}
|
2002-03-05 14:55:20 +00:00
|
|
|
///
|
|
|
|
int getMaxWidth(BufferView *, UpdatableInset const *) const;
|
2002-05-31 12:17:28 +00:00
|
|
|
///
|
|
|
|
void update(BufferView *, LyXFont const &, bool =false);
|
2001-07-27 12:03:36 +00:00
|
|
|
|
2001-07-24 10:13:19 +00:00
|
|
|
private:
|
|
|
|
///
|
|
|
|
void init();
|
2001-07-24 22:08:49 +00:00
|
|
|
///
|
|
|
|
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;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|