2001-02-16 09:25:43 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
|
* \file InsetMathFrac.h
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Alejandro Aguilar Sierra
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2007-10-25 21:53:06 +00:00
|
|
|
|
#ifndef MATH_FRAC_H
|
|
|
|
|
#define MATH_FRAC_H
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
2007-10-25 21:53:06 +00:00
|
|
|
|
#include "InsetMathNest.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
2001-02-26 12:53:35 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
|
2007-10-25 21:53:06 +00:00
|
|
|
|
class InsetMathFracBase : public InsetMathNest {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
explicit InsetMathFracBase(idx_type ncells = 2);
|
|
|
|
|
///
|
|
|
|
|
bool idxUpDown(Cursor &, bool up) const;
|
|
|
|
|
///
|
|
|
|
|
bool idxLeft(Cursor &) const { return false; }
|
|
|
|
|
///
|
|
|
|
|
bool idxRight(Cursor &) const { return false; }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-08-19 13:00:56 +00:00
|
|
|
|
/// Fraction like objects (frac, binom)
|
2006-09-16 18:11:38 +00:00
|
|
|
|
class InsetMathFrac : public InsetMathFracBase {
|
2001-02-13 13:28:32 +00:00
|
|
|
|
public:
|
|
|
|
|
///
|
2006-04-06 09:46:01 +00:00
|
|
|
|
enum Kind {
|
|
|
|
|
FRAC,
|
2006-07-19 10:50:18 +00:00
|
|
|
|
OVER,
|
2006-04-06 09:46:01 +00:00
|
|
|
|
ATOP,
|
2007-09-12 08:15:33 +00:00
|
|
|
|
NICEFRAC,
|
2007-09-15 16:39:51 +00:00
|
|
|
|
UNITFRAC,
|
2007-09-18 15:04:58 +00:00
|
|
|
|
UNIT
|
2006-04-06 09:46:01 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
///
|
2007-09-15 16:39:51 +00:00
|
|
|
|
explicit InsetMathFrac(Kind kind = FRAC, idx_type ncells = 2);
|
|
|
|
|
///
|
|
|
|
|
bool idxRight(Cursor &) const;
|
|
|
|
|
///
|
|
|
|
|
bool idxLeft(Cursor &) const;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
///
|
2007-09-21 20:39:47 +00:00
|
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
2001-04-25 15:43:57 +00:00
|
|
|
|
///
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void draw(PainterInfo &, int x, int y) const;
|
2001-11-13 18:33:48 +00:00
|
|
|
|
///
|
2003-05-28 13:22:36 +00:00
|
|
|
|
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
|
2002-03-19 16:55:58 +00:00
|
|
|
|
///
|
2002-03-21 06:57:13 +00:00
|
|
|
|
void drawT(TextPainter &, int x, int y) const;
|
2002-08-08 16:08:11 +00:00
|
|
|
|
/// identifies FracInsets
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathFrac * asFracInset();
|
2002-08-08 16:08:11 +00:00
|
|
|
|
/// identifies FracInsets
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathFrac const * asFracInset() const;
|
2002-08-01 15:53:46 +00:00
|
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
|
docstring name() const;
|
2006-07-16 17:19:05 +00:00
|
|
|
|
///
|
|
|
|
|
bool extraBraces() const;
|
2001-11-09 08:35:57 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
void write(WriteStream & os) const;
|
|
|
|
|
///
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void maple(MapleStream &) const;
|
2001-11-07 17:30:26 +00:00
|
|
|
|
///
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void mathematica(MathematicaStream &) const;
|
2002-07-01 11:17:14 +00:00
|
|
|
|
///
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void octave(OctaveStream &) const;
|
2002-04-25 15:37:10 +00:00
|
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void mathmlize(MathStream &) const;
|
2006-04-06 09:46:01 +00:00
|
|
|
|
///
|
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
2001-08-17 17:50:00 +00:00
|
|
|
|
public:
|
2007-10-25 21:53:06 +00:00
|
|
|
|
Inset * clone() const;
|
2001-08-17 17:50:00 +00:00
|
|
|
|
///
|
2006-04-06 09:46:01 +00:00
|
|
|
|
Kind kind_;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
};
|
2001-02-16 09:25:43 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
2007-10-25 21:53:06 +00:00
|
|
|
|
/// \dfrac support
|
|
|
|
|
class InsetMathDFrac : public InsetMathFrac {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
InsetMathDFrac() {}
|
|
|
|
|
///
|
|
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
|
|
|
|
///
|
|
|
|
|
void draw(PainterInfo &, int x, int y) const;
|
|
|
|
|
///
|
|
|
|
|
docstring name() const;
|
|
|
|
|
///
|
|
|
|
|
void mathmlize(MathStream &) const;
|
|
|
|
|
///
|
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
|
|
|
|
private:
|
|
|
|
|
Inset * clone() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// \tfrac support
|
|
|
|
|
class InsetMathTFrac : public InsetMathFrac {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
InsetMathTFrac() {}
|
|
|
|
|
///
|
|
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
|
|
|
|
///
|
|
|
|
|
void draw(PainterInfo &, int x, int y) const;
|
|
|
|
|
///
|
|
|
|
|
docstring name() const;
|
|
|
|
|
///
|
|
|
|
|
void mathmlize(MathStream &) const;
|
|
|
|
|
///
|
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
|
|
|
|
private:
|
|
|
|
|
Inset * clone() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Binom like objects
|
|
|
|
|
class InsetMathBinom : public InsetMathFracBase {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
explicit InsetMathBinom(bool choose = false);
|
|
|
|
|
///
|
|
|
|
|
void write(WriteStream & os) const;
|
|
|
|
|
///
|
|
|
|
|
void normalize(NormalStream &) const;
|
|
|
|
|
///
|
|
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
|
|
|
|
///
|
|
|
|
|
void draw(PainterInfo &, int x, int y) const;
|
|
|
|
|
/// draw decorations.
|
|
|
|
|
void drawDecoration(PainterInfo & pi, int x, int y) const
|
|
|
|
|
{ drawMarkers2(pi, x, y); }
|
|
|
|
|
///
|
|
|
|
|
bool extraBraces() const;
|
|
|
|
|
private:
|
|
|
|
|
Inset * clone() const;
|
|
|
|
|
///
|
|
|
|
|
int dw(int height) const;
|
|
|
|
|
///
|
|
|
|
|
bool choose_;
|
|
|
|
|
};
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
2007-10-28 21:48:51 +00:00
|
|
|
|
/// \dbinom support
|
|
|
|
|
class InsetMathDBinom : public InsetMathFracBase {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
InsetMathDBinom() {}
|
|
|
|
|
///
|
|
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
|
|
|
|
///
|
|
|
|
|
void draw(PainterInfo &, int x, int y) const;
|
|
|
|
|
///
|
|
|
|
|
docstring name() const;
|
|
|
|
|
///
|
|
|
|
|
void mathmlize(MathStream &) const;
|
|
|
|
|
///
|
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
|
|
|
|
private:
|
|
|
|
|
Inset * clone() const;
|
|
|
|
|
///
|
|
|
|
|
int dw(int height) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// \tbinom support
|
|
|
|
|
class InsetMathTBinom : public InsetMathFracBase {
|
|
|
|
|
public:
|
|
|
|
|
///
|
|
|
|
|
InsetMathTBinom() {}
|
|
|
|
|
///
|
|
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
|
|
|
|
///
|
|
|
|
|
void draw(PainterInfo &, int x, int y) const;
|
|
|
|
|
///
|
|
|
|
|
docstring name() const;
|
|
|
|
|
///
|
|
|
|
|
void mathmlize(MathStream &) const;
|
|
|
|
|
///
|
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
|
|
|
|
private:
|
|
|
|
|
Inset * clone() const;
|
|
|
|
|
///
|
|
|
|
|
int dw(int height) const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
} // namespace lyx
|
2007-10-25 21:53:06 +00:00
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
#endif
|