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"
40 class InsetOld : public InsetBase {
45 TEXT_TO_INSET_OFFSET = 2
61 InsetOld(InsetOld const & in);
68 /// what appears in the minibuffer when opening
69 virtual std::string const editMessage() const;
71 virtual EDITABLE editable() const;
72 /// can we go further down on mouse click?
73 virtual bool descendable() const { return false; }
75 virtual bool isTextInset() const { return false; }
76 /// return true if the inset should be removed automatically
77 virtual bool autoDelete() const;
78 /// returns true the inset can hold an inset of given type
79 virtual bool insetAllowed(InsetOld::Code) const { return false; }
80 /// wrapper around the above
81 bool insetAllowed(InsetOld * in) const;
83 virtual void write(Buffer const &, std::ostream &) const = 0;
85 virtual void read(Buffer const &, LyXLex & lex) = 0;
86 /// returns the number of rows (\n's) of generated tex code.
87 virtual int latex(Buffer const &, std::ostream &,
88 OutputParams const &) const = 0;
90 virtual int plaintext(Buffer const &, std::ostream &,
91 OutputParams const &) const = 0;
93 virtual int linuxdoc(Buffer const &, std::ostream &,
94 OutputParams const &) const = 0;
96 virtual int docbook(Buffer const &, std::ostream &,
97 OutputParams const &) const = 0;
99 /// returns true to override begin and end inset in file
100 virtual bool directWrite() const;
103 void setInsetName(std::string const & s) { name_ = s; }
105 std::string const & getInsetName() const { return name_; }
107 void setOwner(UpdatableInset * inset) { owner_ = inset; }
109 UpdatableInset * owner() const { return owner_; }
111 virtual void setBackgroundColor(LColor_color);
113 LColor_color backgroundColor() const;
115 int x() const { return xo_; }
117 int y() const { return yo_; }
118 /// returns the actual scroll-value
119 virtual int scroll(bool recursive = true) const;
121 /// if this insets owns text cells (e.g. InsetText) return cell num
122 virtual LyXText * getText(int /*num*/) const { return 0; }
124 virtual int numParagraphs() const { return 0; }
125 /// returns cell covering position (x,y), -1 if none exists
126 virtual int getCell(int x, int y) const;
128 /// used to toggle insets
129 // is the inset open?
130 virtual bool isOpen() const { return false; }
132 virtual void open() {}
134 virtual void close() {}
135 // should this inset be handled like a normal charater
136 virtual bool isChar() const { return false; }
137 // is this equivalent to a letter?
138 virtual bool isLetter() const { return false; }
139 // is this equivalent to a space (which is BTW different from
140 // a line separator)?
141 virtual bool isSpace() const { return false; }
142 // should we have a non-filled line before this inset?
143 virtual bool display() const { return false; }
144 // should we break lines after this inset?
145 virtual bool isLineSeparator() const { return false; }
146 // if this inset has paragraphs should they be output all as default
147 // paragraphs with "Standard" layout?
148 virtual bool forceDefaultParagraphs(InsetOld const *) const;
149 /** returns true if, when outputing LaTeX, font changes should
150 be closed before generating this inset. This is needed for
151 insets that may contain several paragraphs */
152 virtual bool noFontChange() const { return false; }
154 /// mark the inset contents as erased (for change tracking)
155 virtual void markErased() {}
157 /// does this inset allows spellchecking?
158 virtual bool allowSpellCheck() const { return true; }
160 /** Adds a LaTeX snippet to the Preview Loader for transformation
161 * into a bitmap image. Does not start the laoding process.
163 * Most insets have no interest in this capability, so the method
166 virtual void addPreview(lyx::graphics::PreviewLoader &) const {}
175 mutable Dimension dim_;
179 UpdatableInset * owner_;
182 /** We store the LColor::color value as an int to get LColor.h out
183 * of the header file.
185 int background_color_;
189 /** \c InsetOld_code is a wrapper for InsetOld::Code.
190 * It can be forward-declared and passed as a function argument without
191 * having to expose inset.h.
193 class InsetOld_code {
196 InsetOld_code(InsetOld::Code val) : val_(val) {}
197 operator InsetOld::Code() const { return val_; }
202 * returns true if pointer argument is valid
203 * and points to an editable inset
205 bool isEditableInset(InsetOld const * inset);
209 * returns true if pointer argument is valid
210 * and points to a highly editable inset
212 bool isHighlyEditableInset(InsetOld const * inset);