cosmetics, incidently fixing bug 1458

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10270 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2005-07-17 10:31:44 +00:00
parent 4a7f4fb7bf
commit 6b14cbd9c4
15 changed files with 36 additions and 42 deletions

View File

@ -1,3 +1,4 @@
#if 0
/**
* \file math_binaryopinset.C
* This file is part of LyX, the document processor.
@ -56,10 +57,10 @@ void MathBinaryOpInset::metrics(MetricsInfo & mi, Dimension & dim) const
#endif
void MathBinaryOpInset::draw(PainterInfo & pain, int x, int y) const
void MathBinaryOpInset::draw(PainterInfo & pi, int x, int y) const
{
cell(0).draw(pain, x, y);
drawChar(pain, LM_TC_CONST, mi_, x + cell(0).width() , y, op_);
pi.draw(pain, LM_TC_CONST, mi_, x + cell(0).width() , y, op_);
cell(1).draw(pain, x + width() - cell(1).width(), y);
}
@ -74,3 +75,4 @@ void MathBinaryOpInset::normalize(NormalStream & os) const
{
os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']';
}
#endif

View File

@ -1,3 +1,4 @@
#if 0
// -*- C++ -*-
/**
* \file math_binaryopinset.h
@ -40,3 +41,4 @@ private:
mutable MetricsInfo mi_;
};
#endif
#endif

View File

@ -16,6 +16,7 @@
#include "math_support.h"
#include "LColor.h"
#include "support/std_ostream.h"
#include "frontends/Painter.h"
using std::max;
using std::auto_ptr;
@ -58,9 +59,9 @@ void MathBraceInset::draw(PainterInfo & pi, int x, int y) const
font.setColor(LColor::latex);
Dimension t;
mathed_char_dim(font, '{', t);
drawChar(pi, font, x, y, '{');
pi.pain.text(x, y, '{', font);
cell(0).draw(pi, x + t.wid, y);
drawChar(pi, font, x + t.wid + cell(0).width(), y, '}');
pi.pain.text(x + t.wid + cell(0).width(), y, '}', font);
drawMarkers(pi, x, y);
}

View File

@ -330,7 +330,7 @@ void MathHullInset::draw(PainterInfo & pi, int x, int y) const
for (row_type row = 0; row < nrows(); ++row) {
int const yy = y + rowinfo_[row].offset_;
FontSetChanger dummy(pi.base, "mathrm");
drawStr(pi, pi.base.font, xx, yy, nicelabel(row));
pi.draw(xx, yy, nicelabel(row));
}
}
setPosCache(pi, x, y);

View File

@ -21,6 +21,7 @@
#include "debug.h"
#include "BufferView.h"
#include "LaTeXFeatures.h"
#include "frontends/Painter.h"
using std::string;
using std::max;
@ -79,7 +80,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
LyXFont font = pi.base.font;
augmentFont(font, "lyxtex");
int h = y - dim_.ascent() + 2 + tmpl_.ascent();
drawStr(pi, font, x + 3, h, name());
pi.pain.text(x + 3, h, name(), font);
int const w = mathed_string_width(font, name());
tmpl_.draw(pi, x + w + 12, h);
h += tmpl_.descent();
@ -91,7 +92,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
c.draw(pi, x + ldim.wid, h);
char str[] = "#1:";
str[1] += static_cast<char>(i);
drawStr(pi, font, x + 3, h, str);
pi.pain.text(x + 3, h, str, font);
h += max(c.descent(), ldim.des) + 5;
}
} else {

View File

@ -15,7 +15,6 @@
#include "math_streamstr.h"
#include "math_support.h"
using std::string;
using std::auto_ptr;
@ -39,8 +38,7 @@ void MathNumberInset::metrics(MetricsInfo & mi, Dimension & dim) const
void MathNumberInset::draw(PainterInfo & pi, int x, int y) const
{
//lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
drawStr(pi, pi.base.font, x, y, str_);
pi.draw(x, y, str_);
}

View File

@ -245,7 +245,7 @@ void MathScriptInset::draw(PainterInfo & pi, int x, int y) const
else {
nuc().setXY(x + dxx(), y);
if (editing(pi.base.bv))
drawStr(pi, pi.base.font, x + dxx(), y, ".");
pi.draw(x + dxx(), y, ".");
}
ScriptChanger dummy(pi.base);
if (hasUp())

View File

@ -40,7 +40,7 @@ void MathStringInset::metrics(MetricsInfo & mi, Dimension & dim) const
void MathStringInset::draw(PainterInfo & pi, int x, int y) const
{
//lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
drawStr(pi, pi.base.font, x, y, str_);
pi.draw(x, y, str_);
}

View File

@ -480,14 +480,6 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
}
// In the future maybe we use a better fonts renderer
void drawStr(PainterInfo & pi, LyXFont const & font,
int x, int y, string const & str)
{
pi.pain.text(x, y, str, font);
}
void drawStrRed(PainterInfo & pi, int x, int y, string const & str)
{
LyXFont f = pi.base.font;
@ -504,12 +496,6 @@ void drawStrBlack(PainterInfo & pi, int x, int y, string const & str)
}
void drawChar(PainterInfo & pi, LyXFont const & font, int x, int y, char c)
{
pi.pain.text(x, y, c, font);
}
void math_font_max_dim(LyXFont const & font, int & asc, int & des)
{
asc = font_metrics::maxAscent(font);
@ -601,8 +587,6 @@ fontinfo fontinfos[] = {
// LyX internal usage
{"lyxtex", inh_family, inh_series,
LyXFont::UP_SHAPE, LColor::latex},
{"lyxert", LyXFont::TYPEWRITER_FAMILY, inh_series,
LyXFont::UP_SHAPE, LColor::latex},
{"lyxsymbol", LyXFont::SYMBOL_FAMILY, inh_series,
inh_shape, LColor::math},
{"lyxboldsymbol", LyXFont::SYMBOL_FAMILY, LyXFont::BOLD_SERIES,

View File

@ -34,11 +34,8 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
void mathed_string_dim(LyXFont const & font, std::string const & s, Dimension & dim);
int mathed_string_width(LyXFont const &, std::string const & s);
void drawStr(PainterInfo & pi,
LyXFont const &, int x, int y, std::string const & s);
void drawStrRed(PainterInfo & pi, int x, int y, std::string const & s);
void drawStrBlack(PainterInfo & pi, int x, int y, std::string const & s);
void drawChar(PainterInfo & pi, LyXFont const & font, int x, int y, char c);
void math_font_max_dim(LyXFont const &, int & asc, int & desc);

View File

@ -109,7 +109,7 @@ void MathSymbolInset::draw(PainterInfo & pi, int x, int y) const
x += static_cast<int>(0.0833*em+0.5);
FontSetChanger dummy(pi.base, sym_->inset.c_str());
drawStr(pi, pi.base.font, x, y - h_, sym_->draw);
pi.draw(x, y - h_, sym_->draw);
}

View File

@ -117,18 +117,18 @@ void MathXYArrowInset::draw(PainterInfo & pi, int x, int y) const
mathed_string_dim(pi.base.font, "target: ", lasc, ldes, lwid);
cell(0).draw(pi, x + lwid, y);
drawStr(pi, pi.base.font, x + 3, y, "target");
pi.base.text(x + 3, y, "target");
y += max(cell(0).descent(), ldes) + 5;
y += max(cell(1).ascent(), lasc) + 5;
cell(1).draw(pi, x + lwid, y);
drawStr(pi, pi.base.font, x + 3, y, "label");
pi.base.text(x + 3, y, "label");
#endif
} else {
drawStr(pi, font_, x, y, "X");
pi.pain.text(x, y, "X");
MathArray const & s = sourceCell();
MathArray const & t = targetCell();
pi.pain.line(s.xm(), s.ym(), t.xm(), t.ym(), LColor::math);

View File

@ -59,6 +59,12 @@ void PainterInfo::draw(int x, int y, char c)
}
void PainterInfo::draw(int x, int y, std::string const & str)
{
pain.text(x, y, str, base.font);
}
Styles smallerScriptStyle(Styles st)
{
switch (st) {

View File

@ -83,6 +83,8 @@ public:
PainterInfo(BufferView * bv, Painter & pain);
///
void draw(int x, int y, char c);
///
void draw(int x, int y, std::string const & str);
///
MetricsBase base;

View File

@ -415,7 +415,8 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
else
needsUpdate = cursorRight(cur);
if (!needsUpdate && oldTopSlice == cur.top() && cur.boundary() == oldBoundary) {
if (!needsUpdate && oldTopSlice == cur.top()
&& cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_RIGHT);
}
@ -429,9 +430,9 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
needsUpdate = cursorRight(cur);
else
needsUpdate = cursorLeft(cur);
if (!needsUpdate && oldTopSlice == cur.top() &&
cur.boundary() == oldBoundary)
{
if (!needsUpdate && oldTopSlice == cur.top()
&& cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_LEFT);
}
@ -442,10 +443,10 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
update(cur);
//lyxerr << "handle LFUN_UP[SEL]:\n" << cur << endl;
cur.selHandle(cmd.action == LFUN_UPSEL);
needsUpdate = cursorUp(cur);
if (!needsUpdate && oldTopSlice == cur.top() &&
cur.boundary() == oldBoundary)
{
if (!needsUpdate && oldTopSlice == cur.top()
&& cur.boundary() == oldBoundary) {
cur.undispatched();
cmd = FuncRequest(LFUN_FINISHED_UP);
}