mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 13:46:43 +00:00
8b7b3a5895
- make all cache variables mutable, remove const_casts git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2426 a592a061-630c-0410-9148-cb99ea01b6c8
132 lines
2.3 KiB
C++
132 lines
2.3 KiB
C++
// -*- C++ -*-
|
|
#ifndef MATH_GRID_H
|
|
#define MATH_GRID_H
|
|
|
|
#include "math_nestinset.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é Pönitz 2001
|
|
*/
|
|
|
|
class MathGridInset : public MathNestInset {
|
|
|
|
/// additional per-row information
|
|
struct RowInfo {
|
|
///
|
|
RowInfo();
|
|
/// cached descent
|
|
mutable int descent_;
|
|
/// cached ascent
|
|
mutable int ascent_;
|
|
/// cached offset
|
|
mutable int offset_;
|
|
/// hline abow this row?
|
|
bool upperline_;
|
|
/// hline below this row?
|
|
bool lowerline_;
|
|
};
|
|
|
|
// additional per-row information
|
|
struct ColInfo {
|
|
///
|
|
ColInfo();
|
|
///
|
|
char h_align_;
|
|
/// cache for drawing
|
|
int h_offset;
|
|
/// cached width
|
|
mutable int width_;
|
|
/// cached offset
|
|
mutable int offset_;
|
|
///
|
|
bool leftline_;
|
|
///
|
|
bool rightline_;
|
|
};
|
|
|
|
public:
|
|
///
|
|
MathGridInset(int m, int n, string const & nm);
|
|
///
|
|
void write(std::ostream &, bool fragile) const;
|
|
///
|
|
void metrics(MathStyles st) const;
|
|
///
|
|
void draw(Painter &, int x, int y) const;
|
|
///
|
|
void halign(string const &);
|
|
///
|
|
void halign(char c, int col);
|
|
///
|
|
char halign(int col) const;
|
|
///
|
|
void valign(char c);
|
|
///
|
|
char valign() const;
|
|
///
|
|
void resize(short int type, int cols);
|
|
///
|
|
const RowInfo & rowinfo(int row) const;
|
|
///
|
|
RowInfo & rowinfo(int row);
|
|
///
|
|
bool isGrid() const { return true; }
|
|
|
|
///
|
|
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 idxDelete(int &, bool &, bool &);
|
|
///
|
|
void idxDeleteRange(int, int);
|
|
|
|
///
|
|
void addRow(int);
|
|
///
|
|
void delRow(int);
|
|
///
|
|
void addCol(int);
|
|
///
|
|
void delCol(int);
|
|
///
|
|
virtual void appendRow();
|
|
///
|
|
int index(int row, int col) const;
|
|
///
|
|
std::vector<int> idxBetween(int from, int to) const;
|
|
|
|
protected:
|
|
/// row info
|
|
std::vector<RowInfo> rowinfo_;
|
|
/// column info
|
|
std::vector<ColInfo> colinfo_;
|
|
///
|
|
char v_align_; // add approp. type
|
|
};
|
|
|
|
#endif
|