]> git.lyx.org Git - features.git/commitdiff
Better conditioning of drawing vertical grid lines
authorMartin Vermeer <martin.vermeer@hut.fi>
Thu, 24 Mar 2005 16:26:15 +0000 (16:26 +0000)
committerMartin Vermeer <martin.vermeer@hut.fi>
Thu, 24 Mar 2005 16:26:15 +0000 (16:26 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9744 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/math_casesinset.C
src/mathed/math_casesinset.h
src/mathed/math_hullinset.C

index 7c4d353336d167a34526a6852e38f5a650584b10..9e85296406c51ad911789a25fd3d0a44fdceacf3 100644 (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>
 
        * math_hullinset.C (getStatus): intercept and suppress the
index fc1b3316282e2503228fbf399d5b13d7f7aa4522..595a3d0790908fc9dd7e21bf50ab61f8e8b7417e 100644 (file)
 #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 <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;
 
@@ -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())
index cb93c6c41a088148f49aae40795941ad76226c4d..f28776c51b72d6c2c73553ad155abd1e2404ad2b 100644 (file)
@@ -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;
index 58811da4e7bb314eab429e2916f662da336f9196..092b15decdc6b9b05577072876d7bfab41b37497 100644 (file)
@@ -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;