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"
17 #include "support/gettext.h"
22 #include <QPushButton>
30 GuiMathMatrix::GuiMathMatrix(GuiView & lv)
31 : GuiMath(lv, "mathmatrix")
34 setViewTitle(_("Math Matrix"));
36 table->setMinimumSize(100, 100);
38 columnsSB->setValue(5);
39 valignCO->setCurrentIndex(1);
41 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
42 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
44 connect(table, SIGNAL(rowsChanged(int)),
45 rowsSB, SLOT(setValue(int)));
46 connect(table, SIGNAL(colsChanged(int)),
47 columnsSB, SLOT(setValue(int)));
48 connect(rowsSB, SIGNAL(valueChanged(int)),
49 table, SLOT(setNumberRows(int)));
50 connect(columnsSB, SIGNAL(valueChanged(int)),
51 table, SLOT(setNumberColumns(int)));
52 connect(rowsSB, SIGNAL(valueChanged(int)),
53 this, SLOT(rowsChanged(int)));
54 connect(columnsSB, SIGNAL(valueChanged(int)),
55 this, SLOT(columnsChanged(int)) );
56 connect(valignCO, SIGNAL(highlighted(const QString&)),
57 this, SLOT(change_adaptor()));
58 connect(halignED, SIGNAL(textChanged(const QString&)),
59 this, SLOT(change_adaptor()));
61 bc().setPolicy(ButtonPolicy::IgnorantPolicy);
65 void GuiMathMatrix::columnsChanged(int)
67 char h_align_str[80] = "c";
68 int const nx = int(columnsSB->value());
69 for (int i = 0; i < nx; ++i)
72 h_align_str[nx] = '\0';
73 halignED->setText(h_align_str);
77 void GuiMathMatrix::rowsChanged(int)
82 void GuiMathMatrix::change_adaptor()
84 // FIXME: We need a filter for the halign input
88 void GuiMathMatrix::slotOK()
90 char v_align_c[] = "tcb";
91 char const c = v_align_c[valignCO->currentIndex()];
92 string const sh = fromqstr(halignED->text());
93 int const nx = int(columnsSB->value());
94 int const ny = int(rowsSB->value());
97 os << nx << ' ' << ny << ' ' << c << ' ' << sh;
98 dispatchMatrix(os.str().c_str());
105 void GuiMathMatrix::slotClose()
111 Dialog * createGuiMathMatrix(GuiView & lv) { return new GuiMathMatrix(lv); }
114 } // namespace frontend
117 #include "GuiMathMatrix_moc.cpp"