// -*- C++ -*-
-/*
- * File: formula.h
- * Purpose: Declaration of formula inset
- * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
- * Created: January 1996
- * Description: Allows the edition of math paragraphs inside Lyx.
+
+/**
+ * \file formula.h
*
- * Copyright: (c) 1996, Alejandro Aguilar Sierra
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * Version: 0.4, Lyx project.
+ * \author Alejandro Aguilar Sierra
+ * \author André Pönitz
*
- * You are free to use and modify this code under the terms of
- * the GNU General Public Licence version 2 or later.
+ * Full author contact details are available in file CREDITS.
*/
-#ifndef INSET_FORMULA_H
+#ifndef INSET_FORMULA_H
#define INSET_FORMULA_H
-#ifdef __GNUG__
-#pragma interface
-#endif
+#include "formulabase.h"
+#include "math_atom.h"
-#include "insets/lyxinset.h"
-#include "support/LOstream.h"
+#include <boost/scoped_ptr.hpp>
-class MathParInset;
-class MathedCursor;
-///
-class InsetFormula: public UpdatableInset {
+/// The main LyX math inset
+class InsetFormula : public InsetFormulaBase {
public:
///
- InsetFormula(bool display = false);
- ///
- InsetFormula(MathParInset *);
- ///
- ~InsetFormula();
- ///
- int ascent(Painter &, LyXFont const &) const;
- ///
- int descent(Painter &, LyXFont const &) const;
- ///
- int width(Painter &, LyXFont const &) const;
- ///
- void draw(Painter &, LyXFont const &, int baseline, float & x) const;
- ///
- void Write(ostream &) const;
+ InsetFormula(bool chemistry = false);
///
- void Read(LyXLex & lex);
+ explicit InsetFormula(BufferView *);
///
- int Latex(ostream &, signed char fragile) const;
+ explicit InsetFormula(string const & data);
///
- int Latex(string & file, signed char fragile) const;
+ InsetFormula(InsetFormula const &);
///
- int Linuxdoc(string & file) const;
- ///
- int DocBook(string & file) const;
- ///
- void Validate(LaTeXFeatures &) const;
- ///
- Inset * Clone() const;
+ ~InsetFormula();
///
- Inset::Code LyxCode() const { return Inset::MATH_CODE; }
+ void metrics(MetricsInfo & mi, Dimension & dim) const;
///
- LyXFont ConvertFont(LyXFont font) {
- // We have already discussed what was here
- font.setLatex(LyXFont::OFF);
- return font;
- }
+ void draw(PainterInfo & pi, int x, int y) const;
- /// what appears in the minibuffer when opening
- char const * EditMessage() const {return _("Math editor mode");}
- ///
- void Edit(BufferView *, int x, int y);
///
- bool display() const { return (disp_flag) ? true: false; }
+ void write(Buffer const *, std::ostream &) const;
///
- void display(bool);
+ void read(Buffer const *, LyXLex & lex);
///
- void ToggleInsetCursor(BufferView *);
+ int latex(Buffer const *, std::ostream &,
+ LatexRunParams const &) const;
///
- void ShowInsetCursor(BufferView *);
+ int ascii(Buffer const *, std::ostream &, int linelen) const;
///
- void HideInsetCursor(BufferView *);
+ int linuxdoc(Buffer const *, std::ostream &) const;
///
- void GetCursorPos(int &, int &) const;
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
+
///
- void ToggleInsetSelection(BufferView * bv);
+ virtual std::auto_ptr<InsetBase> clone() const;
///
- void InsetButtonPress(BufferView *, int x, int y, int button);
+ void validate(LaTeXFeatures & features) const;
///
- void InsetButtonRelease(BufferView *, int x, int y, int button);
+ InsetOld::Code lyxCode() const;
///
- void InsetKeyPress(XKeyEvent * ev);
+ bool insetAllowed(InsetOld::Code code) const;
///
- void InsetMotionNotify(BufferView *, int x, int y, int state);
+ void getLabelList(std::vector<string> &) const;
///
- void InsetUnlock(BufferView *);
-
- /// To allow transparent use of math editing functions
- virtual bool LocalDispatch(BufferView *, int, char const *);
-
+ MathAtom const & par() const { return par_; }
///
- void InsertSymbol(BufferView *, char const *);
+ MathAtom & par() { return par_; }
///
- bool SetNumber(bool);
+ void generatePreview() const;
///
- int GetNumberOfLabels() const;
+ void addPreview(lyx::graphics::PreviewLoader &) const;
///
- string getLabel(int) const;
-
-protected:
- void UpdateLocal(BufferView * bv);
- MathParInset * par;
- static MathedCursor * mathcursor;
-
-private:
- bool disp_flag;
- string label;
-};
+ void mutate(string const & type);
+private:
+ /// available in AMS only?
+ bool ams() const;
-// If a mathinset exist at cursor pos, just lock it.
-// Otherwise create a new one, and lock it.
-bool OpenMathInset(Buffer *);
+ /// contents
+ MathAtom par_;
+ /// Use the Pimpl idiom to hide the internals of the previewer.
+ class PreviewImpl;
+ friend class PreviewImpl;
+ /// The pointer never changes although *preview_'s contents may.
+ boost::scoped_ptr<PreviewImpl> const preview_;
+};
#endif