1999-09-27 18:44:28 +00:00
|
|
|
// -*- 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.
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright: 1996, Alejandro Aguilar Sierra
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
#ifndef INSET_FORMULA_H
|
|
|
|
#define INSET_FORMULA_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "insets/lyxinset.h"
|
1999-12-07 00:44:53 +00:00
|
|
|
#include "support/LOstream.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
class MathParInset;
|
|
|
|
class MathedCursor;
|
|
|
|
|
|
|
|
///
|
|
|
|
class InsetFormula: public UpdatableInset {
|
|
|
|
public:
|
|
|
|
///
|
1999-11-15 11:06:41 +00:00
|
|
|
InsetFormula(bool display = false);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 11:06:41 +00:00
|
|
|
InsetFormula(MathParInset *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
~InsetFormula();
|
2000-02-10 17:53:36 +00:00
|
|
|
///
|
|
|
|
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;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-18 22:22:42 +00:00
|
|
|
void Write(ostream &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 11:06:41 +00:00
|
|
|
void Read(LyXLex & lex);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-03-09 03:36:48 +00:00
|
|
|
int Latex(ostream &, signed char fragile, bool free_spc) const;
|
2000-03-06 02:42:40 +00:00
|
|
|
///
|
|
|
|
int Linuxdoc(ostream &) const;
|
|
|
|
///
|
|
|
|
int DocBook(ostream &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
void Validate(LaTeXFeatures &) const;
|
|
|
|
///
|
1999-11-24 22:14:46 +00:00
|
|
|
Inset * Clone() const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// what appears in the minibuffer when opening
|
2000-02-25 12:06:15 +00:00
|
|
|
const char * EditMessage() const {return _("Math editor mode");}
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-25 12:06:15 +00:00
|
|
|
void Edit(BufferView *, int x, int y, unsigned int button);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
bool display() const { return (disp_flag) ? true: false; }
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-22 16:19:48 +00:00
|
|
|
void display(bool);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-22 00:36:17 +00:00
|
|
|
void ToggleInsetCursor(BufferView *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-22 00:36:17 +00:00
|
|
|
void ShowInsetCursor(BufferView *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-22 00:36:17 +00:00
|
|
|
void HideInsetCursor(BufferView *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-23 15:59:07 +00:00
|
|
|
void GetCursorPos(int &, int &) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-22 00:36:17 +00:00
|
|
|
void ToggleInsetSelection(BufferView * bv);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-22 00:36:17 +00:00
|
|
|
void InsetButtonPress(BufferView *, int x, int y, int button);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-22 00:36:17 +00:00
|
|
|
void InsetButtonRelease(BufferView *, int x, int y, int button);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
1999-11-15 11:06:41 +00:00
|
|
|
void InsetKeyPress(XKeyEvent * ev);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-22 00:36:17 +00:00
|
|
|
void InsetMotionNotify(BufferView *, int x, int y, int state);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
2000-02-22 00:36:17 +00:00
|
|
|
void InsetUnlock(BufferView *);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
/// To allow transparent use of math editing functions
|
2000-02-25 13:35:38 +00:00
|
|
|
virtual RESULT LocalDispatch(BufferView *, int, string const &);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
///
|
2000-02-22 00:36:17 +00:00
|
|
|
void InsertSymbol(BufferView *, char const *);
|
1999-09-27 18:44:28 +00:00
|
|
|
///
|
|
|
|
bool SetNumber(bool);
|
|
|
|
///
|
|
|
|
int GetNumberOfLabels() const;
|
|
|
|
///
|
1999-10-02 16:21:10 +00:00
|
|
|
string getLabel(int) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
protected:
|
2000-02-22 00:36:17 +00:00
|
|
|
void UpdateLocal(BufferView * bv);
|
1999-11-15 11:06:41 +00:00
|
|
|
MathParInset * par;
|
2000-02-22 00:36:17 +00:00
|
|
|
static MathedCursor * mathcursor;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool disp_flag;
|
1999-10-02 16:21:10 +00:00
|
|
|
string label;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// If a mathinset exist at cursor pos, just lock it.
|
|
|
|
// Otherwise create a new one, and lock it.
|
|
|
|
bool OpenMathInset(Buffer *);
|
|
|
|
|
|
|
|
#endif
|