]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formula.h
mathed uglyfication
[lyx.git] / src / mathed / formula.h
index 365000021fa89c7c01d15a5863a4ae55767e66fe..19acb55cea660525d64b3a5d227ca580b292cd26 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
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- *  Copyright: 1996, Alejandro Aguilar Sierra
+ * \author Alejandro Aguilar Sierra
+ * \author André Pönitz
  *
- *  Version: 0.4, Lyx project.
- *
- *   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 <iosfwd>
+#include <boost/scoped_ptr.hpp>
 
-#include "insets/lyxinset.h"
+class RenderPreview;
 
-class MathParInset;
-class MathedCursor;
 
-///
-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;
-       ///
-       void Write(std::ostream &) const;
-       ///
-       void Read(LyXLex & lex);
+       InsetFormula(bool chemistry = false);
        ///
-       int Latex(std::ostream &, bool fragile, bool free_spc) const;
+       explicit InsetFormula(BufferView *);
        ///
-       int Ascii(std::ostream &) const;
+       explicit InsetFormula(std::string const & data);
        ///
-       int Linuxdoc(std::ostream &) const;
+       InsetFormula(InsetFormula const &);
        ///
-       int DocBook(std::ostream &) 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;
-       ///
-       void Edit(BufferView *, int x, int y, unsigned int button);
-       ///
-       bool display() const { return (disp_flag) ? true: false; }
        ///
-       void display(bool);
+       void write(Buffer const &, std::ostream &) const;
        ///
-       void ToggleInsetCursor(BufferView *);
+       void read(Buffer const &, LyXLex & lex);
        ///
-       void ShowInsetCursor(BufferView *);
+       int latex(Buffer const &, std::ostream &,
+                 OutputParams const &) const;
        ///
-       void HideInsetCursor(BufferView *);
+       int plaintext(Buffer const &, std::ostream &,
+                 OutputParams const &) const;
        ///
-       void GetCursorPos(int &, int &) const;
+       int linuxdoc(Buffer const &, std::ostream &,
+                    OutputParams const &) const;
        ///
-       void ToggleInsetSelection(BufferView * bv);
+       int docbook(Buffer const &, std::ostream &,
+                   OutputParams const &) const;
+
        ///
-       void InsetButtonPress(BufferView *, int x, int y, int button);
+       virtual std::auto_ptr<InsetBase> clone() const;
        ///
-       void InsetButtonRelease(BufferView *, int x, int y, int button);
+       void validate(LaTeXFeatures & features) const;
        ///
-       void InsetKeyPress(XKeyEvent * ev);
+       InsetOld::Code lyxCode() const;
        ///
-       void InsetMotionNotify(BufferView *, int x, int y, int state);
+       bool insetAllowed(InsetOld::Code code) const;
+       /// Appends \c list with all labels found within this inset.
+       void getLabelList(Buffer const &,
+                         std::vector<std::string> & list) 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(Buffer const &) 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(std::string const & type);
 
+private:
+       /// Slot receiving a signal that the preview is ready to display.
+       void statusChanged() const;
+       /// 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_;
 
+       /// The pointer never changes although *preview_'s contents may.
+       boost::scoped_ptr<RenderPreview> const preview_;
+};
 #endif