2000-02-25 12:06:15 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-25 14:26:13 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file insettext.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
|
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 INSETTEXT_H
|
|
|
|
|
#define INSETTEXT_H
|
|
|
|
|
|
2003-02-20 17:39:48 +00:00
|
|
|
|
#include "updatableinset.h"
|
2003-09-06 12:36:58 +00:00
|
|
|
|
#include "ParagraphList_fwd.h"
|
2003-09-06 11:01:50 +00:00
|
|
|
|
#include "RowList_fwd.h"
|
2003-07-10 08:00:41 +00:00
|
|
|
|
#include "lyxtext.h"
|
2002-08-12 00:15:19 +00:00
|
|
|
|
|
2002-07-21 21:21:06 +00:00
|
|
|
|
#include "support/types.h"
|
2001-12-18 03:21:10 +00:00
|
|
|
|
|
2003-07-10 08:00:41 +00:00
|
|
|
|
#include "frontends/mouse_state.h"
|
|
|
|
|
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
2000-03-08 13:52:57 +00:00
|
|
|
|
class Buffer;
|
2002-03-03 20:25:07 +00:00
|
|
|
|
class BufferParams;
|
2003-09-07 01:45:40 +00:00
|
|
|
|
class BufferView;
|
|
|
|
|
class Dimension;
|
2003-09-18 11:48:11 +00:00
|
|
|
|
class LColor_color;
|
2000-05-15 14:49:36 +00:00
|
|
|
|
class LyXCursor;
|
2003-09-07 01:45:40 +00:00
|
|
|
|
class Painter;
|
2002-07-21 21:21:06 +00:00
|
|
|
|
class Paragraph;
|
2003-09-07 01:45:40 +00:00
|
|
|
|
class Row;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
2000-06-12 11:27:15 +00:00
|
|
|
|
/**
|
2000-09-14 17:53:12 +00:00
|
|
|
|
A text inset is like a TeX box to write full text
|
2002-03-21 17:09:55 +00:00
|
|
|
|
(including styles and other insets) in a given space.
|
2000-09-14 17:53:12 +00:00
|
|
|
|
@author: J<EFBFBD>rgen Vigna
|
2000-06-12 11:27:15 +00:00
|
|
|
|
*/
|
2000-02-25 12:06:15 +00:00
|
|
|
|
class InsetText : public UpdatableInset {
|
|
|
|
|
public:
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
|
|
|
|
enum DrawFrame {
|
|
|
|
|
///
|
|
|
|
|
NEVER = 0,
|
|
|
|
|
///
|
|
|
|
|
LOCKED,
|
|
|
|
|
///
|
|
|
|
|
ALWAYS
|
|
|
|
|
};
|
|
|
|
|
///
|
2003-10-08 14:29:16 +00:00
|
|
|
|
explicit InsetText(BufferParams const &);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-10-08 14:29:16 +00:00
|
|
|
|
InsetText(InsetText const &);
|
2003-05-26 09:13:55 +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
|
|
|
|
///
|
2003-10-08 14:29:16 +00:00
|
|
|
|
void operator=(InsetText const & it);
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// empty inset to empty par, or just mark as erased
|
|
|
|
|
void clear(bool just_mark_erased);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-11-28 08:55:12 +00:00
|
|
|
|
void read(Buffer const & buf, LyXLex & lex);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-11-28 08:55:12 +00:00
|
|
|
|
void write(Buffer const & buf, std::ostream & os) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-11-28 08:55:12 +00:00
|
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-05-30 06:48:24 +00:00
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string const editMessage() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool isTextInset() const { return true; }
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int latex(Buffer const &, std::ostream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-11-05 12:06:20 +00:00
|
|
|
|
int plaintext(Buffer const &, std::ostream &,
|
|
|
|
|
OutputParams const &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int linuxdoc(Buffer const &, std::ostream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const ;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-10-31 18:45:43 +00:00
|
|
|
|
int docbook(Buffer const &, std::ostream &,
|
2003-11-05 12:06:20 +00:00
|
|
|
|
OutputParams const &) const ;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld::Code lyxCode() const { return InsetOld::TEXT_CODE; }
|
2003-05-03 18:05:53 +00:00
|
|
|
|
/// FIXME, document
|
2003-11-21 14:59:24 +00:00
|
|
|
|
void getCursorPos(int & x, int & y) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
bool insertInset(BufferView *, InsetOld *);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
bool insetAllowed(InsetOld::Code) const;
|
2001-07-09 14:19:41 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void setFont(BufferView *, LyXFont const &,
|
|
|
|
|
bool toggleall = false,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
bool selectall = false);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void writeParagraphData(Buffer const &, std::ostream &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void setText(std::string const &, LyXFont const &);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void setAutoBreakRows(bool);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-09-16 10:01:29 +00:00
|
|
|
|
bool getAutoBreakRows() const { return autoBreakRows_; }
|
2001-07-31 09:53:40 +00:00
|
|
|
|
///
|
2003-08-11 09:09:01 +00:00
|
|
|
|
void setDrawFrame(DrawFrame);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-09-18 11:48:11 +00:00
|
|
|
|
LColor_color frameColor() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-11-10 09:06:48 +00:00
|
|
|
|
void setFrameColor(LColor_color);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-10 10:06:20 +00:00
|
|
|
|
void setViewCache(BufferView const * bv) const;
|
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool showInsetDialog(BufferView *) const;
|
2003-09-18 20:18:39 +00:00
|
|
|
|
/// Appends \c list with all labels found within this inset.
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void getLabelList(Buffer const &, std::vector<std::string> & list) const;
|
2001-04-04 23:00:42 +00:00
|
|
|
|
///
|
2001-12-18 03:21:10 +00:00
|
|
|
|
int scroll(bool recursive = true) const;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
///
|
2001-12-18 03:21:10 +00:00
|
|
|
|
void scroll(BufferView * bv, float sx) const {
|
2001-04-27 14:03:25 +00:00
|
|
|
|
UpdatableInset::scroll(bv, sx);
|
|
|
|
|
}
|
2001-06-27 14:10:35 +00:00
|
|
|
|
///
|
2001-12-18 03:21:10 +00:00
|
|
|
|
void scroll(BufferView * bv, int offset) const {
|
2001-04-27 14:03:25 +00:00
|
|
|
|
UpdatableInset::scroll(bv, offset);
|
|
|
|
|
}
|
2001-05-28 15:11:24 +00:00
|
|
|
|
///
|
2003-05-05 15:39:48 +00:00
|
|
|
|
ParagraphList * getParagraphs(int) const;
|
2001-09-01 21:26:34 +00:00
|
|
|
|
///
|
2003-10-14 13:01:49 +00:00
|
|
|
|
LyXText * getText(int) const;
|
2003-03-02 23:44:58 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// mark as erased for change tracking
|
|
|
|
|
void markErased() { clear(true); };
|
|
|
|
|
/**
|
|
|
|
|
* Mark as new. Used when pasting in tabular, and adding rows
|
|
|
|
|
* or columns. Note that pasting will ensure that tracking already
|
|
|
|
|
* happens, and this just resets the changes for the copied text,
|
|
|
|
|
* whereas for row/col add, we need to start tracking changes
|
|
|
|
|
* for the (empty) paragraph contained.
|
|
|
|
|
*/
|
|
|
|
|
void markNew(bool track_changes = false);
|
2003-03-02 23:44:58 +00:00
|
|
|
|
|
2001-10-22 09:45:31 +00:00
|
|
|
|
///
|
|
|
|
|
bool checkInsertChar(LyXFont &);
|
|
|
|
|
///
|
2002-02-20 14:55:17 +00:00
|
|
|
|
void getDrawFont(LyXFont &) const;
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// append text onto the existing text
|
2003-04-28 16:22:32 +00:00
|
|
|
|
void appendParagraphs(Buffer * bp, ParagraphList &);
|
2003-03-02 23:44:58 +00:00
|
|
|
|
|
2002-03-21 15:58:54 +00:00
|
|
|
|
///
|
2003-07-04 08:23:23 +00:00
|
|
|
|
void addPreview(lyx::graphics::PreviewLoader &) const;
|
2002-08-02 16:39:43 +00:00
|
|
|
|
|
2003-11-04 12:36:59 +00:00
|
|
|
|
///
|
|
|
|
|
void edit(BufferView *, bool);
|
|
|
|
|
///
|
|
|
|
|
void edit(BufferView *, int, int);
|
|
|
|
|
|
2001-07-20 14:18:48 +00:00
|
|
|
|
///
|
2003-11-01 09:56:18 +00:00
|
|
|
|
int numParagraphs() const { return 1; }
|
2003-03-02 23:44:58 +00:00
|
|
|
|
///
|
2003-08-15 08:03:54 +00:00
|
|
|
|
mutable ParagraphList paragraphs;
|
2003-11-28 08:55:12 +00:00
|
|
|
|
private:
|
2003-10-17 18:01:15 +00:00
|
|
|
|
///
|
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-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-11-28 08:55:12 +00:00
|
|
|
|
void updateLocal(BufferView *);
|
2003-10-08 14:29:16 +00:00
|
|
|
|
///
|
|
|
|
|
void init();
|
2003-11-10 09:06:48 +00:00
|
|
|
|
// If the inset is empty set the language of the current font to the
|
|
|
|
|
// language to the surronding text (if different).
|
|
|
|
|
void sanitizeEmptyText(BufferView *);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void setCharFont(Buffer const &, int pos, LyXFont const & font);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
|
|
|
|
void removeNewlines();
|
|
|
|
|
///
|
2003-03-22 17:26:03 +00:00
|
|
|
|
void drawFrame(Painter &, int x) const;
|
2001-06-28 10:25:20 +00:00
|
|
|
|
///
|
2003-11-28 08:55:12 +00:00
|
|
|
|
void clearInset(Painter &, int x, int y) const;
|
2001-07-12 12:26:06 +00:00
|
|
|
|
///
|
2003-03-06 10:02:40 +00:00
|
|
|
|
void collapseParagraphs(BufferView *);
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
/* Private structures and variables */
|
|
|
|
|
///
|
2003-09-16 10:01:29 +00:00
|
|
|
|
bool autoBreakRows_;
|
|
|
|
|
///
|
|
|
|
|
DrawFrame drawFrame_;
|
2003-09-16 10:30:59 +00:00
|
|
|
|
/** We store the LColor::color value as an int to get LColor.h out
|
|
|
|
|
* of the header file.
|
|
|
|
|
*/
|
|
|
|
|
int frame_color_;
|
2003-09-16 10:01:29 +00:00
|
|
|
|
///
|
2003-10-10 09:01:23 +00:00
|
|
|
|
mutable lyx::paroffset_type old_par;
|
2003-06-27 11:53:41 +00:00
|
|
|
|
|
2003-11-17 20:28:11 +00:00
|
|
|
|
/** to remember old painted frame dimensions to clear it on
|
|
|
|
|
* the right spot!
|
|
|
|
|
*/
|
2001-12-05 15:34:41 +00:00
|
|
|
|
mutable bool in_insetAllowed;
|
2003-07-10 08:00:41 +00:00
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
mutable LyXText text_;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
};
|
|
|
|
|
#endif
|