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