Better conditioning of drawing vertical grid lines

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9744 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Martin Vermeer 2005-03-24 16:26:15 +00:00
parent a73ed93eb0
commit 1506064b51
4 changed files with 79 additions and 3 deletions

View File

@ -1,4 +1,10 @@
2005-03-24 Martin Vermeer <martin.vermeer@hut.fi>
* math_hullinset.C:
* math_casesinset.[Ch]: more precise conditioning of
output of vertical grid lines
2005-03-22 Martin Vermeer <martin.vermeer@hut.fi> 2005-03-22 Martin Vermeer <martin.vermeer@hut.fi>
* math_hullinset.C (getStatus): intercept and suppress the * math_hullinset.C (getStatus): intercept and suppress the

View File

@ -14,8 +14,26 @@
#include "math_data.h" #include "math_data.h"
#include "math_mathmlstream.h" #include "math_mathmlstream.h"
#include "math_support.h" #include "math_support.h"
#include "FuncStatus.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "support/std_ostream.h" #include "support/std_ostream.h"
#include "cursor.h"
#include "funcrequest.h"
#include "gettext.h"
#include "undo.h"
#include "support/lstrings.h"
#include <sstream>
using lyx::support::bformat;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::istringstream;
using std::string;
using std::auto_ptr; using std::auto_ptr;
@ -47,6 +65,47 @@ void MathCasesInset::draw(PainterInfo & pi, int x, int y) const
} }
void MathCasesInset::doDispatch(LCursor & cur, FuncRequest & cmd)
{
//lyxerr << "*** MathCasesInset: request: " << cmd << endl;
switch (cmd.action) {
case LFUN_TABULAR_FEATURE: {
recordUndo(cur);
istringstream is(cmd.argument);
string s;
is >> s;
if (s == "add-vline-left" || s == "add-vline-right") {
cur.undispatched();
break;
}
}
default:
MathGridInset::doDispatch(cur, cmd);
}
}
bool MathCasesInset::getStatus(LCursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const
{
switch (cmd.action) {
case LFUN_TABULAR_FEATURE: {
istringstream is(cmd.argument);
string s;
is >> s;
if (s == "add-vline-left" || s == "add-vline-right") {
flag.enabled(false);
flag.message(bformat(
N_("No vertical grid lines in '%1$s'"), s));
return true;
}
}
default:
return MathGridInset::getStatus(cur, cmd, flag);
}
}
void MathCasesInset::write(WriteStream & os) const void MathCasesInset::write(WriteStream & os) const
{ {
if (os.fragile()) if (os.fragile())

View File

@ -25,6 +25,11 @@ public:
void metrics(MetricsInfo & mi, Dimension & dim) const; void metrics(MetricsInfo & mi, Dimension & dim) const;
/// ///
void draw(PainterInfo & pi, int x, int y) const; void draw(PainterInfo & pi, int x, int y) const;
///
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
///
bool getStatus(LCursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const;
/// ///
void infoize(std::ostream & os) const; void infoize(std::ostream & os) const;

View File

@ -1125,10 +1125,16 @@ bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd,
if ((type_ == "simple" if ((type_ == "simple"
|| type_ == "equation" || type_ == "equation"
|| type_ == "none") && || type_ == "none") &&
(s == "add-hline-above" || s == "add-hline-below" || (s == "add-hline-above" || s == "add-hline-below")) {
s == "add-vline-left" || s == "add-vline-right")) {
flag.message(bformat( flag.message(bformat(
N_("Can't add grid lines in '%1$s'"), N_("Can't add horizontal grid lines in '%1$s'"),
type_));
flag.enabled(false);
return true;
}
if (s == "add-vline-left" || s == "add-vline-right") {
flag.message(bformat(
N_("Can't add vertical grid lines in '%1$s'"),
type_)); type_));
flag.enabled(false); flag.enabled(false);
return true; return true;