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