mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-09-22 16:04:07 +00:00
123 lines
2.0 KiB
C
123 lines
2.0 KiB
C
|
// -*- 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:
|
|||
|
///
|
|||
|
MathGridInset(int m, int n, string const & nm, short ot);
|
|||
|
///
|
|||
|
MathInset * Clone() const = 0;
|
|||
|
///
|
|||
|
void Write(std::ostream &, bool fragile) const;
|
|||
|
///
|
|||
|
void Metrics(MathStyles st);
|
|||
|
///
|
|||
|
void draw(Painter &, int, int);
|
|||
|
///
|
|||
|
void halign(string const &);
|
|||
|
///
|
|||
|
void halign(char c, int col);
|
|||
|
///
|
|||
|
void valign(char c);
|
|||
|
///
|
|||
|
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;
|
|||
|
|
|||
|
///
|
|||
|
void addRow(int);
|
|||
|
///
|
|||
|
void delRow(int);
|
|||
|
///
|
|||
|
void addCol(int);
|
|||
|
///
|
|||
|
void delCol(int);
|
|||
|
///
|
|||
|
virtual void appendRow();
|
|||
|
|
|||
|
protected:
|
|||
|
///
|
|||
|
int index(int row, int col) const;
|
|||
|
|
|||
|
/// row info
|
|||
|
std::vector<RowInfo> rowinfo_;
|
|||
|
/// column info
|
|||
|
std::vector<ColInfo> colinfo_;
|
|||
|
///
|
|||
|
char v_align_; // add approp. type
|
|||
|
};
|
|||
|
|
|||
|
#endif
|