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() {}
238 virtual void close() 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 // should this inset be handled like a normal charater
243 virtual bool isChar() const { return false; }
244 // is this equivalent to a letter?
245 virtual bool isLetter() const { return false; }
246 // is this equivalent to a space (which is BTW different from
247 // a line separator)?
248 virtual bool isSpace() const { return false; }
249 // should we have a non-filled line before this inset?
250 virtual bool display() const { return false; }
251 // should we break lines after this inset?
252 virtual bool isLineSeparator() const { return false; }
253 // if this inset has paragraphs should they be output all as default
254 // paragraphs with "Standard" layout?
255 virtual bool forceDefaultParagraphs(InsetOld const *) const;
256 /** returns true if, when outputing LaTeX, font changes should
257 be closed before generating this inset. This is needed for
258 insets that may contain several paragraphs */
259 virtual bool noFontChange() const { return false; }
261 virtual void getDrawFont(LyXFont &) const {}
262 /* needed for widths which are % of something
263 returns the value of \textwidth in this inset. Most of the
264 time this is the width of the workarea, but if there is a
265 minipage somewhere, it will be the width of this minipage */
266 virtual int latexTextWidth(BufferView *) const;
268 /// mark the inset contents as erased (for change tracking)
269 virtual void markErased() {}
271 /// does this inset allows spellchecking?
272 virtual bool allowSpellCheck() const { return true; }
274 /** Adds a LaTeX snippet to the Preview Loader for transformation
275 * into a bitmap image. Does not start the laoding process.
277 * Most insets have no interest in this capability, so the method
280 virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
289 mutable Dimension dim_;
293 UpdatableInset * owner_;
296 /** We store the LColor::color value as an int to get LColor.h out
297 * of the header file.
299 int background_color_;
303 /** \c InsetOld_code is a wrapper for InsetOld::Code.
304 * It can be forward-declared and passed as a function argument without
305 * having to expose inset.h.
307 class InsetOld_code {
310 InsetOld_code(InsetOld::Code val) : val_(val) {}
311 operator InsetOld::Code() const { return val_; }
316 * returns true if pointer argument is valid
317 * and points to an editable inset
319 bool isEditableInset(InsetOld const * inset);
323 * returns true if pointer argument is valid
324 * and points to a highly editable inset
326 bool isHighlyEditableInset(InsetOld const * inset);