mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-30 05:12:40 +00:00
Implement GUI for fixed size math delimiters (by Enrico Forestieri and me):
* src/lfuns.h (enum kb_action): New lfun LFUN_MATH_BIGDELIM * src/LyXAction.C (void LyXAction::init): New lfun LFUN_MATH_BIGDELIM * src/mathed/math_nestinset.C (void MathNestInset::doDispatch): remove debug message (void MathNestInset::doDispatch): remove LFUN_MATH_DELIM test for multiple cells (now in getStatus) (void MathNestInset::doDispatch): Handle LFUN_MATH_BIGDELIM (bool MathNestInset::getStatus): Disable LFUN_MATH_DELIM and LFUN_MATH_BIGDELIM when the selection spans multiple cells * src/frontends/qt3/ui/QDelimiterDialogBase.ui Added a combobox for selecting delimiter size. * src/frontends/qt3/QDelimiterDialog.[Ch] (fix_name, QDelimiterDialog, insertClicked, size_selected): Allow for fixed size delimiters. * src/frontends/gtk/GMathDelim.C: Add FIXME commnent for fixed size delimiters * src/frontends/qt4/QDelimiterDialog.C: ditto * src/frontends/xforms/FormMathsDelim.C: ditto * src/frontends/controllers/ControlMath.[Ch]: Added dispatchBigDelim() to deal with fixed size delimiters. * src/text3.C (void LyXText::dispatch): Handle LFUN_MATH_BIGDELIM (bool LyXText::getStatus): ditto * src/ToolbarBackend.C (string const ToolbarBackend::getIcon): Handle LFUN_MATH_BIGDELIM git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13806 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
123cc28dba
commit
b6c3478eda
@ -212,6 +212,7 @@ void LyXAction::init()
|
|||||||
{ LFUN_MARK_ON, "mark-on", ReadOnly },
|
{ LFUN_MARK_ON, "mark-on", ReadOnly },
|
||||||
{ LFUN_MARK_TOGGLE, "mark-toggle", ReadOnly },
|
{ LFUN_MARK_TOGGLE, "mark-toggle", ReadOnly },
|
||||||
{ LFUN_MATH_DELIM, "math-delim", Noop },
|
{ LFUN_MATH_DELIM, "math-delim", Noop },
|
||||||
|
{ LFUN_MATH_BIGDELIM, "math-bigdelim", Noop },
|
||||||
{ LFUN_MATH_DISPLAY, "math-display", Noop },
|
{ LFUN_MATH_DISPLAY, "math-display", Noop },
|
||||||
{ LFUN_MATH_INSERT, "math-insert", Noop },
|
{ LFUN_MATH_INSERT, "math-insert", Noop },
|
||||||
{ LFUN_MATH_SUBSCRIPT, "math-subscript", Noop },
|
{ LFUN_MATH_SUBSCRIPT, "math-subscript", Noop },
|
||||||
|
@ -217,12 +217,16 @@ string const ToolbarBackend::getIcon(FuncRequest const & f)
|
|||||||
|
|
||||||
string fullname;
|
string fullname;
|
||||||
|
|
||||||
if (f.action == LFUN_MATH_INSERT) {
|
switch (f.action) {
|
||||||
|
case LFUN_MATH_INSERT:
|
||||||
if (!f.argument.empty())
|
if (!f.argument.empty())
|
||||||
fullname = find_xpm(f.argument.substr(1));
|
fullname = find_xpm(f.argument.substr(1));
|
||||||
} else if (f.action == LFUN_MATH_DELIM) {
|
break;
|
||||||
|
case LFUN_MATH_DELIM:
|
||||||
|
case LFUN_MATH_BIGDELIM:
|
||||||
fullname = find_xpm(f.argument);
|
fullname = find_xpm(f.argument);
|
||||||
} else {
|
break;
|
||||||
|
default:
|
||||||
string const name = lyxaction.getActionName(f.action);
|
string const name = lyxaction.getActionName(f.action);
|
||||||
string xpm_name(name);
|
string xpm_name(name);
|
||||||
|
|
||||||
|
@ -79,6 +79,12 @@ void ControlMath::dispatchDelim(string const & str) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ControlMath::dispatchBigDelim(string const & str) const
|
||||||
|
{
|
||||||
|
dispatchFunc(LFUN_MATH_BIGDELIM, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ControlMath::dispatchToggleDisplay() const
|
void ControlMath::dispatchToggleDisplay() const
|
||||||
{
|
{
|
||||||
dispatchFunc(LFUN_MATH_DISPLAY);
|
dispatchFunc(LFUN_MATH_DISPLAY);
|
||||||
|
@ -43,9 +43,11 @@ public:
|
|||||||
void dispatchCubeRoot() const;
|
void dispatchCubeRoot() const;
|
||||||
/// Insert a matrix
|
/// Insert a matrix
|
||||||
void dispatchMatrix(std::string const & str) const;
|
void dispatchMatrix(std::string const & str) const;
|
||||||
/// Insert a delimiter
|
/// Insert a variable size delimiter
|
||||||
void dispatchDelim(std::string const & str) const;
|
void dispatchDelim(std::string const & str) const;
|
||||||
/// Wwitch between display and inline
|
/// Insert a big delimiter
|
||||||
|
void dispatchBigDelim(std::string const & str) const;
|
||||||
|
/// Switch between display and inline
|
||||||
void dispatchToggleDisplay() const;
|
void dispatchToggleDisplay() const;
|
||||||
/** A request to the kernel to launch a dialog.
|
/** A request to the kernel to launch a dialog.
|
||||||
* \param name the dialog identifier.
|
* \param name the dialog identifier.
|
||||||
|
@ -36,6 +36,8 @@ using std::string;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
|
// FIXME: Implement fixed size delimiters (see qt3 frontend)
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -18,9 +18,14 @@
|
|||||||
|
|
||||||
#include "controllers/ControlMath.h"
|
#include "controllers/ControlMath.h"
|
||||||
|
|
||||||
|
#include "gettext.h"
|
||||||
|
|
||||||
#include <qlabel.h>
|
#include <qlabel.h>
|
||||||
#include <qpixmap.h>
|
#include <qpixmap.h>
|
||||||
#include <qcheckbox.h>
|
#include <qcheckbox.h>
|
||||||
|
#include <qcombobox.h>
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -38,6 +43,12 @@ char const * delim[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
char const * const bigleft[] = {"bigl", "Bigl", "biggl", "Biggl", ""};
|
||||||
|
char const * const bigright[] = {"bigr", "Bigr", "biggr", "Biggr", ""};
|
||||||
|
char const * const biggui[] = {N_("big size"), N_("Big size"),
|
||||||
|
N_("bigg size"), N_("Bigg size"), ""};
|
||||||
|
|
||||||
|
|
||||||
string do_match(const string & str)
|
string do_match(const string & str)
|
||||||
{
|
{
|
||||||
if (str == "(") return ")";
|
if (str == "(") return ")";
|
||||||
@ -59,7 +70,7 @@ string do_match(const string & str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string fix_name(const string & str)
|
string fix_name(const string & str, bool big)
|
||||||
{
|
{
|
||||||
if (str == "slash")
|
if (str == "slash")
|
||||||
return "/";
|
return "/";
|
||||||
@ -67,7 +78,10 @@ string fix_name(const string & str)
|
|||||||
return "\\";
|
return "\\";
|
||||||
if (str == "empty")
|
if (str == "empty")
|
||||||
return ".";
|
return ".";
|
||||||
return str;
|
if (!big || str == "(" || str == ")" || str == "[" || str == "]")
|
||||||
|
return str;
|
||||||
|
|
||||||
|
return "\\" + str;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace anon
|
} // namespace anon
|
||||||
@ -89,11 +103,17 @@ QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
|
|||||||
|
|
||||||
leftIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
|
leftIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
|
||||||
rightIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
|
rightIP->add(QPixmap(toqstr(empty_xpm)), "empty", "empty");
|
||||||
|
delimSize->insertItem(qt_("Variable size"));
|
||||||
|
for (int i = 0; *biggui[i]; ++i)
|
||||||
|
delimSize->insertItem(qt_(biggui[i]));
|
||||||
|
size_ = 0;
|
||||||
// Leave these std:: qualifications alone !
|
// Leave these std:: qualifications alone !
|
||||||
connect(leftIP, SIGNAL(button_clicked(const std::string &)),
|
connect(leftIP, SIGNAL(button_clicked(const std::string &)),
|
||||||
this, SLOT(ldelim_clicked(const std::string &)));
|
this, SLOT(ldelim_clicked(const std::string &)));
|
||||||
connect(rightIP, SIGNAL(button_clicked(const std::string &)),
|
connect(rightIP, SIGNAL(button_clicked(const std::string &)),
|
||||||
this, SLOT(rdelim_clicked(const std::string &)));
|
this, SLOT(rdelim_clicked(const std::string &)));
|
||||||
|
connect(delimSize, SIGNAL(activated(int)),
|
||||||
|
this, SLOT(size_selected(int)) );
|
||||||
ldelim_clicked("(");
|
ldelim_clicked("(");
|
||||||
rdelim_clicked(")");
|
rdelim_clicked(")");
|
||||||
}
|
}
|
||||||
@ -101,7 +121,18 @@ QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
|
|||||||
|
|
||||||
void QDelimiterDialog::insertClicked()
|
void QDelimiterDialog::insertClicked()
|
||||||
{
|
{
|
||||||
form_->controller().dispatchDelim(fix_name(left_) + ' ' + fix_name(right_));
|
if (size_ == 0) {
|
||||||
|
form_->controller().dispatchDelim(
|
||||||
|
fix_name(left_, false) + ' ' +
|
||||||
|
fix_name(right_, false));
|
||||||
|
} else {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << '"' << bigleft[size_ - 1] << "\" \""
|
||||||
|
<< fix_name(left_, true) << "\" \""
|
||||||
|
<< bigright[size_ - 1] << "\" \""
|
||||||
|
<< fix_name(right_, true) << '"';
|
||||||
|
form_->controller().dispatchBigDelim(os.str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -137,5 +168,11 @@ void QDelimiterDialog::rdelim_clicked(const string & str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QDelimiterDialog::size_selected(int index)
|
||||||
|
{
|
||||||
|
size_ = index;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -30,6 +30,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void ldelim_clicked(const std::string & str);
|
void ldelim_clicked(const std::string & str);
|
||||||
void rdelim_clicked(const std::string & str);
|
void rdelim_clicked(const std::string & str);
|
||||||
|
void size_selected(int);
|
||||||
void insertClicked();
|
void insertClicked();
|
||||||
protected:
|
protected:
|
||||||
//needed ? virtual void closeEvent(QCloseEvent * e);
|
//needed ? virtual void closeEvent(QCloseEvent * e);
|
||||||
@ -42,6 +43,9 @@ private:
|
|||||||
/// symbol of right delimiter
|
/// symbol of right delimiter
|
||||||
std::string right_;
|
std::string right_;
|
||||||
|
|
||||||
|
/// size of delimiters
|
||||||
|
int size_;
|
||||||
|
|
||||||
/// owning form
|
/// owning form
|
||||||
QMathDelimiter * form_;
|
QMathDelimiter * form_;
|
||||||
};
|
};
|
||||||
|
@ -307,6 +307,22 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
<widget class="QComboBox">
|
||||||
|
<property name="name">
|
||||||
|
<cstring>delimSize</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>7</hsizetype>
|
||||||
|
<vsizetype>0</vsizetype>
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip" stdset="0">
|
||||||
|
<string>Choose delimiter size</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</hbox>
|
</hbox>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLayoutWidget">
|
<widget class="QLayoutWidget">
|
||||||
|
@ -28,6 +28,8 @@ using std::string;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
|
// FIXME: Implement fixed size delimiters (see qt3 frontend)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
char const * delim[] = {
|
char const * delim[] = {
|
||||||
|
@ -33,6 +33,8 @@ using std::ostringstream;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
|
// FIXME: Implement fixed size delimiters (see qt3 frontend)
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
int const delim_rversion[] = {
|
int const delim_rversion[] = {
|
||||||
|
@ -362,10 +362,11 @@ enum kb_action {
|
|||||||
LFUN_OUTLINE_DOWN,
|
LFUN_OUTLINE_DOWN,
|
||||||
LFUN_OUTLINE_IN,
|
LFUN_OUTLINE_IN,
|
||||||
LFUN_OUTLINE_OUT,
|
LFUN_OUTLINE_OUT,
|
||||||
// 275
|
|
||||||
LFUN_PARAGRAPH_MOVE_DOWN, // Edwin 20060408
|
LFUN_PARAGRAPH_MOVE_DOWN, // Edwin 20060408
|
||||||
LFUN_PARAGRAPH_MOVE_UP, // Edwin 20060408
|
LFUN_PARAGRAPH_MOVE_UP, // Edwin 20060408
|
||||||
|
// 280
|
||||||
LFUN_BUFFER_TOGGLE_COMPRESSION, // bpeng 20060427
|
LFUN_BUFFER_TOGGLE_COMPRESSION, // bpeng 20060427
|
||||||
|
LFUN_MATH_BIGDELIM,
|
||||||
|
|
||||||
LFUN_LASTACTION // end of the table
|
LFUN_LASTACTION // end of the table
|
||||||
};
|
};
|
||||||
|
@ -848,7 +848,6 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case LFUN_MATH_DELIM: {
|
case LFUN_MATH_DELIM: {
|
||||||
lyxerr << "MathNestInset::LFUN_MATH_DELIM" << endl;
|
|
||||||
string ls;
|
string ls;
|
||||||
string rs = lyx::support::split(cmd.argument, ls, ' ');
|
string rs = lyx::support::split(cmd.argument, ls, ' ');
|
||||||
// Reasonable default values
|
// Reasonable default values
|
||||||
@ -857,9 +856,37 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
if (rs.empty())
|
if (rs.empty())
|
||||||
rs = ')';
|
rs = ')';
|
||||||
recordUndo(cur, Undo::ATOMIC);
|
recordUndo(cur, Undo::ATOMIC);
|
||||||
// Don't do this with multi-cell selections
|
cur.handleNest(MathAtom(new MathDelimInset(ls, rs)));
|
||||||
if (cur.selBegin().idx() == cur.selEnd().idx())
|
break;
|
||||||
cur.handleNest(MathAtom(new MathDelimInset(ls, rs)));
|
}
|
||||||
|
|
||||||
|
case LFUN_MATH_BIGDELIM: {
|
||||||
|
string const lname = cmd.getArg(0);
|
||||||
|
string const ldelim = cmd.getArg(1);
|
||||||
|
string const rname = cmd.getArg(2);
|
||||||
|
string const rdelim = cmd.getArg(3);
|
||||||
|
latexkeys const * l = in_word_set(lname);
|
||||||
|
bool const have_l = l && l->inset == "big" &&
|
||||||
|
MathBigInset::isBigInsetDelim(ldelim);
|
||||||
|
l = in_word_set(rname);
|
||||||
|
bool const have_r = l && l->inset == "big" &&
|
||||||
|
MathBigInset::isBigInsetDelim(rdelim);
|
||||||
|
// We mimic LFUN_MATH_DELIM in case we have an empty left
|
||||||
|
// or right delimiter.
|
||||||
|
if (have_l || have_r) {
|
||||||
|
recordUndo(cur, Undo::ATOMIC);
|
||||||
|
string const selection = grabAndEraseSelection(cur);
|
||||||
|
selClearOrDel(cur);
|
||||||
|
if (have_l)
|
||||||
|
cur.insert(MathAtom(new MathBigInset(lname,
|
||||||
|
ldelim)));
|
||||||
|
cur.niceInsert(selection);
|
||||||
|
if (have_r)
|
||||||
|
cur.insert(MathAtom(new MathBigInset(rname,
|
||||||
|
rdelim)));
|
||||||
|
}
|
||||||
|
// Don't call cur.undispatched() if we did nothing, this would
|
||||||
|
// lead to infinite recursion via LyXText::dispatch().
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -917,7 +944,7 @@ void MathNestInset::doDispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MathNestInset::getStatus(LCursor & /*cur*/, FuncRequest const & cmd,
|
bool MathNestInset::getStatus(LCursor & cur, FuncRequest const & cmd,
|
||||||
FuncStatus & flag) const
|
FuncStatus & flag) const
|
||||||
{
|
{
|
||||||
// the font related toggles
|
// the font related toggles
|
||||||
@ -993,6 +1020,13 @@ bool MathNestInset::getStatus(LCursor & /*cur*/, FuncRequest const & cmd,
|
|||||||
case LFUN_MATH_MATRIX:
|
case LFUN_MATH_MATRIX:
|
||||||
flag.enabled(currentMode() == MATH_MODE);
|
flag.enabled(currentMode() == MATH_MODE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LFUN_MATH_DELIM:
|
||||||
|
case LFUN_MATH_BIGDELIM:
|
||||||
|
// Don't do this with multi-cell selections
|
||||||
|
flag.enabled(cur.selBegin().idx() == cur.selEnd().idx());
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = false;
|
ret = false;
|
||||||
break;
|
break;
|
||||||
|
@ -1311,7 +1311,8 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
|
|||||||
|
|
||||||
case LFUN_MATH_INSERT:
|
case LFUN_MATH_INSERT:
|
||||||
case LFUN_MATH_MATRIX:
|
case LFUN_MATH_MATRIX:
|
||||||
case LFUN_MATH_DELIM: {
|
case LFUN_MATH_DELIM:
|
||||||
|
case LFUN_MATH_BIGDELIM: {
|
||||||
cur.insert(new MathHullInset("simple"));
|
cur.insert(new MathHullInset("simple"));
|
||||||
cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
|
cur.dispatch(FuncRequest(LFUN_CHAR_FORWARD));
|
||||||
cur.dispatch(cmd);
|
cur.dispatch(cmd);
|
||||||
@ -1878,6 +1879,7 @@ bool LyXText::getStatus(LCursor & cur, FuncRequest const & cmd,
|
|||||||
case LFUN_MATH_INSERT:
|
case LFUN_MATH_INSERT:
|
||||||
case LFUN_MATH_MATRIX:
|
case LFUN_MATH_MATRIX:
|
||||||
case LFUN_MATH_DELIM:
|
case LFUN_MATH_DELIM:
|
||||||
|
case LFUN_MATH_BIGDELIM:
|
||||||
case LFUN_MATH_SUBSCRIPT:
|
case LFUN_MATH_SUBSCRIPT:
|
||||||
case LFUN_MATH_SUPERSCRIPT:
|
case LFUN_MATH_SUPERSCRIPT:
|
||||||
case LFUN_FONT_DEFAULT:
|
case LFUN_FONT_DEFAULT:
|
||||||
|
Loading…
Reference in New Issue
Block a user