class LyXParagraph;
class LColor;
class LyXText;
+class LyXScreen;
/**
* A text inset is like a TeX box to write full text
class InsetText : public UpdatableInset {
public:
///
- enum { TEXT_TO_INSET_OFFSET = 2 };
+ enum UpdateCodes {
+ NONE = 0,
+ INIT,
+ FULL,
+ CURSOR_PAR,
+ CURSOR,
+ SELECTION,
+ DRAW_FRAME,
+ CLEAR_FRAME
+ };
+ ///
+ enum DrawFrame {
+ NEVER = 0,
+ LOCKED,
+ ALWAYS
+ };
///
explicit
InsetText();
///
int width(Painter &, LyXFont const & f) const;
///
- void draw(Painter & pain, LyXFont const &, int , float &) const;
+ int textWidth(Painter &) const;
+ ///
+ void draw(BufferView *, LyXFont const &, int , float &, bool) const;
+ ///
+ void update(BufferView *, LyXFont const &, bool =false);
///
char const * EditMessage() const;
///
void Edit(BufferView *, int, int, unsigned int);
///
+ bool IsTextInset() const { return true; }
+ ///
+ bool doClearArea() const { return !locked; }
+ ///
void InsetUnlock(BufferView *);
///
bool LockInsetInInset(BufferView *, UpdatableInset *);
///
Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
///
- void GetCursorPos(int & x, int & y) const;
+ void GetCursorPos(BufferView *, int & x, int & y) const;
///
int InsetInInsetY();
///
///
void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
///
+ int getMaxWidth(Painter &, UpdatableInset const *) const;
+ ///
void init(InsetText const * ins = 0);
///
+ void WriteParagraphData(Buffer const *, std::ostream &) const;
+ ///
void SetParagraphData(LyXParagraph *);
///
void SetAutoBreakRows(bool);
///
- void SetDrawLockedFrame(bool);
+ void SetDrawFrame(BufferView *, DrawFrame);
///
- void SetFrameColor(LColor::color);
+ void SetFrameColor(BufferView *, LColor::color);
///
- void computeTextRows(Painter &) const;
+// LyXFont GetDrawFont(BufferView *, LyXParagraph *, int pos) const;
///
+ LyXText * getLyXText(BufferView *) const;
+ void deleteLyXText(BufferView *);
+
LyXParagraph * par;
///
+ mutable UpdateCodes need_update;
protected:
///
- void UpdateLocal(BufferView *, bool);
- ///
- void WriteParagraphData(Buffer const *, std::ostream &) const;
- ///
- void resetPos(Painter &) const;
- ///
- void drawSelection(Painter &, int pos, int baseline, float x);
- ///
- void SingleHeight(Painter &, LyXParagraph * par,int pos,
- int & asc, int & desc) const;
- ///
- int SingleWidth(Painter &, LyXParagraph * par, int pos) const;
- ///
- LyXFont GetFont(Buffer const *, LyXParagraph * par, int pos) const;
- ///
- virtual LyXFont GetDrawFont(Buffer const *, LyXParagraph * par, int pos) const;
- ///
- virtual int getMaxTextWidth(Painter &, UpdatableInset const *) const;
+ void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
- LyXText * text;
- ///
- LyXFont current_font;
- ///
- LyXFont real_current_font;
- ///
- mutable int maxAscent;
- ///
- mutable int maxDescent;
- ///
- mutable int insetWidth;
- ///
mutable int drawTextXOffset;
mutable int drawTextYOffset;
///
bool autoBreakRows;
- bool drawLockedFrame;
+ DrawFrame drawFrame;
///
LColor::color frame_color;
private:
///
- void drawRowSelection(Painter &, int startpos, int endpos, int row,
- int baseline, float x) const;
+ typedef std::map<BufferView *, LyXText *> Cache;
///
- void drawRowText(Painter &, int startpos, int endpos, int baseline,
- float x) const;
- ///
- void computeBaselines(int) const;
+ typedef Cache::value_type value_type;
///
int BeginningOfMainBody(Buffer const *, LyXParagraph * par) const;
///
///
void HideInsetCursor(BufferView *);
///
- void setPos(Painter &, int x, int y) const;
- ///
UpdatableInset::RESULT moveRight(BufferView *, bool activate_inset = true);
///
UpdatableInset::RESULT moveLeft(BufferView *, bool activate_inset = true);
///
UpdatableInset::RESULT moveDown(BufferView *);
///
- bool Delete();
- ///
- bool cutSelection(Buffer const *);
- ///
- bool copySelection(Buffer const *);
- ///
- bool pasteSelection(Buffer const *);
- ///
- bool hasSelection() const
- { return (selection_start_cursor != selection_end_cursor); }
- ///
void SetCharFont(Buffer const *, int pos, LyXFont const & font);
///
string getText(int);
///
+ bool checkAndActivateInset(BufferView * bv, bool behind);
bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
int button = 0);
+ ///
+ int cx(BufferView *) const;
+ int cy(BufferView *) const;
+ int cpos(BufferView *) const;
+ LyXParagraph * cpar(BufferView *) const;
+ Row * crow(BufferView *) const;
+
+ /// This instead of a macro
+ LyXText * TEXT(BufferView * bv) const {
+ return getLyXText(bv);
+ }
/* Private structures and variables */
///
- bool locked;
+ mutable bool locked;
+ ///
+ int insetAscent;
+ int insetDescent;
+ int insetWidth;
+ mutable int last_width;
+ mutable int last_height;
+ mutable int top_y;
+ ///
+ LyXParagraph * inset_par;
///
int inset_pos;
///
///
int interline_space;
///
- LyXCursor selection_start_cursor;
- ///
- LyXCursor selection_end_cursor;
- ///
- mutable LyXCursor cursor;
- ///
- mutable LyXCursor old_cursor;
- ///
- mutable int actrow;
- ///
bool no_selection;
///
mutable float xpos;
///
- mutable bool init_inset;
- ///
UpdatableInset * the_locking_inset;
///
- struct row_struct {
- ///
- int asc;
- ///
- int desc;
- ///
- int pos;
- ///
- int baseline;
- };
- ///
- typedef std::vector<row_struct> RowList;
- ///
- mutable RowList rows;
+ LyXParagraph * old_par;
+ /// The cache.
+ mutable Cache cache;
};
#endif