4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Alejandro Aguilar Sierra
9 * \author Lars Gullik Bjønnes
10 * \author Matthias Ettrich
12 * Full author contact details are available in file CREDITS.
18 #include "insetbase.h"
19 #include "dimension.h"
20 #include "ParagraphList_fwd.h"
42 class InsetOld : public InsetBase {
44 /** This is not quite the correct place for this enum. I think
45 the correct would be to let each subclass of Inset declare
46 its own enum code. Actually the notion of an InsetOld::Code
47 should be avoided, but I am not sure how this could be done
53 TOC_CODE, // do these insets really need a code? (ale)
115 MATHMACRO_CODE, // 30
143 TEXT_TO_INSET_OFFSET = 2
159 InsetOld(InsetOld const & in);
166 /// what appears in the minibuffer when opening
167 virtual std::string const editMessage() const;
169 virtual EDITABLE editable() const;
170 /// can we go further down on mouse click?
171 virtual bool descendable() const { return false; }
173 virtual bool isTextInset() const { return false; }
174 /// return true if the inset should be removed automatically
175 virtual bool autoDelete() const;
176 /// returns true the inset can hold an inset of given type
177 virtual bool insetAllowed(InsetOld::Code) const { return false; }
178 /// wrapper around the above
179 bool insetAllowed(InsetOld * in) const;
181 virtual void write(Buffer const &, std::ostream &) const = 0;
183 virtual void read(Buffer const &, LyXLex & lex) = 0;
184 /// returns the number of rows (\n's) of generated tex code.
185 virtual int latex(Buffer const &, std::ostream &,
186 OutputParams const &) const = 0;
188 virtual int plaintext(Buffer const &, std::ostream &,
189 OutputParams const &) const = 0;
191 virtual int linuxdoc(Buffer const &, std::ostream &,
192 OutputParams const &) const = 0;
194 virtual int docbook(Buffer const &, std::ostream &,
195 OutputParams const &) const = 0;
197 /// returns LyX code associated with the inset. Used for TOC, ...)
198 virtual InsetOld::Code lyxCode() const { return NO_CODE; }
200 /// returns true to override begin and end inset in file
201 virtual bool directWrite() const;
204 void setInsetName(std::string const & s) { name_ = s; }
206 std::string const & getInsetName() const { return name_; }
208 void setOwner(UpdatableInset * inset) { owner_ = inset; }
210 UpdatableInset * owner() const { return owner_; }
212 void setBackgroundColor(LColor_color);
214 LColor_color backgroundColor() const;
216 int x() const { return xo_; }
218 int y() const { return yo_; }
220 virtual void deleteLyXText(BufferView *, bool = true) const {}
221 /// returns the actuall scroll-value
222 virtual int scroll(bool recursive=true) const {
223 if (!recursive || !owner_)
228 /// if this insets owns paragraphs (f.ex. InsetText) then it
229 /// should return it's very first one!
230 virtual ParagraphList * getParagraphs(int /*num*/) const { return 0; }
232 virtual LyXText * getText(int /*num*/) const { return 0; }
234 virtual int numParagraphs() const { return 0; }
236 /// used to toggle insets
237 // is the inset open?
238 virtual bool isOpen() const { return false; }
240 virtual void open(BufferView *) {}
242 virtual void close(BufferView *) const {}
243 /// check if the font of the char we want inserting is correct
244 /// and modify it if it is not.
245 virtual bool checkInsertChar(LyXFont &);
246 /// we need this here because collapsed insets are only EDITABLE
247 virtual void setFont(BufferView *, LyXFont const &,
248 bool toggleall = false, bool selectall = false);
250 // should this inset be handled like a normal charater
251 virtual bool isChar() const { return false; }
252 // is this equivalent to a letter?
253 virtual bool isLetter() const { return false; }
254 // is this equivalent to a space (which is BTW different from
255 // a line separator)?
256 virtual bool isSpace() const { return false; }
257 // should we have a non-filled line before this inset?
258 virtual bool display() const { return false; }
259 // should we break lines after this inset?
260 virtual bool isLineSeparator() const { return false; }
261 // if this inset has paragraphs should they be output all as default
262 // paragraphs with "Standard" layout?
263 virtual bool forceDefaultParagraphs(InsetOld const *) const;
264 /** returns true if, when outputing LaTeX, font changes should
265 be closed before generating this inset. This is needed for
266 insets that may contain several paragraphs */
267 virtual bool noFontChange() const { return false; }
269 virtual void getDrawFont(LyXFont &) const {}
270 /* needed for widths which are % of something
271 returns the value of \textwidth in this inset. Most of the
272 time this is the width of the workarea, but if there is a
273 minipage somewhere, it will be the width of this minipage */
274 virtual int latexTextWidth(BufferView *) const;
276 /// mark the inset contents as erased (for change tracking)
277 virtual void markErased() {}
279 /// does this inset allows spellchecking?
280 virtual bool allowSpellCheck() const { return true; }
282 /** Adds a LaTeX snippet to the Preview Loader for transformation
283 * into a bitmap image. Does not start the laoding process.
285 * Most insets have no interest in this capability, so the method
288 virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
297 mutable Dimension dim_;
301 UpdatableInset * owner_;
304 /** We store the LColor::color value as an int to get LColor.h out
305 * of the header file.
307 int background_color_;
311 /** \c InsetOld_code is a wrapper for InsetOld::Code.
312 * It can be forward-declared and passed as a function argument without
313 * having to expose inset.h.
315 class InsetOld_code {
318 InsetOld_code(InsetOld::Code val) : val_(val) {}
319 operator InsetOld::Code() const { return val_; }
324 * returns true if pointer argument is valid
325 * and points to an editable inset
327 bool isEditableInset(InsetOld const * inset);
331 * returns true if pointer argument is valid
332 * and points to a highly editable inset
334 bool isHighlyEditableInset(InsetOld const * inset);