X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsettext.h;h=b49374fa93d1212034ae6ab7989763c880ca148a;hb=3c8aba3b556871fb1100a2f98cd93d5d4e3f70c9;hp=88de0c5d10e8fea5acd5069757b06ffdbbd1cb6d;hpb=2be7e39279064dacc42a28bc9f02d7c6887ea368;p=lyx.git diff --git a/src/insets/insettext.h b/src/insets/insettext.h index 88de0c5d10..b49374fa93 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -19,12 +19,13 @@ #endif #include "lyxinset.h" -#include "lyxparagraph.h" #include "LString.h" -#include "buffer.h" +#include "lyxparagraph.h" +#include "lyxcursor.h" class Painter; class BufferView; +class Buffer; /** A text inset is like a TeX box @@ -33,20 +34,23 @@ 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 *); /// ~InsetText(); /// - InsetText * Clone() const; + 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; /// @@ -54,8 +58,6 @@ public: /// int width(Painter &, LyXFont const & f) const; /// - int getMaxWidth(UpdatableInset *) const; - /// void draw(Painter & pain, LyXFont const &, int , float &) const; /// char const * EditMessage() const; @@ -64,9 +66,9 @@ public: /// void InsetUnlock(BufferView *); /// - bool UnlockInsetInInset(BufferView *, Inset *, bool lr = false); + bool LockInsetInInset(BufferView *, UpdatableInset *); /// - //void UpdateLocal(bool flag=true); + bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false); /// bool UpdateInsetInInset(BufferView *, Inset *); /// @@ -80,19 +82,19 @@ public: /// UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &); /// - int Latex(ostream &, signed char) const; + int Latex(std::ostream &, bool fragile, bool free_spc) const; /// - int Latex(string &, signed char) const; + int Ascii(std::ostream &) const { return 0; } /// - int Linuxdoc(string &) const { return 0; } + int Linuxdoc(std::ostream &) const { return 0; } /// - int DocBook(string &) const { return 0; } + int DocBook(std::ostream &) const { return 0; } /// void Validate(LaTeXFeatures & features) const; /// Inset::Code LyxCode() const { return Inset::TEXT_CODE; } /// - void GetCursorPos(int & x, int & y); + void GetCursorPos(int & x, int & y) const; /// int InsetInInsetY(); /// @@ -103,14 +105,20 @@ public: UpdatableInset * GetLockingInset(); /// void SetFont(BufferView *, LyXFont const &, bool toggleall = false); + /// + void init(Buffer *, InsetText const * ins = 0); + /// + void SetParagraphData(LyXParagraph *); LyXParagraph * par; protected: /// - void WriteParagraphData(ostream &) const; + void UpdateLocal(BufferView *, bool); + /// + void WriteParagraphData(std::ostream &) const; /// - void resetPos(BufferView *); + void resetPos(Painter &) const; /// void drawSelection(Painter &, int pos, int baseline, float x); /// @@ -121,19 +129,27 @@ protected: /// 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 current_font; /// LyXFont real_current_font; /// - int maxWidth; - /// mutable int maxAscent; /// mutable int maxDescent; /// mutable int insetWidth; + /// + mutable int drawTextXOffset; + mutable int drawTextYOffset; + /// + bool autoBreakRows; private: /// @@ -143,7 +159,7 @@ private: void drawRowText(Painter &, int startpos, int endpos, int baseline, float x) const; /// - void computeTextRows(Painter &) const; + void computeTextRows(Painter &, float x = 0.0) const; /// void computeBaselines(int) const; /// @@ -153,46 +169,51 @@ 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; + LyXCursor selection_start_cursor; /// - int old_x; + LyXCursor selection_end_cursor; /// - int cx; + mutable LyXCursor cursor; /// - int cy; + mutable LyXCursor old_cursor; /// - int actpos; - /// - int actrow; + mutable int actrow; /// bool no_selection; /// + mutable float xpos; + /// mutable bool init_inset; /// UpdatableInset * the_locking_inset; @@ -208,7 +229,7 @@ private: int baseline; }; /// - typedef vector RowList; + typedef std::vector RowList; /// mutable RowList rows; InsetText & operator = (InsetText const & it) { @@ -216,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; @@ -224,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