]> git.lyx.org Git - features.git/commitdiff
small stuff
authorAndré Pönitz <poenitz@gmx.net>
Tue, 20 Nov 2001 14:48:25 +0000 (14:48 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Tue, 20 Nov 2001 14:48:25 +0000 (14:48 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3049 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/formula.C
src/mathed/formulabase.C
src/mathed/formulamacro.C
src/mathed/math_cursor.C

index 8ddb1a075498805fcbb860987bfea4daca8ac557..337924f15f0d24443af18fd5bb1ceaa040b2e5c1 100644 (file)
@@ -31,6 +31,7 @@
 #include "gettext.h"
 #include "debug.h"
 #include "lyx_gui_misc.h"
+#include "lyxtext.h"
 #include "support/LOstream.h"
 #include "support/LAssert.h"
 #include "support/lyxlib.h"
@@ -324,6 +325,13 @@ void InsetFormula::read(Buffer const *, LyXLex & lex)
 }
 
 
+//std::ostream & operator<<(std::ostream & os, LyXCursor const & c)
+//{
+//     os << '[' << c.x() << ' ' << c.y() << ' ' << c.pos() << ']';
+//     return os;
+//}
+
+
 void InsetFormula::draw(BufferView * bv, LyXFont const & font,
                        int y, float & xx, bool) const
 {
@@ -336,11 +344,27 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font,
        int w = par_->width();
        int h = par_->height();
        int a = par_->ascent();
-       pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
 
-       if (mathcursor && mathcursor->formula() == this) {
-               mathcursor->drawSelection(pain);
-               pain.rectangle(x, y - a, w, h, LColor::mathframe);
+       bool done = false;
+/*
+       if (LyXText * t = bv->getLyXText()) {
+               LyXText::Selection & sel = t->selection;
+               lyxerr << "sel.start: " << sel.start << "\n";
+               lyxerr << "sel.end: " << sel.end << "\n";
+               lyxerr << "t->cursor: " << t->cursor << "\n";
+               if (sel.set() && sel.start < t->cursor && t->cursor < sel.end) {
+                       pain.fillRectangle(x, y - a, w, h, LColor::selection);
+                       done = true;
+               }
+       }
+*/
+
+       if (!done) {
+               pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
+               if (mathcursor && mathcursor->formula() == this) {
+                       mathcursor->drawSelection(pain);
+                       pain.rectangle(x, y - a, w, h, LColor::mathframe);
+               }
        }
 
        par_->draw(pain, x, y);
index 48b3041e0027e491d0e762ab231e09e275b214ac..aa5121a13358b0d0185a8824075c4773c09a38bc 100644 (file)
@@ -41,6 +41,7 @@
 #include "math_spaceinset.h"
 #include "math_macrotable.h"
 #include "math_factory.h"
+#include "math_parser.h"
 #include "undo_funcs.h"
 
 using std::endl;
@@ -125,12 +126,14 @@ string const InsetFormulaBase::editMessage() const
 }
 
 
-void InsetFormulaBase::edit(BufferView * bv, int x, int /*y*/, unsigned int)
+void InsetFormulaBase::edit(BufferView * bv, int x, int y, unsigned int button)
 {
        if (!bv->lockInset(this))
                lyxerr[Debug::MATHED] << "Cannot lock inset!!!" << endl;
 
-       mathcursor = new MathCursor(this, x == 0);
+       //lyxerr << "edit: " << x  << " " << y << " button: " << button << "\n";
+       if (!mathcursor)
+               mathcursor = new MathCursor(this, x == 0);
        metrics(bv);
        // if that is removed, we won't get the magenta box when entering an
        // inset for the first time
@@ -242,7 +245,7 @@ void InsetFormulaBase::updateLocal(BufferView * bv, bool dirty)
 
 
 void InsetFormulaBase::insetButtonRelease(BufferView * bv,
-                                         int x, int y, int /*button*/)
+                                         int /*x*/, int /*y*/, int /*button*/)
 {
        if (!mathcursor)
                return;
@@ -254,21 +257,42 @@ void InsetFormulaBase::insetButtonRelease(BufferView * bv,
 
 
 void InsetFormulaBase::insetButtonPress(BufferView * bv,
-                                       int x, int y, int /*button*/)
+                                       int x, int y, int button)
 {
-       //lyxerr << "insetButtonPress: " << x + xo_ << " " << y + yo_ << "\n";
-       first_x = x;
-       first_y = y;
-       if (mathcursor) {
-               mathcursor->selClear();
-               mathcursor->setPos(x + xo_, y + yo_);
+       //lyxerr << "insetButtonPress: " << x + xo_ << " " << y + yo_
+       //      << " but: " << button << "\n";
+       switch (button) {
+               default:
+               case 1:
+                       // just click
+                       first_x = x;
+                       first_y = y;
+                       if (mathcursor) {
+                               mathcursor->selClear();
+                               mathcursor->setPos(x + xo_, y + yo_);
+                       }
+                       break;
+               case 2:
+                       lyxerr << "insetButtonPress: 2\n";
+                       // insert stuff
+                       if (mathcursor) {
+                               bv->lockedInsetStoreUndo(Undo::EDIT);
+                               MathArray ar;
+                               mathcursor->selGet(ar);
+                               mathcursor->setPos(x + xo_, y + yo_);
+                               string sel =
+                                       bv->getLyXText()->selectionAsString(bv->buffer(), false);
+                               //mathed_parse_cell(ar, sel);
+                               mathcursor->insert(ar);
+                       }       
+                       break;
        }
        bv->updateInset(this, false);
 }
 
 
 void InsetFormulaBase::insetMotionNotify(BufferView * bv,
-                                        int x, int y, int button)
+                                        int x, int y, int /*button*/)
 {
        if (!mathcursor)
                return;
index 7740c47da690a57a301784cff304f5444b4ed280..93b0689b479ef52f252da4420c0d97e1340049ac 100644 (file)
@@ -62,10 +62,6 @@ InsetFormulaMacro::InsetFormulaMacro(string const & s)
 {
        string name = mathed_parse_macro(s);
        setInsetName(name);
-#ifdef WITH_WARNINGS
-#warning "metrics disabled"
-#endif
-       //metrics();
 }
 
 
index a6055f5e790765f2dece5bbf9e289aaaeb5ae46e..ea813276afcb0ff95c842ba07bd3e920fb44a20c 100644 (file)
@@ -483,10 +483,6 @@ void MathCursor::niceInsert(MathAtom const & t)
                right();  // do not push for e.g. MathSymbolInset
                selPaste();
        }
-#ifdef WITH_WARNINGS
-#warning "redraw disabled"
-#endif
-       //p->metrics(p->size());
 }