]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formula.h
small up/down tweaking
[lyx.git] / src / mathed / formula.h
index 365000021fa89c7c01d15a5863a4ae55767e66fe..3b39db468eee7c4d7eda76ed576a7e0667e66b73 100644 (file)
 // -*- 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;
+#include <boost/scoped_ptr.hpp>
 
-///
-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(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;
+       InsetFormula();
        ///
-       void Write(std::ostream &) const;
+       explicit InsetFormula(BufferView *);
        ///
-       void Read(LyXLex & lex);
+       explicit InsetFormula(const string & data);
        ///
-       int Latex(std::ostream &, bool fragile, bool free_spc) const;
+       InsetFormula(InsetFormula const &);
        ///
-       int Ascii(std::ostream &) const;
-       ///
-       int Linuxdoc(std::ostream &) const;
-       ///
-       int DocBook(std::ostream &) const;
+       ~InsetFormula();
        ///
-       void Validate(LaTeXFeatures &) const;
+       int ascent(BufferView *, LyXFont const &) const;
        ///
-       Inset * Clone() const;
+       int descent(BufferView *, LyXFont const &) const;
        ///
-       Inset::Code LyxCode() const { return Inset::MATH_CODE; }
+       int width(BufferView *, LyXFont const &) const;
        ///
-       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 *);
-       ///
-       void GetCursorPos(int &, int &) const;
+       int docbook(Buffer const *, std::ostream &, bool mixcont) const;
+
        ///
-       void ToggleInsetSelection(BufferView * bv);
+       Inset * clone(Buffer const &, bool same_id = false) const;
        ///
-       void InsetButtonPress(BufferView *, int x, int y, int button);
+       void validate(LaTeXFeatures & features) const;
        ///
-       void InsetButtonRelease(BufferView *, int x, int y, int button);
+       Inset::Code lyxCode() const;
        ///
-       void InsetKeyPress(XKeyEvent * ev);
+       bool insetAllowed(Inset::Code code) const;
        ///
-       void InsetMotionNotify(BufferView *, int x, int y, int state);
+       std::vector<string> const getLabelList() const;
        ///
-       void InsetUnlock(BufferView *);
-   
-       ///  To allow transparent use of math editing functions
-       virtual RESULT LocalDispatch(BufferView *, int, string 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(grfx::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