]> git.lyx.org Git - features.git/blob - src/frontends/qt2/QMathMatrixDialog.C
Replace LString.h with support/std_string.h,
[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 Juergen Spitzmueller
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
28 static char h_align_str[80] = "c";
29 static char v_align_c[] = "tcb";
30
31
32 QMathMatrixDialog::QMathMatrixDialog(QMathMatrix * form)
33         : QMathMatrixDialogBase(0, 0, false, 0),
34         form_(form)
35 {
36         setCaption(qt_("LyX: Insert Matrix"));
37
38         table->setMinimumSize(100, 100);
39         rowsSB->setValue(2);
40         columnsSB->setValue(2);
41         valignCO->setCurrentItem(1);
42
43         connect(okPB, SIGNAL(clicked()),
44                 this, SLOT(slotOK()));
45         connect(closePB, SIGNAL(clicked()),
46                 this, SLOT(slotClose()));
47 }
48
49
50 void QMathMatrixDialog::columnsChanged(int)
51 {
52         int const nx = int(columnsSB->value());
53         for (int i = 0; i < nx; ++i)
54                 h_align_str[i] = 'c';
55
56         h_align_str[nx] = '\0';
57         halignED->setText(h_align_str);
58
59         return;
60 }
61
62
63 void QMathMatrixDialog::rowsChanged(int)
64 {
65 }
66
67
68 void QMathMatrixDialog::change_adaptor()
69 {
70         // FIXME: We need a filter for the halign input
71 }
72
73
74 void QMathMatrixDialog::slotOK()
75 {
76         char const c = v_align_c[valignCO->currentItem()];
77         string const sh = fromqstr(halignED->text());
78         int const nx = int(columnsSB->value());
79         int const ny = int(rowsSB->value());
80
81         ostringstream os;
82         os << nx << ' ' << ny << ' ' << c << ' ' << sh;
83         form_->controller().dispatchMatrix(os.str().c_str());
84
85         // close the dialog
86         close();
87 }
88
89
90 void QMathMatrixDialog::slotClose()
91 {
92         close();
93 }