]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiMathMatrix.cpp
cosmetics
[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 <QLineEdit>
19 #include <QPushButton>
20 #include <QSpinBox>
21
22 using namespace std;
23
24 namespace lyx {
25 namespace frontend {
26
27 GuiMathMatrix::GuiMathMatrix(GuiView & lv)
28         : GuiMath(lv, "mathmatrix", qt_("Math Matrix"))
29 {
30         setupUi(this);
31
32         table->setMinimumSize(100, 100);
33         rowsSB->setValue(5);
34         columnsSB->setValue(5);
35         valignCO->setCurrentIndex(1);
36
37         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
38         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
39
40         connect(table, SIGNAL(rowsChanged(int)),
41                 rowsSB, SLOT(setValue(int)));
42         connect(table, SIGNAL(colsChanged(int)),
43                 columnsSB, SLOT(setValue(int)));
44         connect(rowsSB, SIGNAL(valueChanged(int)),
45                 table, SLOT(setNumberRows(int)));
46         connect(columnsSB, SIGNAL(valueChanged(int)),
47                 table, SLOT(setNumberColumns(int)));
48         connect(rowsSB, SIGNAL(valueChanged(int)),
49                 this, SLOT(rowsChanged(int)));
50         connect(columnsSB, SIGNAL(valueChanged(int)),
51                 this, SLOT(columnsChanged(int)) );
52         connect(valignCO, SIGNAL(highlighted(QString)),
53                 this, SLOT(change_adaptor()));
54         connect(halignED, SIGNAL(textChanged(QString)),
55                 this, SLOT(change_adaptor()));
56
57         bc().setPolicy(ButtonPolicy::IgnorantPolicy);
58 }
59
60
61 void GuiMathMatrix::columnsChanged(int)
62 {
63         char h_align_str[80] = "c";
64         int const nx = int(columnsSB->value());
65         for (int i = 0; i < nx; ++i)
66                 h_align_str[i] = 'c';
67
68         h_align_str[nx] = '\0';
69         halignED->setText(h_align_str);
70 }
71
72
73 void GuiMathMatrix::rowsChanged(int)
74 {
75 }
76
77
78 void GuiMathMatrix::change_adaptor()
79 {
80         // FIXME: We need a filter for the halign input
81 }
82
83
84 void GuiMathMatrix::slotOK()
85 {
86         char v_align_c[] = "tcb";
87         char const c = v_align_c[valignCO->currentIndex()];
88         QString const sh = halignED->text();
89         int const nx = columnsSB->value();
90         int const ny = rowsSB->value();
91         dispatchMatrix(fromqstr(
92                 QString("%1 %2 %3 %4").arg(nx).arg(ny).arg(c).arg(sh)));
93         close();
94 }
95
96
97 void GuiMathMatrix::slotClose()
98 {
99         close();
100 }
101
102
103 Dialog * createGuiMathMatrix(GuiView & lv) { return new GuiMathMatrix(lv); }
104
105
106 } // namespace frontend
107 } // namespace lyx
108
109 #include "GuiMathMatrix_moc.cpp"