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>
33 char const * delim[] = {
34 "(", ")", "{", "}", "[", "]",
35 "lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
36 "uparrow", "Uparrow", "downarrow", "Downarrow",
37 "|", "Vert", "slash", "backslash", ""
41 string do_match(const string & str)
43 if (str == "(") return ")";
44 if (str == ")") return "(";
45 if (str == "[") return "]";
46 if (str == "]") return "[";
47 if (str == "{") return "}";
48 if (str == "}") return "{";
49 if (str == "l") return "r";
50 if (str == "rceil") return "lceil";
51 if (str == "lceil") return "rceil";
52 if (str == "rfloor") return "lfloor";
53 if (str == "lfloor") return "rfloor";
54 if (str == "rangle") return "langle";
55 if (str == "langle") return "rangle";
56 if (str == "backslash") return "slash";
57 if (str == "slash") return "backslash";
62 string fix_name(const string & str)
66 if (str == "backslash")
76 QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
77 : QDelimiterDialogBase(0, 0, false, 0),
80 setCaption(qt_("LyX: Delimiters"));
82 for (int i = 0; *delim[i]; ++i) {
83 string xpm(find_xpm(delim[i]));
84 leftIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
85 rightIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
88 string empty_xpm(find_xpm("empty"));
90 leftIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
91 rightIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
92 // Leave these std:: qualifications alone !
93 connect(leftIP, SIGNAL(button_clicked(const std::string &)),
94 this, SLOT(ldelim_clicked(const std::string &)));
95 connect(rightIP, SIGNAL(button_clicked(const std::string &)),
96 this, SLOT(rdelim_clicked(const std::string &)));
102 void QDelimiterDialog::insertClicked()
104 form_->controller().dispatchDelim(fix_name(left_) + ' ' + fix_name(right_));
108 void QDelimiterDialog::set_label(QLabel * label, const string & str)
110 label->setUpdatesEnabled(false);
111 label->setPixmap(QPixmap(toqstr(find_xpm(str))));
112 label->setUpdatesEnabled(true);
117 void QDelimiterDialog::ldelim_clicked(const string & str)
121 set_label(leftPI, left_);
122 if (matchCB->isChecked()) {
123 right_ = do_match(left_);
124 set_label(rightPI, right_);
129 void QDelimiterDialog::rdelim_clicked(const string & str)
133 set_label(rightPI, right_);
134 if (matchCB->isChecked()) {
135 left_ = do_match(right_);
136 set_label(leftPI, left_);
140 } // namespace frontend