2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1998 The LyX Team.
10 *======================================================
12 // The pristine updatable inset: Text
24 #include "lyxcursor.h"
36 A text inset is like a TeX box to write full text
37 (including styles and other insets) in a given space.
40 class InsetText : public UpdatableInset {
74 InsetText(InsetText const &);
78 Inset * Clone() const;
80 InsetText & operator=(InsetText const & it);
84 void Read(Buffer const *, LyXLex &);
86 void Write(Buffer const *, std::ostream &) const;
88 int ascent(BufferView *, LyXFont const &) const;
90 int descent(BufferView *, LyXFont const &) const;
92 int width(BufferView *, LyXFont const & f) const;
94 int textWidth(Painter &) const;
96 void draw(BufferView *, LyXFont const &, int , float &, bool) const;
98 void update(BufferView *, LyXFont const &, bool =false);
100 string const EditMessage() const;
102 void Edit(BufferView *, int, int, unsigned int);
104 bool IsTextInset() const { return true; }
106 bool doClearArea() const { return !locked; }
108 void InsetUnlock(BufferView *);
110 bool LockInsetInInset(BufferView *, UpdatableInset *);
112 bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
114 bool UpdateInsetInInset(BufferView *, Inset *);
116 void InsetButtonRelease(BufferView *, int, int, int);
118 void InsetButtonPress(BufferView *, int, int, int);
120 void InsetMotionNotify(BufferView *, int, int, int);
122 void InsetKeyPress(XKeyEvent *);
124 UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
126 int Latex(Buffer const *, std::ostream &,
127 bool fragile, bool free_spc) const;
129 int Ascii(Buffer const *, std::ostream &, int linelen) const;
131 int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
133 int DocBook(Buffer const *, std::ostream &) const { return 0; }
135 void Validate(LaTeXFeatures & features) const;
137 Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
139 void GetCursorPos(BufferView *, int & x, int & y) const;
141 unsigned int InsetInInsetY();
143 void ToggleInsetCursor(BufferView *);
145 bool InsertInset(BufferView *, Inset *);
147 UpdatableInset * GetLockingInset();
149 UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
151 void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
153 int getMaxWidth(Painter &, UpdatableInset const *) const;
155 void init(InsetText const * ins = 0);
157 void WriteParagraphData(Buffer const *, std::ostream &) const;
159 void SetParagraphData(LyXParagraph *);
161 void SetAutoBreakRows(bool);
163 void SetDrawFrame(BufferView *, DrawFrame);
165 void SetFrameColor(BufferView *, LColor::color);
167 LyXText * getLyXText(BufferView *) const;
169 void deleteLyXText(BufferView *, bool recursive=true) const;
171 void resizeLyXText(BufferView *) const;
175 mutable UpdateCodes need_update;
179 void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
181 mutable int drawTextXOffset;
183 mutable int drawTextYOffset;
189 LColor::color frame_color;
193 typedef std::map<BufferView *, LyXText *> Cache;
195 typedef Cache::value_type value_type;
197 int BeginningOfMainBody(Buffer const *, LyXParagraph * par) const;
199 void ShowInsetCursor(BufferView *);
201 void HideInsetCursor(BufferView *);
203 UpdatableInset::RESULT moveRight(BufferView *, bool activate_inset = true,
204 bool selecting = false);
206 UpdatableInset::RESULT moveLeft(BufferView *, bool activate_inset = true,
207 bool selecting = false);
209 UpdatableInset::RESULT moveUp(BufferView *);
211 UpdatableInset::RESULT moveDown(BufferView *);
213 void SetCharFont(Buffer const *, int pos, LyXFont const & font);
215 string const getText(int);
217 bool checkAndActivateInset(BufferView * bv, bool behind);
219 bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
221 void removeNewlines();
224 int cx(BufferView *) const;
226 int cy(BufferView *) const;
228 int cpos(BufferView *) const;
230 LyXParagraph * cpar(BufferView *) const;
232 Row * crow(BufferView *) const;
234 /// This instead of a macro
235 LyXText * TEXT(BufferView * bv) const {
236 return getLyXText(bv);
239 /* Private structures and variables */
243 mutable int insetAscent;
245 mutable int insetDescent;
247 mutable int insetWidth;
249 mutable int last_width;
251 mutable int last_height;
255 LyXParagraph * inset_par;
269 UpdatableInset * the_locking_inset;
271 LyXParagraph * old_par;