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 "ControlMath.h"
16 #include "EmptyTable.h"
17 #include "qt_helpers.h"
23 #include <QPushButton>
26 using std::ostringstream;
32 GuiMathMatrixDialog::GuiMathMatrixDialog(LyXView & lv)
33 : GuiDialog(lv, "mathmatrix")
36 setViewTitle(_("Math Matrix"));
37 setController(new ControlMath(*this));
39 setWindowTitle(qt_("LyX: Insert Matrix"));
41 table->setMinimumSize(100, 100);
43 columnsSB->setValue(5);
44 valignCO->setCurrentIndex(1);
46 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
47 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
49 connect(table, SIGNAL(rowsChanged(int)),
50 rowsSB, SLOT(setValue(int)));
51 connect(table, SIGNAL(colsChanged(int)),
52 columnsSB, SLOT(setValue(int)));
53 connect(rowsSB, SIGNAL(valueChanged(int)),
54 table, SLOT(setNumberRows(int)));
55 connect(columnsSB, SIGNAL(valueChanged(int)),
56 table, SLOT(setNumberColumns(int)));
57 connect(rowsSB, SIGNAL(valueChanged(int)),
58 this, SLOT(rowsChanged(int)));
59 connect(columnsSB, SIGNAL(valueChanged(int)),
60 this, SLOT(columnsChanged(int)) );
61 connect(valignCO, SIGNAL(highlighted(const QString&)),
62 this, SLOT(change_adaptor()));
63 connect(halignED, SIGNAL(textChanged(const QString&)),
64 this, SLOT(change_adaptor()));
66 bc().setPolicy(ButtonPolicy::IgnorantPolicy);
70 ControlMath & GuiMathMatrixDialog::controller() const
72 return static_cast<ControlMath &>(Dialog::controller());
76 void GuiMathMatrixDialog::columnsChanged(int)
78 char h_align_str[80] = "c";
79 int const nx = int(columnsSB->value());
80 for (int i = 0; i < nx; ++i)
83 h_align_str[nx] = '\0';
84 halignED->setText(h_align_str);
88 void GuiMathMatrixDialog::rowsChanged(int)
93 void GuiMathMatrixDialog::change_adaptor()
95 // FIXME: We need a filter for the halign input
99 void GuiMathMatrixDialog::slotOK()
101 char v_align_c[] = "tcb";
102 char const c = v_align_c[valignCO->currentIndex()];
103 string const sh = fromqstr(halignED->text());
104 int const nx = int(columnsSB->value());
105 int const ny = int(rowsSB->value());
108 os << nx << ' ' << ny << ' ' << c << ' ' << sh;
109 controller().dispatchMatrix(os.str().c_str());
116 void GuiMathMatrixDialog::slotClose()
121 } // namespace frontend
124 #include "GuiMathMatrix_moc.cpp"