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)
81 connect( closePB, SIGNAL( clicked() ), this, SLOT( accept() ) );
82 connect( insertPB, SIGNAL( clicked() ), this, SLOT( insertClicked() ) );
84 setCaption(qt_("LyX: Delimiters"));
86 for (int i = 0; *delim[i]; ++i) {
87 string xpm(find_xpm(delim[i]));
88 leftIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
89 rightIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
92 string empty_xpm(find_xpm("empty"));
94 leftIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
95 rightIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
96 // Leave these std:: qualifications alone !
97 connect(leftIP, SIGNAL(button_clicked(const std::string &)),
98 this, SLOT(ldelim_clicked(const std::string &)));
99 connect(rightIP, SIGNAL(button_clicked(const std::string &)),
100 this, SLOT(rdelim_clicked(const std::string &)));
106 void QDelimiterDialog::insertClicked()
108 form_->controller().dispatchDelim(fix_name(left_) + ' ' + fix_name(right_));
112 void QDelimiterDialog::set_label(QLabel * label, const string & str)
114 label->setUpdatesEnabled(false);
115 label->setPixmap(QPixmap(toqstr(find_xpm(str))));
116 label->setUpdatesEnabled(true);
121 void QDelimiterDialog::ldelim_clicked(const string & str)
125 set_label(leftPI, left_);
126 if (matchCB->isChecked()) {
127 right_ = do_match(left_);
128 set_label(rightPI, right_);
133 void QDelimiterDialog::rdelim_clicked(const string & str)
137 set_label(rightPI, right_);
138 if (matchCB->isChecked()) {
139 left_ = do_match(right_);
140 set_label(leftPI, left_);
144 } // namespace frontend