mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-28 06:49:43 +00:00
halfway through fixing size of math in non-standard sizesd paragraohs like
section headings... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2907 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3d8efcecf9
commit
970f0247f7
@ -68,6 +68,8 @@ libmathed_la_SOURCES = \
|
|||||||
math_macrotable.h \
|
math_macrotable.h \
|
||||||
math_matrixinset.C \
|
math_matrixinset.C \
|
||||||
math_matrixinset.h \
|
math_matrixinset.h \
|
||||||
|
math_metricsinfo.h \
|
||||||
|
math_metricsinfo.C \
|
||||||
math_nestinset.C \
|
math_nestinset.C \
|
||||||
math_nestinset.h \
|
math_nestinset.h \
|
||||||
math_notinset.C \
|
math_notinset.C \
|
||||||
|
@ -123,6 +123,8 @@ void InsetFormulaBase::metrics(BufferView * bv, LyXFont const * f) const
|
|||||||
view_ = bv;
|
view_ = bv;
|
||||||
if (f)
|
if (f)
|
||||||
font_ = f;
|
font_ = f;
|
||||||
|
if (f)
|
||||||
|
lyxerr << "fontsize: " << f->size() << "\n";
|
||||||
MathMetricsInfo mi(view_, font_, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
|
MathMetricsInfo mi(view_, font_, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
|
||||||
par()->metrics(mi);
|
par()->metrics(mi);
|
||||||
}
|
}
|
||||||
@ -194,9 +196,10 @@ void InsetFormulaBase::toggleInsetCursor(BufferView * bv)
|
|||||||
//x -= par()->xo();
|
//x -= par()->xo();
|
||||||
y -= par()->yo();
|
y -= par()->yo();
|
||||||
y -= 3;
|
y -= 3;
|
||||||
int asc;
|
int asc = 0;
|
||||||
int des;
|
int des = 0;
|
||||||
math_font_max_dim(LM_TC_TEXTRM, LM_ST_TEXT, asc, des);
|
MathMetricsInfo mi(bv, font_, LM_ST_TEXT);
|
||||||
|
math_font_max_dim(LM_TC_TEXTRM, mi, asc, des);
|
||||||
bv->showLockedInsetCursor(x, y, asc, des);
|
bv->showLockedInsetCursor(x, y, asc, des);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,9 +216,10 @@ void InsetFormulaBase::showInsetCursor(BufferView * bv, bool)
|
|||||||
mathcursor->getPos(x, y);
|
mathcursor->getPos(x, y);
|
||||||
x -= par()->xo();
|
x -= par()->xo();
|
||||||
y -= par()->yo();
|
y -= par()->yo();
|
||||||
int asc;
|
int asc = 0;
|
||||||
int des;
|
int des = 0;
|
||||||
math_font_max_dim(LM_TC_TEXTRM, LM_ST_TEXT, asc, des);
|
MathMetricsInfo mi(bv, font_, LM_ST_TEXT);
|
||||||
|
math_font_max_dim(LM_TC_TEXTRM, mi, asc, des);
|
||||||
bv->fitLockedInsetCursor(x, y, asc, des);
|
bv->fitLockedInsetCursor(x, y, asc, des);
|
||||||
}
|
}
|
||||||
toggleInsetCursor(bv);
|
toggleInsetCursor(bv);
|
||||||
|
@ -46,9 +46,9 @@ void MathArrayInset::write(MathWriteInfo & os) const
|
|||||||
|
|
||||||
void MathArrayInset::metrics(MathMetricsInfo const & st) const
|
void MathArrayInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
MathMetricsInfo m = st;
|
size_ = st;
|
||||||
if (m.size == LM_ST_DISPLAY)
|
if (size_.style == LM_ST_DISPLAY)
|
||||||
m.size = LM_ST_TEXT;
|
size_.style = LM_ST_TEXT;
|
||||||
MathGridInset::metrics(m);
|
MathGridInset::metrics(size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ int MathBinomInset::dw() const
|
|||||||
|
|
||||||
void MathBinomInset::metrics(MathMetricsInfo const & st) const
|
void MathBinomInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
MathMetricsInfo m = st;
|
size_ = st;
|
||||||
m.size = smallerStyleFrac(m.size);
|
smallerStyleFrac(size_);
|
||||||
xcell(0).metrics(m);
|
xcell(0).metrics(size_);
|
||||||
xcell(1).metrics(m);
|
xcell(1).metrics(size_);
|
||||||
ascent_ = xcell(0).height() + 4 + 5;
|
ascent_ = xcell(0).height() + 4 + 5;
|
||||||
descent_ = xcell(1).height() + 4 - 5;
|
descent_ = xcell(1).height() + 4 - 5;
|
||||||
width_ = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
|
width_ = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
|
||||||
|
@ -60,19 +60,19 @@ MathInset * MathCharInset::clone() const
|
|||||||
|
|
||||||
int MathCharInset::ascent() const
|
int MathCharInset::ascent() const
|
||||||
{
|
{
|
||||||
return mathed_char_ascent(code_, size(), char_);
|
return mathed_char_ascent(code_, size_, char_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int MathCharInset::descent() const
|
int MathCharInset::descent() const
|
||||||
{
|
{
|
||||||
return mathed_char_descent(code_, size(), char_);
|
return mathed_char_descent(code_, size_, char_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int MathCharInset::width() const
|
int MathCharInset::width() const
|
||||||
{
|
{
|
||||||
return mathed_char_width(code_, size(), char_);
|
return mathed_char_width(code_, size_, char_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ void MathCharInset::draw(Painter & pain, int x, int y) const
|
|||||||
xo(x);
|
xo(x);
|
||||||
yo(y);
|
yo(y);
|
||||||
//lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
|
//lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
|
||||||
drawChar(pain, code_, size_.size, x, y, char_);
|
drawChar(pain, code_, size_, x, y, char_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -915,12 +915,6 @@ void MathCursor::pullArg(bool goright)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathStyles MathCursor::style() const
|
|
||||||
{
|
|
||||||
return xarray().style();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void MathCursor::normalize() const
|
void MathCursor::normalize() const
|
||||||
{
|
{
|
||||||
#ifdef WITH_WARNINGS
|
#ifdef WITH_WARNINGS
|
||||||
|
@ -195,8 +195,6 @@ public:
|
|||||||
///
|
///
|
||||||
row_type row() const;
|
row_type row() const;
|
||||||
|
|
||||||
///
|
|
||||||
MathStyles style() const;
|
|
||||||
/// Make sure cursor position is valid
|
/// Make sure cursor position is valid
|
||||||
void normalize() const;
|
void normalize() const;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ void MathDecorationInset::draw(Painter & pain, int x, int y) const
|
|||||||
if (wide())
|
if (wide())
|
||||||
mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
|
mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
|
||||||
else {
|
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_);
|
mathed_draw_deco(pain, x + (width_ - w) / 2, y + dy_, w, dh_, name_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,26 +25,6 @@
|
|||||||
#endif
|
#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
|
/** The restrictions of a standard LaTeX math paragraph
|
||||||
allows to get a small number of text codes (<30) */
|
allows to get a small number of text codes (<30) */
|
||||||
enum MathTextCodes {
|
enum MathTextCodes {
|
||||||
|
@ -65,7 +65,7 @@ void MathDelimInset::metrics(MathMetricsInfo const & st) const
|
|||||||
xcell(0).metrics(st);
|
xcell(0).metrics(st);
|
||||||
size_ = st;
|
size_ = st;
|
||||||
int a, d, w;
|
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 h0 = (a + d) / 2;
|
||||||
int a0 = std::max(xcell(0).ascent(), a) - h0;
|
int a0 = std::max(xcell(0).ascent(), a) - h0;
|
||||||
int d0 = std::max(xcell(0).descent(), d) + h0;
|
int d0 = std::max(xcell(0).descent(), d) + h0;
|
||||||
|
@ -35,7 +35,7 @@ void MathDotsInset::draw(Painter & pain, int x, int y) const
|
|||||||
void MathDotsInset::metrics(MathMetricsInfo const & st) const
|
void MathDotsInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
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]) {
|
switch (name_[0]) {
|
||||||
case 'l': dh_ = 0; break;
|
case 'l': dh_ = 0; break;
|
||||||
case 'c': dh_ = ascent_ / 2; break;
|
case 'c': dh_ = ascent_ / 2; break;
|
||||||
|
@ -22,7 +22,7 @@ MathInset * MathFracInset::clone() const
|
|||||||
void MathFracInset::metrics(MathMetricsInfo const & st) const
|
void MathFracInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
size_.size = smallerStyleFrac(size_.size);
|
smallerStyleFrac(size_);
|
||||||
xcell(0).metrics(size_);
|
xcell(0).metrics(size_);
|
||||||
xcell(1).metrics(size_);
|
xcell(1).metrics(size_);
|
||||||
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
|
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
|
||||||
|
@ -52,7 +52,7 @@ void MathFuncInset::writeNormal(std::ostream & os) const
|
|||||||
void MathFuncInset::metrics(MathMetricsInfo const & st) const
|
void MathFuncInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
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_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -60,5 +60,5 @@ void MathFuncInset::draw(Painter & pain, int x, int y) const
|
|||||||
{
|
{
|
||||||
xo(x);
|
xo(x);
|
||||||
yo(y);
|
yo(y);
|
||||||
drawStr(pain, LM_TC_TEX, size_.size, x, y, name_);
|
drawStr(pain, LM_TC_TEX, size_, x, y, name_);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ MathInset * MathFuncLimInset::clone() const
|
|||||||
|
|
||||||
bool MathFuncLimInset::isScriptable() const
|
bool MathFuncLimInset::isScriptable() const
|
||||||
{
|
{
|
||||||
return size_.size == LM_ST_DISPLAY;
|
return size_.style == LM_ST_DISPLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ void MathFuncLimInset::writeNormal(ostream & os) const
|
|||||||
void MathFuncLimInset::metrics(MathMetricsInfo const & st) const
|
void MathFuncLimInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
mathed_string_dim(LM_TC_TEXTRM, size_.size, sym_->name,
|
mathed_string_dim(LM_TC_TEXTRM, size_, sym_->name,
|
||||||
ascent_, descent_, width_);
|
ascent_, descent_, width_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,5 +47,5 @@ void MathFuncLimInset::draw(Painter & pain, int x, int y) const
|
|||||||
{
|
{
|
||||||
xo(x);
|
xo(x);
|
||||||
yo(y);
|
yo(y);
|
||||||
drawStr(pain, LM_TC_TEXTRM, size_.size, x, y, sym_->name);
|
drawStr(pain, LM_TC_TEXTRM, size_, x, y, sym_->name);
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,6 @@ int MathInset::height() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MathStyles MathInset::size() const
|
|
||||||
{
|
|
||||||
return size_.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
std::ostream & operator<<(std::ostream & os, MathInset const & inset)
|
std::ostream & operator<<(std::ostream & os, MathInset const & inset)
|
||||||
{
|
{
|
||||||
MathWriteInfo wi(0, os, false);
|
MathWriteInfo wi(0, os, false);
|
||||||
@ -226,18 +220,6 @@ void MathInset::dump() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
bool MathInset::covers(int x, int y) const
|
||||||
{
|
{
|
||||||
//lyxerr << "cover? p: " << this << " x: " << x << " y: " << y
|
//lyxerr << "cover? p: " << this << " x: " << x << " y: " << y
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "xarray.h"
|
#include "xarray.h"
|
||||||
|
#include "math_defs.h"
|
||||||
|
|
||||||
/** Abstract base class for all math objects.
|
/** Abstract base class for all math objects.
|
||||||
A math insets is for use of the math editor only, it isn't a
|
A math insets is for use of the math editor only, it isn't a
|
||||||
@ -49,27 +50,6 @@ class MathMacroTemplate;
|
|||||||
|
|
||||||
class LaTeXFeatures;
|
class LaTeXFeatures;
|
||||||
class Buffer;
|
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 {
|
struct MathWriteInfo {
|
||||||
@ -144,8 +124,6 @@ public:
|
|||||||
virtual int width() const { return 2; }
|
virtual int width() const { return 2; }
|
||||||
///
|
///
|
||||||
virtual int height() const;
|
virtual int height() const;
|
||||||
///
|
|
||||||
virtual MathStyles size() const;
|
|
||||||
|
|
||||||
/// Where should we go when we press the up cursor key?
|
/// Where should we go when we press the up cursor key?
|
||||||
virtual bool idxUp(idx_type & idx, pos_type & pos) const;
|
virtual bool idxUp(idx_type & idx, pos_type & pos) const;
|
||||||
@ -271,10 +249,6 @@ public:
|
|||||||
/// identifies things that can get \limits or \nolimits
|
/// identifies things that can get \limits or \nolimits
|
||||||
virtual bool takesLimits() const { return false; }
|
virtual bool takesLimits() const { return false; }
|
||||||
|
|
||||||
///
|
|
||||||
virtual void push_back(MathInset *);
|
|
||||||
///
|
|
||||||
virtual void push_back(unsigned char c, MathTextCodes code);
|
|
||||||
///
|
///
|
||||||
virtual void dump() const;
|
virtual void dump() const;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ void MathMacro::metrics(MathMetricsInfo const & st) const
|
|||||||
{
|
{
|
||||||
if (defining()) {
|
if (defining()) {
|
||||||
size_ = st;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,12 +85,12 @@ void MathMacro::metrics(MathMetricsInfo const & st) const
|
|||||||
ascent_ = expanded_.ascent() + 2;
|
ascent_ = expanded_.ascent() + 2;
|
||||||
descent_ = expanded_.descent() + 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 lasc;
|
||||||
int ldes;
|
int ldes;
|
||||||
int lwid;
|
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) {
|
for (idx_type i = 0; i < nargs(); ++i) {
|
||||||
MathXArray const & c = xcell(i);
|
MathXArray const & c = xcell(i);
|
||||||
@ -120,22 +120,22 @@ void MathMacro::draw(Painter & pain, int x, int y) const
|
|||||||
metrics(size_);
|
metrics(size_);
|
||||||
|
|
||||||
if (defining()) {
|
if (defining()) {
|
||||||
drawStr(pain, LM_TC_TEX, size_.size, x, y, name());
|
drawStr(pain, LM_TC_TEX, size_, x, y, name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editing()) {
|
if (editing()) {
|
||||||
int h = y - ascent() + 2 + expanded_.ascent();
|
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);
|
expanded_.draw(pain, x + w + 12, h);
|
||||||
h += expanded_.descent();
|
h += expanded_.descent();
|
||||||
|
|
||||||
int lasc;
|
int lasc;
|
||||||
int ldes;
|
int ldes;
|
||||||
int lwid;
|
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) {
|
for (idx_type i = 0; i < nargs(); ++i) {
|
||||||
MathXArray const & c = xcell(i);
|
MathXArray const & c = xcell(i);
|
||||||
@ -143,7 +143,7 @@ void MathMacro::draw(Painter & pain, int x, int y) const
|
|||||||
c.draw(pain, x + lwid, h);
|
c.draw(pain, x + lwid, h);
|
||||||
char str[] = "#1:";
|
char str[] = "#1:";
|
||||||
str[1] += static_cast<char>(i);
|
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;
|
h += std::max(c.descent(), ldes) + 5;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -43,7 +43,7 @@ void MathMacroArgument::metrics(MathMetricsInfo const & st) const
|
|||||||
ascent_ = xcell(0).ascent();
|
ascent_ = xcell(0).ascent();
|
||||||
descent_ = xcell(0).descent();
|
descent_ = xcell(0).descent();
|
||||||
} else
|
} else
|
||||||
mathed_string_dim(LM_TC_TEX, size_.size, str_, ascent_, descent_, width_);
|
mathed_string_dim(LM_TC_TEX, size_, str_, ascent_, descent_, width_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ void MathMacroArgument::draw(Painter & pain, int x, int y) const
|
|||||||
if (expanded_)
|
if (expanded_)
|
||||||
xcell(0).draw(pain, x, y);
|
xcell(0).draw(pain, x, y);
|
||||||
else
|
else
|
||||||
drawStr(pain, LM_TC_TEX, size_.size, x, y, str_);
|
drawStr(pain, LM_TC_TEX, size_, x, y, str_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ int MathMatrixInset::defaultColSpace(col_type col)
|
|||||||
void MathMatrixInset::metrics(MathMetricsInfo const & st) const
|
void MathMatrixInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
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
|
// let the cells adjust themselves
|
||||||
MathGridInset::metrics(size_);
|
MathGridInset::metrics(size_);
|
||||||
@ -156,7 +156,7 @@ void MathMatrixInset::metrics(MathMetricsInfo const & st) const
|
|||||||
if (numberedType()) {
|
if (numberedType()) {
|
||||||
int l = 0;
|
int l = 0;
|
||||||
for (row_type row = 0; row < nrows(); ++row)
|
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)
|
if (l)
|
||||||
width_ += 30 + l;
|
width_ += 30 + l;
|
||||||
@ -165,7 +165,7 @@ void MathMatrixInset::metrics(MathMetricsInfo const & st) const
|
|||||||
// make it at least as high as the current font
|
// make it at least as high as the current font
|
||||||
int asc = 0;
|
int asc = 0;
|
||||||
int des = 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);
|
ascent_ = std::max(ascent_, asc);
|
||||||
descent_ = std::max(descent_, des);
|
descent_ = std::max(descent_, des);
|
||||||
}
|
}
|
||||||
@ -179,10 +179,10 @@ void MathMatrixInset::draw(Painter & pain, int x, int y) const
|
|||||||
MathGridInset::draw(pain, x, y);
|
MathGridInset::draw(pain, x, y);
|
||||||
|
|
||||||
if (numberedType()) {
|
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) {
|
for (row_type row = 0; row < nrows(); ++row) {
|
||||||
int yy = y + rowinfo_[row].offset_;
|
int const yy = y + rowinfo_[row].offset_;
|
||||||
drawStr(pain, LM_TC_BF, size(), xx, yy, nicelabel(row));
|
drawStr(pain, LM_TC_BF, size_, xx, yy, nicelabel(row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
0
src/mathed/math_metricsinfo.C
Normal file
0
src/mathed/math_metricsinfo.C
Normal file
39
src/mathed/math_metricsinfo.h
Normal file
39
src/mathed/math_metricsinfo.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#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
|
@ -32,9 +32,9 @@ void MathNotInset::metrics(MathMetricsInfo const & st) const
|
|||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
if (math_font_available(LM_TC_CMSY))
|
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
|
else
|
||||||
mathed_char_dim(LM_TC_VAR, size(), '/', ascent_, descent_, width_);
|
mathed_char_dim(LM_TC_VAR, size_, '/', ascent_, descent_, width_);
|
||||||
width_ = 0;
|
width_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ void MathNotInset::draw(Painter & pain, int x, int y) const
|
|||||||
yo(y);
|
yo(y);
|
||||||
|
|
||||||
if (math_font_available(LM_TC_CMSY))
|
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
|
else
|
||||||
drawChar(pain, LM_TC_VAR, size(), x, y, '/');
|
drawChar(pain, LM_TC_VAR, size_, x, y, '/');
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ int MathScriptInset::dy1(MathInset const * nuc) const
|
|||||||
asc += na + 2;
|
asc += na + 2;
|
||||||
else
|
else
|
||||||
asc = std::max(asc, na);
|
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 asc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,21 +162,21 @@ int MathScriptInset::nwid(MathInset const * nuc) const
|
|||||||
{
|
{
|
||||||
return nuc ?
|
return nuc ?
|
||||||
nuc->width() :
|
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
|
int MathScriptInset::nasc(MathInset const * nuc) const
|
||||||
{
|
{
|
||||||
return nuc ? nuc->ascent()
|
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
|
int MathScriptInset::ndes(MathInset const * nuc) const
|
||||||
{
|
{
|
||||||
return nuc ? nuc->descent()
|
return nuc ? nuc->descent()
|
||||||
: mathed_char_descent(LM_TC_VAR, LM_ST_TEXT, 'I');
|
: mathed_char_descent(LM_TC_VAR, size_, 'I');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -211,12 +211,15 @@ void MathScriptInset::draw(MathInset const * nuc, Painter & pain,
|
|||||||
{
|
{
|
||||||
xo(x);
|
xo(x);
|
||||||
yo(y);
|
yo(y);
|
||||||
|
|
||||||
if (nuc)
|
if (nuc)
|
||||||
nuc->draw(pain, x + dxx(nuc), y);
|
nuc->draw(pain, x + dxx(nuc), y);
|
||||||
else
|
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())
|
if (hasUp())
|
||||||
up().draw(pain, x + dx1(nuc), y - dy1(nuc));
|
up().draw(pain, x + dx1(nuc), y - dy1(nuc));
|
||||||
|
|
||||||
if (hasDown())
|
if (hasDown())
|
||||||
down().draw(pain, x + dx0(nuc), y + dy0(nuc));
|
down().draw(pain, x + dx0(nuc), y + dy0(nuc));
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ void MathSizeInset::draw(Painter & pain, int x, int y) const
|
|||||||
void MathSizeInset::metrics(MathMetricsInfo const & st) const
|
void MathSizeInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
size_.size = MathStyles(key_->id);
|
size_.style = MathStyles(key_->id);
|
||||||
xcell(0).metrics(size_);
|
xcell(0).metrics(size_);
|
||||||
ascent_ = xcell(0).ascent_;
|
ascent_ = xcell(0).ascent_;
|
||||||
descent_ = xcell(0).descent_;
|
descent_ = xcell(0).descent_;
|
||||||
|
@ -20,19 +20,19 @@ MathInset * MathSpecialCharInset::clone() const
|
|||||||
|
|
||||||
int MathSpecialCharInset::ascent() const
|
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
|
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
|
int MathSpecialCharInset::width() const
|
||||||
{
|
{
|
||||||
return mathed_char_width(LM_TC_CONST, size(), char_);
|
return mathed_char_width(LM_TC_CONST, size_, char_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ void MathSpecialCharInset::draw(Painter & pain, int x, int y) const
|
|||||||
{
|
{
|
||||||
xo(x);
|
xo(x);
|
||||||
yo(y);
|
yo(y);
|
||||||
drawChar(pain, LM_TC_CONST, size(), x, y, char_);
|
drawChar(pain, LM_TC_CONST, size_, x, y, char_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ MathInset * MathStackrelInset::clone() const
|
|||||||
void MathStackrelInset::metrics(MathMetricsInfo const & st) const
|
void MathStackrelInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
size_.size = smallerStyleFrac(size_.size);
|
smallerStyleFrac(size_);
|
||||||
xcell(0).metrics(size_);
|
xcell(0).metrics(size_);
|
||||||
xcell(1).metrics(st);
|
xcell(1).metrics(st);
|
||||||
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
|
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
|
||||||
|
@ -61,12 +61,11 @@ MathTextCodes MathSymbolInset::code2() const
|
|||||||
void MathSymbolInset::metrics(MathMetricsInfo const & st) const
|
void MathSymbolInset::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
size_ = st;
|
size_ = st;
|
||||||
MathTextCodes Code = code();
|
MathTextCodes c = code();
|
||||||
if (sym_->latex_font_id > 0 && math_font_available(Code)) {
|
if (sym_->latex_font_id > 0 && math_font_available(c)) {
|
||||||
mathed_char_dim(Code, size(), sym_->latex_font_id,
|
mathed_char_dim(c, size_, sym_->latex_font_id, ascent_, descent_, width_);
|
||||||
ascent_, descent_, width_);
|
if (c == LM_TC_CMEX) {
|
||||||
if (Code == LM_TC_CMEX) {
|
h_ = 4 * descent_ / 5;
|
||||||
h_ = 4*descent_/5;
|
|
||||||
ascent_ += h_;
|
ascent_ += h_;
|
||||||
descent_ -= h_;
|
descent_ -= h_;
|
||||||
}
|
}
|
||||||
@ -74,9 +73,9 @@ void MathSymbolInset::metrics(MathMetricsInfo const & st) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB))
|
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
|
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_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -86,11 +85,11 @@ void MathSymbolInset::draw(Painter & pain, int x, int y) const
|
|||||||
yo(y);
|
yo(y);
|
||||||
MathTextCodes Code = code();
|
MathTextCodes Code = code();
|
||||||
if (sym_->latex_font_id > 0 && math_font_available(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))
|
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
|
else
|
||||||
drawStr(pain, LM_TC_TEX, size(), x, y, sym_->name);
|
drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -102,7 +101,7 @@ bool MathSymbolInset::isRelOp() const
|
|||||||
|
|
||||||
bool MathSymbolInset::isScriptable() const
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "FontLoader.h"
|
#include "FontLoader.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "math_defs.h"
|
#include "math_defs.h"
|
||||||
|
#include "math_inset.h"
|
||||||
#include "math_parser.h"
|
#include "math_parser.h"
|
||||||
#include "Painter.h"
|
#include "Painter.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
@ -188,11 +189,20 @@ LyXFont const & whichFontBase(MathTextCodes type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LyXFont whichFont(MathTextCodes type, MathStyles size)
|
LyXFont whichFont(MathTextCodes type, MathMetricsInfo const & size)
|
||||||
{
|
{
|
||||||
LyXFont f = whichFontBase(type);
|
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:
|
case LM_ST_DISPLAY:
|
||||||
if (type == LM_TC_BOLDSYMB || type == LM_TC_CMEX) {
|
if (type == LM_TC_BOLDSYMB || type == LM_TC_CMEX) {
|
||||||
f.incSize();
|
f.incSize();
|
||||||
@ -215,7 +225,7 @@ LyXFont whichFont(MathTextCodes type, MathStyles size)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
lyxerr << "Math Error: wrong font size: " << size << endl;
|
lyxerr << "Math Error: wrong font size: " << size.style << endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,8 +245,7 @@ bool math_font_available(MathTextCodes type)
|
|||||||
{
|
{
|
||||||
if (!font_available_initialized[type]) {
|
if (!font_available_initialized[type]) {
|
||||||
font_available_initialized[type] = true;
|
font_available_initialized[type] = true;
|
||||||
font_available[type] =
|
font_available[type] = fontloader.available(whichFontBase(type));
|
||||||
fontloader.available(whichFontBase(type));
|
|
||||||
}
|
}
|
||||||
return font_available[type];
|
return font_available[type];
|
||||||
}
|
}
|
||||||
@ -505,8 +514,8 @@ deco_struct const * search_deco(string const & name)
|
|||||||
} // namespace anon
|
} // namespace anon
|
||||||
|
|
||||||
|
|
||||||
void mathed_char_dim(MathTextCodes type, MathStyles size, unsigned char c,
|
void mathed_char_dim(MathTextCodes type, MathMetricsInfo const & size,
|
||||||
int & asc, int & des, int & wid)
|
unsigned char c, int & asc, int & des, int & wid)
|
||||||
{
|
{
|
||||||
LyXFont const font = whichFont(type, size);
|
LyXFont const font = whichFont(type, size);
|
||||||
des = lyxfont::descent(c, font);
|
des = lyxfont::descent(c, font);
|
||||||
@ -515,8 +524,8 @@ void mathed_char_dim(MathTextCodes type, MathStyles size, unsigned char c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
|
int mathed_char_height(MathTextCodes type, MathMetricsInfo const & size,
|
||||||
int & asc, int & des)
|
unsigned char c, int & asc, int & des)
|
||||||
{
|
{
|
||||||
LyXFont const font = whichFont(type, size);
|
LyXFont const font = whichFont(type, size);
|
||||||
des = lyxfont::descent(c, font);
|
des = lyxfont::descent(c, font);
|
||||||
@ -525,7 +534,8 @@ int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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 asc;
|
||||||
int des;
|
int des;
|
||||||
@ -533,21 +543,24 @@ int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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);
|
LyXFont const font = whichFont(type, size);
|
||||||
return lyxfont::ascent(c, font);
|
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);
|
LyXFont const font = whichFont(type, size);
|
||||||
return lyxfont::descent(c, font);
|
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);
|
LyXFont const font = whichFont(type, size);
|
||||||
if (isBinaryOp(c, type))
|
if (isBinaryOp(c, type))
|
||||||
@ -557,16 +570,16 @@ int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mathed_string_dim(MathTextCodes type, MathStyles size, string const & s,
|
void mathed_string_dim(MathTextCodes type, MathMetricsInfo const & size,
|
||||||
int & asc, int & des, int & wid)
|
string const & s, int & asc, int & des, int & wid)
|
||||||
{
|
{
|
||||||
mathed_string_height(type, size, s, asc, des);
|
mathed_string_height(type, size, s, asc, des);
|
||||||
wid = mathed_string_width(type, size, s);
|
wid = mathed_string_width(type, size, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int mathed_string_height(MathTextCodes type, MathStyles size, string const & s,
|
int mathed_string_height(MathTextCodes type, MathMetricsInfo const & size,
|
||||||
int & asc, int & des)
|
string const & s, int & asc, int & des)
|
||||||
{
|
{
|
||||||
LyXFont const font = whichFont(type, size);
|
LyXFont const font = whichFont(type, size);
|
||||||
asc = des = 0;
|
asc = des = 0;
|
||||||
@ -578,7 +591,8 @@ int mathed_string_height(MathTextCodes type, MathStyles size, string const & s,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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));
|
return lyxfont::width(s, whichFont(type, size));
|
||||||
}
|
}
|
||||||
@ -653,15 +667,15 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
|
|||||||
|
|
||||||
|
|
||||||
// In the future maybe we use a better fonts renderer
|
// 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)
|
int x, int y, string const & s)
|
||||||
{
|
{
|
||||||
pain.text(x, y, s, whichFont(type, siz));
|
pain.text(x, y, s, whichFont(type, siz));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void drawChar
|
void drawChar(Painter & pain, MathTextCodes type, MathMetricsInfo const & siz,
|
||||||
(Painter & pain, MathTextCodes type, MathStyles siz, int x, int y, char c)
|
int x, int y, char c)
|
||||||
{
|
{
|
||||||
string s;
|
string s;
|
||||||
if (isBinaryOp(c, type))
|
if (isBinaryOp(c, type))
|
||||||
@ -674,30 +688,29 @@ void drawChar
|
|||||||
|
|
||||||
|
|
||||||
// decrease math size for super- and subscripts
|
// 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_DISPLAY:
|
||||||
case LM_ST_TEXT: st = LM_ST_SCRIPT; break;
|
case LM_ST_TEXT: st.style = LM_ST_SCRIPT; break;
|
||||||
default: st = LM_ST_SCRIPTSCRIPT;
|
default: st.style = LM_ST_SCRIPTSCRIPT;
|
||||||
}
|
}
|
||||||
return st;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// decrease math size for fractions
|
// decrease math size for fractions
|
||||||
MathStyles smallerStyleFrac(MathStyles st)
|
void smallerStyleFrac(MathMetricsInfo & st)
|
||||||
{
|
{
|
||||||
switch (st) {
|
switch (st.style) {
|
||||||
case LM_ST_DISPLAY: st = LM_ST_TEXT; break;
|
case LM_ST_DISPLAY: st.style = LM_ST_TEXT; break;
|
||||||
case LM_ST_TEXT: st = LM_ST_SCRIPT; break;
|
case LM_ST_TEXT: st.style = LM_ST_SCRIPT; break;
|
||||||
default: st = LM_ST_SCRIPTSCRIPT;
|
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);
|
LyXFont font = whichFont(code, siz);
|
||||||
asc = lyxfont::maxAscent(font);
|
asc = lyxfont::maxAscent(font);
|
||||||
|
@ -8,37 +8,52 @@
|
|||||||
|
|
||||||
class Painter;
|
class Painter;
|
||||||
class latexkeys;
|
class latexkeys;
|
||||||
|
class MathMetricsInfo;
|
||||||
|
|
||||||
extern char const * latex_mathspace[];
|
extern char const * latex_mathspace[];
|
||||||
|
|
||||||
int mathed_char_height(MathTextCodes type, MathStyles size, unsigned char c,
|
int mathed_char_height(MathTextCodes type, MathMetricsInfo const & size,
|
||||||
int & asc, int & des);
|
unsigned char c, int & asc, int & des);
|
||||||
void mathed_char_dim(MathTextCodes type, MathStyles size, unsigned char c,
|
void mathed_char_dim(MathTextCodes type, MathMetricsInfo const & size,
|
||||||
int & asc, int & des, int & wid);
|
unsigned char c, int & asc, int & des, int & wid);
|
||||||
int mathed_char_width(MathTextCodes type, MathStyles size, unsigned char c);
|
int mathed_char_width(MathTextCodes type, MathMetricsInfo const & size,
|
||||||
int mathed_char_ascent(MathTextCodes type, MathStyles size, unsigned char c);
|
unsigned char c);
|
||||||
int mathed_char_descent(MathTextCodes type, MathStyles 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,
|
void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
|
||||||
string const & name);
|
string const & name);
|
||||||
|
|
||||||
void mathed_string_dim(MathTextCodes type, MathStyles size, string const & s,
|
void mathed_string_dim(MathTextCodes type, MathMetricsInfo const & size,
|
||||||
int & asc, int & des, int & wid);
|
string const & s, int & asc, int & des, int & wid);
|
||||||
int mathed_string_height(MathTextCodes type, MathStyles size, string const & s,
|
int mathed_string_height(MathTextCodes type, MathMetricsInfo const & size,
|
||||||
int & asc, int & des);
|
string const & s, int & asc, int & des);
|
||||||
|
|
||||||
int mathed_string_width(MathTextCodes type, MathStyles size, string const & s);
|
int mathed_string_width(MathTextCodes type, MathMetricsInfo const & size,
|
||||||
int mathed_string_ascent(MathTextCodes type, MathStyles size, string const & s);
|
string const & s);
|
||||||
int mathed_string_descent(MathTextCodes type, MathStyles 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);
|
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);
|
int x, int y, char c);
|
||||||
|
|
||||||
void math_font_max_dim
|
void math_font_max_dim(MathTextCodes code, MathMetricsInfo const & siz,
|
||||||
(MathTextCodes code, MathStyles siz, int & asc, int & desc);
|
int & asc, int & desc);
|
||||||
|
|
||||||
bool math_font_available(MathTextCodes code);
|
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
|
#endif
|
||||||
|
@ -14,20 +14,20 @@
|
|||||||
|
|
||||||
|
|
||||||
MathXArray::MathXArray()
|
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
|
void MathXArray::metrics(MathMetricsInfo const & st) const
|
||||||
{
|
{
|
||||||
style_ = st.size;
|
size_ = st;
|
||||||
mathed_char_dim(LM_TC_VAR, style_, 'I', ascent_, descent_, width_);
|
mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
|
||||||
|
|
||||||
if (data_.empty())
|
if (data_.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
math_font_max_dim(LM_TC_TEXTRM, style_, ascent_, descent_);
|
math_font_max_dim(LM_TC_TEXTRM, st, ascent_, descent_);
|
||||||
width_ = 0;
|
width_ = 0;
|
||||||
|
|
||||||
//lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
|
//lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include "array.h"
|
#include "array.h"
|
||||||
#include "math_defs.h"
|
#include "math_metricsinfo.h"
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface
|
#pragma interface
|
||||||
@ -45,8 +45,6 @@ public:
|
|||||||
int height() const { return ascent_ + descent_; }
|
int height() const { return ascent_ + descent_; }
|
||||||
///
|
///
|
||||||
int width() const { return width_; }
|
int width() const { return width_; }
|
||||||
///
|
|
||||||
MathStyles style() const { return style_; }
|
|
||||||
|
|
||||||
///
|
///
|
||||||
const_iterator begin() const { return data_.begin(); }
|
const_iterator begin() const { return data_.begin(); }
|
||||||
@ -67,7 +65,7 @@ public:
|
|||||||
///
|
///
|
||||||
mutable int yo_;
|
mutable int yo_;
|
||||||
///
|
///
|
||||||
mutable MathStyles style_;
|
mutable MathMetricsInfo size_;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream & operator<<(std::ostream & os, MathXArray const & ar);
|
std::ostream & operator<<(std::ostream & os, MathXArray const & ar);
|
||||||
|
Loading…
Reference in New Issue
Block a user