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