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>
32 char const * delim[] = {
33 "(", ")", "{", "}", "[", "]",
34 "lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
35 "uparrow", "Uparrow", "downarrow", "Downarrow",
36 "|", "Vert", "slash", "backslash", ""
39 string do_match(string str) {
40 if (str == "(") return ")";
41 if (str == ")") return "(";
42 if (str == "[") return "]";
43 if (str == "]") return "[";
44 if (str == "{") return "}";
45 if (str == "}") return "{";
46 if (str == "l") return "r";
47 if (str == "rceil") return "lceil";
48 if (str == "lceil") return "rceil";
49 if (str == "rfloor") return "lfloor";
50 if (str == "lfloor") return "rfloor";
51 if (str == "rangle") return "langle";
52 if (str == "langle") return "rangle";
53 if (str == "backslash") return "slash";
54 if (str == "slash") return "backslash";
60 QDelimiterDialog::QDelimiterDialog(QMath * form)
61 : QDelimiterDialogBase(0, 0, false, 0),
64 setCaption(_("LyX: Delimiters"));
66 for (int i = 0; *delim[i]; ++i) {
67 string xpm_name = LibFileSearch("images/math/", delim[i], "xpm");
68 leftIP->add(QPixmap(xpm_name.c_str()), delim[i], delim[i]);
70 leftIP->add(QPixmap(LibFileSearch("images/math/", "empty", "xpm").c_str()), "empty", "empty");
71 connect(leftIP, SIGNAL(button_clicked(string)), this, SLOT(ldelim_clicked(string)));
74 for (int i = 0; *delim[i]; ++i) {
75 string xpm_name = LibFileSearch("images/math/", delim[i], "xpm");
76 rightIP->add(QPixmap(xpm_name.c_str()), delim[i], delim[i]);
78 rightIP->add(QPixmap(LibFileSearch("images/math/", "empty", "xpm").c_str()), "empty", "empty");
79 connect(rightIP, SIGNAL(button_clicked(string)), this, SLOT(rdelim_clicked(string)));
85 string fix_name(string const & str) {
88 if (str == "backslash")
96 void QDelimiterDialog::insertClicked()
98 form_->insertDelim(fix_name(left_) + " " + fix_name(right_));
102 void QDelimiterDialog::set_label(QLabel * label, string const & str)
104 string xpm_name = LibFileSearch("images/math/", str, "xpm");
105 label->setUpdatesEnabled(false);
106 label->setPixmap(QPixmap(xpm_name.c_str()));
107 label->setUpdatesEnabled(true);
112 void QDelimiterDialog::ldelim_clicked(string 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 str)
128 set_label(rightPI, right_);
129 if (matchCB->isChecked()) {
130 left_ = do_match(right_);
131 set_label(leftPI, left_);