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 "QDelimiterDialog.h"
24 #include "iconpalette.h"
28 #include <qpushbutton.h>
29 #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(string const & 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(string const & str)
66 if (str == "backslash")
76 QDelimiterDialog::QDelimiterDialog(QMath * form)
77 : QDelimiterDialogBase(0, 0, false, 0),
80 setCaption(_("LyX: Delimiters"));
82 for (int i = 0; *delim[i]; ++i) {
83 string xpm_name = LibFileSearch("images/math/", delim[i], "xpm");
84 leftIP->add(QPixmap(xpm_name.c_str()), delim[i], delim[i]);
86 leftIP->add(QPixmap(LibFileSearch("images/math/", "empty", "xpm").c_str()), "empty", "empty");
87 connect(leftIP, SIGNAL(button_clicked(string)), this, SLOT(ldelim_clicked(string)));
90 for (int i = 0; *delim[i]; ++i) {
91 string xpm_name = LibFileSearch("images/math/", delim[i], "xpm");
92 rightIP->add(QPixmap(xpm_name.c_str()), delim[i], delim[i]);
94 rightIP->add(QPixmap(LibFileSearch("images/math/", "empty", "xpm").c_str()), "empty", "empty");
95 connect(rightIP, SIGNAL(button_clicked(string)), this, SLOT(rdelim_clicked(string)));
100 void QDelimiterDialog::insertClicked()
102 form_->insertDelim(fix_name(left_) + " " + fix_name(right_));
106 void QDelimiterDialog::set_label(QLabel * label, string const & str)
108 string xpm_name = LibFileSearch("images/math/", str, "xpm");
109 label->setUpdatesEnabled(false);
110 label->setPixmap(QPixmap(xpm_name.c_str()));
111 label->setUpdatesEnabled(true);
116 void QDelimiterDialog::ldelim_clicked(string str)
120 set_label(leftPI, left_);
121 if (matchCB->isChecked()) {
122 right_ = do_match(left_);
123 set_label(rightPI, right_);
128 void QDelimiterDialog::rdelim_clicked(string str)
132 set_label(rightPI, right_);
133 if (matchCB->isChecked()) {
134 left_ = do_match(right_);
135 set_label(leftPI, left_);