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"
18 #include "FuncRequest.h"
21 #include <QPushButton>
29 GuiMathMatrix::GuiMathMatrix(GuiView & lv)
30 : GuiDialog(lv, "mathmatrix", qt_("Math Matrix"))
34 table->setMinimumSize(100, 100);
36 columnsSB->setValue(5);
37 valignCO->setCurrentIndex(1);
39 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
40 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
42 connect(table, SIGNAL(rowsChanged(int)),
43 rowsSB, SLOT(setValue(int)));
44 connect(table, SIGNAL(colsChanged(int)),
45 columnsSB, SLOT(setValue(int)));
46 connect(rowsSB, SIGNAL(valueChanged(int)),
47 table, SLOT(setNumberRows(int)));
48 connect(columnsSB, SIGNAL(valueChanged(int)),
49 table, SLOT(setNumberColumns(int)));
50 connect(rowsSB, SIGNAL(valueChanged(int)),
51 this, SLOT(rowsChanged(int)));
52 connect(columnsSB, SIGNAL(valueChanged(int)),
53 this, SLOT(columnsChanged(int)) );
54 connect(valignCO, SIGNAL(highlighted(QString)),
55 this, SLOT(change_adaptor()));
56 connect(halignED, SIGNAL(textChanged(QString)),
57 this, SLOT(change_adaptor()));
59 bc().setPolicy(ButtonPolicy::IgnorantPolicy);
63 void GuiMathMatrix::columnsChanged(int)
65 char h_align_str[80] = "c";
66 int const nx = int(columnsSB->value());
67 for (int i = 0; i < nx; ++i)
70 h_align_str[nx] = '\0';
71 halignED->setText(h_align_str);
75 void GuiMathMatrix::rowsChanged(int)
80 void GuiMathMatrix::change_adaptor()
82 // FIXME: We need a filter for the halign input
86 void GuiMathMatrix::slotOK()
88 char v_align_c[] = "tcb";
89 char const c = v_align_c[valignCO->currentIndex()];
90 QString const sh = halignED->text();
91 int const nx = columnsSB->value();
92 int const ny = rowsSB->value();
93 string const str = fromqstr(
94 QString("%1 %2 %3 %4").arg(nx).arg(ny).arg(c).arg(sh));
95 dispatch(FuncRequest(LFUN_MATH_MATRIX, str));
100 void GuiMathMatrix::slotClose()
106 Dialog * createGuiMathMatrix(GuiView & lv) { return new GuiMathMatrix(lv); }
109 } // namespace frontend
112 #include "GuiMathMatrix_moc.cpp"