1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/*
|
|
|
|
* File: math_inset.h
|
|
|
|
* Purpose: Declaration of insets for mathed
|
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
|
|
|
* Created: January 1996
|
|
|
|
* Description: Math paragraph and objects for a WYSIWYG math editor.
|
|
|
|
*
|
|
|
|
* Dependencies: Xlib, XForms
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright: 1996, 1997 Alejandro Aguilar Sierra
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* Version: 0.8beta, Mathed & Lyx project.
|
|
|
|
*
|
|
|
|
* You are free to use and modify this code under the terms of
|
|
|
|
* the GNU General Public Licence version 2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Note: These math insets are internal to Mathed and are not derived
|
|
|
|
// from lyx inset.
|
|
|
|
|
1999-11-15 11:06:41 +00:00
|
|
|
#ifndef MATH_INSET
|
|
|
|
#define MATH_INSET
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2000-12-29 12:48:02 +00:00
|
|
|
#include "LString.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "symbol_def.h"
|
|
|
|
|
2001-02-13 19:10:18 +00:00
|
|
|
class Painter;
|
2001-04-24 16:13:38 +00:00
|
|
|
class MathMacro;
|
2001-02-13 19:10:18 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
/** Abstract base class for all math objects.
|
|
|
|
A math insets is for use of the math editor only, it isn't a
|
|
|
|
general LyX inset. It's used to represent all the math objects.
|
|
|
|
The formulaInset (a LyX inset) encapsulates a math inset.
|
2001-02-15 12:22:01 +00:00
|
|
|
*/
|
2001-02-28 11:56:36 +00:00
|
|
|
class MathedInset {
|
2001-02-15 12:22:01 +00:00
|
|
|
public:
|
|
|
|
/** A math inset has a name (usually its LaTeX name),
|
|
|
|
type and font-size
|
|
|
|
*/
|
|
|
|
MathedInset(string const & nm, short ot, short st);
|
2001-02-28 11:56:36 +00:00
|
|
|
/// The virtual base destructor
|
2001-02-15 12:22:01 +00:00
|
|
|
virtual ~MathedInset() {}
|
|
|
|
/// Draw the object
|
|
|
|
virtual void draw(Painter &, int x, int baseline) = 0;
|
|
|
|
/// Write LaTeX and Lyx code
|
|
|
|
virtual void Write(std::ostream &, bool fragile) = 0;
|
|
|
|
/// Reproduces itself
|
|
|
|
virtual MathedInset * Clone() = 0;
|
2001-04-24 16:13:38 +00:00
|
|
|
/// Reproduces itself with macro arguments substituted
|
|
|
|
virtual void substitute(MathMacro * macro);
|
2001-02-15 12:22:01 +00:00
|
|
|
/// Compute the size of the object
|
|
|
|
virtual void Metrics() = 0;
|
|
|
|
///
|
|
|
|
virtual int Ascent() const;
|
|
|
|
///
|
|
|
|
virtual int Descent() const;
|
|
|
|
///
|
|
|
|
virtual int Width() const;
|
|
|
|
///
|
|
|
|
virtual int Height() const;
|
|
|
|
///
|
|
|
|
virtual bool GetLimits() const;
|
|
|
|
///
|
|
|
|
virtual void SetLimits(bool);
|
|
|
|
///
|
|
|
|
string const & GetName() const;
|
|
|
|
///
|
|
|
|
short GetType() const;
|
|
|
|
///
|
|
|
|
short GetStyle() const;
|
|
|
|
//Man: Avoid to use these functions if it's not strictly necessary
|
|
|
|
///
|
|
|
|
virtual void SetType(short t);
|
|
|
|
///
|
|
|
|
virtual void SetStyle(short st);
|
|
|
|
///
|
|
|
|
virtual void SetName(string const & n);
|
|
|
|
///
|
|
|
|
static int workWidth;
|
|
|
|
///
|
|
|
|
static void defaultAscent(int da);
|
|
|
|
///
|
|
|
|
static void defaultDescent(int dd);
|
|
|
|
///
|
|
|
|
static void defaultWidth(int dw);
|
|
|
|
///
|
2001-02-28 11:56:36 +00:00
|
|
|
short size() const;
|
2001-02-15 12:22:01 +00:00
|
|
|
protected:
|
|
|
|
///
|
|
|
|
string name;
|
|
|
|
///
|
|
|
|
short objtype;
|
|
|
|
///
|
|
|
|
int width;
|
|
|
|
///
|
|
|
|
int ascent;
|
|
|
|
///
|
|
|
|
int descent;
|
|
|
|
/// Default metrics
|
|
|
|
static int df_asc;
|
|
|
|
///
|
|
|
|
static int df_des;
|
|
|
|
///
|
|
|
|
static int df_width;
|
|
|
|
/// In a near future maybe we use a better fonts renderer than X
|
|
|
|
void drawStr(Painter &, short, int, int, int, string const &);
|
|
|
|
///
|
2001-02-28 11:56:36 +00:00
|
|
|
void size(short s);
|
|
|
|
///
|
|
|
|
void incSize();
|
2001-02-15 12:22:01 +00:00
|
|
|
private:
|
|
|
|
///
|
|
|
|
short size_;
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
|
|
|
#endif
|