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"
|
|
|
|
|
2001-02-28 11:56:36 +00:00
|
|
|
|
|
|
|
// Initialize some static class variables.
|
2001-02-13 13:28:32 +00:00
|
|
|
int MathedInset::df_asc;
|
|
|
|
int MathedInset::df_des;
|
|
|
|
int MathedInset::df_width;
|
|
|
|
int MathedInset::workWidth;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2001-02-15 12:22:01 +00:00
|
|
|
MathedInset::MathedInset(string const & nm, short ot, short st)
|
2001-02-28 11:56:36 +00:00
|
|
|
: name(nm), objtype(ot), width(0), ascent(0), descent(0), size_(st)
|
|
|
|
{}
|
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))
|
2001-02-15 12:22:01 +00:00
|
|
|
for (string::const_iterator it = s.begin();
|
|
|
|
it != s.end(); ++it) {
|
2001-02-13 13:28:32 +00:00
|
|
|
st += ' ';
|
|
|
|
st += *it;
|
|
|
|
st += ' ';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
st = s;
|
2001-02-15 12:22:01 +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
|
|
|
}
|
|
|
|
|
2001-02-15 12:22:01 +00:00
|
|
|
|
|
|
|
int MathedInset::Ascent() const
|
|
|
|
{
|
|
|
|
return ascent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathedInset::Descent() const
|
|
|
|
{
|
|
|
|
return descent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathedInset::Width() const
|
|
|
|
{
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathedInset::Height() const
|
|
|
|
{
|
|
|
|
return ascent + descent;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathedInset::GetLimits() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathedInset::SetLimits(bool) {}
|
|
|
|
|
|
|
|
|
|
|
|
string const & MathedInset::GetName() const
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
short MathedInset::GetType() const
|
|
|
|
{
|
|
|
|
return objtype;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
short MathedInset::GetStyle() const
|
|
|
|
{
|
|
|
|
return size_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathedInset::SetType(short t)
|
|
|
|
{
|
|
|
|
objtype = t;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathedInset::SetStyle(short st)
|
|
|
|
{
|
|
|
|
size_ = st;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathedInset::SetName(string const & n)
|
|
|
|
{
|
|
|
|
name = n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathedInset::defaultAscent(int da)
|
|
|
|
{
|
|
|
|
df_asc = da;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathedInset::defaultDescent(int dd)
|
|
|
|
{
|
|
|
|
df_des = dd;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathedInset::defaultWidth(int dw)
|
|
|
|
{
|
|
|
|
df_width = dw;
|
|
|
|
}
|
|
|
|
|
2001-03-01 19:57:01 +00:00
|
|
|
|
|
|
|
short MathedInset::size() const
|
|
|
|
{
|
|
|
|
return size_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathedInset::size(short s)
|
|
|
|
{
|
|
|
|
size_ = s;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathedInset::incSize()
|
|
|
|
{
|
|
|
|
++size_;
|
|
|
|
}
|