2001-06-25 00:06:33 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
#ifndef MATH_GRID_H
|
|
|
|
|
#define MATH_GRID_H
|
|
|
|
|
|
|
|
|
|
#include "math_inset.h"
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma interface
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/** Gridded math inset base class.
|
|
|
|
|
This is the base to all grid-like editable math objects
|
|
|
|
|
like array and eqnarray.
|
|
|
|
|
\author Andr<EFBFBD> P<EFBFBD>nitz 2001
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class MathGridInset : public MathInset {
|
|
|
|
|
|
|
|
|
|
/// additional per-row information
|
|
|
|
|
struct RowInfo {
|
|
|
|
|
///
|
|
|
|
|
RowInfo();
|
|
|
|
|
///
|
|
|
|
|
int descent_;
|
|
|
|
|
///
|
|
|
|
|
int ascent_;
|
|
|
|
|
///
|
|
|
|
|
int offset_;
|
|
|
|
|
///
|
|
|
|
|
bool upperline_;
|
|
|
|
|
///
|
|
|
|
|
bool lowerline_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// additional per-row information
|
|
|
|
|
struct ColInfo {
|
|
|
|
|
///
|
|
|
|
|
ColInfo();
|
|
|
|
|
///
|
|
|
|
|
char h_align_;
|
|
|
|
|
/// cache for drawing
|
|
|
|
|
int h_offset;
|
|
|
|
|
///
|
|
|
|
|
int width_;
|
|
|
|
|
///
|
|
|
|
|
int offset_;
|
|
|
|
|
///
|
|
|
|
|
bool leftline_;
|
|
|
|
|
///
|
|
|
|
|
bool rightline_;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
///
|
2001-06-27 14:10:35 +00:00
|
|
|
|
MathGridInset(int m, int n, string const & nm, MathInsetTypes ot);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
virtual MathInset * clone() const = 0;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-07-26 06:56:43 +00:00
|
|
|
|
void write(std::ostream &, bool fragile) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-07-26 06:56:43 +00:00
|
|
|
|
void metrics(MathStyles st);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
void draw(Painter &, int, int);
|
|
|
|
|
///
|
|
|
|
|
void halign(string const &);
|
|
|
|
|
///
|
|
|
|
|
void halign(char c, int col);
|
|
|
|
|
///
|
2001-06-27 14:10:35 +00:00
|
|
|
|
char halign(int col) const;
|
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void valign(char c);
|
|
|
|
|
///
|
2001-06-27 14:10:35 +00:00
|
|
|
|
char valign() const;
|
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void resize(short int type, int cols);
|
|
|
|
|
///
|
|
|
|
|
const RowInfo & rowinfo(int row) const;
|
|
|
|
|
///
|
|
|
|
|
RowInfo & rowinfo(int row);
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
int ncols() const { return colinfo_.size(); }
|
|
|
|
|
///
|
|
|
|
|
int nrows() const { return rowinfo_.size(); }
|
|
|
|
|
///
|
|
|
|
|
int col(int idx) const { return idx % ncols(); }
|
|
|
|
|
///
|
|
|
|
|
int row(int idx) const { return idx / ncols(); }
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
bool idxUp(int &, int &) const;
|
|
|
|
|
///
|
|
|
|
|
bool idxDown(int &, int &) const;
|
|
|
|
|
///
|
|
|
|
|
bool idxLeft(int &, int &) const;
|
|
|
|
|
///
|
|
|
|
|
bool idxRight(int &, int &) const;
|
|
|
|
|
///
|
|
|
|
|
bool idxFirst(int &, int &) const;
|
|
|
|
|
///
|
|
|
|
|
bool idxLast(int &, int &) const;
|
2001-07-09 16:59:57 +00:00
|
|
|
|
///
|
|
|
|
|
void idxDelete(int &, bool &, bool &);
|
2001-07-16 15:53:25 +00:00
|
|
|
|
///
|
|
|
|
|
void idxDeleteRange(int, int);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
void addRow(int);
|
|
|
|
|
///
|
|
|
|
|
void delRow(int);
|
|
|
|
|
///
|
|
|
|
|
void addCol(int);
|
|
|
|
|
///
|
|
|
|
|
void delCol(int);
|
|
|
|
|
///
|
|
|
|
|
virtual void appendRow();
|
|
|
|
|
///
|
|
|
|
|
int index(int row, int col) const;
|
2001-07-16 15:53:25 +00:00
|
|
|
|
///
|
|
|
|
|
std::vector<int> idxBetween(int from, int to) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2001-07-06 12:09:32 +00:00
|
|
|
|
protected:
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/// row info
|
|
|
|
|
std::vector<RowInfo> rowinfo_;
|
|
|
|
|
/// column info
|
|
|
|
|
std::vector<ColInfo> colinfo_;
|
|
|
|
|
///
|
|
|
|
|
char v_align_; // add approp. type
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|