]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiMathMatrix.cpp
'using namespace std' instead of 'using std::xxx'
[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")
32 {
33         setupUi(this);
34         setViewTitle(_("Math Matrix"));
35
36         table->setMinimumSize(100, 100);
37         rowsSB->setValue(5);
38         columnsSB->setValue(5);
39         valignCO->setCurrentIndex(1);
40
41         connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
42         connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
43
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()));
60
61         bc().setPolicy(ButtonPolicy::IgnorantPolicy);
62 }
63
64
65 void GuiMathMatrix::columnsChanged(int)
66 {
67         char h_align_str[80] = "c";
68         int const nx = int(columnsSB->value());
69         for (int i = 0; i < nx; ++i)
70                 h_align_str[i] = 'c';
71
72         h_align_str[nx] = '\0';
73         halignED->setText(h_align_str);
74 }
75
76
77 void GuiMathMatrix::rowsChanged(int)
78 {
79 }
80
81
82 void GuiMathMatrix::change_adaptor()
83 {
84         // FIXME: We need a filter for the halign input
85 }
86
87
88 void GuiMathMatrix::slotOK()
89 {
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());
95
96         ostringstream os;
97         os << nx << ' ' << ny << ' ' << c << ' ' << sh;
98         dispatchMatrix(os.str().c_str());
99
100         // close the dialog
101         close();
102 }
103
104
105 void GuiMathMatrix::slotClose()
106 {
107         close();
108 }
109
110
111 Dialog * createGuiMathMatrix(GuiView & lv) { return new GuiMathMatrix(lv); }
112
113
114 } // namespace frontend
115 } // namespace lyx
116
117 #include "GuiMathMatrix_moc.cpp"