X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiMathMatrix.cpp;h=25555f7b01d76a2a740598d4467b264dc0181ab9;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=e74bd938c0d634c15a4ccae39c1f44b0efb6b2f7;hpb=f1cba8ff64b369792fd49f5ddf90e8126ab476ac;p=lyx.git diff --git a/src/frontends/qt4/GuiMathMatrix.cpp b/src/frontends/qt4/GuiMathMatrix.cpp index e74bd938c0..25555f7b01 100644 --- a/src/frontends/qt4/GuiMathMatrix.cpp +++ b/src/frontends/qt4/GuiMathMatrix.cpp @@ -4,6 +4,7 @@ * Licence details can be found in the file COPYING. * * \author Jürgen Spitzmüller + * \author Uwe Stöhr * * Full author contact details are available in file CREDITS. */ @@ -35,6 +36,7 @@ GuiMathMatrix::GuiMathMatrix(GuiView & lv) rowsSB->setValue(5); columnsSB->setValue(5); valignCO->setCurrentIndex(1); + decorationCO->setCurrentIndex(0); connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK())); connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose())); @@ -55,6 +57,8 @@ GuiMathMatrix::GuiMathMatrix(GuiView & lv) this, SLOT(change_adaptor())); connect(halignED, SIGNAL(textChanged(QString)), this, SLOT(change_adaptor())); + connect(decorationCO, SIGNAL(activated(int)), + this, SLOT(decorationChanged(int))); bc().setPolicy(ButtonPolicy::IgnorantPolicy); } @@ -77,6 +81,18 @@ void GuiMathMatrix::rowsChanged(int) } +void GuiMathMatrix::decorationChanged(int deco) +{ + // a matrix with a decoration cannot have a vertical alignment + if (deco != 0) { + alignmentGB->setEnabled(false); + valignCO->setCurrentIndex(1); + halignED->clear(); + } else + alignmentGB->setEnabled(true); +} + + void GuiMathMatrix::change_adaptor() { // FIXME: We need a filter for the halign input @@ -85,14 +101,36 @@ void GuiMathMatrix::change_adaptor() void GuiMathMatrix::slotOK() { - char v_align_c[] = "tcb"; - char const c = v_align_c[valignCO->currentIndex()]; - QString const sh = halignED->text(); int const nx = columnsSB->value(); int const ny = rowsSB->value(); - string const str = fromqstr( - QString("%1 %2 %3 %4").arg(nx).arg(ny).arg(c).arg(sh)); - dispatch(FuncRequest(LFUN_MATH_MATRIX, str)); + // a matrix without a decoration is an array, + // otherwise it is an AMS matrix that cannot have a vertical alignment + if (decorationCO->currentIndex() == 0) { + char v_align_c[] = "tcb"; + char const c = v_align_c[valignCO->currentIndex()]; + QString const sh = halignED->text(); + string const str = fromqstr( + QString("%1 %2 %3 %4").arg(nx).arg(ny).arg(c).arg(sh)); + dispatch(FuncRequest(LFUN_MATH_MATRIX, str)); + } else { + int const deco = decorationCO->currentIndex(); + QString deco_name; + switch (deco) { + case 1: deco_name = "bmatrix"; + break; + case 2: deco_name = "pmatrix"; + break; + case 3: deco_name = "Bmatrix"; + break; + case 4: deco_name = "vmatrix"; + break; + case 5: deco_name = "Vmatrix"; + break; + } + string const str_ams = fromqstr( + QString("%1 %2 %3").arg(nx).arg(ny).arg(deco_name)); + dispatch(FuncRequest(LFUN_MATH_AMS_MATRIX, str_ams)); + } close(); }