]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettext.h
clear()->erase() ; lots of using directives for cxx
[lyx.git] / src / insets / insettext.h
index 08d4814d61233e3647b145eca60a14329eb6a405..b49374fa93d1212034ae6ab7989763c880ca148a 100644 (file)
@@ -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,10 +34,10 @@ class Buffer;
 */
 class InsetText : public UpdatableInset {
 public:
-       ///
-       enum { TEXT_TO_INSET_OFFSET = 1 };
     ///
-       explicit
+    enum { TEXT_TO_INSET_OFFSET = 1 };
+    ///
+    explicit
     InsetText(Buffer *);
     ///
     InsetText(InsetText const &, Buffer *);
@@ -46,6 +46,8 @@ public:
     ///
     Inset * Clone() const;
     ///
+    void clear() const { par->clearContents(); }
+    ///
     void Read(LyXLex &);
     ///
     void Write(std::ostream &) const;
@@ -64,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 *);
     ///
@@ -78,7 +82,9 @@ public:
     ///
     UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
     ///
-    int Latex(std::ostream &, signed char, bool free_spc) const;
+    int Latex(std::ostream &, bool fragile, bool free_spc) const;
+    ///
+    int Ascii(std::ostream &) const { return 0; }
     ///
     int Linuxdoc(std::ostream &) const { return 0; }
     ///
@@ -100,7 +106,9 @@ public:
     ///
     void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
     ///
-    void init(Buffer *, LyXParagraph * p = 0);
+    void init(Buffer *, InsetText const * ins = 0);
+    ///
+    void SetParagraphData(LyXParagraph *);
 
     LyXParagraph * par;
 
@@ -110,7 +118,7 @@ protected:
     ///
     void WriteParagraphData(std::ostream &) const;
     ///
-    void resetPos(BufferView *);
+    void resetPos(Painter &) const;
     ///
     void drawSelection(Painter &, int pos, int baseline, float x);
     ///
@@ -120,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;
     ///
@@ -127,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;
 
@@ -157,46 +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;
     ///
@@ -225,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;
@@ -233,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