]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insettabular.C
static_cast-based key/mouse-state. Kill insetKeyPress.
[lyx.git] / src / insets / insettabular.C
index 1aa1b9f01cfbbf72873fe41e9b6256bdda340d4f..8ac934c79d4ecf2232f02bff00e36f2cd8f31e6d 100644 (file)
 #include "lyxfunc.h"
 #include "debug.h"
 #include "LaTeXFeatures.h"
-#include "Painter.h"
-#include "font.h"
+#include "frontends/Painter.h"
+#include "frontends/font_metrics.h"
 #include "lyxtext.h"
-#include "LyXView.h"
+#include "frontends/LyXView.h"
 #include "insets/insettext.h"
 #include "debug.h"
 #include "gettext.h"
@@ -450,8 +450,8 @@ void InsetTabular::drawCellLines(Painter & pain, int x, int baseline,
                          on_off ? Painter::line_onoffdash : Painter::line_solid);
        }
        on_off = !tabular->BottomLine(cell);
-       pain.line(x,baseline +  tabular->GetDescentOfRow(row),
-                 x2, baseline +  tabular->GetDescentOfRow(row),
+       pain.line(x, baseline + tabular->GetDescentOfRow(row),
+                 x2, baseline + tabular->GetDescentOfRow(row),
                  on_off ? LColor::tabularonoffline : LColor::tabularline,
                  on_off ? Painter::line_onoffdash : Painter::line_solid);
        if (!tabular->LeftAlreadyDrawed(cell)) {
@@ -491,8 +491,8 @@ void InsetTabular::drawCellSelection(Painter & pain, int x, int baseline,
 
        if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
                int w = tabular->GetWidthOfColumn(cell);
-               int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row);
-               pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row),
+               int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row)-1;
+               pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row) + 1,
                                   w, h, LColor::selection);
        }
 }
@@ -551,7 +551,7 @@ string const InsetTabular::editMessage() const
 }
 
 
-void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button)
+void InsetTabular::edit(BufferView * bv, int x, int y, mouse_button::state button)
 {
        UpdatableInset::edit(bv, x, y, button);
 
@@ -566,7 +566,7 @@ void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button)
        setPos(bv, x, y);
        clearSelection();
        finishUndo();
-       if (insetHit(bv, x, y) && (button != 3)) {
+       if (insetHit(bv, x, y) && (button != mouse_button::button3)) {
                activateCellInsetAbs(bv, x, y, button);
        }
 }
@@ -766,9 +766,9 @@ bool InsetTabular::insertInset(BufferView * bv, Inset * inset)
 }
 
 
-void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button)
+void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, mouse_button::state button)
 {
-       if (hasSelection() && (button == 3))
+       if (hasSelection() && (button == mouse_button::button3))
                return;
 
        if (hasSelection()) {
@@ -815,7 +815,7 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button)
                updateLocal(bv, CELL, false);
                the_locking_inset = 0;
        }
-       if (button == 2) {
+       if (button == mouse_button::button2) {
                localDispatch(bv, LFUN_PASTESELECTION, "paragraph");
                return;
        }
@@ -833,13 +833,13 @@ void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button)
 
 
 bool InsetTabular::insetButtonRelease(BufferView * bv,
-                                     int x, int y, int button)
+                                     int x, int y, mouse_button::state button)
 {
        bool ret = false;
        if (the_locking_inset)
                ret = the_locking_inset->insetButtonRelease(bv, x - inset_x,
                                                                                                        y - inset_y, button);
-       if (button == 3 && !ret) {
+       if (button == mouse_button::button3 && !ret) {
                bv->owner()->getDialogs()->showTabular(this);
                return true;
        }
@@ -847,7 +847,7 @@ bool InsetTabular::insetButtonRelease(BufferView * bv,
 }
 
 
-void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, int button)
+void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::state button)
 {
        if (the_locking_inset) {
                the_locking_inset->insetMotionNotify(bv,
@@ -871,15 +871,6 @@ void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, int button)
 }
 
 
-void InsetTabular::insetKeyPress(XKeyEvent * xke)
-{
-       if (the_locking_inset) {
-               the_locking_inset->insetKeyPress(xke);
-               return;
-       }
-}
-
-
 UpdatableInset::RESULT
 InsetTabular::localDispatch(BufferView * bv, kb_action action,
                            string const & arg)
@@ -1428,10 +1419,10 @@ void InsetTabular::toggleInsetCursor(BufferView * bv)
        }
 
        LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos);
