// -*- 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: 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 <iosfwd>
+#include "formulabase.h"
+#include "math_atom.h"
-#include "insets/lyxinset.h"
+#include <boost/scoped_ptr.hpp>
-class MathParInset;
-class MathedCursor;
-class Buffer;
-///
-class InsetFormula: public UpdatableInset {
+/// The main LyX math inset
+class InsetFormula : public InsetFormulaBase {
public:
///
- explicit
- InsetFormula(bool display = false);
- ///
- explicit
- InsetFormula(MathParInset *);
- ///
- ~InsetFormula();
- ///
- int ascent(BufferView *, LyXFont const &) const;
- ///
- int descent(BufferView *, LyXFont const &) const;
- ///
- int width(BufferView *, LyXFont const &) const;
- ///
- void draw(BufferView *,LyXFont const &, int, float &, bool) const;
- ///
- void Write(Buffer const *, std::ostream &) const;
- ///
- void Read(Buffer const *, LyXLex & lex);
- ///
- int Latex(Buffer const *, std::ostream &,
- bool fragile, bool free_spc) const;
- ///
- int Ascii(Buffer const *, std::ostream &, int linelen) const;
- ///
- int Linuxdoc(Buffer const *, std::ostream &) const;
+ InsetFormula(bool chemistry = false);
///
- int DocBook(Buffer const *, std::ostream &) const;
+ explicit InsetFormula(BufferView *);
///
- void Validate(LaTeXFeatures &) const;
+ explicit InsetFormula(string const & data);
///
- Inset * Clone(Buffer const &) const;
+ InsetFormula(InsetFormula const &);
///
- Inset::Code LyxCode() const;
- ///
- LyXFont const ConvertFont(LyXFont const & f) const;
- /// what appears in the minibuffer when opening
- string const EditMessage() const;
- ///
- void Edit(BufferView *, int x, int y, unsigned int button);
- ///
- bool display() const;
- ///
- void display(bool);
+ ~InsetFormula();
///
- void ToggleInsetCursor(BufferView *);
+ void metrics(MetricsInfo & mi, Dimension & dim) const;
///
- void ShowInsetCursor(BufferView *, bool show = true);
+ void draw(PainterInfo & pi, int x, int y) const;
+
///
- void HideInsetCursor(BufferView *);
+ void write(Buffer const *, std::ostream &) const;
///
- void GetCursorPos(BufferView *, int &, int &) const;
+ void read(Buffer const *, LyXLex & lex);
///
- void ToggleInsetSelection(BufferView * bv);
+ int latex(Buffer const *, std::ostream &,
+ LatexRunParams const &) const;
///
- void InsetButtonPress(BufferView *, int x, int y, int button);
+ int ascii(Buffer const *, std::ostream &, int linelen) const;
///
- void InsetButtonRelease(BufferView *, int x, int y, int button);
+ int linuxdoc(Buffer const *, std::ostream &) const;
///
- void InsetKeyPress(XKeyEvent * ev);
+ int docbook(Buffer const *, std::ostream &, bool mixcont) const;
+
///
- void InsetMotionNotify(BufferView *, int x, int y, int state);
+ virtual std::auto_ptr<InsetBase> clone() const;
///
- void InsetUnlock(BufferView *);
-
- /// To allow transparent use of math editing functions
- virtual RESULT LocalDispatch(BufferView *, kb_action, string const &);
-
+ void validate(LaTeXFeatures & features) const;
///
- void InsertSymbol(BufferView *, string const &);
+ InsetOld::Code lyxCode() const;
///
- bool SetNumber(bool);
+ bool insetAllowed(InsetOld::Code code) const;
///
- std::vector<string> const getLabelList() const;
-
-protected:
+ void getLabelList(std::vector<string> &) const;
///
- void UpdateLocal(BufferView * bv);
+ MathAtom const & par() const { return par_; }
///
- MathParInset * par;
+ MathAtom & par() { return par_; }
///
- static MathedCursor * mathcursor;
-
-private:
+ void generatePreview() const;
///
- bool disp_flag_;
+ void addPreview(lyx::graphics::PreviewLoader &) const;
///
- string label_;
-};
-
-
-inline
-Inset::Code InsetFormula::LyxCode() const
-{
- return Inset::MATH_CODE;
-}
+ void mutate(string const & type);
+private:
+ /// available in AMS only?
+ bool ams() const;
-inline
-LyXFont const InsetFormula::ConvertFont(LyXFont const & f) const
-{
- // We have already discussed what was here
- LyXFont font(f);
- font.setLatex(LyXFont::OFF);
- return font;
-}
-
+ /// contents
+ MathAtom par_;
-inline
-bool InsetFormula::display() const
-{
- return (disp_flag_) ? true : false;
-}
+ /// 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