2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1998 The LyX Team.
9 *======================================================
11 // The pristine updatable inset: Text
22 #include "lyxparagraph.h"
30 /** A text inset is like a TeX box
32 To write full text (including styles and other insets) in a given
35 class InsetText : public UpdatableInset {
38 enum { TEXT_TO_INSET_OFFSET = 1 };
42 InsetText(InsetText const &, Buffer *);
46 Inset * Clone() const;
50 void Write(ostream &) const;
52 int ascent(Painter &, LyXFont const &) const;
54 int descent(Painter &, LyXFont const &) const;
56 int width(Painter &, LyXFont const & f) const;
58 void draw(Painter & pain, LyXFont const &, int , float &) const;
60 char const * EditMessage() const;
62 void Edit(BufferView *, int, int, unsigned int);
64 void InsetUnlock(BufferView *);
66 bool UnlockInsetInInset(BufferView *, Inset *, bool lr = false);
68 bool UpdateInsetInInset(BufferView *, Inset *);
70 void InsetButtonRelease(BufferView *, int, int, int);
72 void InsetButtonPress(BufferView *, int, int, int);
74 void InsetMotionNotify(BufferView *, int, int, int);
76 void InsetKeyPress(XKeyEvent *);
78 UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
80 int Latex(ostream &, signed char, bool free_spc) const;
82 int Linuxdoc(ostream &) const { return 0; }
84 int DocBook(ostream &) const { return 0; }
86 void Validate(LaTeXFeatures & features) const;
88 Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
90 void GetCursorPos(int & x, int & y) const;
94 void ToggleInsetCursor(BufferView *);
96 bool InsertInset(BufferView *, Inset *);
98 UpdatableInset * GetLockingInset();
100 void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
106 void UpdateLocal(BufferView *, bool);
108 void WriteParagraphData(ostream &) const;
110 void resetPos(BufferView *);
112 void drawSelection(Painter &, int pos, int baseline, float x);
114 void SingleHeight(Painter &, LyXParagraph * par,int pos,
115 int & asc, int & desc) const;
117 int SingleWidth(Painter &, LyXParagraph * par, int pos) const;
119 LyXFont GetFont(LyXParagraph * par, int pos) const;
123 LyXFont current_font;
125 LyXFont real_current_font;
127 mutable int maxWidth;
129 mutable int maxAscent;
131 mutable int maxDescent;
133 mutable int insetWidth;
141 void drawRowSelection(Painter &, int startpos, int endpos, int row,
142 int baseline, float x) const;
144 void drawRowText(Painter &, int startpos, int endpos, int baseline,
147 void computeTextRows(Painter &, float x = 0.0) const;
149 void computeBaselines(int) const;
151 int BeginningOfMainBody(LyXParagraph * par) const;
153 void ShowInsetCursor(BufferView *);
155 void HideInsetCursor(BufferView *);
157 void setPos(BufferView *, int x, int y, bool activate_inset = true);
159 bool moveRight(BufferView *, bool activate_inset = true);
160 bool moveLeft(BufferView *, bool activate_inset = true);
161 bool moveUp(BufferView *, bool activate_inset = true);
162 bool moveDown(BufferView *, bool activate_inset = true);
165 bool hasSelection() const { return selection_start != selection_end; }
167 void SetCharFont(int pos, LyXFont const & font);
171 /* Private structures and variables */
199 mutable bool init_inset;
201 UpdatableInset * the_locking_inset;
214 typedef vector<row_struct> RowList;
216 mutable RowList rows;
217 InsetText & operator = (InsetText const & it) {
219 buffer = it.buffer; // suspect
220 current_font = it.current_font;
221 real_current_font = it.real_current_font;
222 maxWidth = it.maxWidth;
223 maxAscent = it.maxAscent;
224 maxDescent = it.maxDescent;
225 insetWidth = it.insetWidth;
226 inset_pos = it.inset_pos;
227 inset_x = it.inset_x;
228 inset_y = it.inset_y;
229 interline_space = it.interline_space;
230 selection_start = it.selection_start;
231 selection_end = it.selection_end;
237 no_selection = it.no_selection;
238 the_locking_inset = it.the_locking_inset; // suspect