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)
112 MATHMACRO_CODE, // 30
144 TEXT_TO_INSET_OFFSET = 2
160 InsetOld(InsetOld const & in);
167 /// what appears in the minibuffer when opening
168 virtual std::string const editMessage() const;
170 virtual EDITABLE editable() const;
171 /// can we go further down on mouse click?
172 virtual bool descendable() const { return false; }
174 virtual bool isTextInset() const { return false; }
175 /// return true if the inset should be removed automatically
176 virtual bool autoDelete() const;
177 /// returns true the inset can hold an inset of given type
178 virtual bool insetAllowed(InsetOld::Code) const { return false; }
179 /// wrapper around the above
180 bool insetAllowed(InsetOld * in) const;
182 virtual void write(Buffer const &, std::ostream &) const = 0;
184 virtual void read(Buffer const &, LyXLex & lex) = 0;
185 /// returns the number of rows (\n's) of generated tex code.
186 virtual int latex(Buffer const &, std::ostream &,
187 OutputParams const &) const = 0;
189 virtual int plaintext(Buffer const &, std::ostream &,
190 OutputParams const &) const = 0;
192 virtual int linuxdoc(Buffer const &, std::ostream &,
193 OutputParams const &) const = 0;
195 virtual int docbook(Buffer const &, std::ostream &,
196 OutputParams const &) const = 0;
198 /// returns LyX code associated with the inset. Used for TOC, ...)
199 virtual InsetOld::Code lyxCode() const { return NO_CODE; }
201 /// returns true to override begin and end inset in file
202 virtual bool directWrite() const;
205 void setInsetName(std::string const & s) { name_ = s; }
207 std::string const & getInsetName() const { return name_; }
209 void setOwner(UpdatableInset * inset) { owner_ = inset; }
211 UpdatableInset * owner() const { return owner_; }
213 virtual void setBackgroundColor(LColor_color);
215 LColor_color backgroundColor() const;
217 int x() const { return xo_; }
219 int y() const { return yo_; }
220 /// returns the actual scroll-value
221 virtual int scroll(bool recursive = true) const;
223 /// if this insets owns text cells (e.g. InsetText) return cell num
224 virtual LyXText * getText(int /*num*/) const { return 0; }
226 virtual int numParagraphs() const { return 0; }
227 /// returns cell covering position (x,y), -1 if none exists
228 virtual int getCell(int x, int y) const;
230 /// used to toggle insets
231 // is the inset open?
232 virtual bool isOpen() const { return false; }
234 virtual void open() {}
236 virtual void close() {}
237 // should this inset be handled like a normal charater
238 virtual bool isChar() const { return false; }
239 // is this equivalent to a letter?
240 virtual bool isLetter() const { return false; }
241 // is this equivalent to a space (which is BTW different from
242 // a line separator)?
243 virtual bool isSpace() const { return false; }
244 // should we have a non-filled line before this inset?
245 virtual bool display() const { return false; }
246 // should we break lines after this inset?
247 virtual bool isLineSeparator() const { return false; }
248 // if this inset has paragraphs should they be output all as default
249 // paragraphs with "Standard" layout?
250 virtual bool forceDefaultParagraphs(InsetOld const *) const;
251 /** returns true if, when outputing LaTeX, font changes should
252 be closed before generating this inset. This is needed for
253 insets that may contain several paragraphs */
254 virtual bool noFontChange() const { return false; }
256 /// mark the inset contents as erased (for change tracking)
257 virtual void markErased() {}
259 /// does this inset allows spellchecking?
260 virtual bool allowSpellCheck() const { return true; }
262 /** Adds a LaTeX snippet to the Preview Loader for transformation
263 * into a bitmap image. Does not start the laoding process.
265 * Most insets have no interest in this capability, so the method
268 virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
277 mutable Dimension dim_;
281 UpdatableInset * owner_;
284 /** We store the LColor::color value as an int to get LColor.h out
285 * of the header file.
287 int background_color_;
291 /** \c InsetOld_code is a wrapper for InsetOld::Code.
292 * It can be forward-declared and passed as a function argument without
293 * having to expose inset.h.
295 class InsetOld_code {
298 InsetOld_code(InsetOld::Code val) : val_(val) {}
299 operator InsetOld::Code() const { return val_; }
304 * returns true if pointer argument is valid
305 * and points to an editable inset
307 bool isEditableInset(InsetOld const * inset);
311 * returns true if pointer argument is valid
312 * and points to a highly editable inset
314 bool isHighlyEditableInset(InsetOld const * inset);