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
This commit is contained in:
André Pönitz 2002-02-14 12:38:02 +00:00
parent e18db30e3c
commit e5fed66b3b
7 changed files with 140 additions and 27 deletions

View 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 \

View File

@ -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_ << ']';
}

View File

@ -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

View 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) << ']';
}

View 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

View 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 + " ";
}

View File

@ -59,5 +59,6 @@ void smallerStyleFrac(MathMetricsInfo & st);
char const * math_font_name(MathTextCodes type);
string convertDelimToLatexName(string const & name);
#endif