namespace lyx {
namespace frontend {
-namespace {
+static QString const bigleft[] = {"", "bigl", "Bigl", "biggl", "Biggl"};
-QString const bigleft[] = {"", "bigl", "Bigl", "biggl", "Biggl"};
+static QString const bigright[] = {"", "bigr", "Bigr", "biggr", "Biggr"};
-
-QString const bigright[] = {"", "bigr", "Bigr", "biggr", "Biggr"};
-
-
-char const * const biggui[] = {N_("big[[delimiter size]]"), N_("Big[[delimiter size]]"),
- N_("bigg[[delimiter size]]"), N_("Bigg[[delimiter size]]"), ""};
+static char const * const biggui[] = {
+ N_("big[[delimiter size]]"),
+ N_("Big[[delimiter size]]"),
+ N_("bigg[[delimiter size]]"),
+ N_("Bigg[[delimiter size]]"),
+ ""
+};
// FIXME: It might be better to fix the big delim LFUN to not require
// additional '\' prefix.
-QString fix_name(QString const & str, bool big)
+static QString fix_name(QString const & str, bool big)
{
if (str.isEmpty())
return ".";
return "\\" + str;
}
-} // namespace anon
-
-
-GuiDelimiter::GuiDelimiter(Dialog & parent)
- : GuiView<GuiDelimiterDialog>(parent, _("Math Delimiter"))
-{}
-
-
-void GuiDelimiter::build_dialog()
-{
- dialog_.reset(new GuiDelimiterDialog(this,
- static_cast<GuiViewBase *>(controller().view())));
-}
-
-
-char_type GuiDelimiterDialog::doMatch(char_type const symbol) const
-{
- string const & str = form_->controller().texName(symbol);
- string match;
- if (str == "(") match = ")";
- else if (str == ")") match = "(";
- else if (str == "[") match = "]";
- else if (str == "]") match = "[";
- else if (str == "{") match = "}";
- else if (str == "}") match = "{";
- else if (str == "l") match = "r";
- else if (str == "rceil") match = "lceil";
- else if (str == "lceil") match = "rceil";
- else if (str == "rfloor") match = "lfloor";
- else if (str == "lfloor") match = "rfloor";
- else if (str == "rangle") match = "langle";
- else if (str == "langle") match = "rangle";
- else if (str == "backslash") match = "/";
- else if (str == "/") match = "backslash";
- else return symbol;
-
- return form_->controller().mathSymbol(match).unicode;
-}
-
-GuiDelimiterDialog::GuiDelimiterDialog(GuiDelimiter * form, QWidget * parent)
- : QDialog(parent), form_(form)
+GuiDelimiterDialog::GuiDelimiterDialog(LyXView & lv)
+ : GuiDialog(lv, "mathdelimiter")
{
setupUi(this);
+ setViewTitle(_("Math Delimiter"));
+ setController(new ControlMath(*this));
connect(closePB, SIGNAL(clicked()), this, SLOT(accept()));
- setWindowTitle(qt_("LyX: Delimiters"));
setFocusProxy(leftLW);
leftLW->setViewMode(QListView::IconMode);
int const end = nr_latex_delimiters - 1;
for (int i = 0; i < end; ++i) {
string const delim = latex_delimiters[i];
- MathSymbol const & ms = form_->controller().mathSymbol(delim);
+ MathSymbol const & ms = controller().mathSymbol(delim);
QString symbol(ms.fontcode?
QChar(ms.fontcode) : toqstr(docstring(1, ms.unicode)));
QListWidgetItem * lwi = new QListWidgetItem(symbol);
}
for (int i = 0; i != leftLW->count(); ++i) {
- MathSymbol const & ms = form_->controller().mathSymbol(
+ MathSymbol const & ms = controller().mathSymbol(
fromqstr(leftLW->item(i)->toolTip()));
rightLW->addItem(list_items[doMatch(ms.unicode)]->clone());
}
sizeCO->addItem(qt_(biggui[i]));
on_leftLW_currentRowChanged(0);
+ bc().setPolicy(ButtonPolicy::IgnorantPolicy);
+}
+
+
+ControlMath & GuiDelimiterDialog::controller() const
+{
+ return static_cast<ControlMath &>(GuiDialog::controller());
+}
+
+
+char_type GuiDelimiterDialog::doMatch(char_type const symbol) const
+{
+ string const & str = controller().texName(symbol);
+ string match;
+ if (str == "(") match = ")";
+ else if (str == ")") match = "(";
+ else if (str == "[") match = "]";
+ else if (str == "]") match = "[";
+ else if (str == "{") match = "}";
+ else if (str == "}") match = "{";
+ else if (str == "l") match = "r";
+ else if (str == "rceil") match = "lceil";
+ else if (str == "lceil") match = "rceil";
+ else if (str == "rfloor") match = "lfloor";
+ else if (str == "lfloor") match = "rfloor";
+ else if (str == "rangle") match = "langle";
+ else if (str == "langle") match = "rangle";
+ else if (str == "backslash") match = "/";
+ else if (str == "/") match = "backslash";
+ else return symbol;
+
+ return controller().mathSymbol(match).unicode;
}
void GuiDelimiterDialog::on_insertPB_clicked()
{
if (sizeCO->currentIndex() == 0)
- form_->controller().dispatchDelim(fromqstr(tex_code_));
+ controller().dispatchDelim(fromqstr(tex_code_));
else {
QString command = '"' + tex_code_ + '"';
command.replace(' ', "\" \"");
- form_->controller().dispatchBigDelim(fromqstr(command));
+ controller().dispatchBigDelim(fromqstr(command));
}
}