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
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2009-04-04 11:33:13 +00:00
|
|
|
* \author Uwe Stöhr
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
InsetMathFracBase(Buffer * buf, idx_type ncells = 2);
|
2007-10-25 21:53:06 +00:00
|
|
|
///
|
2020-12-02 15:13:32 +00:00
|
|
|
marker_type marker(BufferView const *) const override { return marker_type::MARKER2; }
|
2017-06-14 13:38:47 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool idxUpDown(Cursor &, bool up) const override;
|
2007-10-25 21:53:06 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool idxBackward(Cursor &) const override { return false; }
|
2007-10-25 21:53:06 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool idxForward(Cursor &) const override { return false; }
|
2015-06-14 16:10:29 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetMathFracBase * asFracBaseInset() override { return this; }
|
2015-06-14 16:10:29 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetMathFracBase const * asFracBaseInset() const override { return this; }
|
2007-10-25 21:53:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
2009-04-05 19:52:53 +00:00
|
|
|
CFRAC,
|
2009-04-06 23:58:42 +00:00
|
|
|
CFRACLEFT,
|
|
|
|
CFRACRIGHT,
|
2009-04-05 19:52:53 +00:00
|
|
|
DFRAC,
|
|
|
|
TFRAC,
|
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
|
|
|
};
|
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
explicit InsetMathFrac(Buffer * buf, Kind kind = FRAC, idx_type ncells = 2);
|
2007-09-15 16:39:51 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool idxForward(Cursor &) const override;
|
2007-09-15 16:39:51 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool idxBackward(Cursor &) const override;
|
2001-02-13 13:28:32 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
MathClass mathClass() const override;
|
2016-05-30 08:33:35 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const override;
|
2001-04-25 15:43:57 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void draw(PainterInfo &, int x, int y) const override;
|
2001-11-13 18:33:48 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const override;
|
2002-03-19 16:55:58 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void drawT(TextPainter &, int x, int y) const override;
|
2002-08-08 16:08:11 +00:00
|
|
|
/// identifies FracInsets
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetMathFrac * asFracInset() override;
|
2002-08-08 16:08:11 +00:00
|
|
|
/// identifies FracInsets
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetMathFrac const * asFracInset() const override;
|
2002-08-01 15:53:46 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
docstring name() const override;
|
2006-07-16 17:19:05 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool extraBraces() const override;
|
2001-11-09 08:35:57 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void write(WriteStream & os) const override;
|
2001-11-09 08:35:57 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void maple(MapleStream &) const override;
|
2001-11-07 17:30:26 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void mathematica(MathematicaStream &) const override;
|
2002-07-01 11:17:14 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void octave(OctaveStream &) const override;
|
2002-04-25 15:37:10 +00:00
|
|
|
///
|
2020-12-26 19:02:46 +00:00
|
|
|
void mathmlize(MathMLStream &) const override;
|
2006-04-06 09:46:01 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void htmlize(HtmlStream &) const override;
|
2010-03-30 02:03:45 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void validate(LaTeXFeatures & features) const override;
|
2016-11-20 19:35:02 +00:00
|
|
|
private:
|
|
|
|
/// vertical displacement
|
|
|
|
int dy(FontInfo & fi) const;
|
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
Inset * clone() const override;
|
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
|
|
|
|
2009-02-28 02:43:26 +00:00
|
|
|
|
2007-10-25 21:53:06 +00:00
|
|
|
/// Binom like objects
|
|
|
|
class InsetMathBinom : public InsetMathFracBase {
|
|
|
|
public:
|
|
|
|
///
|
2008-03-31 01:23:25 +00:00
|
|
|
enum Kind {
|
|
|
|
BINOM,
|
2009-04-05 19:52:53 +00:00
|
|
|
DBINOM,
|
|
|
|
TBINOM,
|
2008-03-31 01:23:25 +00:00
|
|
|
CHOOSE,
|
|
|
|
BRACE,
|
|
|
|
BRACK
|
|
|
|
};
|
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
explicit InsetMathBinom(Buffer * buf, Kind kind = BINOM);
|
2007-10-25 21:53:06 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void write(WriteStream & os) const override;
|
2007-10-25 21:53:06 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void normalize(NormalStream &) const override;
|
2016-05-30 08:33:35 +00:00
|
|
|
/// Generalized fractions are of inner class (see The TeXbook, p.292)
|
2020-10-01 07:42:11 +00:00
|
|
|
MathClass mathClass() const override { return MC_INNER; }
|
2007-10-25 21:53:06 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const override;
|
2007-10-25 21:53:06 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void draw(PainterInfo &, int x, int y) const override;
|
2007-10-25 21:53:06 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
bool extraBraces() const override;
|
2008-03-31 01:23:25 +00:00
|
|
|
///
|
2020-12-26 19:02:46 +00:00
|
|
|
void mathmlize(MathMLStream &) const override;
|
2007-10-28 21:48:51 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void htmlize(HtmlStream &) const override;
|
2010-03-31 21:33:33 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
void validate(LaTeXFeatures & features) const override;
|
2009-07-16 19:00:24 +00:00
|
|
|
///
|
2020-10-01 07:42:11 +00:00
|
|
|
InsetCode lyxCode() const override { return MATH_FRAC_CODE; }
|
2007-10-28 21:48:51 +00:00
|
|
|
private:
|
2020-10-01 07:42:11 +00:00
|
|
|
Inset * clone() const override;
|
2007-10-28 21:48:51 +00:00
|
|
|
///
|
|
|
|
int dw(int height) const;
|
|
|
|
///
|
2009-04-05 19:52:53 +00:00
|
|
|
Kind kind_;
|
2007-10-28 21:48:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-04-05 19:52:53 +00:00
|
|
|
|
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
|