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"
22 #include <QPushButton>
25 using std::ostringstream;
31 GuiMathMatrix::GuiMathMatrix(GuiView & lv)
32 : GuiMath(lv, "mathmatrix")
35 setViewTitle(_("Math Matrix"));
37 table->setMinimumSize(100, 100);
39 columnsSB->setValue(5);
40 valignCO->setCurrentIndex(1);
42 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
43 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
45 connect(table, SIGNAL(rowsChanged(int)),
46 rowsSB, SLOT(setValue(int)));
47 connect(table, SIGNAL(colsChanged(int)),
48 columnsSB, SLOT(setValue(int)));
49 connect(rowsSB, SIGNAL(valueChanged(int)),
50 table, SLOT(setNumberRows(int)));
51 connect(columnsSB, SIGNAL(valueChanged(int)),
52 table, SLOT(setNumberColumns(int)));
53 connect(rowsSB, SIGNAL(valueChanged(int)),
54 this, SLOT(rowsChanged(int)));
55 connect(columnsSB, SIGNAL(valueChanged(int)),
56 this, SLOT(columnsChanged(int)) );
57 connect(valignCO, SIGNAL(highlighted(const QString&)),
58 this, SLOT(change_adaptor()));
59 connect(halignED, SIGNAL(textChanged(const QString&)),
60 this, SLOT(change_adaptor()));
62 bc().setPolicy(ButtonPolicy::IgnorantPolicy);
66 void GuiMathMatrix::columnsChanged(int)
68 char h_align_str[80] = "c";
69 int const nx = int(columnsSB->value());
70 for (int i = 0; i < nx; ++i)
73 h_align_str[nx] = '\0';
74 halignED->setText(h_align_str);
78 void GuiMathMatrix::rowsChanged(int)
83 void GuiMathMatrix::change_adaptor()
85 // FIXME: We need a filter for the halign input
89 void GuiMathMatrix::slotOK()
91 char v_align_c[] = "tcb";
92 char const c = v_align_c[valignCO->currentIndex()];
93 string const sh = fromqstr(halignED->text());
94 int const nx = int(columnsSB->value());
95 int const ny = int(rowsSB->value());
98 os << nx << ' ' << ny << ' ' << c << ' ' << sh;
99 dispatchMatrix(os.str().c_str());
106 void GuiMathMatrix::slotClose()
112 Dialog * createGuiMathMatrix(GuiView & lv) { return new GuiMathMatrix(lv); }
115 } // namespace frontend
118 #include "GuiMathMatrix_moc.cpp"