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"
17 #include "support/gettext.h"
22 #include <QPushButton>
30 GuiMathMatrix::GuiMathMatrix(GuiView & lv)
31 : GuiMath(lv, "mathmatrix", qt_("Math Matrix"))
35 table->setMinimumSize(100, 100);
37 columnsSB->setValue(5);
38 valignCO->setCurrentIndex(1);
40 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
41 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
43 connect(table, SIGNAL(rowsChanged(int)),
44 rowsSB, SLOT(setValue(int)));
45 connect(table, SIGNAL(colsChanged(int)),
46 columnsSB, SLOT(setValue(int)));
47 connect(rowsSB, SIGNAL(valueChanged(int)),
48 table, SLOT(setNumberRows(int)));
49 connect(columnsSB, SIGNAL(valueChanged(int)),
50 table, SLOT(setNumberColumns(int)));
51 connect(rowsSB, SIGNAL(valueChanged(int)),
52 this, SLOT(rowsChanged(int)));
53 connect(columnsSB, SIGNAL(valueChanged(int)),
54 this, SLOT(columnsChanged(int)) );
55 connect(valignCO, SIGNAL(highlighted(const QString&)),
56 this, SLOT(change_adaptor()));
57 connect(halignED, SIGNAL(textChanged(const QString&)),
58 this, SLOT(change_adaptor()));
60 bc().setPolicy(ButtonPolicy::IgnorantPolicy);
64 void GuiMathMatrix::columnsChanged(int)
66 char h_align_str[80] = "c";
67 int const nx = int(columnsSB->value());
68 for (int i = 0; i < nx; ++i)
71 h_align_str[nx] = '\0';
72 halignED->setText(h_align_str);
76 void GuiMathMatrix::rowsChanged(int)
81 void GuiMathMatrix::change_adaptor()
83 // FIXME: We need a filter for the halign input
87 void GuiMathMatrix::slotOK()
89 char v_align_c[] = "tcb";
90 char const c = v_align_c[valignCO->currentIndex()];
91 string const sh = fromqstr(halignED->text());
92 int const nx = int(columnsSB->value());
93 int const ny = int(rowsSB->value());
96 os << nx << ' ' << ny << ' ' << c << ' ' << sh;
97 dispatchMatrix(os.str().c_str());
104 void GuiMathMatrix::slotClose()
110 Dialog * createGuiMathMatrix(GuiView & lv) { return new GuiMathMatrix(lv); }
113 } // namespace frontend
116 #include "GuiMathMatrix_moc.cpp"