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"
41 class InsetOld : public InsetBase {
43 /** This is not quite the correct place for this enum. I think
44 the correct would be to let each subclass of Inset declare
45 its own enum code. Actually the notion of an InsetOld::Code
46 should be avoided, but I am not sure how this could be done
52 TOC_CODE, // do these insets really need a code? (ale)
114 MATHMACRO_CODE, // 30
146 TEXT_TO_INSET_OFFSET = 2
162 InsetOld(InsetOld const & in);
169 /// what appears in the minibuffer when opening
170 virtual std::string const editMessage() const;
172 virtual EDITABLE editable() const;
173 /// can we go further down on mouse click?
174 virtual bool descendable() const { return false; }
176 virtual bool isTextInset() const { return false; }
177 /// return true if the inset should be removed automatically
178 virtual bool autoDelete() const;
179 /// returns true the inset can hold an inset of given type
180 virtual bool insetAllowed(InsetOld::Code) const { return false; }
181 /// wrapper around the above
182 bool insetAllowed(InsetOld * in) const;
184 virtual void write(Buffer const &, std::ostream &) const = 0;
186 virtual void read(Buffer const &, LyXLex & lex) = 0;
187 /// returns the number of rows (\n's) of generated tex code.
188 virtual int latex(Buffer const &, std::ostream &,
189 OutputParams const &) const = 0;
191 virtual int plaintext(Buffer const &, std::ostream &,
192 OutputParams const &) const = 0;
194 virtual int linuxdoc(Buffer const &, std::ostream &,
195 OutputParams const &) const = 0;
197 virtual int docbook(Buffer const &, std::ostream &,
198 OutputParams const &) const = 0;
200 /// returns LyX code associated with the inset. Used for TOC, ...)
201 virtual InsetOld::Code lyxCode() const { return NO_CODE; }
203 /// returns true to override begin and end inset in file
204 virtual bool directWrite() const;
207 void setInsetName(std::string const & s) { name_ = s; }
209 std::string const & getInsetName() const { return name_; }
211 void setOwner(UpdatableInset * inset) { owner_ = inset; }
213 UpdatableInset * owner() const { return owner_; }
215 virtual void setBackgroundColor(LColor_color);
217 LColor_color backgroundColor() const;
219 int x() const { return xo_; }
221 int y() const { return yo_; }
222 /// returns the actual scroll-value
223 virtual int scroll(bool recursive = true) const;
225 /// if this insets owns text cells (e.g. InsetText) return cell num
226 virtual LyXText * getText(int /*num*/) const { return 0; }
228 virtual int numParagraphs() const { return 0; }
229 /// returns cell covering position (x,y), -1 if none exists
230 virtual int getCell(int x, int y) const;
232 /// used to toggle insets
233 // is the inset open?
234 virtual bool isOpen() const { return false; }
236 virtual void open() {}
238 virtual void close() {}
239 // should this inset be handled like a normal charater
240 virtual bool isChar() const { return false; }
241 // is this equivalent to a letter?
242 virtual bool isLetter() const { return false; }
243 // is this equivalent to a space (which is BTW different from
244 // a line separator)?
245 virtual bool isSpace() const { return false; }
246 // should we have a non-filled line before this inset?
247 virtual bool display() const { return false; }
248 // should we break lines after this inset?
249 virtual bool isLineSeparator() const { return false; }
250 // if this inset has paragraphs should they be output all as default
251 // paragraphs with "Standard" layout?
252 virtual bool forceDefaultParagraphs(InsetOld const *) const;
253 /** returns true if, when outputing LaTeX, font changes should
254 be closed before generating this inset. This is needed for
255 insets that may contain several paragraphs */
256 virtual bool noFontChange() const { return false; }
258 /// mark the inset contents as erased (for change tracking)
259 virtual void markErased() {}
261 /// does this inset allows spellchecking?
262 virtual bool allowSpellCheck() const { return true; }
264 /** Adds a LaTeX snippet to the Preview Loader for transformation
265 * into a bitmap image. Does not start the laoding process.
267 * Most insets have no interest in this capability, so the method
270 virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
279 mutable Dimension dim_;
283 UpdatableInset * owner_;
286 /** We store the LColor::color value as an int to get LColor.h out
287 * of the header file.
289 int background_color_;
293 /** \c InsetOld_code is a wrapper for InsetOld::Code.
294 * It can be forward-declared and passed as a function argument without
295 * having to expose inset.h.
297 class InsetOld_code {
300 InsetOld_code(InsetOld::Code val) : val_(val) {}
301 operator InsetOld::Code() const { return val_; }
306 * returns true if pointer argument is valid
307 * and points to an editable inset
309 bool isEditableInset(InsetOld const * inset);
313 * returns true if pointer argument is valid
314 * and points to a highly editable inset
316 bool isHighlyEditableInset(InsetOld const * inset);