#endif
#include "lyxinset.h"
-#include "lyxparagraph.h"
#include "LString.h"
-//#include "buffer.h"
+#include "lyxparagraph.h"
+#include "lyxcursor.h"
class Painter;
class BufferView;
*/
class InsetText : public UpdatableInset {
public:
- ///
- enum { TEXT_TO_INSET_OFFSET = 1 };
///
+ enum { TEXT_TO_INSET_OFFSET = 1 };
+ ///
+ explicit
InsetText(Buffer *);
///
InsetText(InsetText const &, Buffer *);
///
Inset * Clone() const;
///
+ void clear() const { par->clearContents(); }
+ ///
void Read(LyXLex &);
///
- void Write(ostream &) const;
+ void Write(std::ostream &) const;
///
int ascent(Painter &, LyXFont const &) const;
///
///
void InsetUnlock(BufferView *);
///
- bool UnlockInsetInInset(BufferView *, Inset *, bool lr = false);
+ bool LockInsetInInset(BufferView *, UpdatableInset *);
+ ///
+ bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
///
bool UpdateInsetInInset(BufferView *, Inset *);
///
///
UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
///
- int Latex(ostream &, signed char, bool free_spc) const;
+ int Latex(std::ostream &, bool fragile, bool free_spc) const;
///
- int Linuxdoc(ostream &) const { return 0; }
+ int Ascii(std::ostream &) const { return 0; }
///
- int DocBook(ostream &) const { return 0; }
+ int Linuxdoc(std::ostream &) const { return 0; }
+ ///
+ int DocBook(std::ostream &) const { return 0; }
///
void Validate(LaTeXFeatures & features) const;
///
UpdatableInset * GetLockingInset();
///
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
+ ///
+ void init(Buffer *, InsetText const * ins = 0);
+ ///
+ void SetParagraphData(LyXParagraph *);
LyXParagraph * par;
///
void UpdateLocal(BufferView *, bool);
///
- void WriteParagraphData(ostream &) const;
+ void WriteParagraphData(std::ostream &) const;
///
- void resetPos(BufferView *);
+ void resetPos(Painter &) const;
///
void drawSelection(Painter &, int pos, int baseline, float x);
///
int SingleWidth(Painter &, LyXParagraph * par, int pos) const;
///
LyXFont GetFont(LyXParagraph * par, int pos) const;
+ ///
+ virtual LyXFont GetDrawFont(LyXParagraph * par, int pos) const;
+ ///
+ virtual int getMaxTextWidth(Painter &, UpdatableInset const *,
+ int x=0) const;
Buffer * buffer;
///
///
LyXFont real_current_font;
///
- mutable int maxWidth;
- ///
mutable int maxAscent;
///
mutable int maxDescent;
///
mutable int insetWidth;
///
- int widthOffset;
+ mutable int drawTextXOffset;
+ mutable int drawTextYOffset;
///
bool autoBreakRows;
///
void HideInsetCursor(BufferView *);
///
- void setPos(BufferView *, int x, int y, bool activate_inset = true);
+ void setPos(Painter &, int x, int y) const;
///
- bool moveRight(BufferView *, bool activate_inset = true);
- bool moveLeft(BufferView *, bool activate_inset = true);
- bool moveUp(BufferView *, bool activate_inset = true);
- bool moveDown(BufferView *, bool activate_inset = true);
+ UpdatableInset::RESULT moveRight(BufferView *, bool activate_inset = true);
+ UpdatableInset::RESULT moveLeft(BufferView *, bool activate_inset = true);
+ UpdatableInset::RESULT moveUp(BufferView *);
+ UpdatableInset::RESULT moveDown(BufferView *);
bool Delete();
+ bool cutSelection();
+ bool copySelection();
+ bool pasteSelection();
///
- bool hasSelection() const { return selection_start != selection_end; }
+ bool hasSelection() const
+ { return (selection_start_cursor != selection_end_cursor); }
///
void SetCharFont(int pos, LyXFont const & font);
///
string getText(int);
+ ///
+ bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
+ int button = 0);
/* Private structures and variables */
///
int inset_pos;
///
- int inset_x;
+ mutable int inset_x;
///
- int inset_y;
+ mutable int inset_y;
///
int interline_space;
///
- int selection_start;
- ///
- int selection_end;
- ///
- int old_x;
+ LyXCursor selection_start_cursor;
///
- int cx;
+ LyXCursor selection_end_cursor;
///
- int cy;
+ mutable LyXCursor cursor;
///
- int actpos;
+ mutable LyXCursor old_cursor;
///
- int actrow;
+ mutable int actrow;
///
bool no_selection;
///
int baseline;
};
///
- typedef vector<row_struct> RowList;
+ typedef std::vector<row_struct> RowList;
///
mutable RowList rows;
InsetText & operator = (InsetText const & it) {
buffer = it.buffer; // suspect
current_font = it.current_font;
real_current_font = it.real_current_font;
- maxWidth = it.maxWidth;
maxAscent = it.maxAscent;
maxDescent = it.maxDescent;
insetWidth = it.insetWidth;
inset_x = it.inset_x;
inset_y = it.inset_y;
interline_space = it.interline_space;
- selection_start = it.selection_start;
- selection_end = it.selection_end;
- old_x = it.old_x;
- cx = it.cx;
- cy = it.cy;
- actpos = it.actpos;
+ selection_start_cursor = selection_end_cursor = cursor = it.cursor;
actrow = it.actrow;
no_selection = it.no_selection;
the_locking_inset = it.the_locking_inset; // suspect