move things around

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4799 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2002-07-26 17:23:44 +00:00
parent 11398a3316
commit 4d51fc96b4
8 changed files with 74 additions and 40 deletions

View File

@ -416,6 +416,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
switch (action) {
case LFUN_WORDRIGHTSEL:
case LFUN_RIGHTSEL:
sel = true; // fall through...
case LFUN_RIGHT:
@ -427,6 +428,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
//bv->owner()->message(mathcursor->info());
break;
case LFUN_WORDLEFTSEL:
case LFUN_LEFTSEL:
sel = true; // fall through
case LFUN_LEFT:
@ -543,9 +545,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
mathcursor->selCopy();
break;
case LFUN_WORDRIGHTSEL:
case LFUN_WORDLEFTSEL:
break;
// Special casing for superscript in case of LyX handling
// dead-keys:

View File

@ -660,46 +660,14 @@ void MathCursor::selGet(MathArray & ar)
void MathCursor::drawSelection(MathPainterInfo & pain) const
void MathCursor::drawSelection(MathPainterInfo & pi) const
{
if (!selection_)
return;
MathCursorPos i1;
MathCursorPos i2;
getSelection(i1, i2);
if (i1.idx_ == i2.idx_) {
MathXArray & c = i1.xcell();
int x1 = c.xo() + c.pos2x(i1.pos_);
int y1 = c.yo() - c.ascent();
int x2 = c.xo() + c.pos2x(i2.pos_);
int y2 = c.yo() + c.descent();
pain.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
} else {
vector<MathInset::idx_type> indices
= i1.par_->idxBetween(i1.idx_, i2.idx_);
for (unsigned i = 0; i < indices.size(); ++i) {
MathXArray & c = i1.xcell(indices[i]);
int x1 = c.xo();
int y1 = c.yo() - c.ascent();
int x2 = c.xo() + c.width();
int y2 = c.yo() + c.descent();
pain.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
}
}
#if 0
// draw anchor if different from selection boundary
MathCursorPos anc = Anchor_.back();
if (anc != i1 && anc != i2) {
MathXArray & c = anc.xcell();
int x = c.xo() + c.pos2x(anc.pos_);
int y1 = c.yo() - c.ascent();
int y2 = c.yo() + c.descent();
pain.line(x, y1, x, y2, LColor::math);
}
#endif
i1.par_->drawSelection(pi, i1.idx_, i1.pos_, i2.idx_, i2.pos_);
}

View File

@ -224,6 +224,13 @@ void MathInset::draw(MathPainterInfo &, int, int) const
}
void MathInset::drawSelection(MathPainterInfo &,
idx_type, pos_type, idx_type, pos_type) const
{
lyxerr << "MathInset::drawSelection() called directly!\n";
}
void MathInset::metricsT(TextMetricsInfo const &) const
{
#ifdef WITH_WARNINGS

View File

@ -110,9 +110,12 @@ public:
virtual void substitute(MathMacro const & macro);
/// compute the size of the object, sets ascend_, descend_ and width_
// updates the (xo,yo)-caches of all contained cells
virtual void metrics(MathMetricsInfo & st) const;
virtual void metrics(MathMetricsInfo & mi) const;
/// draw the object
virtual void draw(MathPainterInfo &, int x, int y) const;
virtual void draw(MathPainterInfo & pi, int x, int y) const;
/// draw selection between two positions
virtual void drawSelection(MathPainterInfo & pi,
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
/// the ascent of the inset above the baseline
/// compute the size of the object for text based drawing
virtual void metricsT(TextMetricsInfo const & st) const;

View File

@ -182,6 +182,30 @@ void MathNestInset::draw(MathPainterInfo &, int, int) const
}
void MathNestInset::drawSelection(MathPainterInfo & pi,
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const
{
if (idx1 == idx2) {
MathXArray const & c = xcell(idx1);
int x1 = c.xo() + c.pos2x(pos1);
int y1 = c.yo() - c.ascent();
int x2 = c.xo() + c.pos2x(pos2);
int y2 = c.yo() + c.descent();
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
} else {
vector<MathInset::idx_type> indices = idxBetween(idx1, idx2);
for (unsigned i = 0; i < indices.size(); ++i) {
MathXArray const & c = xcell(indices[i]);
int x1 = c.xo();
int y1 = c.yo() - c.ascent();
int x2 = c.xo() + c.width();
int y2 = c.yo() + c.descent();
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
}
}
}
void MathNestInset::drawMarkers(MathPainterInfo & pi, int x, int y) const
{
if (!editing())

View File

@ -28,7 +28,9 @@ public:
void metricsMarkers2(int frame = 1) const;
/// draw background if locked
void draw(MathPainterInfo & pi, int x, int y) const;
/// draw two angular markers
/// draw selection background
void drawSelection(MathPainterInfo & pi,
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
void drawMarkers(MathPainterInfo & pi, int x, int y) const;
/// draw four angular markers
void drawMarkers2(MathPainterInfo & pi, int x, int y) const;

View File

@ -207,6 +207,34 @@ void MathParboxInset::draw(MathPainterInfo & pi, int x, int y) const
}
void MathParboxInset::drawSelection(MathPainterInfo & pi,
idx_type, pos_type pos1, idx_type, pos_type pos2) const
{
int row1 = pos2row(pos1);
int row2 = pos2row(pos2);
if (row1 == row2) {
/*
MathXArray & c = xcell(0);
int x1 = c.xo() + c.pos2x(i1.pos_);
int y1 = c.yo() - c.ascent();
int x2 = c.xo() + c.pos2x(i2.pos_);
int y2 = c.yo() + c.descent();
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
} else {
vector<MathInset::idx_type> indices = idxBetween(idx1, idx2);
for (unsigned i = 0; i < indices.size(); ++i) {
MathXArray & c = i1.xcell(indices[i]);
int x1 = c.xo();
int y1 = c.yo() - c.ascent();
int x2 = c.xo() + c.width();
int y2 = c.yo() + c.descent();
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
}
*/
}
}
void MathParboxInset::write(WriteStream & os) const
{
os << "\\parbox";

View File

@ -19,6 +19,9 @@ public:
void metrics(MathMetricsInfo & mi) const;
///
void draw(MathPainterInfo &, int x, int y) const;
/// draw selection background
void drawSelection(MathPainterInfo & pi,
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
///
void infoize(std::ostream & os) const;
///