2002-09-14 23:59:19 +00:00
|
|
|
/**
|
|
|
|
* \file QDelimiterDialog.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-09-14 23:59:19 +00:00
|
|
|
*
|
2002-10-20 01:48:28 +00:00
|
|
|
* \author John Levon
|
2002-09-24 13:57:09 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2002-09-14 23:59:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2002-09-24 13:57:09 +00:00
|
|
|
|
2002-09-14 23:59:19 +00:00
|
|
|
#include "support/filetools.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-09-14 23:59:19 +00:00
|
|
|
#include "debug.h"
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-06-12 14:21:04 +00:00
|
|
|
#include "ControlMath2.h"
|
2002-09-14 23:59:19 +00:00
|
|
|
#include "QMath.h"
|
|
|
|
#include "QDelimiterDialog.h"
|
|
|
|
|
|
|
|
#include "iconpalette.h"
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-14 23:59:19 +00:00
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qpixmap.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qcheckbox.h>
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-14 23:59:19 +00:00
|
|
|
namespace {
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
char const * delim[] = {
|
|
|
|
"(", ")", "{", "}", "[", "]",
|
|
|
|
"lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
|
|
|
|
"uparrow", "Uparrow", "downarrow", "Downarrow",
|
|
|
|
"|", "Vert", "slash", "backslash", ""
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
string do_match(string const & str)
|
|
|
|
{
|
|
|
|
if (str == "(") return ")";
|
|
|
|
if (str == ")") return "(";
|
|
|
|
if (str == "[") return "]";
|
|
|
|
if (str == "]") return "[";
|
|
|
|
if (str == "{") return "}";
|
|
|
|
if (str == "}") return "{";
|
|
|
|
if (str == "l") return "r";
|
|
|
|
if (str == "rceil") return "lceil";
|
|
|
|
if (str == "lceil") return "rceil";
|
|
|
|
if (str == "rfloor") return "lfloor";
|
|
|
|
if (str == "lfloor") return "rfloor";
|
|
|
|
if (str == "rangle") return "langle";
|
|
|
|
if (str == "langle") return "rangle";
|
|
|
|
if (str == "backslash") return "slash";
|
|
|
|
if (str == "slash") return "backslash";
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string fix_name(string const & str)
|
|
|
|
{
|
|
|
|
if (str == "slash")
|
|
|
|
return "/";
|
|
|
|
if (str == "backslash")
|
|
|
|
return "\\";
|
|
|
|
if (str == "empty")
|
|
|
|
return ".";
|
|
|
|
return str;
|
2002-09-14 23:59:19 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
2003-06-17 00:30:47 +00:00
|
|
|
QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
|
2002-09-14 23:59:19 +00:00
|
|
|
: QDelimiterDialogBase(0, 0, false, 0),
|
|
|
|
form_(form)
|
|
|
|
{
|
2002-12-17 20:37:13 +00:00
|
|
|
setCaption(qt_("LyX: Delimiters"));
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-14 23:59:19 +00:00
|
|
|
for (int i = 0; *delim[i]; ++i) {
|
2002-11-20 16:11:18 +00:00
|
|
|
string xpm(find_xpm(delim[i]));
|
2002-12-17 20:37:13 +00:00
|
|
|
leftIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
|
|
|
|
rightIP->add(QPixmap(toqstr(xpm)), delim[i], delim[i]);
|
2002-09-14 23:59:19 +00:00
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-20 16:11:18 +00:00
|
|
|
string empty_xpm(find_xpm("empty"));
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
leftIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
|
|
|
|
rightIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
|
2002-12-07 18:09:39 +00:00
|
|
|
connect(leftIP, SIGNAL(button_clicked(const string &)), this, SLOT(ldelim_clicked(const string &)));
|
|
|
|
connect(rightIP, SIGNAL(button_clicked(const string &)), this, SLOT(rdelim_clicked(const string &)));
|
2002-11-20 16:11:18 +00:00
|
|
|
ldelim_clicked("(");
|
2002-09-14 23:59:19 +00:00
|
|
|
rdelim_clicked(")");
|
|
|
|
}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-14 23:59:19 +00:00
|
|
|
void QDelimiterDialog::insertClicked()
|
|
|
|
{
|
2003-06-12 14:21:04 +00:00
|
|
|
form_->controller().dispatchDelim(fix_name(left_) + ' ' + fix_name(right_));
|
2002-09-14 23:59:19 +00:00
|
|
|
}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-14 23:59:19 +00:00
|
|
|
void QDelimiterDialog::set_label(QLabel * label, string const & str)
|
|
|
|
{
|
|
|
|
label->setUpdatesEnabled(false);
|
2002-12-17 20:37:13 +00:00
|
|
|
label->setPixmap(QPixmap(toqstr(find_xpm(str))));
|
2002-09-14 23:59:19 +00:00
|
|
|
label->setUpdatesEnabled(true);
|
|
|
|
label->update();
|
|
|
|
}
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-11-20 15:21:07 +00:00
|
|
|
void QDelimiterDialog::ldelim_clicked(string const & str)
|
2002-09-14 23:59:19 +00:00
|
|
|
{
|
|
|
|
left_ = str;
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-14 23:59:19 +00:00
|
|
|
set_label(leftPI, left_);
|
|
|
|
if (matchCB->isChecked()) {
|
|
|
|
right_ = do_match(left_);
|
|
|
|
set_label(rightPI, right_);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-20 15:21:07 +00:00
|
|
|
void QDelimiterDialog::rdelim_clicked(string const & str)
|
2002-09-14 23:59:19 +00:00
|
|
|
{
|
|
|
|
right_ = str;
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-09-14 23:59:19 +00:00
|
|
|
set_label(rightPI, right_);
|
|
|
|
if (matchCB->isChecked()) {
|
|
|
|
left_ = do_match(right_);
|
|
|
|
set_label(leftPI, left_);
|
|
|
|
}
|
|
|
|
}
|