switch (action) {
+ case LFUN_WORDRIGHTSEL:
case LFUN_RIGHTSEL:
sel = true; // fall through...
case LFUN_RIGHT:
//bv->owner()->message(mathcursor->info());
break;
+ case LFUN_WORDLEFTSEL:
case LFUN_LEFTSEL:
sel = true; // fall through
case LFUN_LEFT:
mathcursor->selCopy();
break;
- case LFUN_WORDRIGHTSEL:
- case LFUN_WORDLEFTSEL:
- break;
// Special casing for superscript in case of LyX handling
// dead-keys:
-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_);
}
}
+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
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;
}
+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())
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;
}
+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";
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;
///