-
-       int const asc = lyxfont::maxAscent(font);
-       int const desc = lyxfont::maxDescent(font);
-
+       
+       int const asc = font_metrics::maxAscent(font);
+       int const desc = font_metrics::maxDescent(font);
+       
        if (isCursorVisible())
                bv->hideLockedInsetCursor();
        else
@@ -1446,9 +1437,9 @@ void InsetTabular::showInsetCursor(BufferView * bv, bool show)
                return;
        if (!isCursorVisible()) {
                LyXFont font; // = GetFont(par, cursor.pos);
-
-               int const asc = lyxfont::maxAscent(font);
-               int const desc = lyxfont::maxDescent(font);
+       
+               int const asc = font_metrics::maxAscent(font);
+               int const desc = font_metrics::maxDescent(font);
                bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
                if (show)
                        bv->showLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
@@ -1476,9 +1467,11 @@ void InsetTabular::fitInsetCursor(BufferView * bv) const
                return;
        }
        LyXFont font;
+       
+       int const asc = font_metrics::maxAscent(font);
+       int const desc = font_metrics::maxDescent(font);
+       resetPos(bv);
 
-       int const asc = lyxfont::maxAscent(font);
-       int const desc = lyxfont::maxDescent(font);
        if (bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc))
                need_update = FULL;
 }
@@ -1633,7 +1626,7 @@ UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
        if (!moved)
                return FINISHED;
        if (lock) {       // behind the inset
-               if (activateCellInset(bv, 0, 0, 0, true))
+               if (activateCellInset(bv, 0, 0, mouse_button::none, true))
                        return DISPATCHED;
        }
        resetPos(bv);
@@ -1705,7 +1698,7 @@ bool InsetTabular::moveNextCell(BufferView * bv, bool lock)
        if (lock) {
                bool rtl = tabular->GetCellInset(actcell)->paragraph()->
                        isRightToLeftPar(bv->buffer()->params);
-               activateCellInset(bv, 0, 0, 0, !rtl);
+               activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
        }
        resetPos(bv);
        return true;
@@ -1734,7 +1727,7 @@ bool InsetTabular::movePrevCell(BufferView * bv, bool lock)
        if (lock) {
                bool rtl = tabular->GetCellInset(actcell)->paragraph()->
                        isRightToLeftPar(bv->buffer()->params);
-               activateCellInset(bv, 0, 0, 0, !rtl);
+               activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
        }
        resetPos(bv);
        return true;
@@ -2168,7 +2161,7 @@ void InsetTabular::tabularFeatures(BufferView * bv,
 }
 
 
-bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, int button,
+bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, mouse_button::state button,
                                     bool behind)
 {
        UpdatableInset * inset =
@@ -2189,7 +2182,7 @@ bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, int button,
 
 
 bool InsetTabular::activateCellInsetAbs(BufferView * bv, int x, int y,
-                                       int button)
+                                       mouse_button::state button)
 {
        inset_x = cursor_.x()
                - top_x + tabular->GetBeginningOfTextInCell(actcell);
@@ -2693,7 +2686,7 @@ InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const
        // otherwise we have to lock the next inset and ask for it's selecttion
        UpdatableInset * inset =
                static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
-       inset->edit(bv, 0,  0, 0);
+       inset->edit(bv, 0,  0, mouse_button::none);
        string const str(selectNextWordInt(bv, value));
        nodraw(false);
        if (!str.empty())