X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fqt4%2FGuiMathMatrix.cpp;h=25555f7b01d76a2a740598d4467b264dc0181ab9;hb=425d092204118ea6c24c28e85fdf03fcf2bb51a4;hp=5a83b0d09de9082b7c64a0a3e0b4eeed473f61d0;hpb=d5483e355148aadc4887948ac5b7288dc37c9936;p=lyx.git diff --git a/src/frontends/qt4/GuiMathMatrix.cpp b/src/frontends/qt4/GuiMathMatrix.cpp index 5a83b0d09d..25555f7b01 100644 --- a/src/frontends/qt4/GuiMathMatrix.cpp +++ b/src/frontends/qt4/GuiMathMatrix.cpp @@ -3,7 +3,8 @@ * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * - * \author Jürgen Spitzmüller + * \author Jürgen Spitzmüller + * \author Uwe Stöhr * * Full author contact details are available in file CREDITS. */ @@ -14,42 +15,28 @@ #include "EmptyTable.h" #include "qt_helpers.h" -#include "gettext.h" -#include +#include "FuncRequest.h" #include #include #include -using std::ostringstream; -using std::string; +using namespace std; namespace lyx { namespace frontend { -GuiMathMatrix::GuiMathMatrix(Dialog & parent) - : GuiView(parent, _("Math Matrix")) -{} - - -void GuiMathMatrix::build_dialog() -{ - dialog_.reset(new GuiMathMatrixDialog(this)); -} - - -GuiMathMatrixDialog::GuiMathMatrixDialog(GuiMathMatrix * form) - : form_(form) +GuiMathMatrix::GuiMathMatrix(GuiView & lv) + : GuiDialog(lv, "mathmatrix", qt_("Math Matrix")) { setupUi(this); - setWindowTitle(qt_("LyX: Insert Matrix")); - table->setMinimumSize(100, 100); 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())); @@ -66,14 +53,18 @@ GuiMathMatrixDialog::GuiMathMatrixDialog(GuiMathMatrix * form) this, SLOT(rowsChanged(int))); connect(columnsSB, SIGNAL(valueChanged(int)), this, SLOT(columnsChanged(int)) ); - connect(valignCO, SIGNAL(highlighted(const QString&)), + connect(valignCO, SIGNAL(highlighted(QString)), this, SLOT(change_adaptor())); - connect(halignED, SIGNAL(textChanged(const QString&)), + connect(halignED, SIGNAL(textChanged(QString)), this, SLOT(change_adaptor())); + connect(decorationCO, SIGNAL(activated(int)), + this, SLOT(decorationChanged(int))); + + bc().setPolicy(ButtonPolicy::IgnorantPolicy); } -void GuiMathMatrixDialog::columnsChanged(int) +void GuiMathMatrix::columnsChanged(int) { char h_align_str[80] = "c"; int const nx = int(columnsSB->value()); @@ -85,40 +76,75 @@ void GuiMathMatrixDialog::columnsChanged(int) } -void GuiMathMatrixDialog::rowsChanged(int) +void GuiMathMatrix::rowsChanged(int) { } -void GuiMathMatrixDialog::change_adaptor() +void GuiMathMatrix::decorationChanged(int deco) { - // FIXME: We need a filter for the halign input + // 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 GuiMathMatrixDialog::slotOK() +void GuiMathMatrix::change_adaptor() { - char v_align_c[] = "tcb"; - char const c = v_align_c[valignCO->currentIndex()]; - string const sh = fromqstr(halignED->text()); - int const nx = int(columnsSB->value()); - int const ny = int(rowsSB->value()); + // FIXME: We need a filter for the halign input +} - ostringstream os; - os << nx << ' ' << ny << ' ' << c << ' ' << sh; - form_->controller().dispatchMatrix(os.str().c_str()); - // close the dialog +void GuiMathMatrix::slotOK() +{ + int const nx = columnsSB->value(); + int const ny = rowsSB->value(); + // 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(); } -void GuiMathMatrixDialog::slotClose() +void GuiMathMatrix::slotClose() { close(); } + +Dialog * createGuiMathMatrix(GuiView & lv) { return new GuiMathMatrix(lv); } + + } // namespace frontend } // namespace lyx -#include "GuiMathMatrix_moc.cpp" +#include "moc_GuiMathMatrix.cpp"