2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-1999 the LyX Team.
10 * ======================================================*/
19 #include "definitions.h"
23 #include "lyxscreen.h"
31 /** This is not quite the correct place for this enum, but it is
32 better than definitions.h. I think the correct would be to let
33 each subclass of Inset declare its own enum code. Actually the
34 notion of an Inset::Code should be avoided, but I am not sure how
35 this could be done in a cleaner way. */
40 TOC_CODE, // do these insets really need a code? (ale)
84 virtual int Ascent(LyXFont const & font) const = 0;
86 virtual int Descent(LyXFont const & font) const = 0;
88 virtual int Width(LyXFont const & font) const = 0;
90 virtual LyXFont ConvertFont(LyXFont font);
92 virtual void Draw(LyXFont font, LyXScreen & scr,
93 int baseline, float & x) = 0;
95 //virtual void setBuffer(Buffer const&) {;}
96 /// what appears in the minibuffer when opening
97 virtual char const * EditMessage() {return _("Opened inset");}
99 virtual void Edit(int, int);
101 virtual unsigned char Editable() const;
103 virtual bool AutoDelete() const;
105 virtual void Write(FILE * file)=0;
107 virtual void Read(LyXLex & lex)=0;
108 /** returns the number of rows (\n's) of generated tex code.
109 fragile != 0 means, that the inset should take care about
110 fragile commands by adding a \protect before.
112 virtual int Latex(FILE * file, signed char fragile) = 0;
113 virtual int Latex(string & file, signed char fragile) = 0;
115 virtual int Linuxdoc(string &/*file*/) = 0;
117 virtual int DocBook(string &/*file*/) = 0;
118 /// Updates needed features for this inset.
119 virtual void Validate(LaTeXFeatures & features) const;
121 virtual bool Deletable() const;
123 /// returns LyX code associated with the inset. Used for TOC, ...)
124 virtual Inset::Code LyxCode() const = 0;
126 /// Get the label that appears at screen
127 virtual string getLabel(int) const {
131 /// used for autocorrection
132 virtual bool IsEqual(Inset * /*other*/){
137 virtual Inset * Clone() = 0;
139 /// returns true to override begin and end inset in file
140 virtual bool DirectWrite() const;
142 /// Returns true if the inset should be centered alone
143 virtual bool Display() const { return false; }
145 /// Changes the display state of the inset
146 virtual void SetDisplay(bool) { }
148 virtual int GetNumberOfLabels() const {
155 // Updatable Insets. These insets can be locked and receive
156 // directly user interaction. Currently used only for mathed.
157 // Note that all pure methods from Inset class are pure here too.
158 // [Alejandro 080596]
160 /** Extracted from Matthias notes:
162 * An inset can simple call LockInset in it's edit call and *ONLY*
165 * Unlocking is either done by LyX or the inset itself with a
168 * During the lock, all button and keyboard events will be modified
169 * and send to the inset through the following inset-features. Note that
170 * Inset::InsetUnlock will be called from inside UnlockInset. It is meant
171 * to contain the code for restoring the menus and things like this.
173 * If a inset wishes any redraw and/or update it just has to call
176 * It's is completly irrelevant, where the inset is. UpdateInset will
177 * find it in any paragraph in any buffer.
178 * Of course the_locking_inset and the insets in the current paragraph/buffer
179 * are checked first, so no performance problem should occur.
181 class UpdatableInset: public Inset {
184 virtual ~UpdatableInset() {}
186 virtual unsigned char Editable() const;
188 /// may call ToggleLockedInsetCursor
189 virtual void ToggleInsetCursor();
191 virtual void GetCursorPos(int &, int &) {}
193 virtual void InsetButtonPress(int x, int y, int button);
195 virtual void InsetButtonRelease(int x, int y, int button);
198 virtual void InsetKeyPress(XKeyEvent * ev);
200 virtual void InsetMotionNotify(int x, int y, int state);
202 virtual void InsetUnlock();
204 /// An updatable inset could handle lyx editing commands
205 virtual bool LocalDispatch(int, char const *) { return false; };
207 bool isCursorVisible() const { return cursor_visible; }