4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
17 #include "ColorCode.h"
31 A text inset is like a TeX box to write full text
32 (including styles and other insets) in a given space.
34 class InsetText : public Inset {
37 explicit InsetText(BufferParams const &);
41 InsetText(InsetText const &);
44 Dimension const dimension(BufferView const &) const;
46 /// empty inset to empty par
49 void read(Lexer & lex);
51 void write(std::ostream & os) const;
53 void metrics(MetricsInfo & mi, Dimension & dim) const;
55 void draw(PainterInfo & pi, int x, int y) const;
57 docstring editMessage() const;
59 EDITABLE editable() const { return HIGHLY_EDITABLE; }
61 bool canTrackChanges() const { return true; }
63 InsetText * asInsetText() { return this; }
65 InsetText const * asInsetText() const { return this; }
67 int latex(odocstream &, OutputParams const &) const;
69 int plaintext(odocstream &, OutputParams const &) const;
71 int docbook(odocstream &, OutputParams const &) const;
73 void validate(LaTeXFeatures & features) const;
75 /// return x,y of given position relative to the inset's baseline
76 void cursorPos(BufferView const & bv, CursorSlice const & sl,
77 bool boundary, int & x, int & y) const;
79 InsetCode lyxCode() const { return TEXT_CODE; }
81 void setText(docstring const &, Font const &, bool trackChanges);
83 void setAutoBreakRows(bool);
85 bool getAutoBreakRows() const { return text_.autoBreakRows_; }
87 void setDrawFrame(bool);
89 ColorCode frameColor() const;
91 void setFrameColor(ColorCode);
93 bool showInsetDialog(BufferView *) const;
95 Text * getText(int i) const {
96 return (i == 0) ? const_cast<Text*>(&text_) : 0;
99 virtual bool getStatus(Cursor & cur, FuncRequest const & cmd, FuncStatus &) const;
101 /// set the change for the entire inset
102 void setChange(Change const & change);
103 /// accept the changes within the inset
104 void acceptChanges(BufferParams const & bparams);
105 /// reject the changes within the inset
106 void rejectChanges(BufferParams const & bparams);
108 /// append text onto the existing text
109 void appendParagraphs(ParagraphList &);
112 void addPreview(graphics::PreviewLoader &) const;
115 void edit(Cursor & cur, bool front, EntryDirection entry_from);
117 Inset * editXY(Cursor & cur, int x, int y);
119 /// number of cells in this inset
120 size_t nargs() const { return 1; }
122 ParagraphList & paragraphs();
124 ParagraphList const & paragraphs() const;
126 bool insetAllowed(InsetCode) const { return true; }
128 bool allowSpellCheck() const { return true; }
129 /// should paragraph indendation be ommitted in any case?
130 bool neverIndent() const;
132 virtual bool isMacroScope() const { return true; }
134 virtual bool allowMultiPar() const { return true; }
136 // Update the counters of this inset and of its contents
137 void updateLabels(ParIterator const &);
139 Inset * clone() const;
141 virtual bool notifyCursorLeaves(Cursor const & old, Cursor & cur);
144 bool completionSupported(Cursor const &) const;
146 bool inlineCompletionSupported(Cursor const & cur) const;
148 bool automaticInlineCompletion() const;
150 bool automaticPopupCompletion() const;
152 CompletionList const * createCompletionList(Cursor const & cur) const;
154 docstring completionPrefix(Cursor const & cur) const;
156 bool insertCompletion(Cursor & cur, docstring const & s, bool finished);
158 void completionPosAndDim(Cursor const &, int & x, int & y, Dimension & dim) const;
162 virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
166 void setParagraphOwner();
170 ColorCode frame_color_;
172 mutable pit_type old_pit;
174 docstring previousWord(CursorSlice const & sl) const;