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
14 #include "support/filetools.h"
15 #include "qt_helpers.h"
19 #include "ControlMath.h"
20 #include "QDelimiterDialog.h"
22 #include "iconpalette.h"
26 #include <qpushbutton.h>
27 #include <qcheckbox.h>
31 char const * delim[] = {
32 "(", ")", "{", "}", "[", "]",
33 "lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
34 "uparrow", "Uparrow", "downarrow", "Downarrow",
35 "|", "Vert", "slash", "backslash", ""
39 string do_match(string const & str)
41 if (str == "(") return ")";
42 if (str == ")") return "(";
43 if (str == "[") return "]";
44 if (str == "]") return "[";
45 if (str == "{") return "}";
46 if (str == "}") return "{";
47 if (str == "l") return "r";
48 if (str == "rceil") return "lceil";
49 if (str == "lceil") return "rceil";
50 if (str == "rfloor") return "lfloor";
51 if (str == "lfloor") return "rfloor";
52 if (str == "rangle") return "langle";
53 if (str == "langle") return "rangle";
54 if (str == "backslash") return "slash";
55 if (str == "slash") return "backslash";
60 string fix_name(string const & str)
64 if (str == "backslash")
74 QDelimiterDialog::QDelimiterDialog(QMath * form)
75 : QDelimiterDialogBase(0, 0, false, 0),
78 setCaption(qt_("LyX: Delimiters"));
80 for (int i = 0; *delim[i]; ++i) {
81 string xpm(find_xpm(delim[i]));
82 leftIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
83 rightIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
86 string empty_xpm(find_xpm("empty"));
88 leftIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
89 rightIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
90 connect(leftIP, SIGNAL(button_clicked(const string &)), this, SLOT(ldelim_clicked(const string &)));
91 connect(rightIP, SIGNAL(button_clicked(const string &)), this, SLOT(rdelim_clicked(const string &)));
97 void QDelimiterDialog::insertClicked()
99 form_->insertDelim(fix_name(left_) + ' ' + fix_name(right_));
103 void QDelimiterDialog::set_label(QLabel * label, string const & str)
105 label->setUpdatesEnabled(false);
106 label->setPixmap(QPixmap(toqstr(find_xpm(str))));
107 label->setUpdatesEnabled(true);
112 void QDelimiterDialog::ldelim_clicked(string const & str)
116 set_label(leftPI, left_);
117 if (matchCB->isChecked()) {
118 right_ = do_match(left_);
119 set_label(rightPI, right_);
124 void QDelimiterDialog::rdelim_clicked(string const & str)
128 set_label(rightPI, right_);
129 if (matchCB->isChecked()) {
130 left_ = do_match(right_);
131 set_label(leftPI, left_);