From b542257bd80653d755dd668f222be2ee6013393b Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sun, 3 Apr 2005 12:07:49 +0000 Subject: [PATCH] Martins and my getStatus and infoize fixes git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9772 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 15 +++++++++++++ src/mathed/math_amsarrayinset.C | 38 +++++++++++++++++++++++++++++++++ src/mathed/math_amsarrayinset.h | 5 +++++ src/mathed/math_arrayinset.C | 6 +++++- src/mathed/math_casesinset.C | 10 ++------- src/mathed/math_gridinset.C | 4 +--- src/mathed/math_splitinset.C | 37 ++++++++++++++++++++++++++++++++ src/mathed/math_splitinset.h | 6 ++++++ src/mathed/math_substackinset.C | 30 ++++++++++++++++++++++++++ src/mathed/math_substackinset.h | 3 ++- src/mathed/math_tabularinset.C | 11 ++++++++++ src/mathed/math_tabularinset.h | 2 ++ 12 files changed, 154 insertions(+), 13 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index a48e87d78e..1a350f45ea 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,18 @@ +2005-03-31 Georg Baum + + * math_amsarrayinset.[Ch], math_tabularinset.[Ch], + math_splitinset.[Ch] (infoize): implement + * math_casesinset.C (getStatus, doDispatch): use cmd.argument directly + * math_gridinset.C (getStatus): ditto + * math_arrayinset.C (infoize): generalize + +2005-03-30 Martin Vermeer + + * math_amsarrayinset.[Ch] (getStatus): + * math_splitinset.[Ch] (getStatus): + * math_substackinset.[Ch]: suppress output of vertical gridlines + where appropriate + 2005-04-03 Martin Vermeer * math_fontinset.[Ch] (draw): add call to setPosCache, diff --git a/src/mathed/math_amsarrayinset.C b/src/mathed/math_amsarrayinset.C index 4acba92900..dea483859e 100644 --- a/src/mathed/math_amsarrayinset.C +++ b/src/mathed/math_amsarrayinset.C @@ -17,8 +17,17 @@ #include "math_streamstr.h" #include "math_support.h" +#include "funcrequest.h" +#include "FuncStatus.h" +#include "gettext.h" + +#include "support/lstrings.h" +#include "support/std_ostream.h" + + using std::string; using std::auto_ptr; +using lyx::support::bformat; MathAMSArrayInset::MathAMSArrayInset(string const & name, int m, int n) @@ -90,6 +99,27 @@ void MathAMSArrayInset::draw(PainterInfo & pi, int x, int y) const } +bool MathAMSArrayInset::getStatus(LCursor & cur, FuncRequest const & cmd, + FuncStatus & flag) const +{ + switch (cmd.action) { + case LFUN_TABULAR_FEATURE: { + string const s = cmd.argument; + if (s == "add-vline-left" || s == "add-vline-right") { + flag.message(bformat( + N_("Can't add vertical grid lines in '%1$s'"), + name_)); + flag.enabled(false); + return true; + } + return MathGridInset::getStatus(cur, cmd, flag); + } + default: + return MathGridInset::getStatus(cur, cmd, flag); + } +} + + void MathAMSArrayInset::write(WriteStream & os) const { os << "\\begin{" << name_ << '}'; @@ -98,6 +128,14 @@ void MathAMSArrayInset::write(WriteStream & os) const } +void MathAMSArrayInset::infoize(std::ostream & os) const +{ + string name = name_; + name[0] = lyx::support::uppercase(name[0]); + os << name << ' '; +} + + void MathAMSArrayInset::normalize(NormalStream & os) const { os << '[' << name_ << ' '; diff --git a/src/mathed/math_amsarrayinset.h b/src/mathed/math_amsarrayinset.h index 9f3901fe54..8ff70cbdc8 100644 --- a/src/mathed/math_amsarrayinset.h +++ b/src/mathed/math_amsarrayinset.h @@ -31,9 +31,14 @@ public: /// MathAMSArrayInset const * asAMSArrayInset() const { return this; } + /// + bool getStatus(LCursor & cur, FuncRequest const & cmd, + FuncStatus & flag) const; /// void write(WriteStream & os) const; /// + void infoize(std::ostream & os) const; + /// void normalize(NormalStream &) const; /// void validate(LaTeXFeatures & features) const; diff --git a/src/mathed/math_arrayinset.C b/src/mathed/math_arrayinset.C index 6cbcd3a093..8bc8b449ea 100644 --- a/src/mathed/math_arrayinset.C +++ b/src/mathed/math_arrayinset.C @@ -17,6 +17,8 @@ #include "math_mathmlstream.h" #include "math_streamstr.h" +#include "support/lstrings.h" + #include #include @@ -113,7 +115,9 @@ void MathArrayInset::write(WriteStream & os) const void MathArrayInset::infoize(std::ostream & os) const { - os << "Array"; + string name = name_; + name[0] = lyx::support::uppercase(name[0]); + os << name << ' '; } diff --git a/src/mathed/math_casesinset.C b/src/mathed/math_casesinset.C index 595a3d0790..6c489ccddc 100644 --- a/src/mathed/math_casesinset.C +++ b/src/mathed/math_casesinset.C @@ -24,7 +24,6 @@ #include "support/lstrings.h" -#include using lyx::support::bformat; @@ -32,7 +31,6 @@ using std::endl; using std::max; using std::min; using std::swap; -using std::istringstream; using std::string; using std::auto_ptr; @@ -71,9 +69,7 @@ void MathCasesInset::doDispatch(LCursor & cur, FuncRequest & cmd) switch (cmd.action) { case LFUN_TABULAR_FEATURE: { recordUndo(cur); - istringstream is(cmd.argument); - string s; - is >> s; + string const s = cmd.argument; if (s == "add-vline-left" || s == "add-vline-right") { cur.undispatched(); break; @@ -90,9 +86,7 @@ bool MathCasesInset::getStatus(LCursor & cur, FuncRequest const & cmd, { switch (cmd.action) { case LFUN_TABULAR_FEATURE: { - istringstream is(cmd.argument); - string s; - is >> s; + string const s = cmd.argument; if (s == "add-vline-left" || s == "add-vline-right") { flag.enabled(false); flag.message(bformat( diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index a07aaf39a0..e104f2cbc2 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -1237,9 +1237,7 @@ bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd, { switch (cmd.action) { case LFUN_TABULAR_FEATURE: { - istringstream is(cmd.argument); - string s; - is >> s; + string const s = cmd.argument; if (nrows() <= 1 && (s == "delete-row" || s == "swap-row")) { flag.enabled(false); flag.message(N_("Only one row")); diff --git a/src/mathed/math_splitinset.C b/src/mathed/math_splitinset.C index e903a04b84..5f5af3d87a 100644 --- a/src/mathed/math_splitinset.C +++ b/src/mathed/math_splitinset.C @@ -15,7 +15,15 @@ #include "math_mathmlstream.h" #include "math_streamstr.h" +#include "funcrequest.h" +#include "FuncStatus.h" +#include "gettext.h" +#include "support/lstrings.h" +#include "support/std_ostream.h" + + +using lyx::support::bformat; using std::string; using std::auto_ptr; @@ -47,6 +55,27 @@ char MathSplitInset::defaultColAlign(col_type col) } +bool MathSplitInset::getStatus(LCursor & cur, FuncRequest const & cmd, + FuncStatus & flag) const +{ + switch (cmd.action) { + case LFUN_TABULAR_FEATURE: { + string const s = cmd.argument; + if (s == "add-vline-left" || s == "add-vline-right") { + flag.message(bformat( + N_("Can't add vertical grid lines in '%1$s'"), + name_)); + flag.enabled(false); + return true; + } + return MathGridInset::getStatus(cur, cmd, flag); + } + default: + return MathGridInset::getStatus(cur, cmd, flag); + } +} + + void MathSplitInset::write(WriteStream & ws) const { if (ws.fragile()) @@ -57,3 +86,11 @@ void MathSplitInset::write(WriteStream & ws) const ws << "\\protect"; ws << "\\end{" << name_ << "}\n"; } + + +void MathSplitInset::infoize(std::ostream & os) const +{ + string name = name_; + name[0] = lyx::support::uppercase(name[0]); + os << name << ' '; +} diff --git a/src/mathed/math_splitinset.h b/src/mathed/math_splitinset.h index 49faf48f4e..8df3002267 100644 --- a/src/mathed/math_splitinset.h +++ b/src/mathed/math_splitinset.h @@ -19,9 +19,15 @@ class MathSplitInset : public MathGridInset { public: /// explicit MathSplitInset(std::string const & name); + /// + bool getStatus(LCursor & cur, FuncRequest const & cmd, + FuncStatus & flag) const; + void write(WriteStream & os) const; /// + void infoize(std::ostream & os) const; + /// int defaultColSpace(col_type) { return 0; } /// char defaultColAlign(col_type); diff --git a/src/mathed/math_substackinset.C b/src/mathed/math_substackinset.C index b60e4898cc..1dd634d337 100644 --- a/src/mathed/math_substackinset.C +++ b/src/mathed/math_substackinset.C @@ -16,6 +16,15 @@ #include "math_mathmlstream.h" #include "support/std_ostream.h" +#include "funcrequest.h" +#include "FuncStatus.h" +#include "gettext.h" + +#include "support/lstrings.h" + + +using lyx::support::bformat; +using std::string; using std::auto_ptr; @@ -48,6 +57,27 @@ void MathSubstackInset::draw(PainterInfo & pi, int x, int y) const } +bool MathSubstackInset::getStatus(LCursor & cur, FuncRequest const & cmd, + FuncStatus & flag) const +{ + switch (cmd.action) { + case LFUN_TABULAR_FEATURE: { + string const name("substack"); + string const s = cmd.argument; + if (s == "add-vline-left" || s == "add-vline-right") { + flag.message(bformat( + N_("Can't add vertical grid lines in '%1$s'"), name)); + flag.enabled(false); + return true; + } + return MathGridInset::getStatus(cur, cmd, flag); + } + default: + return MathGridInset::getStatus(cur, cmd, flag); + } +} + + void MathSubstackInset::infoize(std::ostream & os) const { os << "Substack "; diff --git a/src/mathed/math_substackinset.h b/src/mathed/math_substackinset.h index ca84d21e58..36f6a4209a 100644 --- a/src/mathed/math_substackinset.h +++ b/src/mathed/math_substackinset.h @@ -29,7 +29,8 @@ public: MathSubstackInset const * asSubstackInset() const { return this; } /// - void normalize(); + bool getStatus(LCursor & cur, FuncRequest const & cmd, + FuncStatus & flag) const; /// void infoize(std::ostream & os) const; /// diff --git a/src/mathed/math_tabularinset.C b/src/mathed/math_tabularinset.C index 78712160eb..e67203f255 100644 --- a/src/mathed/math_tabularinset.C +++ b/src/mathed/math_tabularinset.C @@ -15,6 +15,9 @@ #include "math_mathmlstream.h" #include "math_streamstr.h" +#include "support/lstrings.h" +#include "support/std_ostream.h" + #include @@ -79,6 +82,14 @@ void MathTabularInset::write(WriteStream & os) const } +void MathTabularInset::infoize(std::ostream & os) const +{ + string name = name_; + name[0] = lyx::support::uppercase(name[0]); + os << name << ' '; +} + + void MathTabularInset::normalize(NormalStream & os) const { os << '[' << name_ << ' '; diff --git a/src/mathed/math_tabularinset.h b/src/mathed/math_tabularinset.h index e2476d246e..469983dde2 100644 --- a/src/mathed/math_tabularinset.h +++ b/src/mathed/math_tabularinset.h @@ -37,6 +37,8 @@ public: /// void write(WriteStream & os) const; /// + void infoize(std::ostream & os) const; + /// void normalize(NormalStream &) const; /// void maple(MapleStream &) const; -- 2.39.2