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