2 * \file QDelimiterDialog.C
3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author John Levon <moz@compsoc.man.ac.uk>
11 #include "support/filetools.h"
16 #include "QDelimiterDialog.h"
18 #include "iconpalette.h"
22 #include <qpushbutton.h>
23 #include <qcheckbox.h>
26 char const * delim[] = {
27 "(", ")", "{", "}", "[", "]",
28 "lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
29 "uparrow", "Uparrow", "downarrow", "Downarrow",
30 "|", "Vert", "slash", "backslash", ""
33 string do_match(string str) {
34 if (str == "(") return ")";
35 if (str == ")") return "(";
36 if (str == "[") return "]";
37 if (str == "]") return "[";
38 if (str == "{") return "}";
39 if (str == "}") return "{";
40 if (str == "l") return "r";
41 if (str == "rceil") return "lceil";
42 if (str == "lceil") return "rceil";
43 if (str == "rfloor") return "lfloor";
44 if (str == "lfloor") return "rfloor";
45 if (str == "rangle") return "langle";
46 if (str == "langle") return "rangle";
47 if (str == "backslash") return "slash";
48 if (str == "slash") return "backslash";
54 QDelimiterDialog::QDelimiterDialog(QMath * form)
55 : QDelimiterDialogBase(0, 0, false, 0),
58 setCaption(_("LyX: Delimiters"));
60 for (int i = 0; *delim[i]; ++i) {
61 string xpm_name = LibFileSearch("images/math/", delim[i], "xpm");
62 leftIP->add(QPixmap(xpm_name.c_str()), delim[i], delim[i]);
64 leftIP->add(QPixmap(LibFileSearch("images/math/", "empty", "xpm").c_str()), "empty", "empty");
65 connect(leftIP, SIGNAL(button_clicked(string)), this, SLOT(ldelim_clicked(string)));
68 for (int i = 0; *delim[i]; ++i) {
69 string xpm_name = LibFileSearch("images/math/", delim[i], "xpm");
70 rightIP->add(QPixmap(xpm_name.c_str()), delim[i], delim[i]);
72 rightIP->add(QPixmap(LibFileSearch("images/math/", "empty", "xpm").c_str()), "empty", "empty");
73 connect(rightIP, SIGNAL(button_clicked(string)), this, SLOT(rdelim_clicked(string)));
79 string fix_name(string const & str) {
82 if (str == "backslash")
90 void QDelimiterDialog::insertClicked()
92 form_->insertDelim(fix_name(left_) + " " + fix_name(right_));
96 void QDelimiterDialog::set_label(QLabel * label, string const & str)
98 string xpm_name = LibFileSearch("images/math/", str, "xpm");
99 label->setUpdatesEnabled(false);
100 label->setPixmap(QPixmap(xpm_name.c_str()));
101 label->setUpdatesEnabled(true);
106 void QDelimiterDialog::ldelim_clicked(string str)
110 set_label(leftPI, left_);
111 if (matchCB->isChecked()) {
112 right_ = do_match(left_);
113 set_label(rightPI, right_);
118 void QDelimiterDialog::rdelim_clicked(string str)
122 set_label(rightPI, right_);
123 if (matchCB->isChecked()) {
124 left_ = do_match(right_);
125 set_label(leftPI, left_);