]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathHull.cpp
Allow automatic text direction in Painter::text()
[lyx.git] / src / mathed / InsetMathHull.cpp
index 097a3445c5f5196b6ba65ecd06de5716d2efeee6..a782751b1048bc9c99e4203cb41c4f857e2a6578 100644 (file)
@@ -158,7 +158,7 @@ static InsetLabel * dummy_pointer = 0;
 InsetMathHull::InsetMathHull(Buffer * buf)
        : InsetMathGrid(buf, 1, 1), type_(hullNone), numbered_(1, NUMBER),
          numbers_(1, empty_docstring()), label_(1, dummy_pointer),
-         preview_(new RenderPreview(this)), use_preview_(false)
+         preview_(new RenderPreview(this))
 {
        //lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
        //lyxerr << "sizeof MetricsInfo: " << sizeof(MetricsInfo) << endl;
@@ -173,7 +173,7 @@ InsetMathHull::InsetMathHull(Buffer * buf)
 InsetMathHull::InsetMathHull(Buffer * buf, HullType type)
        : InsetMathGrid(buf, getCols(type), 1), type_(type), numbered_(1, NUMBER),
          numbers_(1, empty_docstring()), label_(1, dummy_pointer),
-         preview_(new RenderPreview(this)), use_preview_(false)
+         preview_(new RenderPreview(this))
 {
        buffer_ = buf;
        initMath();
@@ -316,7 +316,7 @@ void InsetMathHull::addToToc(DocIterator const & pit, bool output_active,
 
 Inset * InsetMathHull::editXY(Cursor & cur, int x, int y)
 {
-       if (use_preview_) {
+       if (previewState(&cur.bv())) {
                edit(cur, true);
                return this;
        }
@@ -526,7 +526,6 @@ void InsetMathHull::drawBackground(PainterInfo & pi, int x, int y) const
 void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
 {
        BufferView const * const bv = pi.base.bv;
-       use_preview_ = previewState(bv);
 
        if (type_ == hullRegexp) {
                Dimension const dim = dimension(*bv);
@@ -534,7 +533,7 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const
                        dim.width() - 2, dim.height() - 2, Color_regexpframe);
        }
 
-       if (use_preview_) {
+       if (previewState(bv)) {
                Dimension const dim = dimension(*bv);
                if (previewTooSmall(dim)) {
                        // we have an extra frame
@@ -1040,6 +1039,28 @@ void InsetMathHull::footer_write(WriteStream & os) const
 }
 
 
+bool InsetMathHull::isTable() const
+{
+       switch (type_) {
+       case hullEqnArray:
+       case hullAlign:
+       case hullAlignAt:
+       case hullXAlignAt:
+       case hullXXAlignAt:
+       case hullFlAlign:
+       case hullMultline:
+       case hullGather:
+               return true;
+       case hullNone:
+       case hullSimple:
+       case hullEquation:
+       case hullRegexp:
+               break;
+       }
+       return false;
+}
+
+
 bool InsetMathHull::rowChangeOK() const
 {
        return
@@ -1702,6 +1723,13 @@ void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
                break;
        }
 
+       case LFUN_TABULAR_FEATURE:
+               if (!isTable())
+                       cur.undispatched();
+               else
+                       InsetMathGrid::doDispatch(cur, cmd);
+               break;
+
        default:
                InsetMathGrid::doDispatch(cur, cmd);
                break;
@@ -1816,13 +1844,10 @@ bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
                }
                return InsetMathGrid::getStatus(cur, cmd, status);
 
-       case LFUN_INSET_MODIFY: {
-               istringstream is(to_utf8(cmd.argument()));
-               string s;
-               is >> s;
-               if (s != "tabular")
-                       return InsetMathGrid::getStatus(cur, cmd, status);
-               is >> s;
+       case LFUN_TABULAR_FEATURE: {
+               if (!isTable())
+                       return false;
+               string s = cmd.getArg(0);
                if (!rowChangeOK()
                    && (s == "append-row"
                        || s == "delete-row"
@@ -1843,16 +1868,6 @@ bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
                        status.setEnabled(false);
                        return true;
                }
-               if ((type_ == hullSimple
-                 || type_ == hullEquation
-                 || type_ == hullNone) &&
-                   (s == "add-hline-above" || s == "add-hline-below")) {
-                       status.message(bformat(
-                               from_utf8(N_("Can't add horizontal grid lines in '%1$s'")),
-                               hullName(type_)));
-                       status.setEnabled(false);
-                       return true;
-               }
                if (s == "add-vline-left" || s == "add-vline-right") {
                        status.message(bformat(
                                from_utf8(N_("Can't add vertical grid lines in '%1$s'")),