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-08-28 07:41:31 +00:00
|
|
|
|
void read(Buffer const &, LyXLex &);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
void write(Buffer const &, std::ostream &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void metrics(MetricsInfo &, Dimension &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-18 12:05:50 +00:00
|
|
|
|
int textWidth() 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
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void insetUnlock(BufferView *);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool lockInsetInInset(BufferView *, UpdatableInset *);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
bool unlockInsetInInset(BufferView *,
|
|
|
|
|
UpdatableInset *, bool lr = false);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2002-08-13 17:43:40 +00:00
|
|
|
|
RESULT localDispatch(FuncRequest const &);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
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-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int ascii(Buffer const &, std::ostream &, int linelen) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int linuxdoc(Buffer const &, std::ostream &) const ;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-28 07:41:31 +00:00
|
|
|
|
int docbook(Buffer const &, std::ostream &, bool mixcont) 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
|
2001-06-28 10:25:20 +00:00
|
|
|
|
void getCursorPos(BufferView *, int & x, int & y) const;
|
2003-05-03 18:05:53 +00:00
|
|
|
|
/// Get the absolute document x,y of the cursor
|
|
|
|
|
virtual void getCursor(BufferView &, int &, int &) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2002-04-16 14:10:39 +00:00
|
|
|
|
int insetInInsetY() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-07-20 14:18:48 +00:00
|
|
|
|
void fitInsetCursor(BufferView *) const;
|
|
|
|
|
///
|
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-07-12 12:26:06 +00:00
|
|
|
|
UpdatableInset * getLockingInset() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
UpdatableInset * getFirstLockingInsetOfType(InsetOld::Code);
|
2001-04-02 14:02:58 +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;
|
|
|
|
|
void setFrameColor(LColor_color);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-06-27 14:10:35 +00:00
|
|
|
|
LyXText * getLyXText(BufferView const *,
|
|
|
|
|
bool const recursive = false) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-10 10:06:20 +00:00
|
|
|
|
void setViewCache(BufferView const * bv) const;
|
|
|
|
|
///
|
2001-06-27 14:10:35 +00:00
|
|
|
|
void deleteLyXText(BufferView *, bool recursive = true) const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
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
|
|
|
|
///
|
2001-12-18 03:21:10 +00:00
|
|
|
|
void clearSelection(BufferView * bv);
|
2001-07-06 15:57:54 +00:00
|
|
|
|
///
|
2003-07-25 21:20:24 +00:00
|
|
|
|
InsetOld * getInsetFromID(int id) const;
|
2001-07-06 15:57:54 +00:00
|
|
|
|
///
|
2003-05-05 15:39:48 +00:00
|
|
|
|
ParagraphList * getParagraphs(int) const;
|
2001-09-01 21:26:34 +00:00
|
|
|
|
///
|
2001-07-06 15:57:54 +00:00
|
|
|
|
LyXCursor const & cursor(BufferView *) const;
|
|
|
|
|
///
|
2003-02-08 19:18:01 +00:00
|
|
|
|
bool allowSpellcheck() const { return true; }
|
2001-12-18 03:21:10 +00:00
|
|
|
|
///
|
2002-08-13 14:40:38 +00:00
|
|
|
|
WordLangTuple const
|
|
|
|
|
selectNextWordToSpellcheck(BufferView *, float & value) const;
|
|
|
|
|
///
|
2001-07-17 15:39:12 +00:00
|
|
|
|
void selectSelectedWord(BufferView *);
|
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);
|
|
|
|
|
/// find next change
|
|
|
|
|
bool nextChange(BufferView *, lyx::pos_type & length);
|
2003-03-02 23:44:58 +00:00
|
|
|
|
|
2001-07-17 15:39:12 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool searchForward(BufferView *, std::string const &,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
bool = true, bool = false);
|
2001-12-18 03:21:10 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
bool searchBackward(BufferView *, std::string const &,
|
2002-03-21 17:09:55 +00:00
|
|
|
|
bool = true, bool = false);
|
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
|
|
|
|
|
2001-07-20 14:18:48 +00:00
|
|
|
|
///
|
2003-04-28 16:22:32 +00:00
|
|
|
|
bool haveParagraphs() const {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2003-03-02 23:44:58 +00:00
|
|
|
|
///
|
2003-08-15 08:03:54 +00:00
|
|
|
|
mutable ParagraphList paragraphs;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
protected:
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-04 15:14:11 +00:00
|
|
|
|
void updateLocal(BufferView *, bool mark_dirty);
|
2002-04-16 14:10:39 +00:00
|
|
|
|
/// set parameters for an initial lock of this inset
|
|
|
|
|
void lockInset(BufferView *);
|
|
|
|
|
/// lock an inset inside this one
|
2001-12-14 11:55:58 +00:00
|
|
|
|
void lockInset(BufferView *, UpdatableInset *);
|
2000-02-25 12:06:15 +00:00
|
|
|
|
|
|
|
|
|
private:
|
2003-10-08 14:29:16 +00:00
|
|
|
|
///
|
|
|
|
|
void init();
|
2002-08-19 10:11:13 +00:00
|
|
|
|
///
|
|
|
|
|
void lfunMousePress(FuncRequest const &);
|
|
|
|
|
///
|
|
|
|
|
bool lfunMouseRelease(FuncRequest const &);
|
|
|
|
|
///
|
|
|
|
|
void lfunMouseMotion(FuncRequest const &);
|
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-05 10:54:19 +00:00
|
|
|
|
RESULT moveRight(BufferView *);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-08-05 10:54:19 +00:00
|
|
|
|
RESULT moveLeft(BufferView *);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2002-08-19 10:11:13 +00:00
|
|
|
|
RESULT moveRightIntern(BufferView *, bool front,
|
2001-04-04 22:08:13 +00:00
|
|
|
|
bool activate_inset = true,
|
|
|
|
|
bool selecting = false);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2002-08-19 10:11:13 +00:00
|
|
|
|
RESULT moveLeftIntern(BufferView *, bool front,
|
2001-04-04 22:08:13 +00:00
|
|
|
|
bool activate_inset = true,
|
|
|
|
|
bool selecting = false);
|
2001-01-08 16:14:09 +00:00
|
|
|
|
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2002-08-19 10:11:13 +00:00
|
|
|
|
RESULT moveUp(BufferView *);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2002-08-19 10:11:13 +00:00
|
|
|
|
RESULT moveDown(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
|
|
|
|
///
|
2002-04-17 08:34:59 +00:00
|
|
|
|
bool checkAndActivateInset(BufferView * bv, bool front);
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
|
|
|
|
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
|
2002-05-26 17:33:14 +00:00
|
|
|
|
mouse_button::state button = mouse_button::none);
|
2001-04-27 14:03:25 +00:00
|
|
|
|
///
|
2001-04-02 14:02:58 +00:00
|
|
|
|
void removeNewlines();
|
|
|
|
|
///
|
2003-07-27 22:46:33 +00:00
|
|
|
|
int cx() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-14 15:17:40 +00:00
|
|
|
|
int cy() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-10 13:21:45 +00:00
|
|
|
|
lyx::pos_type cpos() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-10 13:21:45 +00:00
|
|
|
|
ParagraphList::iterator cpar() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-10 13:21:45 +00:00
|
|
|
|
bool cboundary() const;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2003-07-10 13:21:45 +00:00
|
|
|
|
RowList::iterator crow() const;
|
2001-04-27 14:03:25 +00:00
|
|
|
|
///
|
2003-03-22 17:26:03 +00:00
|
|
|
|
void drawFrame(Painter &, int x) const;
|
2001-06-28 10:25:20 +00:00
|
|
|
|
///
|
2003-03-22 17:26:03 +00:00
|
|
|
|
void clearInset(BufferView *, int start_x, int baseline) 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
|
|
|
|
///
|
2001-04-02 14:02:58 +00:00
|
|
|
|
mutable bool locked;
|
|
|
|
|
///
|
|
|
|
|
mutable int top_y;
|
|
|
|
|
///
|
2003-10-10 09:01:23 +00:00
|
|
|
|
lyx::paroffset_type inset_par;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
2001-11-27 10:34:16 +00:00
|
|
|
|
lyx::pos_type inset_pos;
|
2001-04-02 14:02:58 +00:00
|
|
|
|
///
|
|
|
|
|
bool inset_boundary;
|
|
|
|
|
///
|
|
|
|
|
mutable int inset_x;
|
|
|
|
|
///
|
|
|
|
|
mutable int inset_y;
|
|
|
|
|
///
|
|
|
|
|
bool no_selection;
|
|
|
|
|
///
|
|
|
|
|
UpdatableInset * the_locking_inset;
|
|
|
|
|
///
|
2003-10-10 09:01:23 +00:00
|
|
|
|
mutable lyx::paroffset_type old_par;
|
2003-06-27 11:53:41 +00:00
|
|
|
|
|
2001-07-31 09:53:40 +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;
|
2001-12-24 14:36:31 +00:00
|
|
|
|
///
|
|
|
|
|
// these are used to check for mouse movement in Motion selection code
|
|
|
|
|
///
|
|
|
|
|
int mouse_x;
|
|
|
|
|
int mouse_y;
|
2003-07-10 08:00:41 +00:00
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
mutable LyXText text_;
|
2003-07-18 07:47:07 +00:00
|
|
|
|
///
|
|
|
|
|
mutable int textwidth_;
|
2000-02-25 12:06:15 +00:00
|
|
|
|
};
|
|
|
|
|
#endif
|