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
|
|
|
|
|
|
2005-07-15 22:10:25 +00:00
|
|
|
|
#include "inset.h"
|
2003-09-06 11:01:50 +00:00
|
|
|
|
#include "RowList_fwd.h"
|
2003-12-03 18:17:20 +00:00
|
|
|
|
#include "lyxfont.h"
|
2003-07-10 08:00:41 +00:00
|
|
|
|
#include "lyxtext.h"
|
2006-03-24 17:37:15 +00:00
|
|
|
|
#include "ParagraphList_fwd.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-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;
|
2005-07-15 22:10:25 +00:00
|
|
|
|
class CursorSlice;
|
2003-09-07 01:45:40 +00:00
|
|
|
|
class Dimension;
|
2003-09-18 11:48:11 +00:00
|
|
|
|
class LColor_color;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
2004-03-01 17:12:09 +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-06-12 11:27:15 +00:00
|
|
|
|
*/
|
2005-07-15 22:10:25 +00:00
|
|
|
|
class InsetText : public InsetOld {
|
2000-02-25 12:06:15 +00:00
|
|
|
|
public:
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-10-08 14:29:16 +00:00
|
|
|
|
explicit InsetText(BufferParams const &);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2004-11-23 23:04:52 +00:00
|
|
|
|
InsetText();
|
2005-09-07 10:37:05 +00:00
|
|
|
|
/// empty inset to empty par
|
|
|
|
|
void clear();
|
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;
|
2004-02-06 11:12:49 +00:00
|
|
|
|
/// draw inset selection
|
|
|
|
|
void drawSelection(PainterInfo & pi, int x, int y) const;
|
2006-10-20 16:46:03 +00:00
|
|
|
|
/// do we cover screen position x/y?
|
|
|
|
|
virtual bool covers(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
|
|
|
|
///
|
2005-07-15 22:10:25 +00:00
|
|
|
|
EDITABLE editable() const { return HIGHLY_EDITABLE; }
|
|
|
|
|
///
|
2006-04-06 12:06:37 +00:00
|
|
|
|
bool canTrackChanges() const { return true; }
|
|
|
|
|
///
|
|
|
|
|
InsetText const * asTextInset() const { return this; }
|
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 &,
|
2004-04-08 15:03:33 +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 &,
|
2004-04-08 15:03:33 +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;
|
2004-11-30 01:59:49 +00:00
|
|
|
|
|
|
|
|
|
/// return x,y of given position relative to the inset's baseline
|
2005-07-15 15:49:40 +00:00
|
|
|
|
void cursorPos(CursorSlice const & sl, bool boundary, int & x, int & y) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2004-11-23 23:04:52 +00:00
|
|
|
|
Code lyxCode() const { return TEXT_CODE; }
|
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
|
|
|
|
///
|
2004-12-17 16:27:12 +00:00
|
|
|
|
bool getAutoBreakRows() const { return text_.autoBreakRows_; }
|
2001-07-31 09:53:40 +00:00
|
|
|
|
///
|
2004-08-14 15:55:22 +00:00
|
|
|
|
void setDrawFrame(bool);
|
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;
|
2001-04-04 23:00:42 +00:00
|
|
|
|
///
|
2005-07-18 12:57:08 +00:00
|
|
|
|
LyXText * getText(int i) const {
|
|
|
|
|
return (i == 0) ? const_cast<LyXText*>(&text_) : 0;
|
|
|
|
|
}
|
2004-03-18 13:57:20 +00:00
|
|
|
|
///
|
|
|
|
|
bool getStatus(LCursor & cur, FuncRequest const & cmd, FuncStatus &) const;
|
2003-03-02 23:44:58 +00:00
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/// mark as erased for change tracking
|
2005-09-07 10:37:05 +00:00
|
|
|
|
void markErased(bool erased);
|
|
|
|
|
|
2003-02-08 19:18:01 +00:00
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
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
|
|
|
|
///
|
2004-02-06 16:14:06 +00:00
|
|
|
|
void edit(LCursor & cur, bool left);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
///
|
2005-07-15 00:39:44 +00:00
|
|
|
|
InsetBase * editXY(LCursor & cur, int x, int y);
|
2003-11-04 12:36:59 +00:00
|
|
|
|
|
2004-02-16 11:58:51 +00:00
|
|
|
|
/// number of cells in this inset
|
|
|
|
|
size_t nargs() const { return 1; }
|
2003-03-02 23:44:58 +00:00
|
|
|
|
///
|
2004-03-28 22:00:22 +00:00
|
|
|
|
ParagraphList & paragraphs();
|
|
|
|
|
///
|
|
|
|
|
ParagraphList const & paragraphs() const;
|
2004-03-28 19:13:11 +00:00
|
|
|
|
///
|
|
|
|
|
bool insetAllowed(Code) const { return true; }
|
2004-03-31 17:58:11 +00:00
|
|
|
|
///
|
|
|
|
|
bool allowSpellCheck() const { return true; }
|
2005-09-10 06:51:58 +00:00
|
|
|
|
/// should paragraph indendation be ommitted in any case?
|
|
|
|
|
bool neverIndent() const;
|
2005-05-12 12:22:39 +00:00
|
|
|
|
///
|
|
|
|
|
InsetText(InsetText const &);
|
2006-04-06 12:06:37 +00:00
|
|
|
|
///
|
|
|
|
|
bool & Wide() const { return wide_inset_; }
|
2004-04-03 08:37:12 +00:00
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
protected:
|
2003-10-17 18:01:15 +00:00
|
|
|
|
///
|
2004-11-24 21:58:42 +00:00
|
|
|
|
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
2004-11-23 23:04:52 +00:00
|
|
|
|
|
2005-07-15 22:19:49 +00:00
|
|
|
|
private:
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2005-07-15 22:19:49 +00:00
|
|
|
|
virtual std::auto_ptr<InsetBase> doClone() const;
|
2003-10-08 14:29:16 +00:00
|
|
|
|
///
|
|
|
|
|
void init();
|
2002-03-21 17:09:55 +00:00
|
|
|
|
|
2003-09-16 10:01:29 +00:00
|
|
|
|
///
|
2004-08-14 15:55:22 +00:00
|
|
|
|
bool 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
|
|
|
|
///
|
2004-11-30 01:59:49 +00:00
|
|
|
|
mutable lyx::pit_type old_pit;
|
2005-02-15 19:53:42 +00:00
|
|
|
|
///
|
|
|
|
|
static int border_;
|
2006-04-06 12:06:37 +00:00
|
|
|
|
///
|
|
|
|
|
mutable bool wide_inset_;
|
2003-07-10 08:00:41 +00:00
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
mutable LyXText text_;
|
2003-12-03 18:17:20 +00:00
|
|
|
|
///
|
|
|
|
|
mutable LyXFont font_;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
};
|
|
|
|
|
#endif
|