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(LyXView & lv)
32 : GuiMath(lv, "mathmatrix")
35 setViewTitle(_("Math Matrix"));
36 setController(this, false);
38 table->setMinimumSize(100, 100);
40 columnsSB->setValue(5);
41 valignCO->setCurrentIndex(1);
43 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
44 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
46 connect(table, SIGNAL(rowsChanged(int)),
47 rowsSB, SLOT(setValue(int)));
48 connect(table, SIGNAL(colsChanged(int)),
49 columnsSB, SLOT(setValue(int)));
50 connect(rowsSB, SIGNAL(valueChanged(int)),
51 table, SLOT(setNumberRows(int)));
52 connect(columnsSB, SIGNAL(valueChanged(int)),
53 table, SLOT(setNumberColumns(int)));
54 connect(rowsSB, SIGNAL(valueChanged(int)),
55 this, SLOT(rowsChanged(int)));
56 connect(columnsSB, SIGNAL(valueChanged(int)),
57 this, SLOT(columnsChanged(int)) );
58 connect(valignCO, SIGNAL(highlighted(const QString&)),
59 this, SLOT(change_adaptor()));
60 connect(halignED, SIGNAL(textChanged(const QString&)),
61 this, SLOT(change_adaptor()));
63 bc().setPolicy(ButtonPolicy::IgnorantPolicy);
67 void GuiMathMatrix::columnsChanged(int)
69 char h_align_str[80] = "c";
70 int const nx = int(columnsSB->value());
71 for (int i = 0; i < nx; ++i)
74 h_align_str[nx] = '\0';
75 halignED->setText(h_align_str);
79 void GuiMathMatrix::rowsChanged(int)
84 void GuiMathMatrix::change_adaptor()
86 // FIXME: We need a filter for the halign input
90 void GuiMathMatrix::slotOK()
92 char v_align_c[] = "tcb";
93 char const c = v_align_c[valignCO->currentIndex()];
94 string const sh = fromqstr(halignED->text());
95 int const nx = int(columnsSB->value());
96 int const ny = int(rowsSB->value());
99 os << nx << ' ' << ny << ' ' << c << ' ' << sh;
100 dispatchMatrix(os.str().c_str());
107 void GuiMathMatrix::slotClose()
113 Dialog * createGuiMathMatrix(LyXView & lv) { return new GuiMathMatrix(lv); }
116 } // namespace frontend
119 #include "GuiMathMatrix_moc.cpp"