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