X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsettext.h;h=b49374fa93d1212034ae6ab7989763c880ca148a;hb=3c8aba3b556871fb1100a2f98cd93d5d4e3f70c9;hp=b7adc791d270a905767b4fca5549e211f7239f49;hpb=d6fa7c567c47f1af95f026174a83bf75dde08f84;p=lyx.git diff --git a/src/insets/insettext.h b/src/insets/insettext.h index b7adc791d2..b49374fa93 100644 --- a/src/insets/insettext.h +++ b/src/insets/insettext.h @@ -4,7 +4,7 @@ * * LyX, The Document Processor * - * Copyright (C) 1998 The LyX Team. + * Copyright 1998 The LyX Team. * *====================================================== */ @@ -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,19 +58,17 @@ public: /// int width(Painter &, LyXFont const & f) const; /// - int getMaxWidth(UpdatableInset *) const; - /// - void draw(Painter & pain, const LyXFont &, int , float &) const; + void draw(Painter & pain, LyXFont const &, int , float &) const; /// - const char * EditMessage() const; + char const * EditMessage() const; /// void Edit(BufferView *, int, int, unsigned int); /// 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 *); /// @@ -78,21 +80,21 @@ public: /// void InsetKeyPress(XKeyEvent *); /// - UpdatableInset::RESULT LocalDispatch(BufferView *, int, string); + 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(class string &) const { return true; } + int Linuxdoc(std::ostream &) const { return 0; } /// - int DocBook(class string &) const { return true; } + 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(); /// @@ -104,38 +106,50 @@ public: /// void SetFont(BufferView *, LyXFont const &, bool toggleall = false); /// - void init(BufferView *); + void init(Buffer *, InsetText const * ins = 0); + /// + void SetParagraphData(LyXParagraph *); LyXParagraph * par; protected: /// - void WriteParagraphData(ostream &) const; + void UpdateLocal(BufferView *, bool); /// - void resetPos(BufferView *); + void WriteParagraphData(std::ostream &) const; /// - void drawSelection(Painter & pain, int pos, int baseline, float x); + void resetPos(Painter &) const; /// - void SingleHeight(BufferView *, LyXParagraph * par,int pos, - int & asc, int & desc); + void drawSelection(Painter &, int pos, int baseline, float x); /// - int SingleWidth(BufferView * bv, LyXParagraph * par, int pos); + void SingleHeight(Painter &, LyXParagraph * par,int pos, + int & asc, int & desc) const; + /// + 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 current_font; - /// - LyXFont real_current_font; - /// - int maxWidth; - /// - int maxAscent; - /// - int maxDescent; - /// - int insetWidth; + /// + LyXFont real_current_font; + /// + mutable int maxAscent; + /// + mutable int maxDescent; + /// + mutable int insetWidth; + /// + mutable int drawTextXOffset; + mutable int drawTextYOffset; + /// + bool autoBreakRows; private: /// @@ -145,7 +159,7 @@ private: void drawRowText(Painter &, int startpos, int endpos, int baseline, float x) const; /// - void computeTextRows(BufferView *); + void computeTextRows(Painter &, float x = 0.0) const; /// void computeBaselines(int) const; /// @@ -155,47 +169,52 @@ 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 font); + 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; + LyXCursor selection_start_cursor; /// - int selection_end; + LyXCursor selection_end_cursor; /// - int old_x; + mutable LyXCursor cursor; /// - int cx; + mutable LyXCursor old_cursor; /// - int cy; - /// - int actpos; - /// - int actrow; + mutable int actrow; /// bool no_selection; /// - bool init_inset; + mutable float xpos; + /// + mutable bool init_inset; /// UpdatableInset * the_locking_inset; /// @@ -210,7 +229,7 @@ private: int baseline; }; /// - typedef vector RowList; + typedef std::vector RowList; /// mutable RowList rows; InsetText & operator = (InsetText const & it) { @@ -218,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; @@ -226,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