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
147 TEXT_TO_INSET_OFFSET = 2
163 InsetOld(InsetOld const & in);
170 /// what appears in the minibuffer when opening
171 virtual std::string const editMessage() const;
173 virtual EDITABLE editable() const;
174 /// can we go further down on mouse click?
175 virtual bool descendable() const { return false; }
177 virtual bool isTextInset() const { return false; }
178 /// return true if the inset should be removed automatically
179 virtual bool autoDelete() const;
180 /// returns true the inset can hold an inset of given type
181 virtual bool insetAllowed(InsetOld::Code) const { return false; }
182 /// wrapper around the above
183 bool insetAllowed(InsetOld * in) const;
185 virtual void write(Buffer const &, std::ostream &) const = 0;
187 virtual void read(Buffer const &, LyXLex & lex) = 0;
188 /// returns the number of rows (\n's) of generated tex code.
189 virtual int latex(Buffer const &, std::ostream &,
190 OutputParams const &) const = 0;
192 virtual int plaintext(Buffer const &, std::ostream &,
193 OutputParams const &) const = 0;
195 virtual int linuxdoc(Buffer const &, std::ostream &,
196 OutputParams const &) const = 0;
198 virtual int docbook(Buffer const &, std::ostream &,
199 OutputParams const &) const = 0;
201 /// returns LyX code associated with the inset. Used for TOC, ...)
202 virtual InsetOld::Code lyxCode() const { return NO_CODE; }
204 /// returns true to override begin and end inset in file
205 virtual bool directWrite() const;
208 void setInsetName(std::string const & s) { name_ = s; }
210 std::string const & getInsetName() const { return name_; }
212 void setOwner(UpdatableInset * inset) { owner_ = inset; }
214 UpdatableInset * owner() const { return owner_; }
216 virtual void setBackgroundColor(LColor_color);
218 LColor_color backgroundColor() const;
220 int x() const { return xo_; }
222 int y() const { return yo_; }
223 /// returns the actual scroll-value
224 virtual int scroll(bool recursive = true) const;
226 /// if this insets owns paragraphs (f.ex. InsetText) then it
227 /// should return it's very first one!
228 virtual ParagraphList * getParagraphs(int /*num*/) const { return 0; }
230 virtual LyXText * getText(int /*num*/) const { return 0; }
232 virtual int numParagraphs() const { return 0; }
234 /// used to toggle insets
235 // is the inset open?
236 virtual bool isOpen() const { return false; }
238 virtual void open() {}
240 virtual void close() const {}
241 // should this inset be handled like a normal charater
242 virtual bool isChar() const { return false; }
243 // is this equivalent to a letter?
244 virtual bool isLetter() const { return false; }
245 // is this equivalent to a space (which is BTW different from
246 // a line separator)?
247 virtual bool isSpace() const { return false; }
248 // should we have a non-filled line before this inset?
249 virtual bool display() const { return false; }
250 // should we break lines after this inset?
251 virtual bool isLineSeparator() const { return false; }
252 // if this inset has paragraphs should they be output all as default
253 // paragraphs with "Standard" layout?
254 virtual bool forceDefaultParagraphs(InsetOld const *) const;
255 /** returns true if, when outputing LaTeX, font changes should
256 be closed before generating this inset. This is needed for
257 insets that may contain several paragraphs */
258 virtual bool noFontChange() const { return false; }
260 virtual void getDrawFont(LyXFont &) const {}
262 /// mark the inset contents as erased (for change tracking)
263 virtual void markErased() {}
265 /// does this inset allows spellchecking?
266 virtual bool allowSpellCheck() const { return true; }
268 /** Adds a LaTeX snippet to the Preview Loader for transformation
269 * into a bitmap image. Does not start the laoding process.
271 * Most insets have no interest in this capability, so the method
274 virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
283 mutable Dimension dim_;
287 UpdatableInset * owner_;
290 /** We store the LColor::color value as an int to get LColor.h out
291 * of the header file.
293 int background_color_;
297 /** \c InsetOld_code is a wrapper for InsetOld::Code.
298 * It can be forward-declared and passed as a function argument without
299 * having to expose inset.h.
301 class InsetOld_code {
304 InsetOld_code(InsetOld::Code val) : val_(val) {}
305 operator InsetOld::Code() const { return val_; }
310 * returns true if pointer argument is valid
311 * and points to an editable inset
313 bool isEditableInset(InsetOld const * inset);
317 * returns true if pointer argument is valid
318 * and points to a highly editable inset
320 bool isHighlyEditableInset(InsetOld const * inset);