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(Dialog & parent)
32 : GuiView<GuiMathMatrixDialog>(parent, _("Math Matrix"))
36 void GuiMathMatrix::build_dialog()
38 dialog_.reset(new GuiMathMatrixDialog(this));
42 GuiMathMatrixDialog::GuiMathMatrixDialog(GuiMathMatrix * form)
47 setWindowTitle(qt_("LyX: Insert Matrix"));
49 table->setMinimumSize(100, 100);
51 columnsSB->setValue(5);
52 valignCO->setCurrentIndex(1);
54 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
55 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
57 connect(table, SIGNAL(rowsChanged(int)),
58 rowsSB, SLOT(setValue(int)));
59 connect(table, SIGNAL(colsChanged(int)),
60 columnsSB, SLOT(setValue(int)));
61 connect(rowsSB, SIGNAL(valueChanged(int)),
62 table, SLOT(setNumberRows(int)));
63 connect(columnsSB, SIGNAL(valueChanged(int)),
64 table, SLOT(setNumberColumns(int)));
65 connect(rowsSB, SIGNAL(valueChanged(int)),
66 this, SLOT(rowsChanged(int)));
67 connect(columnsSB, SIGNAL(valueChanged(int)),
68 this, SLOT(columnsChanged(int)) );
69 connect(valignCO, SIGNAL(highlighted(const QString&)),
70 this, SLOT(change_adaptor()));
71 connect(halignED, SIGNAL(textChanged(const QString&)),
72 this, SLOT(change_adaptor()));
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 form_->controller().dispatchMatrix(os.str().c_str());
116 void GuiMathMatrixDialog::slotClose()
121 } // namespace frontend
124 #include "GuiMathMatrix_moc.cpp"