]> git.lyx.org Git - features.git/commitdiff
inactive new stuff to re-sync my tree before going on holyday
authorAndré Pönitz <poenitz@gmx.net>
Thu, 14 Feb 2002 12:38:02 +0000 (12:38 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 14 Feb 2002 12:38:02 +0000 (12:38 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3535 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/Makefile.am
src/mathed/math_biginset.C [new file with mode: 0644]
src/mathed/math_biginset.h [new file with mode: 0644]
src/mathed/math_deliminset.C
src/mathed/math_deliminset.h
src/mathed/math_support.C
src/mathed/math_support.h

index 4849bff9f6ebbfd2cba68e0dc5d41c0849a6c6d8..d08baff33aece6b4d83fa0f0073b321075c52206 100644 (file)
@@ -20,6 +20,8 @@ libmathed_la_SOURCES = \
        math_arrayinset.h \
        math_atom.C \
        math_atom.h \
+       math_biginset.C \
+       math_biginset.h \
        math_binominset.C \
        math_binominset.h \
        math_braceinset.C \
diff --git a/src/mathed/math_biginset.C b/src/mathed/math_biginset.C
new file mode 100644 (file)
index 0000000..896310a
--- /dev/null
@@ -0,0 +1,68 @@
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_biginset.h"
+#include "math_support.h"
+#include "math_parser.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+
+
+MathBigInset::MathBigInset(string const & name, string const & delim)
+       : name_(name), delim_(delim)
+{}
+
+
+MathInset * MathBigInset::clone() const
+{   
+       return new MathBigInset(*this);
+}
+
+
+int MathBigInset::size() const
+{
+       return name_.size() - 4;
+}
+
+
+double MathBigInset::increase() const
+{
+       switch (size()) {
+               case 1:  return 0.2;
+               case 2:  return 0.44;
+               case 3:  return 0.7;
+               default: return 0.0;
+       }
+       return 0.0;
+}
+
+
+void MathBigInset::metrics(MathMetricsInfo const & mi) const
+{
+       double h = mathed_char_height(LM_TC_VAR, mi, 'I', ascent_, descent_);  
+       double f = increase();
+       width_   = 6;
+       ascent_  = int(h + f * h);
+       descent_ = int(f * h);
+}
+
+
+void MathBigInset::draw(Painter & pain, int x, int y) const
+{ 
+       mathed_draw_deco(pain, x + 1, y - ascent_, 4, height(), delim_);
+}
+
+
+void MathBigInset::write(WriteStream & os) const
+{
+       os << '\\' << name_ << ' ' << delim_;
+}
+
+
+void MathBigInset::normalize(NormalStream & os) const
+{
+       os << "[" << name_ << ' ' <<  delim_ << ']';
+}
diff --git a/src/mathed/math_biginset.h b/src/mathed/math_biginset.h
new file mode 100644 (file)
index 0000000..a82cd31
--- /dev/null
@@ -0,0 +1,43 @@
+// -*- C++ -*-
+#ifndef MATH_BIGINSET_H
+#define MATH_BIGINSET_H
+
+#include "math_diminset.h"
+#include "LString.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** Inset for \bigl & Co.
+    \author André Pönitz
+ */
+
+class MathBigInset : public MathDimInset {
+public:
+       ///
+       MathBigInset(string const & name, string const & delim);
+       ///
+       MathInset * clone() const;
+       ///
+       void draw(Painter &, int x, int y) const;
+       ///
+       void write(WriteStream & os) const;
+       ///
+       void metrics(MathMetricsInfo const & st) const;
+       ///
+       void normalize(NormalStream & os) const;
+
+private:
+       ///
+       int size() const;
+       ///
+       double increase() const;
+       
+       /// \bigl or what?
+       string const name_;
+       /// ( or [ or Vert...
+       string const delim_;
+};
+
+#endif
index 882f8cb16576602ac0dbe6fb9d9c2fc704e52c31..952318be26b88c02968ae65caf8dfc976bd73747 100644 (file)
@@ -23,37 +23,17 @@ MathInset * MathDelimInset::clone() const
 }
 
 
-string MathDelimInset::latexName(string const & name)
-{
-       if (name == "(")
-               return name;
-       if (name == "[")
-               return name;
-       if (name == ".")
-               return name;
-       if (name == ")")
-               return name;
-       if (name == "]")
-               return name;
-       if (name == "/")
-               return name;
-       if (name == "|")
-               return name;
-       return "\\" + name + " ";
-}
-
-
 void MathDelimInset::write(WriteStream & os) const
 {
-       os << "\\left" << latexName(left_) << cell(0)
-          << "\\right" << latexName(right_);
+       os << "\\left" << convertDelimToLatexName(left_) << cell(0)
+          << "\\right" << convertDelimToLatexName(right_);
 }
 
 
 void MathDelimInset::normalize(NormalStream & os) const
 {
-       os << "[delim " << latexName(left_) << ' '
-          << latexName(right_) << ' ' << cell(0) << ']';
+       os << "[delim " << convertDelimToLatexName(left_) << ' '
+          << convertDelimToLatexName(right_) << ' ' << cell(0) << ']';
 }
 
 
index 16ff2f20d362cc9e74ed43b64751a01b324a2675..c96ffa5924cb30ce63916d5919271b66c7b54391 100644 (file)
@@ -16,7 +16,7 @@
 class MathDelimInset : public MathNestInset {
 public:
        ///
-       MathDelimInset(string const &, string const &);
+       MathDelimInset(string const & left, string const & right);
        ///
        MathInset * clone() const;
        ///
@@ -51,7 +51,5 @@ public:
 private:
        ///
        int dw() const;
-       ///
-       static string latexName(string const & name);
 };
 #endif
index 45facff9de719d845e5c98f8b7603f16247a3b2a..b19eeab53a14799344383825d634ff516a9218ac 100644 (file)
@@ -812,3 +812,24 @@ char const * math_font_name(MathTextCodes code)
                return theFontNames[code - LM_TC_RM];
        return 0;
 }
+
+string convertDelimToLatexName(string const & name)
+{
+       if (name == "(")
+               return name;
+       if (name == "[")
+               return name;
+       if (name == ".")
+               return name;
+       if (name == ")")
+               return name;
+       if (name == "]")
+               return name;
+       if (name == "/")
+               return name;
+       if (name == "|")
+               return name;
+       return "\\" + name + " ";
+}
+
+
index 5be27bc06d1edbbd487e079f0cd8a9b4d6083569..ba2d711c80a5649ca2dbbebc3b2860562b53f714 100644 (file)
@@ -59,5 +59,6 @@ void smallerStyleFrac(MathMetricsInfo & st);
 
 char const * math_font_name(MathTextCodes type);
 
+string convertDelimToLatexName(string const & name);
 
 #endif