X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsettext.h;h=b49374fa93d1212034ae6ab7989763c880ca148a;hb=3c8aba3b556871fb1100a2f98cd93d5d4e3f70c9;hp=dff8829384fddf9c042a0131257e1d178fddca75;hpb=132fe5e1322fbc86a32692df51eba78d6b4e479c;p=lyx.git diff --git a/src/insets/insettext.h b/src/insets/insettext.h index dff8829384..b49374fa93 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -19,9 +19,9 @@ #endif #include "lyxinset.h" -#include "lyxparagraph.h" #include "LString.h" -//#include "buffer.h" +#include "lyxparagraph.h" +#include "lyxcursor.h" class Painter; class BufferView; @@ -34,9 +34,10 @@ class Buffer; */ class InsetText : public UpdatableInset { public: - /// - enum { TEXT_TO_INSET_OFFSET = 1 }; /// + enum { TEXT_TO_INSET_OFFSET = 1 }; + /// + explicit InsetText(Buffer *); /// InsetText(InsetText const &, Buffer *); @@ -45,9 +46,11 @@ public: /// 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; /// @@ -63,7 +66,9 @@ public: /// 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 *); /// @@ -77,20 +82,13 @@ public: /// UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &); /// - int Latex(ostream &, signed char, bool free_spc) const; -#ifndef USE_OSTREAM_ONLY - /// - int Latex(string &, signed char, bool free_spc) const; + int Latex(std::ostream &, bool fragile, bool free_spc) const; /// - int Linuxdoc(string &) const { return 0; } + int Ascii(std::ostream &) const { return 0; } /// - int DocBook(string &) const { return 0; } -#else + int Linuxdoc(std::ostream &) const { return 0; } /// - int Linuxdoc(ostream &) const { return 0; } - /// - int DocBook(ostream &) const { return 0; } -#endif + int DocBook(std::ostream &) const { return 0; } /// void Validate(LaTeXFeatures & features) const; /// @@ -107,6 +105,10 @@ public: UpdatableInset * GetLockingInset(); /// void SetFont(BufferView *, LyXFont const &, bool toggleall = false); + /// + void init(Buffer *, InsetText const * ins = 0); + /// + void SetParagraphData(LyXParagraph *); LyXParagraph * par; @@ -114,9 +116,9 @@ protected: /// 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); /// @@ -126,6 +128,11 @@ protected: 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; /// @@ -133,15 +140,14 @@ protected: /// 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; @@ -163,43 +169,46 @@ private: /// 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; /// @@ -220,7 +229,7 @@ private: int baseline; }; /// - typedef vector RowList; + typedef std::vector RowList; /// mutable RowList rows; InsetText & operator = (InsetText const & it) { @@ -228,7 +237,6 @@ private: 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; @@ -236,12 +244,7 @@ private: 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