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