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