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