+2001-10-17 André Pönitz <poenitz@gmx.net>
+
+ * math_*inset.[Ch]: remove MathStyles cache from insets that
+ don't need it
+
+ * support.C:
+ formulabase.C: fix math font sizes in headings etc
+
+ * math_inset.[Ch]:
+ formula.C: remove unused static member int MathInset::workwidth
+
2001-10-17 André Pönitz <poenitz@gmx.net>
* math_inset.h:
using std::vector;
+namespace {
+
+ void stripFromLastEqualSign(MathArray & ar)
+ {
+ // find position of last '=' in the array
+ MathArray::size_type pos = ar.size();
+ for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ if ((*it)->getChar() == '=')
+ pos = it - ar.begin();
+
+ // delete everything behind this position
+ ar.erase(pos, ar.size());
+ }
+
+}
+
InsetFormula::InsetFormula()
: par_(MathAtom(new MathMatrixInset))
int x = int(xx) - 1;
y -= 2;
- MathInset::workwidth = bv->workWidth();
Painter & pain = bv->painter();
- metrics(bv, &font);
+ metrics(bv, font);
int w = par_->width();
int h = par_->height();
int a = par_->ascent();
case LFUN_MATH_EXTERN:
bv->lockedInsetStoreUndo(Undo::EDIT);
- handleExtern(arg, bv);
+ handleExtern(arg);
+ // re-compute inset dimension
+ metrics(bv);
updateLocal(bv, true);
break;
}
-void InsetFormula::handleExtern(const string & arg, BufferView * bv)
+void InsetFormula::handleExtern(const string & arg)
{
// where are we?
+ if (!mathcursor)
+ return;
+
MathArray & ar = mathcursor->cursor().cell();
- // find position of last '=' in the array for handleExtern
- MathArray::size_type pos = ar.size();
- for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
- if ((*it)->getChar() == '=')
- pos = it - ar.begin();
+ // parse args
+ string lang;
+ string extra;
+ istringstream iss(arg.c_str());
+ iss >> lang >> extra;
+ if (extra.empty())
+ extra = "noextra";
- // delete everything behind this position
- ar.erase(pos, ar.size());
+ // strip last '=' and everything behind
+ stripFromLastEqualSign(ar);
// create normalized expression
//string outfile = lyx::tempName("maple.out");
- string outfile = "/tmp/lyx2" + arg + ".out";
+ string outfile = "/tmp/lyx2" + lang + ".out";
ostringstream os;
+ os << "[" << extra << ' ';
ar.writeNormal(os);
+ os << "]";
string code = os.str().c_str();
// run external sript
ifstream is(outfile.c_str());
mathed_parse_cell(ar, is);
mathcursor->end();
-
- // re-compute inset dimension
- metrics(bv);
}
int InsetFormula::width(BufferView * bv, LyXFont const & font) const
{
- metrics(bv, &font);
+ metrics(bv, font);
return par_->width();
}
///
std::vector<string> const getLabelList() const;
///
- void handleExtern(string const & arg, BufferView * bv);
+ void handleExtern(string const & arg);
///
bool display() const;
///
MathArrayInset * matrixpar(MathInset::idx_type & idx)
{
idx = 0;
- return (mathcursor ? mathcursor->enclosingArray(idx) : 0);
+ return mathcursor ? mathcursor->enclosingArray(idx) : 0;
}
InsetFormulaBase::InsetFormulaBase()
- : view_(0), font_(0)
+ : view_(0), font_()
{
// This is needed as long the math parser is not re-entrant
MathMacroTable::builtinMacros();
{}
-void InsetFormulaBase::metrics(BufferView * bv, LyXFont const * f) const
+void InsetFormulaBase::metrics(BufferView * bv, LyXFont const & f) const
{
if (bv)
view_ = bv;
- if (f)
- font_ = f;
- if (f)
- lyxerr << "fontsize: " << f->size() << "\n";
+ font_ = f;
MathMetricsInfo mi(view_, font_, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
par()->metrics(mi);
}
#include <iosfwd>
#include "insets/inset.h"
+#include "lyxfont.h"
// only for getType():
#include "math_defs.h"
///
virtual MathAtom & par() = 0;
///
- virtual void metrics(BufferView * bv = 0, LyXFont const * font = 0) const;
+ virtual void metrics(BufferView * bv = 0, LyXFont const & font = LyXFont()) const;
///
virtual void updateLocal(BufferView * bv, bool mark_dirty);
private:
///
mutable BufferView * view_;
///
- mutable LyXFont const * font_;
+ mutable LyXFont font_;
};
// We don't really mess want around with mathed stuff outside mathed.
int InsetFormulaMacro::width(BufferView * bv, LyXFont const & f) const
{
- metrics(bv, &f);
+ metrics(bv, f);
return 10 + lyxfont::width(prefix(), f) + par()->width();
}
void MathArrayInset::metrics(MathMetricsInfo const & st) const
{
- size_ = st;
- if (size_.style == LM_ST_DISPLAY)
- size_.style = LM_ST_TEXT;
- MathGridInset::metrics(size_);
+ MathMetricsInfo mi = st;
+ if (mi.style == LM_ST_DISPLAY)
+ mi.style = LM_ST_TEXT;
+ MathGridInset::metrics(mi);
}
void MathBinomInset::metrics(MathMetricsInfo const & st) const
{
- size_ = st;
- smallerStyleFrac(size_);
- xcell(0).metrics(size_);
- xcell(1).metrics(size_);
+ MathMetricsInfo mi = st;
+ smallerStyleFrac(mi);
+ xcell(0).metrics(mi);
+ xcell(1).metrics(mi);
ascent_ = xcell(0).height() + 4 + 5;
descent_ = xcell(1).height() + 4 - 5;
width_ = std::max(xcell(0).width(), xcell(1).width()) + 2 * dw() + 4;
void MathBoxInset::metrics(MathMetricsInfo const & st) const
{
- size_ = st;
- if (text_ && st.view && st.font) {
- ascent_ = text_->ascent(st.view, *st.font) + 2;
- descent_ = text_->descent(st.view, *st.font) + 2;
- width_ = text_->width(st.view, *st.font) + 4;
+ mi_ = st;
+ if (text_ && mi_.view) {
+ ascent_ = text_->ascent(mi_.view, mi_.font) + 2;
+ descent_ = text_->descent(mi_.view, mi_.font) + 2;
+ width_ = text_->width(mi_.view, mi_.font) + 4;
} else {
ascent_ = 10;
descent_ = 0;
{
float fx = x + 2;
- if (text_ && size_.view && size_.font)
- text_->draw(size_.view, *(size_.font), y, fx, false);
+ if (text_ && mi_.view)
+ text_->draw(mi_.view, mi_.font, y, fx, false);
if (mathcursor && mathcursor->isInside(this))
pain.rectangle(x, y - ascent(), xcell(0).width(), height(),
LColor::mathframe);
///
void writeNormal(std::ostream &) const;
///
- void metrics(MathMetricsInfo const & st) const;
+ void metrics(MathMetricsInfo const &) const;
/// identifies BoxInsets
MathBoxInset * asBoxInset() { return this; }
/// unimplemented
void operator=(MathBoxInset const &);
+ ///
+ mutable MathMetricsInfo mi_;
///
string name_;
///
int MathCharInset::ascent() const
{
- return mathed_char_ascent(code_, size_, char_);
+ return mathed_char_ascent(code_, mi_, char_);
}
int MathCharInset::descent() const
{
- return mathed_char_descent(code_, size_, char_);
+ return mathed_char_descent(code_, mi_, char_);
}
int MathCharInset::width() const
{
- return mathed_char_width(code_, size_, char_);
+ return mathed_char_width(code_, mi_, char_);
}
-void MathCharInset::metrics(MathMetricsInfo const & st) const
+void MathCharInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
+ mi_ = mi;
}
xo(x);
yo(y);
//lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
- drawChar(pain, code_, size_, x, y, char_);
+ drawChar(pain, code_, mi_, x, y, char_);
}
char char_;
/// the font to be used on screen
MathTextCodes code_;
+ ///
+ mutable MathMetricsInfo mi_;
};
#endif
mutable int dh_;
/// vertical offset cache of deco
mutable int dy_;
+ ///
+ mutable MathMetricsInfo size_;
};
#endif
}
-void MathDelimInset::metrics(MathMetricsInfo const & st) const
+void MathDelimInset::metrics(MathMetricsInfo const & mi) const
{
- xcell(0).metrics(st);
- size_ = st;
+ xcell(0).metrics(mi);
int a, d, w;
- mathed_char_dim(LM_TC_VAR, size_, 'I', a, d, w);
+ mathed_char_dim(LM_TC_VAR, mi, '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
+void MathDotsInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
- mathed_char_dim(LM_TC_VAR, size_, 'M', ascent_, descent_, width_);
+ mathed_char_dim(LM_TC_VAR, mi, '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
+void MathFracInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
- smallerStyleFrac(size_);
- xcell(0).metrics(size_);
- xcell(1).metrics(size_);
+ MathMetricsInfo m = mi;
+ smallerStyleFrac(m);
+ xcell(0).metrics(m);
+ xcell(1).metrics(m);
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
ascent_ = xcell(0).height() + 4 + 5;
descent_ = xcell(1).height() + 4 - 5;
}
-void MathFuncInset::metrics(MathMetricsInfo const & st) const
+void MathFuncInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
- mathed_string_dim(LM_TC_TEX, size_, name_, ascent_, descent_, width_);
+ mi_ = mi;
+ mathed_string_dim(LM_TC_TEX, mi_, name_, ascent_, descent_, width_);
}
{
xo(x);
yo(y);
- drawStr(pain, LM_TC_TEX, size_, x, y, name_);
+ drawStr(pain, LM_TC_TEX, mi_, x, y, name_);
}
private:
///
string name_;
+ ///
+ mutable MathMetricsInfo mi_;
};
#endif
bool MathFuncLimInset::isScriptable() const
{
- return size_.style == LM_ST_DISPLAY;
+ return mi_.style == LM_ST_DISPLAY;
}
}
-void MathFuncLimInset::metrics(MathMetricsInfo const & st) const
+void MathFuncLimInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
- mathed_string_dim(LM_TC_TEXTRM, size_, sym_->name,
- ascent_, descent_, width_);
+ mi_ = mi;
+ mathed_string_dim(LM_TC_TEXTRM, mi_, sym_->name, ascent_, descent_, width_);
}
{
xo(x);
yo(y);
- drawStr(pain, LM_TC_TEXTRM, size_, x, y, sym_->name);
+ drawStr(pain, LM_TC_TEXTRM, mi_, x, y, sym_->name);
}
private:
///
latexkeys const * sym_;
+ ///
+ mutable MathMetricsInfo mi_;
};
#endif
#endif
#include "math_gridinset.h"
+#include "lyxfont.h"
#include "support/LOstream.h"
#include "debug.h"
}
-void MathGridInset::metrics(MathMetricsInfo const & st) const
+void MathGridInset::metrics(MathMetricsInfo const & mi) const
{
// let the cells adjust themselves
- MathNestInset::metrics(st);
- size_ = st;
+ MathNestInset::metrics(mi);
// adjust vertical structure
for (row_type row = 0; row < nrows(); ++row) {
#include "debug.h"
-int MathInset::workwidth;
-
-
MathInset::MathInset()
: xo_(0), yo_(0)
{}
}
-void MathInset::metrics(MathMetricsInfo const & st) const
+void MathInset::metrics(MathMetricsInfo const &) const
{
lyxerr << "MathInset::metrics() called directly!\n";
- size_ = st;
}
///
virtual void handleFont(MathTextCodes) {}
- ///
- static int workwidth;
-
-protected:
- /// the used font size
- mutable MathMetricsInfo size_;
-
private:
/// the following are used for positioning the cursor with the mouse
/// cached cursor start position in pixels from the document left
}
-void MathLefteqnInset::metrics(MathMetricsInfo const & st) const
+void MathLefteqnInset::metrics(MathMetricsInfo const & mi) const
{
- MathNestInset::metrics(st);
- size_ = st;
+ MathNestInset::metrics(mi);
ascent_ = xcell(0).ascent() + 2;
descent_ = xcell(0).descent() + 2;
width_ = 4;
}
-void MathMacro::metrics(MathMetricsInfo const & st) const
+void MathMacro::metrics(MathMetricsInfo const & mi) const
{
+ mi_ = mi;
+
if (defining()) {
- size_ = st;
- mathed_string_dim(LM_TC_TEX, size_, name(), ascent_, descent_, width_);
+ mathed_string_dim(LM_TC_TEX, mi_, name(), ascent_, descent_, width_);
return;
}
if (editing()) {
expanded_ = tmplate_->xcell(0);
- expanded_.metrics(st);
- size_ = st;
+ expanded_.metrics(mi_);
width_ = expanded_.width() + 4;
ascent_ = expanded_.ascent() + 2;
descent_ = expanded_.descent() + 2;
- width_ += mathed_string_width(LM_TC_TEXTRM, size_, name()) + 10;
+ width_ += mathed_string_width(LM_TC_TEXTRM, mi_, name()) + 10;
int lasc;
int ldes;
int lwid;
- mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
+ mathed_string_dim(LM_TC_TEXTRM, mi_, "#1: ", lasc, ldes, lwid);
for (idx_type i = 0; i < nargs(); ++i) {
MathXArray const & c = xcell(i);
- c.metrics(st);
+ c.metrics(mi_);
width_ = std::max(width_, c.width() + lwid);
descent_ += std::max(c.ascent(), lasc) + 5;
descent_ += std::max(c.descent(), ldes) + 5;
expanded_ = tmplate_->xcell(0);
expanded_.data_.substitute(*this);
- expanded_.metrics(st);
- size_ = st;
+ expanded_.metrics(mi_);
width_ = expanded_.width() + 6;
ascent_ = expanded_.ascent() + 3;
descent_ = expanded_.descent() + 3;
xo(x);
yo(y);
- metrics(size_);
+ metrics(mi_);
if (defining()) {
- drawStr(pain, LM_TC_TEX, size_, x, y, name());
+ drawStr(pain, LM_TC_TEX, mi_, x, y, name());
return;
}
if (editing()) {
int h = y - ascent() + 2 + expanded_.ascent();
- drawStr(pain, LM_TC_TEXTRM, size_, x + 3, h, name());
+ drawStr(pain, LM_TC_TEXTRM, mi_, x + 3, h, name());
- int const w = mathed_string_width(LM_TC_TEXTRM, size_, name());
+ int const w = mathed_string_width(LM_TC_TEXTRM, mi_, name());
expanded_.draw(pain, x + w + 12, h);
h += expanded_.descent();
int lasc;
int ldes;
int lwid;
- mathed_string_dim(LM_TC_TEXTRM, size_, "#1: ", lasc, ldes, lwid);
+ mathed_string_dim(LM_TC_TEXTRM, mi_, "#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_, x + 3, h, str);
+ drawStr(pain, LM_TC_TEX, mi_, x + 3, h, str);
h += std::max(c.descent(), ldes) + 5;
}
return;
MathAtom & tmplate_;
///
mutable MathXArray expanded_;
+ ///
+ mutable MathMetricsInfo mi_;
};
}
-void MathMacroArgument::metrics(MathMetricsInfo const & st) const
+void MathMacroArgument::metrics(MathMetricsInfo const & mi) const
{
+ mi_ = mi;
if (expanded_) {
- xcell(0).metrics(st);
+ xcell(0).metrics(mi_);
width_ = xcell(0).width();
ascent_ = xcell(0).ascent();
descent_ = xcell(0).descent();
} else
- mathed_string_dim(LM_TC_TEX, size_, str_, ascent_, descent_, width_);
+ mathed_string_dim(LM_TC_TEX, mi_, str_, ascent_, descent_, width_);
}
if (expanded_)
xcell(0).draw(pain, x, y);
else
- drawStr(pain, LM_TC_TEX, size_, x, y, str_);
+ drawStr(pain, LM_TC_TEX, mi_, x, y, str_);
}
char str_[3];
///
bool expanded_;
+ ///
+ mutable MathMetricsInfo mi_;
};
#endif
}
-void MathMacroTemplate::metrics(MathMetricsInfo const & st) const
+void MathMacroTemplate::metrics(MathMetricsInfo const & mi) const
{
- xcell(0).metrics(st);
- size_ = st;
+ xcell(0).metrics(mi);
width_ = xcell(0).width() + 4;
ascent_ = xcell(0).ascent() + 2;
descent_ = xcell(0).descent() + 2;
}
-void MathMatrixInset::metrics(MathMetricsInfo const & st) const
+void MathMatrixInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
- size_.style = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
+ mi_ = mi;
+ mi_.style = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
// let the cells adjust themselves
- MathGridInset::metrics(size_);
+ MathGridInset::metrics(mi_);
if (display()) {
ascent_ += 12;
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, mi_, 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, size_, asc, des);
+ math_font_max_dim(LM_TC_TEXTRM, mi_, asc, des);
ascent_ = std::max(ascent_, asc);
descent_ = std::max(descent_, des);
}
int const xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
for (row_type row = 0; row < nrows(); ++row) {
int const yy = y + rowinfo_[row].offset_;
- drawStr(pain, LM_TC_BF, size_, xx, yy, nicelabel(row));
+ drawStr(pain, LM_TC_BF, mi_, xx, yy, nicelabel(row));
}
}
}
std::vector<int> nonum_;
///
std::vector<string> label_;
+ ///
+ mutable MathMetricsInfo mi_;
};
#endif
#ifndef MATH_METRICSINFO
#define MATH_METRICSINFO
+#include "lyxfont.h"
+
class BufferView;
-class LyXFont;
/// Standard Math Sizes (Math mode styles)
struct MathMetricsInfo {
///
MathMetricsInfo()
- : view(0), font(0), style(LM_ST_TEXT)
+ : view(0), font(), style(LM_ST_TEXT)
{}
///
- MathMetricsInfo(BufferView * v, LyXFont const * f, MathStyles s)
+ MathMetricsInfo(BufferView * v, LyXFont const & f, MathStyles s)
: view(v), font(f), style(s)
{}
///
BufferView * view;
///
- LyXFont const * font;
+ LyXFont font;
///
MathStyles style;
};
}
-void MathNestInset::metrics(MathMetricsInfo const & st) const
+void MathNestInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
for (idx_type i = 0; i < nargs(); ++i)
- xcell(i).metrics(st);
+ xcell(i).metrics(mi);
}
}
-void MathNotInset::metrics(MathMetricsInfo const & st) const
+void MathNotInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
+ mi_ = mi;
if (math_font_available(LM_TC_CMSY))
- mathed_char_dim(LM_TC_CMSY, size_, 54, ascent_, descent_, width_);
+ mathed_char_dim(LM_TC_CMSY, mi_, 54, ascent_, descent_, width_);
else
- mathed_char_dim(LM_TC_VAR, size_, '/', ascent_, descent_, width_);
+ mathed_char_dim(LM_TC_VAR, mi_, '/', 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, mi_, x, y, 54);
else
- drawChar(pain, LM_TC_VAR, size_, x, y, '/');
+ drawChar(pain, LM_TC_VAR, mi_, x, y, '/');
}
void metrics(MathMetricsInfo const & st) const;
///
void draw(Painter &, int x, int y) const;
+private:
+ ///
+ mutable MathMetricsInfo mi_;
};
#endif
#include "support/LOstream.h"
#include "Painter.h"
+
MathRootInset::MathRootInset()
: MathNestInset(2)
{}
}
-void MathRootInset::metrics(MathMetricsInfo const & st) const
+void MathRootInset::metrics(MathMetricsInfo const & mi) const
{
- MathNestInset::metrics(st);
- size_ = st;
+ MathNestInset::metrics(mi);
ascent_ = std::max(xcell(0).ascent() + 5, xcell(1).ascent()) + 2;
descent_ = std::max(xcell(1).descent() + 5, xcell(0).descent()) + 2;
width_ = xcell(0).width() + xcell(1).width() + 10;
asc += na + 2;
else
asc = std::max(asc, na);
- asc = std::max(asc, mathed_char_ascent(LM_TC_VAR, size_, 'I'));
+ asc = std::max(asc, mathed_char_ascent(LM_TC_VAR, mi_, 'I'));
return asc;
}
{
return nuc ?
nuc->width() :
- mathed_char_width(LM_TC_TEX, size_, '.');
+ mathed_char_width(LM_TC_TEX, mi_, '.');
}
int MathScriptInset::nasc(MathInset const * nuc) const
{
return nuc ? nuc->ascent()
- : mathed_char_ascent(LM_TC_VAR, size_, 'I');
+ : mathed_char_ascent(LM_TC_VAR, mi_, 'I');
}
int MathScriptInset::ndes(MathInset const * nuc) const
{
return nuc ? nuc->descent()
- : mathed_char_descent(LM_TC_VAR, size_, 'I');
+ : mathed_char_descent(LM_TC_VAR, mi_, 'I');
}
-void MathScriptInset::metrics(MathMetricsInfo const & st) const
+void MathScriptInset::metrics(MathMetricsInfo const & mi) const
{
- metrics(0, st);
+ metrics(0, mi);
}
void MathScriptInset::metrics(MathInset const * nuc,
- MathMetricsInfo const & st) const
+ MathMetricsInfo const & mi) const
{
- MathNestInset::metrics(st);
+ MathNestInset::metrics(mi);
if (nuc)
- nuc->metrics(st);
+ nuc->metrics(mi);
ascent_ = ascent(nuc);
descent_ = descent(nuc);
if (nuc)
nuc->draw(pain, x + dxx(nuc), y);
else
- drawStr(pain, LM_TC_TEX, size_, x + dxx(nuc), y, ".");
+ drawStr(pain, LM_TC_TEX, mi_, x + dxx(nuc), y, ".");
if (hasUp())
up().draw(pain, x + dx1(nuc), y - dy1(nuc));
bool script_[2];
///
int limits_;
+ ///
+ mutable MathMetricsInfo mi_;
};
#endif
}
-void MathSizeInset::metrics(MathMetricsInfo const & st) const
+void MathSizeInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
- size_.style = MathStyles(key_->id);
- xcell(0).metrics(size_);
+ MathMetricsInfo m = mi;
+ m.style = MathStyles(key_->id);
+ xcell(0).metrics(m);
ascent_ = xcell(0).ascent_;
descent_ = xcell(0).descent_;
width_ = xcell(0).width_;
}
-void MathSpaceInset::draw(Painter & pain, int x, int y) const
-{
-
-// XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
-
-// Sadly, HP-UX CC can't handle that kind of initialization.
-
- int xp[4];
- int yp[4];
-
- xp[0] = ++x; yp[0] = y - 3;
- xp[1] = x; yp[1] = y;
- xp[2] = x + width_ - 2; yp[2] = y;
- xp[3] = x + width_ - 2; yp[3] = y - 3;
-
- pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
-}
-
-
void MathSpaceInset::write(MathWriteInfo & os) const
{
if (space_ >= 0 && space_ < 6)
}
-void MathSpaceInset::metrics(MathMetricsInfo const & st) const
+void MathSpaceInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
width_ = space_ ? space_ * 2 : 2;
if (space_ > 3)
width_ *= 2;
}
+void MathSpaceInset::draw(Painter & pain, int x, int y) const
+{
+
+// XPoint p[4] = {{++x, y-3}, {x, y}, {x+width-2, y}, {x+width-2, y-3}};
+
+// Sadly, HP-UX CC can't handle that kind of initialization.
+
+ int xp[4];
+ int yp[4];
+
+ xp[0] = ++x; yp[0] = y - 3;
+ xp[1] = x; yp[1] = y;
+ xp[2] = x + width_ - 2; yp[2] = y;
+ xp[3] = x + width_ - 2; yp[3] = y - 3;
+
+ pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
+}
+
+
void MathSpaceInset::incSpace()
{
space_ = (space_ + 1) % 6;
int MathSpecialCharInset::ascent() const
{
- return mathed_char_ascent(LM_TC_CONST, size_, char_);
+ return mathed_char_ascent(LM_TC_CONST, mi_, char_);
}
int MathSpecialCharInset::descent() const
{
- return mathed_char_descent(LM_TC_CONST, size_, char_);
+ return mathed_char_descent(LM_TC_CONST, mi_, char_);
}
int MathSpecialCharInset::width() const
{
- return mathed_char_width(LM_TC_CONST, size_, char_);
+ return mathed_char_width(LM_TC_CONST, mi_, char_);
}
-void MathSpecialCharInset::metrics(MathMetricsInfo const & st) const
+void MathSpecialCharInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
+ mi_ = mi;
}
{
xo(x);
yo(y);
- drawChar(pain, LM_TC_CONST, size_, x, y, char_);
+ drawChar(pain, LM_TC_CONST, mi_, x, y, char_);
}
private:
/// the character
char char_;
+ ///
+ mutable MathMetricsInfo mi_;
};
#endif
}
-void MathSqrtInset::metrics(MathMetricsInfo const & st) const
+void MathSqrtInset::metrics(MathMetricsInfo const & mi) const
{
- xcell(0).metrics(st);
- size_ = st;
+ xcell(0).metrics(mi);
ascent_ = xcell(0).ascent() + 4;
descent_ = xcell(0).descent() + 2;
width_ = xcell(0).width() + 12;
}
-void MathStackrelInset::metrics(MathMetricsInfo const & st) const
+void MathStackrelInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
- smallerStyleFrac(size_);
- xcell(0).metrics(size_);
- xcell(1).metrics(st);
+ MathMetricsInfo m = mi;
+ smallerStyleFrac(m);
+ xcell(0).metrics(m);
+ xcell(1).metrics(mi);
width_ = std::max(xcell(0).width(), xcell(1).width()) + 4;
ascent_ = xcell(1).ascent() + xcell(0).height() + 4;
descent_ = xcell(1).descent();
}
-void MathSymbolInset::metrics(MathMetricsInfo const & st) const
+void MathSymbolInset::metrics(MathMetricsInfo const & mi) const
{
- size_ = st;
+ mi_ = mi;
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_);
+ mathed_char_dim(c, mi_, sym_->latex_font_id, ascent_, descent_, width_);
if (c == LM_TC_CMEX) {
h_ = 4 * descent_ / 5;
ascent_ += 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(), mi_, sym_->id, ascent_, descent_, width_);
else
- mathed_string_dim(LM_TC_TEX, size_, sym_->name, ascent_, descent_, width_);
+ mathed_string_dim(LM_TC_TEX, mi_, 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, mi_, 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(), mi_, x, y, sym_->id);
else
- drawStr(pain, LM_TC_TEX, size_, x, y, sym_->name);
+ drawStr(pain, LM_TC_TEX, mi_, x, y, sym_->name);
}
bool MathSymbolInset::isScriptable() const
{
- return size_.style == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
+ return mi_.style == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
}
latexkeys const * sym_;
///
mutable int h_;
+ ///
+ mutable MathMetricsInfo mi_;
};
#endif
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());
- }
+ // use actual size
+ f.setSize(size.font.size());
switch (size.style) {
case LM_ST_DISPLAY: