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 * ====================================================== */
32 /** This is not quite the correct place for this enum. I think
33 the correct would be to let each subclass of Inset declare
34 its own enum code. Actually the notion of an Inset::Code
35 should be avoided, but I am not sure how this could be done
41 TOC_CODE, // do these insets really need a code? (ale)
85 virtual int ascent(Painter &, LyXFont const &) const = 0;
87 virtual int descent(Painter &, LyXFont const &) const = 0;
89 virtual int width(Painter &, LyXFont const &) const = 0;
91 virtual void draw(Painter &, LyXFont const &,
92 int baseline, float & x) const = 0;
94 virtual LyXFont ConvertFont(LyXFont font);
95 /// what appears in the minibuffer when opening
96 virtual char const * EditMessage() const {return _("Opened inset");}
98 virtual void Edit(BufferView *, int, int);
100 virtual unsigned char Editable() const;
102 virtual bool AutoDelete() const;
104 virtual void Write(ostream &) const = 0;
106 virtual void Read(LyXLex & lex) = 0;
107 /** returns the number of rows (\n's) of generated tex code.
108 fragile != 0 means, that the inset should take care about
109 fragile commands by adding a \protect before.
111 virtual int Latex(ostream &, signed char fragile) const = 0;
113 virtual int Latex(string & file, signed char fragile) const = 0;
115 virtual int Linuxdoc(string & /*file*/) const = 0;
117 virtual int DocBook(string & /*file*/) const = 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 {
132 virtual Inset * Clone() const = 0;
134 /// returns true to override begin and end inset in file
135 virtual bool DirectWrite() const;
137 /// Returns true if the inset should be centered alone
138 virtual bool display() const { return false; }
139 /// Changes the display state of the inset
140 virtual void display(bool) {}
142 virtual int GetNumberOfLabels() const {
149 // Updatable Insets. These insets can be locked and receive
150 // directly user interaction. Currently used only for mathed.
151 // Note that all pure methods from Inset class are pure here too.
152 // [Alejandro 080596]
154 /** Extracted from Matthias notes:
156 * An inset can simple call LockInset in it's edit call and *ONLY*
159 * Unlocking is either done by LyX or the inset itself with a
162 * During the lock, all button and keyboard events will be modified
163 * and send to the inset through the following inset-features. Note that
164 * Inset::InsetUnlock will be called from inside UnlockInset. It is meant
165 * to contain the code for restoring the menus and things like this.
167 * If a inset wishes any redraw and/or update it just has to call
170 * It's is completly irrelevant, where the inset is. UpdateInset will
171 * find it in any paragraph in any buffer.
172 * Of course the_locking_inset and the insets in the current paragraph/buffer
173 * are checked first, so no performance problem should occur.
175 class UpdatableInset: public Inset {
178 //virtual ~UpdatableInset() {}
180 virtual unsigned char Editable() const;
182 /// may call ToggleLockedInsetCursor
183 virtual void ToggleInsetCursor(BufferView *);
185 virtual void GetCursorPos(int &, int &) const {}
187 virtual void InsetButtonPress(BufferView *, int x, int y, int button);
189 virtual void InsetButtonRelease(BufferView *,
190 int x, int y, int button);
193 virtual void InsetKeyPress(XKeyEvent * ev);
195 virtual void InsetMotionNotify(BufferView *, int x, int y, int state);
197 virtual void InsetUnlock(BufferView *);
199 /// An updatable inset could handle lyx editing commands
200 virtual bool LocalDispatch(BufferView *, int, char const *) { return false; };
202 bool isCursorVisible() const { return cursor_visible; }
205 mutable bool cursor_visible;