]> git.lyx.org Git - features.git/blob - src/frontends/qt2/QMathMatrixDialog.C
Wrap most of the frontend code up inside namespace lyx::frontend.
[features.git] / src / frontends / qt2 / QMathMatrixDialog.C
1 /**
2  * \file QMathMatrixDialog.C
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 "qt_helpers.h"
14
15 #include "support/std_sstream.h"
16 #include "ControlMath.h"
17
18 #include "QMath.h"
19 #include "QMathMatrixDialog.h"
20
21 #include <qcombobox.h>
22 #include <qlineedit.h>
23 #include <qpushbutton.h>
24 #include <qspinbox.h>
25 #include "emptytable.h"
26
27 using std::ostringstream;
28 using std::string;
29
30 namespace lyx {
31 namespace frontend {
32
33 namespace {
34
35 char h_align_str[80] = "c";
36 char v_align_c[] = "tcb";
37
38 } // namespace anon
39
40
41 QMathMatrixDialog::QMathMatrixDialog(QMathMatrix * form)
42         : QMathMatrixDialogBase(0, 0, false, 0),
43         form_(form)
44 {
45         setCaption(qt_("LyX: Insert Matrix"));
46
47         table->setMinimumSize(100, 100);
48         rowsSB->setValue(2);
49         columnsSB->setValue(2);
50         valignCO->setCurrentItem(1);
51
52         connect(okPB, SIGNAL(clicked()),
53                 this, SLOT(slotOK()));
54         connect(closePB, SIGNAL(clicked()),
55                 this, SLOT(slotClose()));
56 }
57
58
59 void QMathMatrixDialog::columnsChanged(int)
60 {
61         int const nx = int(columnsSB->value());
62         for (int i = 0; i < nx; ++i)
63                 h_align_str[i] = 'c';
64
65         h_align_str[nx] = '\0';
66         halignED->setText(h_align_str);
67
68         return;
69 }
70
71
72 void QMathMatrixDialog::rowsChanged(int)
73 {
74 }
75
76
77 void QMathMatrixDialog::change_adaptor()
78 {
79         // FIXME: We need a filter for the halign input
80 }
81
82
83 void QMathMatrixDialog::slotOK()
84 {
85         char const c = v_align_c[valignCO->currentItem()];
86         string const sh = fromqstr(halignED->text());
87         int const nx = int(columnsSB->value());
88         int const ny = int(rowsSB->value());
89
90         ostringstream os;
91         os << nx << ' ' << ny << ' ' << c << ' ' << sh;
92         form_->controller().dispatchMatrix(os.str().c_str());
93
94         // close the dialog
95         close();
96 }
97
98
99 void QMathMatrixDialog::slotClose()
100 {
101         close();
102 }
103
104 } // namespace frontend
105 } // namespace lyx