2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 22:37:05 +00:00
|
|
|
* \file GuiMathMatrix.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Spitzmüller
|
2009-07-13 23:25:47 +00:00
|
|
|
* \author Uwe Stöhr
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 22:37:05 +00:00
|
|
|
#include "GuiMathMatrix.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-04-26 03:53:02 +00:00
|
|
|
#include "EmptyTable.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
2008-06-02 10:05:29 +00:00
|
|
|
#include "FuncRequest.h"
|
|
|
|
|
2007-08-31 22:16:11 +00:00
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QSpinBox>
|
2007-04-19 21:42:42 +00:00
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiMathMatrix::GuiMathMatrix(GuiView & lv)
|
2008-06-02 10:05:29 +00:00
|
|
|
: GuiDialog(lv, "mathmatrix", qt_("Math Matrix"))
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
table->setMinimumSize(100, 100);
|
2007-05-07 18:30:41 +00:00
|
|
|
rowsSB->setValue(5);
|
|
|
|
columnsSB->setValue(5);
|
2006-08-17 08:57:44 +00:00
|
|
|
valignCO->setCurrentIndex(1);
|
2009-07-12 21:39:21 +00:00
|
|
|
decorationCO->setCurrentIndex(0);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-08-12 12:44:42 +00:00
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
|
|
|
|
|
|
|
connect(table, SIGNAL(rowsChanged(int)),
|
|
|
|
rowsSB, SLOT(setValue(int)));
|
|
|
|
connect(table, SIGNAL(colsChanged(int)),
|
|
|
|
columnsSB, SLOT(setValue(int)));
|
|
|
|
connect(rowsSB, SIGNAL(valueChanged(int)),
|
|
|
|
table, SLOT(setNumberRows(int)));
|
|
|
|
connect(columnsSB, SIGNAL(valueChanged(int)),
|
|
|
|
table, SLOT(setNumberColumns(int)));
|
|
|
|
connect(rowsSB, SIGNAL(valueChanged(int)),
|
|
|
|
this, SLOT(rowsChanged(int)));
|
|
|
|
connect(columnsSB, SIGNAL(valueChanged(int)),
|
|
|
|
this, SLOT(columnsChanged(int)) );
|
2008-04-20 21:05:35 +00:00
|
|
|
connect(valignCO, SIGNAL(highlighted(QString)),
|
2007-08-12 12:44:42 +00:00
|
|
|
this, SLOT(change_adaptor()));
|
2008-04-20 21:05:35 +00:00
|
|
|
connect(halignED, SIGNAL(textChanged(QString)),
|
2007-08-12 12:44:42 +00:00
|
|
|
this, SLOT(change_adaptor()));
|
2009-07-12 21:39:21 +00:00
|
|
|
connect(decorationCO, SIGNAL(activated(int)),
|
|
|
|
this, SLOT(decorationChanged(int)));
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
bc().setPolicy(ButtonPolicy::IgnorantPolicy);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
void GuiMathMatrix::columnsChanged(int)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2007-08-31 22:16:11 +00:00
|
|
|
char h_align_str[80] = "c";
|
2006-03-05 17:24:44 +00:00
|
|
|
int const nx = int(columnsSB->value());
|
|
|
|
for (int i = 0; i < nx; ++i)
|
|
|
|
h_align_str[i] = 'c';
|
|
|
|
|
|
|
|
h_align_str[nx] = '\0';
|
|
|
|
halignED->setText(h_align_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
void GuiMathMatrix::rowsChanged(int)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-07-12 21:39:21 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
void GuiMathMatrix::change_adaptor()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
// FIXME: We need a filter for the halign input
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
void GuiMathMatrix::slotOK()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2008-04-20 21:05:35 +00:00
|
|
|
int const nx = columnsSB->value();
|
|
|
|
int const ny = rowsSB->value();
|
2009-07-12 21:39:21 +00:00
|
|
|
// 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));
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
void GuiMathMatrix::slotClose()
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
2007-10-07 20:34:09 +00:00
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiMathMatrix(GuiView & lv) { return new GuiMathMatrix(lv); }
|
2007-10-07 20:34:09 +00:00
|
|
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2006-05-18 08:51:12 +00:00
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiMathMatrix.cpp"
|