]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiMathMatrix.cpp
Get rid of GuiMath layer.
[lyx.git] / src / frontends / qt4 / GuiMathMatrix.cpp
1 /**
2  * \file GuiMathMatrix.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Jürgen Spitzmüller
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GuiMathMatrix.h"
14
15 #include "EmptyTable.h"
16 #include "qt_helpers.h"
17
18 #include "FuncRequest.h"
19
20 #include <QLineEdit>
21 #include <QPushButton>
22 #include <QSpinBox>
23
24 using namespace std;
25
26 namespace lyx {
27 namespace frontend {
28
29 GuiMathMatrix::GuiMathMatrix(GuiView & lv)
30         : GuiDialog(lv, "mathmatrix", qt_("Math Matrix"))
31 {
32         setupUi(this);
33
34         table->setMinimumSize(100, 100);
35         rowsSB->setValue(5);
36         columnsSB->setValue(5);
37         valignCO->setCurrentIndex(1);
38
39         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
40         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
41
42         connect(table, SIGNAL(rowsChanged(int)),
43                 rowsSB, SLOT(setValue(int)));
44         connect(table, SIGNAL(colsChanged(int)),
45                 columnsSB, SLOT(setValue(int)));
46         connect(rowsSB, SIGNAL(valueChanged(int)),
47                 table, SLOT(setNumberRows(int)));
48         connect(columnsSB, SIGNAL(valueChanged(int)),
49                 table, SLOT(setNumberColumns(int)));
50         connect(rowsSB, SIGNAL(valueChanged(int)),
51                 this, SLOT(rowsChanged(int)));
52         connect(columnsSB, SIGNAL(valueChanged(int)),
53                 this, SLOT(columnsChanged(int)) );
54         connect(valignCO, SIGNAL(highlighted(QString)),
55                 this, SLOT(change_adaptor()));
56         connect(halignED, SIGNAL(textChanged(QString)),
57                 this, SLOT(change_adaptor()));
58
59         bc().setPolicy(ButtonPolicy::IgnorantPolicy);
60 }
61
62
63 void GuiMathMatrix::columnsChanged(int)
64 {
65         char h_align_str[80] = "c";
66         int const nx = int(columnsSB->value());
67         for (int i = 0; i < nx; ++i)
68                 h_align_str[i] = 'c';
69
70         h_align_str[nx] = '\0';
71         halignED->setText(h_align_str);
72 }
73
74
75 void GuiMathMatrix::rowsChanged(int)
76 {
77 }
78
79
80 void GuiMathMatrix::change_adaptor()
81 {
82         // FIXME: We need a filter for the halign input
83 }
84
85
86 void GuiMathMatrix::slotOK()
87 {
88         char v_align_c[] = "tcb";
89         char const c = v_align_c[valignCO->currentIndex()];
90         QString const sh = halignED->text();
91         int const nx = columnsSB->value();
92         int const ny = rowsSB->value();
93         string const str = fromqstr(
94                 QString("%1 %2 %3 %4").arg(nx).arg(ny).arg(c).arg(sh));
95         dispatch(FuncRequest(LFUN_MATH_MATRIX, str));
96         close();
97 }
98
99
100 void GuiMathMatrix::slotClose()
101 {
102         close();
103 }
104
105
106 Dialog * createGuiMathMatrix(GuiView & lv) { return new GuiMathMatrix(lv); }
107
108
109 } // namespace frontend
110 } // namespace lyx
111
112 #include "GuiMathMatrix_moc.cpp"