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
23 #include "lyxcursor.h"
34 * A text inset is like a TeX box to write full text
35 * (including styles and other insets) in a given space.
37 class InsetText : public UpdatableInset {
40 enum { TEXT_TO_INSET_OFFSET = 2 };
45 InsetText(InsetText const &);
49 Inset * Clone() const;
51 InsetText & operator= (InsetText const & it);
53 void clear() const { par->clearContents(); }
55 void Read(Buffer const *, LyXLex &);
57 void Write(Buffer const *, std::ostream &) const;
59 int ascent(Painter &, LyXFont const &) const;
61 int descent(Painter &, LyXFont const &) const;
63 int width(Painter &, LyXFont const & f) const;
65 void draw(Painter & pain, LyXFont const &, int , float &) const;
67 void update(BufferView *, LyXFont const &) const;
69 char const * EditMessage() const;
71 void Edit(BufferView *, int, int, unsigned int);
73 void InsetUnlock(BufferView *);
75 bool LockInsetInInset(BufferView *, UpdatableInset *);
77 bool UnlockInsetInInset(BufferView *, UpdatableInset *, bool lr = false);
79 bool UpdateInsetInInset(BufferView *, Inset *);
81 void InsetButtonRelease(BufferView *, int, int, int);
83 void InsetButtonPress(BufferView *, int, int, int);
85 void InsetMotionNotify(BufferView *, int, int, int);
87 void InsetKeyPress(XKeyEvent *);
89 UpdatableInset::RESULT LocalDispatch(BufferView *, int, string const &);
91 int Latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
93 int Ascii(Buffer const *, std::ostream &) const { return 0; }
95 int Linuxdoc(Buffer const *, std::ostream &) const { return 0; }
97 int DocBook(Buffer const *, std::ostream &) const { return 0; }
99 void Validate(LaTeXFeatures & features) const;
101 Inset::Code LyxCode() const { return Inset::TEXT_CODE; }
103 void GetCursorPos(int & x, int & y) const;
107 void ToggleInsetCursor(BufferView *);
109 bool InsertInset(BufferView *, Inset *);
111 UpdatableInset * GetLockingInset();
113 UpdatableInset * GetFirstLockingInsetOfType(Inset::Code);
115 void SetFont(BufferView *, LyXFont const &, bool toggleall = false);
117 void init(InsetText const * ins = 0);
119 void SetParagraphData(LyXParagraph *);
121 void SetAutoBreakRows(bool);
123 void SetDrawLockedFrame(bool);
125 void SetFrameColor(LColor::color);
127 LyXFont GetDrawFont(Buffer const *, LyXParagraph *, int pos) const;
134 void UpdateLocal(BufferView *, bool what, bool mark_dirty);
136 void WriteParagraphData(Buffer const *, std::ostream &) const;
138 virtual int getMaxTextWidth(Painter &, UpdatableInset const *) const;
142 mutable int drawTextXOffset;
143 mutable int drawTextYOffset;
146 bool drawLockedFrame;
148 LColor::color frame_color;
152 int BeginningOfMainBody(Buffer const *, LyXParagraph * par) const;
154 void ShowInsetCursor(BufferView *);
156 void HideInsetCursor(BufferView *);
158 UpdatableInset::RESULT moveRight(BufferView *, bool activate_inset = true);
160 UpdatableInset::RESULT moveLeft(BufferView *, bool activate_inset = true);
162 UpdatableInset::RESULT moveUp(BufferView *);
164 UpdatableInset::RESULT moveDown(BufferView *);
168 void SetCharFont(Buffer const *, int pos, LyXFont const & font);
172 bool checkAndActivateInset(BufferView * bv, int x = 0, int y = 0,
177 LyXParagraph * cpar() const;
180 /* Private structures and variables */
196 mutable bool init_inset;
198 UpdatableInset * the_locking_inset;
200 LyXParagraph * old_par;