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 #pragma implementation
17 #include "support/filetools.h"
22 #include "ControlMath.h"
23 #include "QDelimiterDialog.h"
25 #include "iconpalette.h"
29 #include <qpushbutton.h>
30 #include <qcheckbox.h>
34 char const * delim[] = {
35 "(", ")", "{", "}", "[", "]",
36 "lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
37 "uparrow", "Uparrow", "downarrow", "Downarrow",
38 "|", "Vert", "slash", "backslash", ""
42 string do_match(string const & str)
44 if (str == "(") return ")";
45 if (str == ")") return "(";
46 if (str == "[") return "]";
47 if (str == "]") return "[";
48 if (str == "{") return "}";
49 if (str == "}") return "{";
50 if (str == "l") return "r";
51 if (str == "rceil") return "lceil";
52 if (str == "lceil") return "rceil";
53 if (str == "rfloor") return "lfloor";
54 if (str == "lfloor") return "rfloor";
55 if (str == "rangle") return "langle";
56 if (str == "langle") return "rangle";
57 if (str == "backslash") return "slash";
58 if (str == "slash") return "backslash";
63 string fix_name(string const & str)
67 if (str == "backslash")
77 QDelimiterDialog::QDelimiterDialog(QMath * form)
78 : QDelimiterDialogBase(0, 0, false, 0),
81 setCaption(_("LyX: Delimiters"));
83 for (int i = 0; *delim[i]; ++i) {
84 string xpm(find_xpm(delim[i]));
85 leftIP->add(QPixmap(xpm.c_str()), delim[i], delim[i]);
86 rightIP->add(QPixmap(xpm.c_str()), delim[i], delim[i]);
89 string empty_xpm(find_xpm("empty"));
91 leftIP->add(QPixmap(empty_xpm.c_str()), "empty", "empty");
92 rightIP->add(QPixmap(empty_xpm.c_str()), "empty", "empty");
93 connect(leftIP, SIGNAL(button_clicked(string const &)), this, SLOT(ldelim_clicked(string const &)));
94 connect(rightIP, SIGNAL(button_clicked(string const &)), this, SLOT(rdelim_clicked(string const &)));
100 void QDelimiterDialog::insertClicked()
102 form_->insertDelim(fix_name(left_) + " " + fix_name(right_));
106 void QDelimiterDialog::set_label(QLabel * label, string const & str)
108 label->setUpdatesEnabled(false);
109 label->setPixmap(QPixmap(find_xpm(str).c_str()));
110 label->setUpdatesEnabled(true);
115 void QDelimiterDialog::ldelim_clicked(string const & str)
119 set_label(leftPI, left_);
120 if (matchCB->isChecked()) {
121 right_ = do_match(left_);
122 set_label(rightPI, right_);
127 void QDelimiterDialog::rdelim_clicked(string const & str)
131 set_label(rightPI, right_);
132 if (matchCB->isChecked()) {
133 left_ = do_match(right_);
134 set_label(leftPI, left_);