math_macrotable.h \
math_matrixinset.C \
math_matrixinset.h \
+ math_metricsinfo.h \
+ math_metricsinfo.C \
math_nestinset.C \
math_nestinset.h \
math_notinset.C \
view_ = bv;
if (f)
font_ = f;
+ if (f)
+ lyxerr << "fontsize: " << f->size() << "\n";
MathMetricsInfo mi(view_, font_, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
par()->metrics(mi);
}
//x -= par()->xo();
y -= par()->yo();
y -= 3;
- int asc;
- int des;
- math_font_max_dim(LM_TC_TEXTRM, LM_ST_TEXT, asc, des);
+ int asc = 0;
+ int des = 0;
+ MathMetricsInfo mi(bv, font_, LM_ST_TEXT);
+ math_font_max_dim(LM_TC_TEXTRM, mi, asc, des);
bv->showLockedInsetCursor(x, y, asc, des);
}
mathcursor->getPos(x, y);
x -= par()->xo();
y -= par()->yo();
- int asc;
- int des;
- math_font_max_dim(LM_TC_TEXTRM, LM_ST_TEXT, asc, des);
+ int asc = 0;
+ int des = 0;
+ MathMetricsInfo mi(bv, font_, LM_ST_TEXT);
+ math_font_max_dim(LM_TC_TEXTRM, mi, asc, des);
bv->fitLockedInsetCursor(x, y, asc, des);
}
toggleInsetCursor(bv);
void MathArrayInset::metrics(MathMetricsInfo const & st) const
{
- MathMetricsInfo m = st;
- if (m.size == LM_ST_DISPLAY)
- m.size = LM_ST_TEXT;
- MathGridInset::metrics(m);
+ size_ = st;
+ if (size_.style == LM_ST_DISPLAY)
+ size_.style = LM_ST_TEXT;
+ MathGridInset::metrics(size_);
}
void MathBinomInset::metrics(MathMetricsInfo const & st) const
{
- MathMetricsInfo m = st;
- m.size = smallerStyleFrac(m.size);
- xcell(0).metrics(m);
- xcell(1).metrics(m);
+ size_ = st;
+ smallerStyleFrac(size_);
+ xcell(0).metrics(size_);
+ xcell(1).metrics(size_);
ascent_ = xcell(0).height() + 4 + 5;
descent_ = xcell(1).height() + 4 - 5;
width_ = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
int MathCharInset::ascent() const
{
- return mathed_char_ascent(code_, size(), char_);
+ return mathed_char_ascent(code_, size_, char_);
}
int MathCharInset::descent() const
{
- return mathed_char_descent(code_, size(), char_);
+ return mathed_char_descent(code_, size_, char_);
}
int MathCharInset::width() const
{
- return mathed_char_width(code_, size(), char_);
+ return mathed_char_width(code_, size_, char_);
}
xo(x);
yo(y);
//lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
- drawChar(pain, code_, size_.size, x, y, char_);
+ drawChar(pain, code_, size_, x, y, char_);
}
}
-MathStyles MathCursor::style() const
-{
- return xarray().style();
-}
-
-
void MathCursor::normalize() const
{
#ifdef WITH_WARNINGS
///
row_type row() const;
- ///
- MathStyles style() const;
/// Make sure cursor position is valid
void normalize() const;
if (wide())
mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
else {
- int w = 2 + mathed_char_width(LM_TC_VAR, size(), 'x');
+ int w = 2 + mathed_char_width(LM_TC_VAR, size_, 'x');
mathed_draw_deco(pain, x + (width_ - w) / 2, y + dy_, w, dh_, name_);
}
}
#endif
-/// Standard Math Sizes (Math mode styles)
-enum MathStyles {
- ///
- LM_ST_DISPLAY = 0,
- ///
- LM_ST_TEXT,
- ///
- LM_ST_SCRIPT,
- ///
- LM_ST_SCRIPTSCRIPT
-};
-
-// decrease math size for super- and subscripts
-MathStyles smallerStyleScript(MathStyles);
-
-// decrease math size for fractions
-MathStyles smallerStyleFrac(MathStyles st);
-
-
-
/** The restrictions of a standard LaTeX math paragraph
allows to get a small number of text codes (<30) */
enum MathTextCodes {
xcell(0).metrics(st);
size_ = st;
int a, d, w;
- mathed_char_dim(LM_TC_VAR, size_.size,'I', a, d, w);
+ mathed_char_dim(LM_TC_VAR, size_, 'I', a, d, w);
int h0 = (a + d) / 2;
int a0 = std::max(xcell(0).ascent(), a) - h0;
int d0 = std::max(xcell(0).descent(), d) + h0;
void MathDotsInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
- mathed_char_dim(LM_TC_VAR, size(), 'M', ascent_, descent_, width_);
+ mathed_char_dim(LM_TC_VAR, size_, 'M', ascent_, descent_, width_);
switch (name_[0]) {
case 'l': dh_ = 0; break;
case 'c': dh_ = ascent_ / 2; break;
void MathFracInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
- size_.size = smallerStyleFrac(size_.size);
+ smallerStyleFrac(size_);
xcell(0).metrics(size_);
xcell(1).metrics(size_);
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
void MathFuncInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
- mathed_string_dim(LM_TC_TEX, size_.size, name_, ascent_, descent_, width_);
+ mathed_string_dim(LM_TC_TEX, size_, name_, ascent_, descent_, width_);
}
{
xo(x);
yo(y);
- drawStr(pain, LM_TC_TEX, size_.size, x, y, name_);
+ drawStr(pain, LM_TC_TEX, size_, x, y, name_);
}
bool MathFuncLimInset::isScriptable() const
{
- return size_.size == LM_ST_DISPLAY;
+ return size_.style == LM_ST_DISPLAY;
}
void MathFuncLimInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
- mathed_string_dim(LM_TC_TEXTRM, size_.size, sym_->name,
+ mathed_string_dim(LM_TC_TEXTRM, size_, sym_->name,
ascent_, descent_, width_);
}
{
xo(x);
yo(y);
- drawStr(pain, LM_TC_TEXTRM, size_.size, x, y, sym_->name);
+ drawStr(pain, LM_TC_TEXTRM, size_, x, y, sym_->name);
}
}
-MathStyles MathInset::size() const
-{
- return size_.size;
-}
-
-
std::ostream & operator<<(std::ostream & os, MathInset const & inset)
{
MathWriteInfo wi(0, os, false);
}
-void MathInset::push_back(unsigned char, MathTextCodes)
-{
- lyxerr << "can't push without a cell\n";
-}
-
-
-void MathInset::push_back(MathInset *)
-{
- lyxerr << "can't push without a cell\n";
-}
-
-
bool MathInset::covers(int x, int y) const
{
//lyxerr << "cover? p: " << this << " x: " << x << " y: " << y
#endif
#include "xarray.h"
+#include "math_defs.h"
/** Abstract base class for all math objects.
A math insets is for use of the math editor only, it isn't a
class LaTeXFeatures;
class Buffer;
-class BufferView;
-class LyXFont;
-
-
-struct MathMetricsInfo {
- ///
- MathMetricsInfo()
- : view(0), font(0), size(LM_ST_TEXT)
- {}
- ///
- MathMetricsInfo(BufferView * v, LyXFont const * f, MathStyles s)
- : view(v), font(f), size(s)
- {}
-
- ///
- BufferView * view;
- ///
- LyXFont const * font;
- ///
- MathStyles size;
-};
struct MathWriteInfo {
virtual int width() const { return 2; }
///
virtual int height() const;
- ///
- virtual MathStyles size() const;
/// Where should we go when we press the up cursor key?
virtual bool idxUp(idx_type & idx, pos_type & pos) const;
/// identifies things that can get \limits or \nolimits
virtual bool takesLimits() const { return false; }
- ///
- virtual void push_back(MathInset *);
- ///
- virtual void push_back(unsigned char c, MathTextCodes code);
///
virtual void dump() const;
{
if (defining()) {
size_ = st;
- mathed_string_dim(LM_TC_TEX, size_.size, name(), ascent_, descent_, width_);
+ mathed_string_dim(LM_TC_TEX, size_, name(), ascent_, descent_, width_);
return;
}
ascent_ = expanded_.ascent() + 2;
descent_ = expanded_.descent() + 2;
- width_ += mathed_string_width(LM_TC_TEXTRM, size_.size, name()) + 10;
+ width_ += mathed_string_width(LM_TC_TEXTRM, size_, name()) + 10;
int lasc;
int ldes;
int lwid;
- mathed_string_dim(LM_TC_TEXTRM, size_.size, "#1: ", lasc, ldes, lwid);
+ mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
for (idx_type i = 0; i < nargs(); ++i) {
MathXArray const & c = xcell(i);
metrics(size_);
if (defining()) {
- drawStr(pain, LM_TC_TEX, size_.size, x, y, name());
+ drawStr(pain, LM_TC_TEX, size_, x, y, name());
return;
}
if (editing()) {
int h = y - ascent() + 2 + expanded_.ascent();
- drawStr(pain, LM_TC_TEXTRM, size_.size, x + 3, h, name());
+ drawStr(pain, LM_TC_TEXTRM, size_, x + 3, h, name());
- int const w = mathed_string_width(LM_TC_TEXTRM, size_.size, name());
+ int const w = mathed_string_width(LM_TC_TEXTRM, size_, name());
expanded_.draw(pain, x + w + 12, h);
h += expanded_.descent();
int lasc;
int ldes;
int lwid;
- mathed_string_dim(LM_TC_TEXTRM, size_.size, "#1: ", lasc, ldes, lwid);
+ mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
for (idx_type i = 0; i < nargs(); ++i) {
MathXArray const & c = xcell(i);
c.draw(pain, x + lwid, h);
char str[] = "#1:";
str[1] += static_cast<char>(i);
- drawStr(pain, LM_TC_TEX, size_.size, x + 3, h, str);
+ drawStr(pain, LM_TC_TEX, size_, x + 3, h, str);
h += std::max(c.descent(), ldes) + 5;
}
return;
ascent_ = xcell(0).ascent();
descent_ = xcell(0).descent();
} else
- mathed_string_dim(LM_TC_TEX, size_.size, str_, ascent_, descent_, width_);
+ mathed_string_dim(LM_TC_TEX, size_, str_, ascent_, descent_, width_);
}
if (expanded_)
xcell(0).draw(pain, x, y);
else
- drawStr(pain, LM_TC_TEX, size_.size, x, y, str_);
+ drawStr(pain, LM_TC_TEX, size_, x, y, str_);
}
void MathMatrixInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
- size_.size = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
+ size_.style = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
// let the cells adjust themselves
MathGridInset::metrics(size_);
if (numberedType()) {
int l = 0;
for (row_type row = 0; row < nrows(); ++row)
- l = std::max(l, mathed_string_width(LM_TC_BF, size(), nicelabel(row)));
+ l = std::max(l, mathed_string_width(LM_TC_BF, size_, nicelabel(row)));
if (l)
width_ += 30 + l;
// make it at least as high as the current font
int asc = 0;
int des = 0;
- math_font_max_dim(LM_TC_TEXTRM, LM_ST_TEXT, asc, des);
+ math_font_max_dim(LM_TC_TEXTRM, size_, asc, des);
ascent_ = std::max(ascent_, asc);
descent_ = std::max(descent_, des);
}
MathGridInset::draw(pain, x, y);
if (numberedType()) {
- int xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
+ int const xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
for (row_type row = 0; row < nrows(); ++row) {
- int yy = y + rowinfo_[row].offset_;
- drawStr(pain, LM_TC_BF, size(), xx, yy, nicelabel(row));
+ int const yy = y + rowinfo_[row].offset_;
+ drawStr(pain, LM_TC_BF, size_, xx, yy, nicelabel(row));
}
}
}
--- /dev/null
+#ifndef MATH_METRICSINFO
+#define MATH_METRICSINFO
+
+class BufferView;
+class LyXFont;
+
+
+/// Standard Math Sizes (Math mode styles)
+enum MathStyles {
+ ///
+ LM_ST_DISPLAY = 0,
+ ///
+ LM_ST_TEXT,
+ ///
+ LM_ST_SCRIPT,
+ ///
+ LM_ST_SCRIPTSCRIPT
+};
+
+
+struct MathMetricsInfo {
+ ///
+ MathMetricsInfo()
+ : view(0), font(0), style(LM_ST_TEXT)
+ {}
+ ///
+ MathMetricsInfo(BufferView * v, LyXFont const * f, MathStyles s)
+ : view(v), font(f), style(s)
+ {}
+
+ ///
+ BufferView * view;
+ ///
+ LyXFont const * font;
+ ///
+ MathStyles style;
+};
+
+#endif
{
size_ = st;
if (math_font_available(LM_TC_CMSY))
- mathed_char_dim(LM_TC_CMSY, size(), 54, ascent_, descent_, width_);
+ mathed_char_dim(LM_TC_CMSY, size_, 54, ascent_, descent_, width_);
else
- mathed_char_dim(LM_TC_VAR, size(), '/', ascent_, descent_, width_);
+ mathed_char_dim(LM_TC_VAR, size_, '/', ascent_, descent_, width_);
width_ = 0;
}
yo(y);
if (math_font_available(LM_TC_CMSY))
- drawChar(pain, LM_TC_CMSY, size(), x, y, 54);
+ drawChar(pain, LM_TC_CMSY, size_, x, y, 54);
else
- drawChar(pain, LM_TC_VAR, size(), x, y, '/');
+ drawChar(pain, LM_TC_VAR, size_, x, y, '/');
}
asc += na + 2;
else
asc = std::max(asc, na);
- asc = std::max(asc, mathed_char_ascent(LM_TC_VAR, LM_ST_TEXT, 'I'));
+ asc = std::max(asc, mathed_char_ascent(LM_TC_VAR, size_, 'I'));
return asc;
}
{
return nuc ?
nuc->width() :
- mathed_char_width(LM_TC_TEX, LM_ST_TEXT, '.');
+ mathed_char_width(LM_TC_TEX, size_, '.');
}
int MathScriptInset::nasc(MathInset const * nuc) const
{
return nuc ? nuc->ascent()
- : mathed_char_ascent(LM_TC_VAR, LM_ST_TEXT, 'I');
+ : mathed_char_ascent(LM_TC_VAR, size_, 'I');
}
int MathScriptInset::ndes(MathInset const * nuc) const
{
return nuc ? nuc->descent()
- : mathed_char_descent(LM_TC_VAR, LM_ST_TEXT, 'I');
+ : mathed_char_descent(LM_TC_VAR, size_, 'I');
}
{
xo(x);
yo(y);
+
if (nuc)
nuc->draw(pain, x + dxx(nuc), y);
else
- drawStr(pain, LM_TC_TEX, LM_ST_TEXT, x + dxx(nuc), y, ".");
+ drawStr(pain, LM_TC_TEX, size_, x + dxx(nuc), y, ".");
+
if (hasUp())
up().draw(pain, x + dx1(nuc), y - dy1(nuc));
+
if (hasDown())
down().draw(pain, x + dx0(nuc), y + dy0(nuc));
}
void MathSizeInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
- size_.size = MathStyles(key_->id);
+ size_.style = MathStyles(key_->id);
xcell(0).metrics(size_);
ascent_ = xcell(0).ascent_;
descent_ = xcell(0).descent_;
int MathSpecialCharInset::ascent() const
{
- return mathed_char_ascent(LM_TC_CONST, size(), char_);
+ return mathed_char_ascent(LM_TC_CONST, size_, char_);
}
int MathSpecialCharInset::descent() const
{
- return mathed_char_descent(LM_TC_CONST, size(), char_);
+ return mathed_char_descent(LM_TC_CONST, size_, char_);
}
int MathSpecialCharInset::width() const
{
- return mathed_char_width(LM_TC_CONST, size(), char_);
+ return mathed_char_width(LM_TC_CONST, size_, char_);
}
{
xo(x);
yo(y);
- drawChar(pain, LM_TC_CONST, size(), x, y, char_);
+ drawChar(pain, LM_TC_CONST, size_, x, y, char_);
}
void MathStackrelInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
- size_.size = smallerStyleFrac(size_.size);
+ smallerStyleFrac(size_);
xcell(0).metrics(size_);
xcell(1).metrics(st);
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
void MathSymbolInset::metrics(MathMetricsInfo const & st) const
{
size_ = st;
- MathTextCodes Code = code();
- if (sym_->latex_font_id > 0 && math_font_available(Code)) {
- mathed_char_dim(Code, size(), sym_->latex_font_id,
- ascent_, descent_, width_);
- if (Code == LM_TC_CMEX) {
- h_ = 4*descent_/5;
+ MathTextCodes c = code();
+ if (sym_->latex_font_id > 0 && math_font_available(c)) {
+ mathed_char_dim(c, size_, sym_->latex_font_id, ascent_, descent_, width_);
+ if (c == LM_TC_CMEX) {
+ h_ = 4 * descent_ / 5;
ascent_ += h_;
descent_ -= h_;
}
}
if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
- mathed_char_dim(code2(), size(), sym_->id, ascent_, descent_, width_);
+ mathed_char_dim(code2(), size_, sym_->id, ascent_, descent_, width_);
else
- mathed_string_dim(LM_TC_TEX, size(), sym_->name, ascent_, descent_, width_);
+ mathed_string_dim(LM_TC_TEX, size_, sym_->name, ascent_, descent_, width_);
}
yo(y);
MathTextCodes Code = code();
if (sym_->latex_font_id > 0 && math_font_available(Code))
- drawChar(pain, Code, size(), x, y - h_, sym_->latex_font_id);
+ drawChar(pain, Code, size_, x, y - h_, sym_->latex_font_id);
else if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
- drawChar(pain, code2(), size(), x, y, sym_->id);
+ drawChar(pain, code2(), size_, x, y, sym_->id);
else
- drawStr(pain, LM_TC_TEX, size(), x, y, sym_->name);
+ drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name);
}
bool MathSymbolInset::isScriptable() const
{
- return size() == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
+ return size_.style == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
}
#include "FontLoader.h"
#include "font.h"
#include "math_defs.h"
+#include "math_inset.h"
#include "math_parser.h"
#include "Painter.h"
#include "debug.h"
}
-LyXFont whichFont(MathTextCodes type, MathStyles size)
+LyXFont whichFont(MathTextCodes type, MathMetricsInfo const & size)
{
LyXFont f = whichFontBase(type);
+ if (size.font) {
+#ifdef WITH_WARNINGS
+#warning Want to fix formula sizes in headings? Look here!
+#endif
+ // unfortunatly, size.font is sometimes nonzero and size.font->size()
+ // is huge...
+ //lyxerr << "setting font size to " << size.font->size() << "\n";
+ //f.setSize(size.font->size());
+ }
- switch (size) {
+ switch (size.style) {
case LM_ST_DISPLAY:
if (type == LM_TC_BOLDSYMB || type == LM_TC_CMEX) {
f.incSize();
break;
default:
- lyxerr << "Math Error: wrong font size: " << size << endl;
+ lyxerr << "Math Error: wrong font size: " << size.style << endl;
break;
}
{
if (!font_available_initialized[type]) {
font_available_initialized[type] = true;
- font_available[type] =
- fontloader.available(whichFontBase(type));
+ font_available[type] = fontloader.available(whichFontBase(type));
}
return font_available[type];
}
} // namespace anon
-void mathed_char_dim(MathTextCodes type, MathStyles size, unsigned char c,
- int & asc, int & des, int & wid)
+void mathed_char_dim(MathTextCodes type, MathMetricsInfo const & size,
+ unsigned char c, int & asc, int & des, int & wid)
{
LyXFont const font = whichFont(type, size);
des = lyxfont::descent(c, font);
}
-int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
- int & asc, int & des)
+int mathed_char_height(MathTextCodes type, MathMetricsInfo const & size,
+ unsigned char c, int & asc, int & des)
{
LyXFont const font = whichFont(type, size);
des = lyxfont::descent(c, font);
}
-int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c)
+int mathed_char_height(MathTextCodes type, MathMetricsInfo const & size,
+ unsigned char c)
{
int asc;
int des;
}
-int mathed_char_ascent(MathTextCodes type, MathStyles size, unsigned char c)
+int mathed_char_ascent(MathTextCodes type, MathMetricsInfo const & size,
+ unsigned char c)
{
LyXFont const font = whichFont(type, size);
return lyxfont::ascent(c, font);
}
-int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c)
+int mathed_char_descent(MathTextCodes type, MathMetricsInfo const & size,
+ unsigned char c)
{
LyXFont const font = whichFont(type, size);
return lyxfont::descent(c, font);
}
-int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c)
+int mathed_char_width(MathTextCodes type, MathMetricsInfo const & size,
+ unsigned char c)
{
LyXFont const font = whichFont(type, size);
if (isBinaryOp(c, type))
}
-void mathed_string_dim(MathTextCodes type, MathStyles size, string const & s,
- int & asc, int & des, int & wid)
+void mathed_string_dim(MathTextCodes type, MathMetricsInfo const & size,
+ string const & s, int & asc, int & des, int & wid)
{
mathed_string_height(type, size, s, asc, des);
wid = mathed_string_width(type, size, s);
}
-int mathed_string_height(MathTextCodes type, MathStyles size, string const & s,
- int & asc, int & des)
+int mathed_string_height(MathTextCodes type, MathMetricsInfo const & size,
+ string const & s, int & asc, int & des)
{
LyXFont const font = whichFont(type, size);
asc = des = 0;
}
-int mathed_string_width(MathTextCodes type, MathStyles size, string const & s)
+int mathed_string_width(MathTextCodes type, MathMetricsInfo const & size,
+ string const & s)
{
return lyxfont::width(s, whichFont(type, size));
}
// In the future maybe we use a better fonts renderer
-void drawStr(Painter & pain, MathTextCodes type, MathStyles siz,
+void drawStr(Painter & pain, MathTextCodes type, MathMetricsInfo const & siz,
int x, int y, string const & s)
{
pain.text(x, y, s, whichFont(type, siz));
}
-void drawChar
- (Painter & pain, MathTextCodes type, MathStyles siz, int x, int y, char c)
+void drawChar(Painter & pain, MathTextCodes type, MathMetricsInfo const & siz,
+ int x, int y, char c)
{
string s;
if (isBinaryOp(c, type))
// decrease math size for super- and subscripts
-MathStyles smallerStyleScript(MathStyles st)
+void smallerStyleScript(MathMetricsInfo & st)
{
- switch (st) {
+ switch (st.style) {
case LM_ST_DISPLAY:
- case LM_ST_TEXT: st = LM_ST_SCRIPT; break;
- default: st = LM_ST_SCRIPTSCRIPT;
+ case LM_ST_TEXT: st.style = LM_ST_SCRIPT; break;
+ default: st.style = LM_ST_SCRIPTSCRIPT;
}
- return st;
}
// decrease math size for fractions
-MathStyles smallerStyleFrac(MathStyles st)
+void smallerStyleFrac(MathMetricsInfo & st)
{
- switch (st) {
- case LM_ST_DISPLAY: st = LM_ST_TEXT; break;
- case LM_ST_TEXT: st = LM_ST_SCRIPT; break;
- default: st = LM_ST_SCRIPTSCRIPT;
+ switch (st.style) {
+ case LM_ST_DISPLAY: st.style = LM_ST_TEXT; break;
+ case LM_ST_TEXT: st.style = LM_ST_SCRIPT; break;
+ default: st.style = LM_ST_SCRIPTSCRIPT;
}
- return st;
}
-void math_font_max_dim(MathTextCodes code, MathStyles siz, int & asc, int & des)
+void math_font_max_dim(MathTextCodes code, MathMetricsInfo const & siz,
+ int & asc, int & des)
{
LyXFont font = whichFont(code, siz);
asc = lyxfont::maxAscent(font);
class Painter;
class latexkeys;
+class MathMetricsInfo;
extern char const * latex_mathspace[];
-int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
- int & asc, int & des);
-void mathed_char_dim(MathTextCodes type, MathStyles size, unsigned char c,
- int & asc, int & des, int & wid);
-int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c);
-int mathed_char_ascent(MathTextCodes type, MathStyles size, unsigned char c);
-int mathed_char_descent(MathTextCodes type, MathStyles size, unsigned char c);
+int mathed_char_height(MathTextCodes type, MathMetricsInfo const & size,
+ unsigned char c, int & asc, int & des);
+void mathed_char_dim(MathTextCodes type, MathMetricsInfo const & size,
+ unsigned char c, int & asc, int & des, int & wid);
+int mathed_char_width(MathTextCodes type, MathMetricsInfo const & size,
+ unsigned char c);
+int mathed_char_ascent(MathTextCodes type, MathMetricsInfo const & size,
+ unsigned char c);
+int mathed_char_descent(MathTextCodes type, MathMetricsInfo const & size,
+ unsigned char c);
void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
string const & name);
-void mathed_string_dim(MathTextCodes type, MathStyles size, string const & s,
- int & asc, int & des, int & wid);
-int mathed_string_height(MathTextCodes type, MathStyles size, string const & s,
- int & asc, int & des);
+void mathed_string_dim(MathTextCodes type, MathMetricsInfo const & size,
+ string const & s, int & asc, int & des, int & wid);
+int mathed_string_height(MathTextCodes type, MathMetricsInfo const & size,
+ string const & s, int & asc, int & des);
-int mathed_string_width(MathTextCodes type, MathStyles size, string const & s);
-int mathed_string_ascent(MathTextCodes type, MathStyles size, string const & s);
-int mathed_string_descent(MathTextCodes type, MathStyles size, string const & s);
+int mathed_string_width(MathTextCodes type, MathMetricsInfo const & size,
+ string const & s);
+int mathed_string_ascent(MathTextCodes type, MathMetricsInfo const & size,
+ string const & s);
+int mathed_string_descent(MathTextCodes type, MathMetricsInfo const & size,
+ string const & s);
-void drawStr(Painter & pain, MathTextCodes type, MathStyles siz,
+void drawStr(Painter & pain, MathTextCodes type, MathMetricsInfo const & siz,
int x, int y, string const & s);
-void drawChar(Painter & pain, MathTextCodes type, MathStyles siz,
+void drawChar(Painter & pain, MathTextCodes type, MathMetricsInfo const & siz,
int x, int y, char c);
-void math_font_max_dim
- (MathTextCodes code, MathStyles siz, int & asc, int & desc);
+void math_font_max_dim(MathTextCodes code, MathMetricsInfo const & siz,
+ int & asc, int & desc);
bool math_font_available(MathTextCodes code);
+// decrease math size for super- and subscripts
+void smallerStyleScript(MathMetricsInfo &);
+
+// decrease math size for fractions
+void smallerStyleFrac(MathMetricsInfo & st);
+
+
+
#endif
MathXArray::MathXArray()
- : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), style_(LM_ST_TEXT)
+ : width_(0), ascent_(0), descent_(0), xo_(0), yo_(0), size_()
{}
void MathXArray::metrics(MathMetricsInfo const & st) const
{
- style_ = st.size;
- mathed_char_dim(LM_TC_VAR, style_, 'I', ascent_, descent_, width_);
+ size_ = st;
+ mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
if (data_.empty())
return;
- math_font_max_dim(LM_TC_TEXTRM, style_, ascent_, descent_);
- width_ = 0;
+ math_font_max_dim(LM_TC_TEXTRM, st, ascent_, descent_);
+ width_ = 0;
//lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
#include <iosfwd>
#include "array.h"
-#include "math_defs.h"
+#include "math_metricsinfo.h"
#ifdef __GNUG__
#pragma interface
int height() const { return ascent_ + descent_; }
///
int width() const { return width_; }
- ///
- MathStyles style() const { return style_; }
///
const_iterator begin() const { return data_.begin(); }
///
mutable int yo_;
///
- mutable MathStyles style_;
+ mutable MathMetricsInfo size_;
};
std::ostream & operator<<(std::ostream & os, MathXArray const & ar);