2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1998 The LyX Team.
9 * @author: Jürgen Vigna
11 *======================================================
13 // The pristine updatable inset: Text
25 #include "lyxcursor.h"
37 * A text inset is like a TeX box to write full text
38 * (including styles and other insets) in a given space.
40 class InsetText : public UpdatableInset {
63 InsetText(InsetText const &);
67 Inset * Clone() const;
69 InsetText & operator= (InsetText const & it);
73 void Read(Buffer const *, LyXLex &);
75 void Write(Buffer const *, std::ostream &) const;
77 int ascent(BufferView *, LyXFont const &) const;
79 int descent(BufferView *, LyXFont const &) const;
81 int width(BufferView *, LyXFont const & f) const;
83 int textWidth(Painter &) const;
85 void draw(BufferView *, LyXFont const &, int , float &, bool) const;
87 void update(BufferView *, LyXFont const &, bool =false);
89 char const * EditMessage() const;
91 void Edit(BufferView *, int, int, unsigned int);
93 bool IsTextInset() const { return true; }
95 bool doClearArea() const { return !locked; }
97 void InsetUnlock(BufferView *);
99 bool LockInsetInInset(BufferView *, UpdatableInset *);
101 bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
103 bool UpdateInsetInInset(BufferView *, Inset *);
105 void InsetButtonRelease(BufferView *, int, int, int);
107 void InsetButtonPress(BufferView *, int, int, int);
109 void InsetMotionNotify(BufferView *, int, int, int);
111 void InsetKeyPress(XKeyEvent *);
113 UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
115 int Latex(Buffer const *, std::ostream &,
116 bool fragile, bool free_spc) const;
118 int Ascii(Buffer const *, std::ostream &) const { return 0; }
120 int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
122 int DocBook(Buffer const *, std::ostream &) const { return 0; }
124 void Validate(LaTeXFeatures & features) const;
126 Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
128 void GetCursorPos(BufferView *, int & x, int & y) const;
132 void ToggleInsetCursor(BufferView *);
134 bool InsertInset(BufferView *, Inset *);
136 UpdatableInset * GetLockingInset();
138 UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
140 void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
142 int getMaxWidth(Painter &, UpdatableInset const *) const;
144 void init(InsetText const * ins = 0);
146 void WriteParagraphData(Buffer const *, std::ostream &) const;
148 void SetParagraphData(LyXParagraph *);
150 void SetAutoBreakRows(bool);
152 void SetDrawFrame(BufferView *, DrawFrame);
154 void SetFrameColor(BufferView *, LColor::color);
156 // LyXFont GetDrawFont(BufferView *, LyXParagraph *, int pos) const;
158 LyXText * getLyXText(BufferView *) const;
160 void deleteLyXText(BufferView *, bool recursive=true) const;
162 void resizeLyXText(BufferView *) const;
166 mutable UpdateCodes need_update;
170 void UpdateLocal(BufferView *, UpdateCodes, bool mark_dirty);
172 mutable int drawTextXOffset;
174 mutable int drawTextYOffset;
180 LColor::color frame_color;
184 typedef std::map<BufferView *, LyXText *> Cache;
186 typedef Cache::value_type value_type;
188 int BeginningOfMainBody(Buffer const *, LyXParagraph * par) const;
190 void ShowInsetCursor(BufferView *);
192 void HideInsetCursor(BufferView *);
194 UpdatableInset::RESULT moveRight(BufferView *, bool activate_inset = true);
196 UpdatableInset::RESULT moveLeft(BufferView *, bool activate_inset = true);
198 UpdatableInset::RESULT moveUp(BufferView *);
200 UpdatableInset::RESULT moveDown(BufferView *);
202 void SetCharFont(Buffer const *, int pos, LyXFont const & font);
206 bool checkAndActivateInset(BufferView * bv, bool behind);
208 bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
210 void removeNewlines();
213 int cx(BufferView *) const;
215 int cy(BufferView *) const;
217 int cpos(BufferView *) const;
219 LyXParagraph * cpar(BufferView *) const;
221 Row * crow(BufferView *) const;
223 /// This instead of a macro
224 LyXText * TEXT(BufferView * bv) const {
225 return getLyXText(bv);
228 /* Private structures and variables */
232 mutable int insetAscent;
234 mutable int insetDescent;
236 mutable int insetWidth;
238 mutable int last_width;
240 mutable int last_height;
244 LyXParagraph * inset_par;
258 UpdatableInset * the_locking_inset;
260 LyXParagraph * old_par;