]> git.lyx.org Git - features.git/commitdiff
move things around
authorAndré Pönitz <poenitz@gmx.net>
Fri, 26 Jul 2002 17:23:44 +0000 (17:23 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Fri, 26 Jul 2002 17:23:44 +0000 (17:23 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4799 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/formulabase.C
src/mathed/math_cursor.C
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_nestinset.C
src/mathed/math_nestinset.h
src/mathed/math_parboxinset.C
src/mathed/math_parboxinset.h

index dbc150a52fcd4fb0cbcc830dd662b69d9b5317e5..6be371e6d36afb69a683205111100a59993254cc 100644 (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:
index 77b4a35697818f30b349e962ee69bd4581e510c9..b7c66d5d37cdcddd93055e418cf94332b3725438 100644 (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_);
 }
 
 
index 6d0e9cda0e56cacf9cffd9f36464f66f72cd21a5..e1a60690464811b7640b7c5630d548ec6f49493d 100644 (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
index 41894271c35c5ca67f48340e5bd9b61726f0a926..5a62a1bc82707fe8507e974ec643295237150be3 100644 (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;
index e3d219470f1f1dac62758312bffc99d8841d506e..dd328b8312041905cc5710a5a11e2e4e36427fc5 100644 (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())
index ba791df4d7351371a133a168e794aaeb06a75905..3f8fd3e18064495dd594a61ab81cc610d76412f2 100644 (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;
index 459949cc5f1883f2fdb0430f816c6a6e98805011..609f9bdeb06db42dc7953bd47f4ca9e0b3800d32 100644 (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";
index 71e6ac07ce57457678814ab9a5b04530d999721d..ab129d9b668692a934d1b6be5bb4dca17bd89232 100644 (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;
        ///