Martins and my getStatus and infoize fixes

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9772 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2005-04-03 12:07:49 +00:00
parent d6981c3b30
commit b542257bd8
12 changed files with 154 additions and 13 deletions

View File

@ -1,3 +1,18 @@
2005-03-31 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* 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 <martin.vermeer@hut.fi>
* math_amsarrayinset.[Ch] (getStatus):
* math_splitinset.[Ch] (getStatus):
* math_substackinset.[Ch]: suppress output of vertical gridlines
where appropriate
2005-04-03 Martin Vermeer <martin.vermeer@hut.fi> 2005-04-03 Martin Vermeer <martin.vermeer@hut.fi>
* math_fontinset.[Ch] (draw): add call to setPosCache, * math_fontinset.[Ch] (draw): add call to setPosCache,

View File

@ -17,8 +17,17 @@
#include "math_streamstr.h" #include "math_streamstr.h"
#include "math_support.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::string;
using std::auto_ptr; using std::auto_ptr;
using lyx::support::bformat;
MathAMSArrayInset::MathAMSArrayInset(string const & name, int m, int n) 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 void MathAMSArrayInset::write(WriteStream & os) const
{ {
os << "\\begin{" << name_ << '}'; 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 void MathAMSArrayInset::normalize(NormalStream & os) const
{ {
os << '[' << name_ << ' '; os << '[' << name_ << ' ';

View File

@ -31,9 +31,14 @@ public:
/// ///
MathAMSArrayInset const * asAMSArrayInset() const { return this; } MathAMSArrayInset const * asAMSArrayInset() const { return this; }
///
bool getStatus(LCursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const;
/// ///
void write(WriteStream & os) const; void write(WriteStream & os) const;
/// ///
void infoize(std::ostream & os) const;
///
void normalize(NormalStream &) const; void normalize(NormalStream &) const;
/// ///
void validate(LaTeXFeatures & features) const; void validate(LaTeXFeatures & features) const;

View File

@ -17,6 +17,8 @@
#include "math_mathmlstream.h" #include "math_mathmlstream.h"
#include "math_streamstr.h" #include "math_streamstr.h"
#include "support/lstrings.h"
#include <iterator> #include <iterator>
#include <sstream> #include <sstream>
@ -113,7 +115,9 @@ void MathArrayInset::write(WriteStream & os) const
void MathArrayInset::infoize(std::ostream & os) const void MathArrayInset::infoize(std::ostream & os) const
{ {
os << "Array"; string name = name_;
name[0] = lyx::support::uppercase(name[0]);
os << name << ' ';
} }

View File

@ -24,7 +24,6 @@
#include "support/lstrings.h" #include "support/lstrings.h"
#include <sstream>
using lyx::support::bformat; using lyx::support::bformat;
@ -32,7 +31,6 @@ using std::endl;
using std::max; using std::max;
using std::min; using std::min;
using std::swap; using std::swap;
using std::istringstream;
using std::string; using std::string;
using std::auto_ptr; using std::auto_ptr;
@ -71,9 +69,7 @@ void MathCasesInset::doDispatch(LCursor & cur, FuncRequest & cmd)
switch (cmd.action) { switch (cmd.action) {
case LFUN_TABULAR_FEATURE: { case LFUN_TABULAR_FEATURE: {
recordUndo(cur); recordUndo(cur);
istringstream is(cmd.argument); string const s = cmd.argument;
string s;
is >> s;
if (s == "add-vline-left" || s == "add-vline-right") { if (s == "add-vline-left" || s == "add-vline-right") {
cur.undispatched(); cur.undispatched();
break; break;
@ -90,9 +86,7 @@ bool MathCasesInset::getStatus(LCursor & cur, FuncRequest const & cmd,
{ {
switch (cmd.action) { switch (cmd.action) {
case LFUN_TABULAR_FEATURE: { case LFUN_TABULAR_FEATURE: {
istringstream is(cmd.argument); string const s = cmd.argument;
string s;
is >> s;
if (s == "add-vline-left" || s == "add-vline-right") { if (s == "add-vline-left" || s == "add-vline-right") {
flag.enabled(false); flag.enabled(false);
flag.message(bformat( flag.message(bformat(

View File

@ -1237,9 +1237,7 @@ bool MathGridInset::getStatus(LCursor & cur, FuncRequest const & cmd,
{ {
switch (cmd.action) { switch (cmd.action) {
case LFUN_TABULAR_FEATURE: { case LFUN_TABULAR_FEATURE: {
istringstream is(cmd.argument); string const s = cmd.argument;
string s;
is >> s;
if (nrows() <= 1 && (s == "delete-row" || s == "swap-row")) { if (nrows() <= 1 && (s == "delete-row" || s == "swap-row")) {
flag.enabled(false); flag.enabled(false);
flag.message(N_("Only one row")); flag.message(N_("Only one row"));

View File

@ -15,7 +15,15 @@
#include "math_mathmlstream.h" #include "math_mathmlstream.h"
#include "math_streamstr.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::string;
using std::auto_ptr; 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 void MathSplitInset::write(WriteStream & ws) const
{ {
if (ws.fragile()) if (ws.fragile())
@ -57,3 +86,11 @@ void MathSplitInset::write(WriteStream & ws) const
ws << "\\protect"; ws << "\\protect";
ws << "\\end{" << name_ << "}\n"; ws << "\\end{" << name_ << "}\n";
} }
void MathSplitInset::infoize(std::ostream & os) const
{
string name = name_;
name[0] = lyx::support::uppercase(name[0]);
os << name << ' ';
}

View File

@ -19,9 +19,15 @@ class MathSplitInset : public MathGridInset {
public: public:
/// ///
explicit MathSplitInset(std::string const & name); explicit MathSplitInset(std::string const & name);
/// ///
bool getStatus(LCursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const;
void write(WriteStream & os) const; void write(WriteStream & os) const;
/// ///
void infoize(std::ostream & os) const;
///
int defaultColSpace(col_type) { return 0; } int defaultColSpace(col_type) { return 0; }
/// ///
char defaultColAlign(col_type); char defaultColAlign(col_type);

View File

@ -16,6 +16,15 @@
#include "math_mathmlstream.h" #include "math_mathmlstream.h"
#include "support/std_ostream.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; 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 void MathSubstackInset::infoize(std::ostream & os) const
{ {
os << "Substack "; os << "Substack ";

View File

@ -29,7 +29,8 @@ public:
MathSubstackInset const * asSubstackInset() const { return this; } MathSubstackInset const * asSubstackInset() const { return this; }
/// ///
void normalize(); bool getStatus(LCursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const;
/// ///
void infoize(std::ostream & os) const; void infoize(std::ostream & os) const;
/// ///

View File

@ -15,6 +15,9 @@
#include "math_mathmlstream.h" #include "math_mathmlstream.h"
#include "math_streamstr.h" #include "math_streamstr.h"
#include "support/lstrings.h"
#include "support/std_ostream.h"
#include <iterator> #include <iterator>
@ -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 void MathTabularInset::normalize(NormalStream & os) const
{ {
os << '[' << name_ << ' '; os << '[' << name_ << ' ';

View File

@ -37,6 +37,8 @@ public:
/// ///
void write(WriteStream & os) const; void write(WriteStream & os) const;
/// ///
void infoize(std::ostream & os) const;
///
void normalize(NormalStream &) const; void normalize(NormalStream &) const;
/// ///
void maple(MapleStream &) const; void maple(MapleStream &) const;