]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formula.h
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / formula.h
index b2406d0578b8c4f4bb554ec6240a602e3cf46736..fd9c7550bef78ccc1e601f95ea8ba270d9cde67f 100644 (file)
@@ -1,43 +1,37 @@
 // -*- 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 "insets/lyxinset.h"
+#include "formulabase.h"
+#include "math_atom.h"
 
-class MathParInset;
-class MathedCursor;
-class Buffer;
+#include <boost/scoped_ptr.hpp>
 
-///
-class InsetFormula: public UpdatableInset {
+/// The main LyX math inset
+class InsetFormula : public InsetFormulaBase {
 public:
        ///
-       explicit
-       InsetFormula(bool display = false);
+       InsetFormula();
+       ///
+       explicit InsetFormula(BufferView *);
+       ///
+       explicit InsetFormula(const string & data);
        ///
-       explicit
-       InsetFormula(MathParInset *);
+       InsetFormula(InsetFormula const &);
        ///
        ~InsetFormula();
        ///
@@ -47,84 +41,53 @@ public:
        ///
        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 &) const;
-       ///
-       int Linuxdoc(Buffer const *, std::ostream &) const;
-       ///
-       int DocBook(Buffer const *, std::ostream &) const;
-       ///
-       void Validate(LaTeXFeatures &) const;
-       ///
-       Inset * Clone() const;
-       ///
-       Inset::Code LyxCode() const { return Inset::MATH_CODE; }
-       ///
-       LyXFont ConvertFont(LyXFont font) {
-               // We have already discussed what was here
-               font.setLatex(LyXFont::OFF);
-               return font;
-       }
+       void draw(BufferView *, LyXFont const &, int, float &, bool) const;
 
-       /// what appears in the minibuffer when opening
-       char const * EditMessage() const;
        ///
-       void Edit(BufferView *, int x, int y, unsigned int button);
+       void write(Buffer const *, std::ostream &) const;
        ///
-       bool display() const { return (disp_flag) ? true: false; }
+       void read(Buffer const *, LyXLex & lex);
        ///
-       void display(bool);
+       int latex(Buffer const *, std::ostream &, bool fragile, bool free_spc) const;
        ///
-       void ToggleInsetCursor(BufferView *);
+       int ascii(Buffer const *, std::ostream &, int linelen) const;
        ///
-       void ShowInsetCursor(BufferView *);
+       int linuxdoc(Buffer const *, std::ostream &) const;
        ///
-       void HideInsetCursor(BufferView *);
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
+
        ///
-       void GetCursorPos(BufferView *, int &, int &) const;
+       Inset * clone(Buffer const &, bool same_id = false) const;
        ///
-       void ToggleInsetSelection(BufferView * bv);
+       void validate(LaTeXFeatures & features) const;
        ///
-       void InsetButtonPress(BufferView *, int x, int y, int button);
+       Inset::Code lyxCode() const;
        ///
-       void InsetButtonRelease(BufferView *, int x, int y, int button);
+       bool insetAllowed(Inset::Code code) const;
        ///
-       void InsetKeyPress(XKeyEvent * ev);
+       std::vector<string> const getLabelList() const;
        ///
-       void InsetMotionNotify(BufferView *, int x, int y, int state);
+       MathAtom const & par() const { return par_; }
        ///
-       void InsetUnlock(BufferView *);
-   
-       ///  To allow transparent use of math editing functions
-       virtual RESULT LocalDispatch(BufferView *, int, string const &);
-    
+       MathAtom & par() { return par_; }
        ///
-       void InsertSymbol(BufferView *, char const *);
+       void generatePreview() const;
        ///
-       bool SetNumber(bool);
+       void addPreview(grfx::PreviewLoader &) const;
        ///
-       std::vector<string> getLabelList() 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