2 * \file QDelimiterDialog.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "QDelimiterDialog.h"
15 #include "iconpalette.h"
17 #include "qt_helpers.h"
19 #include "controllers/ControlMath.h"
23 #include <qcheckbox.h>
31 // FIXME: Implement fixed size delimiters (see qt3 frontend)
35 char const * delim[] = {
36 "(", ")", "{", "}", "[", "]",
37 "lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
38 "uparrow", "Uparrow", "downarrow", "Downarrow",
39 "|", "Vert", "slash", "backslash", ""
43 string do_match(const string & str)
45 if (str == "(") return ")";
46 if (str == ")") return "(";
47 if (str == "[") return "]";
48 if (str == "]") return "[";
49 if (str == "{") return "}";
50 if (str == "}") return "{";
51 if (str == "l") return "r";
52 if (str == "rceil") return "lceil";
53 if (str == "lceil") return "rceil";
54 if (str == "rfloor") return "lfloor";
55 if (str == "lfloor") return "rfloor";
56 if (str == "rangle") return "langle";
57 if (str == "langle") return "rangle";
58 if (str == "backslash") return "slash";
59 if (str == "slash") return "backslash";
64 string fix_name(const string & str)
68 if (str == "backslash")
78 QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
83 connect( closePB, SIGNAL( clicked() ), this, SLOT( accept() ) );
84 connect( insertPB, SIGNAL( clicked() ), this, SLOT( insertClicked() ) );
86 setCaption(qt_("LyX: Delimiters"));
88 for (int i = 0; *delim[i]; ++i) {
89 string xpm(find_xpm(delim[i]));
90 leftIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
91 rightIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
94 string empty_xpm(find_xpm("empty"));
96 leftIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
97 rightIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
98 // Leave these std:: qualifications alone !
99 connect(leftIP, SIGNAL(button_clicked(const std::string &)),
100 this, SLOT(ldelim_clicked(const std::string &)));
101 connect(rightIP, SIGNAL(button_clicked(const std::string &)),
102 this, SLOT(rdelim_clicked(const std::string &)));
108 void QDelimiterDialog::insertClicked()
110 form_->controller().dispatchDelim(fix_name(left_) + ' ' + fix_name(right_));
114 void QDelimiterDialog::set_label(QLabel * label, const string & str)
116 label->setUpdatesEnabled(false);
117 label->setPixmap(QPixmap(toqstr(find_xpm(str))));
118 label->setUpdatesEnabled(true);
123 void QDelimiterDialog::ldelim_clicked(const string & str)
127 set_label(leftPI, left_);
128 if (matchCB->isChecked()) {
129 right_ = do_match(left_);
130 set_label(rightPI, right_);
135 void QDelimiterDialog::rdelim_clicked(const string & str)
139 set_label(rightPI, right_);
140 if (matchCB->isChecked()) {
141 left_ = do_match(right_);
142 set_label(leftPI, left_);
146 } // namespace frontend
149 #include "QDelimiterDialog_moc.cpp"