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 * ====================================================== */
22 #include "lyxscreen.h"
31 /** This is not quite the correct place for this enum. I think
32 the correct would be to let each subclass of Inset declare
33 its own enum code. Actually the notion of an Inset::Code
34 should be avoided, but I am not sure how this could be done
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;
94 /// what appears in the minibuffer when opening
95 virtual char const * EditMessage() const {return _("Opened inset");}
97 virtual void Edit(int, int);
99 virtual unsigned char Editable() const;
101 virtual bool AutoDelete() const;
103 virtual void Write(ostream &) = 0;
105 virtual void Read(LyXLex & lex) = 0;
106 /** returns the number of rows (\n's) of generated tex code.
107 fragile != 0 means, that the inset should take care about
108 fragile commands by adding a \protect before.
110 virtual int Latex(ostream &, signed char fragile) = 0;
112 virtual int Latex(string & file, signed char fragile) = 0;
114 virtual int Linuxdoc(string & /*file*/) = 0;
116 virtual int DocBook(string & /*file*/) = 0;
117 /// Updates needed features for this inset.
118 virtual void Validate(LaTeXFeatures & features) const;
120 virtual bool Deletable() const;
122 /// returns LyX code associated with the inset. Used for TOC, ...)
123 virtual Inset::Code LyxCode() const = 0;
125 /// Get the label that appears at screen
126 virtual string getLabel(int) const {
131 virtual Inset * Clone() const = 0;
133 /// returns true to override begin and end inset in file
134 virtual bool DirectWrite() const;
136 /// Returns true if the inset should be centered alone
137 virtual bool display() const { return false; }
138 /// Changes the display state of the inset
139 virtual void display(bool) {}
141 virtual int GetNumberOfLabels() const {
148 // Updatable Insets. These insets can be locked and receive
149 // directly user interaction. Currently used only for mathed.
150 // Note that all pure methods from Inset class are pure here too.
151 // [Alejandro 080596]
153 /** Extracted from Matthias notes:
155 * An inset can simple call LockInset in it's edit call and *ONLY*
158 * Unlocking is either done by LyX or the inset itself with a
161 * During the lock, all button and keyboard events will be modified
162 * and send to the inset through the following inset-features. Note that
163 * Inset::InsetUnlock will be called from inside UnlockInset. It is meant
164 * to contain the code for restoring the menus and things like this.
166 * If a inset wishes any redraw and/or update it just has to call
169 * It's is completly irrelevant, where the inset is. UpdateInset will
170 * find it in any paragraph in any buffer.
171 * Of course the_locking_inset and the insets in the current paragraph/buffer
172 * are checked first, so no performance problem should occur.
174 class UpdatableInset: public Inset {
177 //virtual ~UpdatableInset() {}
179 virtual unsigned char Editable() const;
181 /// may call ToggleLockedInsetCursor
182 virtual void ToggleInsetCursor();
184 virtual void GetCursorPos(int &, int &) const {}
186 virtual void InsetButtonPress(int x, int y, int button);
188 virtual void InsetButtonRelease(int x, int y, int button);
191 virtual void InsetKeyPress(XKeyEvent * ev);
193 virtual void InsetMotionNotify(int x, int y, int state);
195 virtual void InsetUnlock();
197 /// An updatable inset could handle lyx editing commands
198 virtual bool LocalDispatch(int, char const *) { return false; };
200 bool isCursorVisible() const { return cursor_visible; }