2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright (C) 1998 The LyX Team.
9 *======================================================
11 // The pristine updatable inset: Text
22 #include "lyxparagraph.h"
29 /** A text inset is like a TeX box
31 To write full text (including styles and other insets) in a given
34 class InsetText : public UpdatableInset {
37 enum { TEXT_TO_INSET_OFFSET = 1 };
41 InsetText(InsetText const &, Buffer *);
45 InsetText * Clone() const;
49 void Write(ostream &) const;
51 int ascent(Painter &, LyXFont const &) const;
53 int descent(Painter &, LyXFont const &) const;
55 int width(Painter &, LyXFont const & f) const;
57 int getMaxWidth(UpdatableInset *) const;
59 void draw(Painter & pain, const LyXFont &, int , float &) const;
61 const char * EditMessage() const;
63 void Edit(BufferView *, int, int, unsigned int);
65 void InsetUnlock(BufferView *);
67 bool UnlockInsetInInset(BufferView *, Inset *, bool lr=false);
69 //void UpdateLocal(bool flag=true);
71 bool UpdateInsetInInset(BufferView *, Inset *);
73 void InsetButtonRelease(BufferView *, int, int, int);
75 void InsetButtonPress(BufferView *, int, int, int);
77 void InsetMotionNotify(BufferView *, int, int, int);
79 void InsetKeyPress(XKeyEvent *);
81 UpdatableInset::RESULT LocalDispatch(BufferView *, int, string);
83 int Latex(ostream &, signed char) const;
85 int Latex(string &, signed char) const;
87 int Linuxdoc(class string &) const { return true; }
89 int DocBook(class string &) const { return true; }
91 void Validate(LaTeXFeatures & features) const;
93 Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
95 void GetCursorPos(int & x, int & y);
99 void ToggleInsetCursor(BufferView *);
101 bool InsertInset(BufferView *, Inset *);
103 UpdatableInset * GetLockingInset();
105 void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
107 void init(BufferView *);
113 void WriteParagraphData(ostream &) const;
115 void resetPos(BufferView *);
117 void drawSelection(Painter & pain, int pos, int baseline, float x);
119 void SingleHeight(BufferView *, LyXParagraph * par,int pos,
120 int & asc, int & desc);
122 int SingleWidth(BufferView * bv, LyXParagraph * par, int pos);
124 LyXFont GetFont(LyXParagraph * par, int pos) const;
128 LyXFont current_font;
130 LyXFont real_current_font;
142 void drawRowSelection(Painter &, int startpos, int endpos, int row,
143 int baseline, float x) const;
145 void drawRowText(Painter &, int startpos, int endpos, int baseline,
148 void computeTextRows(BufferView *);
150 void computeBaselines(int) const;
152 int BeginningOfMainBody(LyXParagraph * par) const;
154 void ShowInsetCursor(BufferView *);
156 void HideInsetCursor(BufferView *);
158 void setPos(BufferView *, int x, int y, bool activate_inset=true);
160 bool moveRight(BufferView *, bool activate_inset = true);
161 bool moveLeft(BufferView *, bool activate_inset = true);
162 bool moveUp(BufferView *, bool activate_inset = true);
163 bool moveDown(BufferView *, bool activate_inset = true);
166 bool hasSelection() const {return (selection_start != selection_end);}
168 void SetCharFont(int pos, LyXFont font);
172 /* Private structures and variables */
200 UpdatableInset * the_locking_inset;
213 typedef vector<row_struct> RowList;
215 mutable RowList rows;
216 InsetText & operator = (InsetText const & it) {
218 buffer = it.buffer; // suspect
219 current_font = it.current_font;
220 real_current_font = it.real_current_font;
221 maxWidth = it.maxWidth;
222 maxAscent = it.maxAscent;
223 maxDescent = it.maxDescent;
224 insetWidth = it.insetWidth;
225 inset_pos = it.inset_pos;
226 inset_x = it.inset_x;
227 inset_y = it.inset_y;
228 interline_space = it.interline_space;
229 selection_start = it.selection_start;
230 selection_end = it.selection_end;
236 no_selection = it.no_selection;
237 the_locking_inset = it.the_locking_inset; // suspect