1999-09-27 18:44:28 +00:00
|
|
|
/*
|
|
|
|
* File: math_inset.C
|
|
|
|
* Purpose: Implementation of insets for mathed
|
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
|
|
|
* Created: January 1996
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You are free to use and modify this code under the terms of
|
|
|
|
* the GNU General Public Licence version 2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
2001-02-13 13:28:32 +00:00
|
|
|
#pragma implementation
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "math_iter.h"
|
|
|
|
#include "math_inset.h"
|
|
|
|
#include "symbol_def.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
#include "lyxfont.h"
|
|
|
|
#include "mathed/support.h"
|
|
|
|
#include "Painter.h"
|
|
|
|
|
|
|
|
int MathedInset::df_asc;
|
|
|
|
int MathedInset::df_des;
|
|
|
|
int MathedInset::df_width;
|
|
|
|
int MathedInset::workWidth;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
1999-11-23 14:39:02 +00:00
|
|
|
MathedInset::MathedInset(MathedInset * inset)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
|
|
|
if (inset) {
|
|
|
|
name = inset->GetName();
|
|
|
|
objtype = inset->GetType();
|
|
|
|
size = inset->GetStyle();
|
|
|
|
width = inset->Width();
|
|
|
|
ascent = inset->Ascent();
|
|
|
|
descent = inset->Descent();
|
|
|
|
} else {
|
|
|
|
objtype = LM_OT_UNDEF;
|
|
|
|
size = LM_ST_TEXT;
|
|
|
|
width = ascent = descent = 0;
|
2000-09-14 17:53:12 +00:00
|
|
|
//name = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
MathedInset::MathedInset(string const & nm, short ot, short st):
|
|
|
|
name(nm), objtype(ot), size(st)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-13 13:28:32 +00:00
|
|
|
width = ascent = descent = 0;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
// In a near future maybe we use a better fonts renderer
|
|
|
|
void MathedInset::drawStr(Painter & pain, short type, int siz,
|
|
|
|
int x, int y, string const & s)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2001-02-13 13:28:32 +00:00
|
|
|
string st;
|
|
|
|
if (MathIsBinary(type))
|
|
|
|
for (string::const_iterator it = s.begin(); it != s.end(); ++it) {
|
|
|
|
st += ' ';
|
|
|
|
st += *it;
|
|
|
|
st += ' ';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
st = s;
|
1999-11-24 22:14:46 +00:00
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
LyXFont const mf = mathed_get_font(type, siz);
|
|
|
|
pain.text(x, y, st, mf);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|