From e5fed66b3b96e9bc448c2e53e4ceb36b7d50481c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 14 Feb 2002 12:38:02 +0000 Subject: [PATCH] inactive new stuff to re-sync my tree before going on holyday git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3535 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/Makefile.am | 2 ++ src/mathed/math_biginset.C | 68 ++++++++++++++++++++++++++++++++++++ src/mathed/math_biginset.h | 43 +++++++++++++++++++++++ src/mathed/math_deliminset.C | 28 +++------------ src/mathed/math_deliminset.h | 4 +-- src/mathed/math_support.C | 21 +++++++++++ src/mathed/math_support.h | 1 + 7 files changed, 140 insertions(+), 27 deletions(-) create mode 100644 src/mathed/math_biginset.C create mode 100644 src/mathed/math_biginset.h diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index 4849bff9f6..d08baff33a 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -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 index 0000000000..896310a9a1 --- /dev/null +++ b/src/mathed/math_biginset.C @@ -0,0 +1,68 @@ +#include + +#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 index 0000000000..a82cd31e0c --- /dev/null +++ b/src/mathed/math_biginset.h @@ -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 diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index 882f8cb165..952318be26 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -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) << ']'; } diff --git a/src/mathed/math_deliminset.h b/src/mathed/math_deliminset.h index 16ff2f20d3..c96ffa5924 100644 --- a/src/mathed/math_deliminset.h +++ b/src/mathed/math_deliminset.h @@ -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 diff --git a/src/mathed/math_support.C b/src/mathed/math_support.C index 45facff9de..b19eeab53a 100644 --- a/src/mathed/math_support.C +++ b/src/mathed/math_support.C @@ -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 + " "; +} + + diff --git a/src/mathed/math_support.h b/src/mathed/math_support.h index 5be27bc06d..ba2d711c80 100644 --- a/src/mathed/math_support.h +++ b/src/mathed/math_support.h @@ -59,5 +59,6 @@ void smallerStyleFrac(MathMetricsInfo & st); char const * math_font_name(MathTextCodes type); +string convertDelimToLatexName(string const & name); #endif -- 2.39.2