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 table->setMinimumSize(100, 100);
41 columnsSB->setValue(5);
42 valignCO->setCurrentIndex(1);
44 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
45 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
47 connect(table, SIGNAL(rowsChanged(int)),
48 rowsSB, SLOT(setValue(int)));
49 connect(table, SIGNAL(colsChanged(int)),
50 columnsSB, SLOT(setValue(int)));
51 connect(rowsSB, SIGNAL(valueChanged(int)),
52 table, SLOT(setNumberRows(int)));
53 connect(columnsSB, SIGNAL(valueChanged(int)),
54 table, SLOT(setNumberColumns(int)));
55 connect(rowsSB, SIGNAL(valueChanged(int)),
56 this, SLOT(rowsChanged(int)));
57 connect(columnsSB, SIGNAL(valueChanged(int)),
58 this, SLOT(columnsChanged(int)) );
59 connect(valignCO, SIGNAL(highlighted(const QString&)),
60 this, SLOT(change_adaptor()));
61 connect(halignED, SIGNAL(textChanged(const QString&)),
62 this, SLOT(change_adaptor()));
64 bc().setPolicy(ButtonPolicy::IgnorantPolicy);
68 ControlMath & GuiMathMatrixDialog::controller()
70 return static_cast<ControlMath &>(GuiDialog::controller());
74 void GuiMathMatrixDialog::columnsChanged(int)
76 char h_align_str[80] = "c";
77 int const nx = int(columnsSB->value());
78 for (int i = 0; i < nx; ++i)
81 h_align_str[nx] = '\0';
82 halignED->setText(h_align_str);
86 void GuiMathMatrixDialog::rowsChanged(int)
91 void GuiMathMatrixDialog::change_adaptor()
93 // FIXME: We need a filter for the halign input
97 void GuiMathMatrixDialog::slotOK()
99 char v_align_c[] = "tcb";
100 char const c = v_align_c[valignCO->currentIndex()];
101 string const sh = fromqstr(halignED->text());
102 int const nx = int(columnsSB->value());
103 int const ny = int(rowsSB->value());
106 os << nx << ' ' << ny << ' ' << c << ' ' << sh;
107 controller().dispatchMatrix(os.str().c_str());
114 void GuiMathMatrixDialog::slotClose()
119 } // namespace frontend
122 #include "GuiMathMatrix_moc.cpp"