mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Matrix and delimiter.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5307 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d552aa7602
commit
4a55e3463e
@ -48,7 +48,7 @@ pair<bool, string> const askForText_pimpl(string const & msg, string const & dfl
|
||||
string title = _("LyX: ");
|
||||
title += msg;
|
||||
|
||||
QAskForTextDialog d(0, msg.c_str(), true);
|
||||
QAskForTextDialog d(0, title.c_str(), true);
|
||||
// less than ideal !
|
||||
d.askLA->setText((string("&") + msg).c_str());
|
||||
d.askLE->setText(dflt.c_str());
|
||||
|
@ -1,3 +1,26 @@
|
||||
2002-09-15 John Levon <levon@movementarian.org>
|
||||
|
||||
* Makefile.dialogs:
|
||||
* ui/QDelimiterDialog.ui:
|
||||
* QDelimiterDialog.h:
|
||||
* QDelimiterDialog.C:
|
||||
* QMath.h:
|
||||
* QMath.C:
|
||||
* QMathDialog.h:
|
||||
* QMathDialog.C: add delimiter dialog
|
||||
|
||||
2002-09-15 John Levon <levon@movementarian.org>
|
||||
|
||||
* Alert_pimpl.C: title fix
|
||||
|
||||
2002-09-14 John Levon <levon@movementarian.org>
|
||||
|
||||
* QMath.h:
|
||||
* QMath.C:
|
||||
* QMathDialog.h:
|
||||
* QMathDialog.C:
|
||||
* ui/QMathDialog.ui: matrix
|
||||
|
||||
2002-09-14 John Levon <levon@movementarian.org>
|
||||
|
||||
* qlkey.h: fix two typos to be Alt_R instead
|
||||
|
@ -42,6 +42,7 @@ DIALOGSOURCES = \
|
||||
QCharacter.C QCharacterDialog.C \
|
||||
QCitation.h QCitationDialog.h \
|
||||
QCitation.C QCitationDialog.C \
|
||||
QDelimiterDialog.h QDelimiterDialog.C \
|
||||
QError.h QErrorDialog.h \
|
||||
QError.C QErrorDialog.C \
|
||||
QERT.h QERTDialog.h \
|
||||
@ -95,6 +96,7 @@ MOCDIALOGS = \
|
||||
QBibtexDialog_moc.C \
|
||||
QCharacterDialog_moc.C \
|
||||
QCitationDialog_moc.C \
|
||||
QDelimiterDialog_moc.C \
|
||||
QErrorDialog_moc.C \
|
||||
QERTDialog_moc.C \
|
||||
QExternalDialog_moc.C \
|
||||
@ -132,6 +134,8 @@ UIDIALOGS = \
|
||||
QCharacterDialogBase.C \
|
||||
QCitationDialogBase.h \
|
||||
QCitationDialogBase.C \
|
||||
QDelimiterDialogBase.h \
|
||||
QDelimiterDialogBase.C \
|
||||
QErrorDialogBase.C \
|
||||
QErrorDialogBase.h \
|
||||
QERTDialogBase.C \
|
||||
@ -186,6 +190,7 @@ UIMOCDIALOGS = \
|
||||
QBibtexDialogBase_moc.C \
|
||||
QCharacterDialogBase_moc.C \
|
||||
QCitationDialogBase_moc.C \
|
||||
QDelimiterDialogBase_moc.C \
|
||||
QErrorDialogBase_moc.C \
|
||||
QERTDialogBase_moc.C \
|
||||
QExternalDialogBase_moc.C \
|
||||
|
127
src/frontends/qt2/QDelimiterDialog.C
Normal file
127
src/frontends/qt2/QDelimiterDialog.C
Normal file
@ -0,0 +1,127 @@
|
||||
/**
|
||||
* \file QDelimiterDialog.C
|
||||
* Copyright 2001 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author John Levon <moz@compsoc.man.ac.uk>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "support/filetools.h"
|
||||
#include "gettext.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "QMath.h"
|
||||
#include "QDelimiterDialog.h"
|
||||
|
||||
#include "iconpalette.h"
|
||||
|
||||
#include <qlabel.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qcheckbox.h>
|
||||
|
||||
namespace {
|
||||
char const * delim[] = {
|
||||
"(", ")", "{", "}", "[", "]",
|
||||
"lceil", "rceil", "lfloor", "rfloor", "langle", "rangle",
|
||||
"uparrow", "Uparrow", "downarrow", "Downarrow",
|
||||
"|", "Vert", "slash", "backslash", ""
|
||||
};
|
||||
|
||||
string do_match(string 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QDelimiterDialog::QDelimiterDialog(QMath * form)
|
||||
: QDelimiterDialogBase(0, 0, false, 0),
|
||||
form_(form)
|
||||
{
|
||||
setCaption(_("LyX: Delimiters"));
|
||||
|
||||
for (int i = 0; *delim[i]; ++i) {
|
||||
string xpm_name = LibFileSearch("images/math/", delim[i], "xpm");
|
||||
leftIP->add(QPixmap(xpm_name.c_str()), delim[i], delim[i]);
|
||||
}
|
||||
leftIP->add(QPixmap(LibFileSearch("images/math/", "empty", "xpm").c_str()), "empty", "empty");
|
||||
connect(leftIP, SIGNAL(button_clicked(string)), this, SLOT(ldelim_clicked(string)));
|
||||
ldelim_clicked("(");
|
||||
|
||||
for (int i = 0; *delim[i]; ++i) {
|
||||
string xpm_name = LibFileSearch("images/math/", delim[i], "xpm");
|
||||
rightIP->add(QPixmap(xpm_name.c_str()), delim[i], delim[i]);
|
||||
}
|
||||
rightIP->add(QPixmap(LibFileSearch("images/math/", "empty", "xpm").c_str()), "empty", "empty");
|
||||
connect(rightIP, SIGNAL(button_clicked(string)), this, SLOT(rdelim_clicked(string)));
|
||||
rdelim_clicked(")");
|
||||
}
|
||||
|
||||
|
||||
namespace {
|
||||
string fix_name(string const & str) {
|
||||
if (str == "slash")
|
||||
return "/";
|
||||
if (str == "backslash")
|
||||
return "\\";
|
||||
if (str == "empty")
|
||||
return "";
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
void QDelimiterDialog::insertClicked()
|
||||
{
|
||||
form_->insertDelim(fix_name(left_) + " " + fix_name(right_));
|
||||
}
|
||||
|
||||
|
||||
void QDelimiterDialog::set_label(QLabel * label, string const & str)
|
||||
{
|
||||
string xpm_name = LibFileSearch("images/math/", str, "xpm");
|
||||
label->setUpdatesEnabled(false);
|
||||
label->setPixmap(QPixmap(xpm_name.c_str()));
|
||||
label->setUpdatesEnabled(true);
|
||||
label->update();
|
||||
}
|
||||
|
||||
|
||||
void QDelimiterDialog::ldelim_clicked(string str)
|
||||
{
|
||||
left_ = str;
|
||||
|
||||
set_label(leftPI, left_);
|
||||
if (matchCB->isChecked()) {
|
||||
right_ = do_match(left_);
|
||||
set_label(rightPI, right_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QDelimiterDialog::rdelim_clicked(string str)
|
||||
{
|
||||
right_ = str;
|
||||
|
||||
set_label(rightPI, right_);
|
||||
if (matchCB->isChecked()) {
|
||||
left_ = do_match(right_);
|
||||
set_label(leftPI, left_);
|
||||
}
|
||||
}
|
50
src/frontends/qt2/QDelimiterDialog.h
Normal file
50
src/frontends/qt2/QDelimiterDialog.h
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
* \file QDelimiterDialog.h
|
||||
* Copyright 2001 the LyX Team
|
||||
* Read the file COPYING
|
||||
*
|
||||
* \author John Levon <moz@compsoc.man.ac.uk>
|
||||
*/
|
||||
|
||||
#ifndef QDELIMITERDIALOG_H
|
||||
#define QDELIMITERDIALOG_H
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "LString.h"
|
||||
|
||||
#include "ui/QDelimiterDialogBase.h"
|
||||
|
||||
class QMath;
|
||||
class IconPalette;
|
||||
class QLabel;
|
||||
|
||||
class QDelimiterDialog : public QDelimiterDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QDelimiterDialog(QMath * form);
|
||||
|
||||
public slots:
|
||||
void ldelim_clicked(string str);
|
||||
void rdelim_clicked(string str);
|
||||
void insertClicked();
|
||||
|
||||
protected:
|
||||
//needed ? virtual void closeEvent(QCloseEvent * e);
|
||||
|
||||
private:
|
||||
void set_label(QLabel * label, string const & str);
|
||||
|
||||
/// symbol of left delimiter
|
||||
string left_;
|
||||
|
||||
/// symbol of right delimiter
|
||||
string right_;
|
||||
|
||||
/// owning form
|
||||
QMath * form_;
|
||||
};
|
||||
|
||||
#endif // QDELIMITERDIALOG_H
|
@ -88,6 +88,12 @@ void QMath::insertMatrix()
|
||||
}
|
||||
|
||||
|
||||
void QMath::insertDelim(string const & str)
|
||||
{
|
||||
current_view->owner()->dispatch(FuncRequest(LFUN_MATH_DELIM, str));
|
||||
}
|
||||
|
||||
|
||||
void QMath::toggleDisplay()
|
||||
{
|
||||
current_view->owner()->dispatch(FuncRequest(LFUN_MATH_DISPLAY));
|
||||
|
@ -40,6 +40,9 @@ public:
|
||||
/// insert a matrix
|
||||
void insertMatrix();
|
||||
|
||||
/// insert delim
|
||||
void insertDelim(string const & str);
|
||||
|
||||
/// add a subscript
|
||||
void subscript();
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "ControlMath.h"
|
||||
#include "iconpalette.h"
|
||||
#include "QDelimiterDialog.h"
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qwidgetstack.h>
|
||||
@ -190,6 +191,9 @@ void QMathDialog::fracClicked()
|
||||
|
||||
void QMathDialog::delimiterClicked()
|
||||
{
|
||||
// FIXME: leak
|
||||
QDelimiterDialog * d = new QDelimiterDialog(form_);
|
||||
d->show();
|
||||
}
|
||||
|
||||
|
||||
|
440
src/frontends/qt2/ui/QDelimiterDialog.ui
Normal file
440
src/frontends/qt2/ui/QDelimiterDialog.ui
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user