From 1506064b51f02024102992f1feda8835dd413db1 Mon Sep 17 00:00:00 2001 From: Martin Vermeer Date: Thu, 24 Mar 2005 16:26:15 +0000 Subject: [PATCH] Better conditioning of drawing vertical grid lines git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9744 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 6 ++++ src/mathed/math_casesinset.C | 59 ++++++++++++++++++++++++++++++++++++ src/mathed/math_casesinset.h | 5 +++ src/mathed/math_hullinset.C | 12 ++++++-- 4 files changed, 79 insertions(+), 3 deletions(-) diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 7c4d353336..9e85296406 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,4 +1,10 @@ +2005-03-24 Martin Vermeer + + * math_hullinset.C: + * math_casesinset.[Ch]: more precise conditioning of + output of vertical grid lines + 2005-03-22 Martin Vermeer * math_hullinset.C (getStatus): intercept and suppress the diff --git a/src/mathed/math_casesinset.C b/src/mathed/math_casesinset.C index fc1b331628..595a3d0790 100644 --- a/src/mathed/math_casesinset.C +++ b/src/mathed/math_casesinset.C @@ -14,8 +14,26 @@ #include "math_data.h" #include "math_mathmlstream.h" #include "math_support.h" +#include "FuncStatus.h" #include "LaTeXFeatures.h" #include "support/std_ostream.h" +#include "cursor.h" +#include "funcrequest.h" +#include "gettext.h" +#include "undo.h" + +#include "support/lstrings.h" + +#include + +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; @@ -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 { if (os.fragile()) diff --git a/src/mathed/math_casesinset.h b/src/mathed/math_casesinset.h index cb93c6c41a..f28776c51b 100644 --- a/src/mathed/math_casesinset.h +++ b/src/mathed/math_casesinset.h @@ -25,6 +25,11 @@ public: void metrics(MetricsInfo & mi, Dimension & dim) 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; diff --git a/src/mathed/math_hullinset.C b/src/mathed/math_hullinset.C index 58811da4e7..092b15decd 100644 --- a/src/mathed/math_hullinset.C +++ b/src/mathed/math_hullinset.C @@ -1125,10 +1125,16 @@ bool MathHullInset::getStatus(LCursor & cur, FuncRequest const & cmd, if ((type_ == "simple" || type_ == "equation" || type_ == "none") && - (s == "add-hline-above" || s == "add-hline-below" || - s == "add-vline-left" || s == "add-vline-right")) { + (s == "add-hline-above" || s == "add-hline-below")) { 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_)); flag.enabled(false); return true; -- 2.39.2