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
145 TEXT_TO_INSET_OFFSET = 2
161 InsetOld(InsetOld const & in);
168 /// what appears in the minibuffer when opening
169 virtual std::string const editMessage() const;
171 virtual EDITABLE editable() const;
172 /// can we go further down on mouse click?
173 virtual bool descendable() const { return false; }
175 virtual bool isTextInset() const { return false; }
176 /// return true if the inset should be removed automatically
177 virtual bool autoDelete() const;
178 /// returns true the inset can hold an inset of given type
179 virtual bool insetAllowed(InsetOld::Code) const { return false; }
180 /// wrapper around the above
181 bool insetAllowed(InsetOld * in) const;
183 virtual void write(Buffer const &, std::ostream &) const = 0;
185 virtual void read(Buffer const &, LyXLex & lex) = 0;
186 /// returns the number of rows (\n's) of generated tex code.
187 virtual int latex(Buffer const &, std::ostream &,
188 OutputParams const &) const = 0;
190 virtual int plaintext(Buffer const &, std::ostream &,
191 OutputParams const &) const = 0;
193 virtual int linuxdoc(Buffer const &, std::ostream &,
194 OutputParams const &) const = 0;
196 virtual int docbook(Buffer const &, std::ostream &,
197 OutputParams const &) const = 0;
199 /// returns LyX code associated with the inset. Used for TOC, ...)
200 virtual InsetOld::Code lyxCode() const { return NO_CODE; }
202 /// returns true to override begin and end inset in file
203 virtual bool directWrite() const;
206 void setInsetName(std::string const & s) { name_ = s; }
208 std::string const & getInsetName() const { return name_; }
210 void setOwner(UpdatableInset * inset) { owner_ = inset; }
212 UpdatableInset * owner() const { return owner_; }
214 void setBackgroundColor(LColor_color);
216 LColor_color backgroundColor() const;
218 int x() const { return xo_; }
220 int y() const { return yo_; }
221 /// returns the actual scroll-value
222 virtual int scroll(bool recursive = true) const;
224 /// if this insets owns paragraphs (f.ex. InsetText) then it
225 /// should return it's very first one!
226 virtual ParagraphList * getParagraphs(int /*num*/) const { return 0; }
228 virtual LyXText * getText(int /*num*/) const { return 0; }
230 virtual int numParagraphs() const { return 0; }
232 /// used to toggle insets
233 // is the inset open?
234 virtual bool isOpen() const { return false; }
236 virtual void open(BufferView *) {}
238 virtual void close(BufferView *) const {}
239 /// check if the font of the char we want inserting is correct
240 /// and modify it if it is not.
241 virtual bool checkInsertChar(LyXFont &);
242 /// we need this here because collapsed insets are only EDITABLE
243 virtual void setFont(BufferView *, LyXFont const &,
244 bool toggleall = false, bool selectall = false);
246 // should this inset be handled like a normal charater
247 virtual bool isChar() const { return false; }
248 // is this equivalent to a letter?
249 virtual bool isLetter() const { return false; }
250 // is this equivalent to a space (which is BTW different from
251 // a line separator)?
252 virtual bool isSpace() const { return false; }
253 // should we have a non-filled line before this inset?
254 virtual bool display() const { return false; }
255 // should we break lines after this inset?
256 virtual bool isLineSeparator() const { return false; }
257 // if this inset has paragraphs should they be output all as default
258 // paragraphs with "Standard" layout?
259 virtual bool forceDefaultParagraphs(InsetOld const *) const;
260 /** returns true if, when outputing LaTeX, font changes should
261 be closed before generating this inset. This is needed for
262 insets that may contain several paragraphs */
263 virtual bool noFontChange() const { return false; }
265 virtual void getDrawFont(LyXFont &) const {}
266 /* needed for widths which are % of something
267 returns the value of \textwidth in this inset. Most of the
268 time this is the width of the workarea, but if there is a
269 minipage somewhere, it will be the width of this minipage */
270 virtual int latexTextWidth(BufferView *) const;
272 /// mark the inset contents as erased (for change tracking)
273 virtual void markErased() {}
275 /// does this inset allows spellchecking?
276 virtual bool allowSpellCheck() const { return true; }
278 /** Adds a LaTeX snippet to the Preview Loader for transformation
279 * into a bitmap image. Does not start the laoding process.
281 * Most insets have no interest in this capability, so the method
284 virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
293 mutable Dimension dim_;
297 UpdatableInset * owner_;
300 /** We store the LColor::color value as an int to get LColor.h out
301 * of the header file.
303 int background_color_;
307 /** \c InsetOld_code is a wrapper for InsetOld::Code.
308 * It can be forward-declared and passed as a function argument without
309 * having to expose inset.h.
311 class InsetOld_code {
314 InsetOld_code(InsetOld::Code val) : val_(val) {}
315 operator InsetOld::Code() const { return val_; }
320 * returns true if pointer argument is valid
321 * and points to an editable inset
323 bool isEditableInset(InsetOld const * inset);
327 * returns true if pointer argument is valid
328 * and points to a highly editable inset
330 bool isHighlyEditableInset(InsetOld const * inset);