2 * \file GuiMathMatrix.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Jürgen Spitzmüller
8 * Full author contact details are available in file CREDITS.
13 #include "GuiMathMatrix.h"
15 #include "EmptyTable.h"
16 #include "qt_helpers.h"
19 #include <QPushButton>
27 GuiMathMatrix::GuiMathMatrix(GuiView & lv)
28 : GuiMath(lv, "mathmatrix", qt_("Math Matrix"))
32 table->setMinimumSize(100, 100);
34 columnsSB->setValue(5);
35 valignCO->setCurrentIndex(1);
37 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
38 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
40 connect(table, SIGNAL(rowsChanged(int)),
41 rowsSB, SLOT(setValue(int)));
42 connect(table, SIGNAL(colsChanged(int)),
43 columnsSB, SLOT(setValue(int)));
44 connect(rowsSB, SIGNAL(valueChanged(int)),
45 table, SLOT(setNumberRows(int)));
46 connect(columnsSB, SIGNAL(valueChanged(int)),
47 table, SLOT(setNumberColumns(int)));
48 connect(rowsSB, SIGNAL(valueChanged(int)),
49 this, SLOT(rowsChanged(int)));
50 connect(columnsSB, SIGNAL(valueChanged(int)),
51 this, SLOT(columnsChanged(int)) );
52 connect(valignCO, SIGNAL(highlighted(QString)),
53 this, SLOT(change_adaptor()));
54 connect(halignED, SIGNAL(textChanged(QString)),
55 this, SLOT(change_adaptor()));
57 bc().setPolicy(ButtonPolicy::IgnorantPolicy);
61 void GuiMathMatrix::columnsChanged(int)
63 char h_align_str[80] = "c";
64 int const nx = int(columnsSB->value());
65 for (int i = 0; i < nx; ++i)
68 h_align_str[nx] = '\0';
69 halignED->setText(h_align_str);
73 void GuiMathMatrix::rowsChanged(int)
78 void GuiMathMatrix::change_adaptor()
80 // FIXME: We need a filter for the halign input
84 void GuiMathMatrix::slotOK()
86 char v_align_c[] = "tcb";
87 char const c = v_align_c[valignCO->currentIndex()];
88 QString const sh = halignED->text();
89 int const nx = columnsSB->value();
90 int const ny = rowsSB->value();
91 dispatchMatrix(fromqstr(
92 QString("%1 %2 %3 %4").arg(nx).arg(ny).arg(c).arg(sh)));
97 void GuiMathMatrix::slotClose()
103 Dialog * createGuiMathMatrix(GuiView & lv) { return new GuiMathMatrix(lv); }
106 } // namespace frontend
109 #include "GuiMathMatrix_moc.cpp"