2001-06-25 00:06:33 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
#ifndef MATH_GRID_H
|
|
|
|
|
#define MATH_GRID_H
|
|
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
|
#include "math_nestinset.h"
|
2001-08-10 11:51:06 +00:00
|
|
|
|
#include "vspace.h"
|
2001-08-09 09:19:18 +00:00
|
|
|
|
#include "LString.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
*/
|
|
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
|
class MathGridInset : public MathNestInset {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
/// additional per-row information
|
|
|
|
|
struct RowInfo {
|
|
|
|
|
///
|
|
|
|
|
RowInfo();
|
2001-08-10 12:12:03 +00:00
|
|
|
|
///
|
|
|
|
|
int skipPixels() const;
|
2001-08-06 17:20:26 +00:00
|
|
|
|
/// cached descent
|
|
|
|
|
mutable int descent_;
|
|
|
|
|
/// cached ascent
|
|
|
|
|
mutable int ascent_;
|
|
|
|
|
/// cached offset
|
|
|
|
|
mutable int offset_;
|
|
|
|
|
/// hline abow this row?
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool upperline_;
|
2001-08-06 17:20:26 +00:00
|
|
|
|
/// hline below this row?
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool lowerline_;
|
2001-08-10 11:51:06 +00:00
|
|
|
|
/// distance
|
|
|
|
|
LyXLength skip_;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// additional per-row information
|
|
|
|
|
struct ColInfo {
|
|
|
|
|
///
|
|
|
|
|
ColInfo();
|
2001-09-04 13:32:06 +00:00
|
|
|
|
/// currently possible: 'l', 'c', 'r'
|
|
|
|
|
char align_;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
/// cache for drawing
|
|
|
|
|
int h_offset;
|
2001-08-06 17:20:26 +00:00
|
|
|
|
/// cached width
|
|
|
|
|
mutable int width_;
|
|
|
|
|
/// cached offset
|
|
|
|
|
mutable int offset_;
|
2001-09-04 13:32:06 +00:00
|
|
|
|
/// do we need a line to the left?
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool leftline_;
|
2001-09-04 13:32:06 +00:00
|
|
|
|
/// do we need a line to the right?
|
2001-06-25 00:06:33 +00:00
|
|
|
|
bool rightline_;
|
2001-09-04 13:32:06 +00:00
|
|
|
|
/// additional amount to be skipped when drawing
|
|
|
|
|
int skip_;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
MathGridInset(unsigned int m, unsigned int n);
|
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-08-06 17:20:26 +00:00
|
|
|
|
void metrics(MathStyles st) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-08-06 17:20:26 +00:00
|
|
|
|
void draw(Painter &, int x, int y) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
void halign(string const &);
|
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
void halign(char c, unsigned int col);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
char halign(unsigned int col) const;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
///
|
2001-06-25 00:06:33 +00:00
|
|
|
|
void valign(char c);
|
|
|
|
|
///
|
2001-06-27 14:10:35 +00:00
|
|
|
|
char valign() const;
|
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
void vskip(LyXLength const &, unsigned int row);
|
2001-08-10 11:51:06 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
LyXLength vskip(unsigned int row) const;
|
2001-08-10 11:51:06 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
void resize(short int type, unsigned int cols);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
const RowInfo & rowinfo(unsigned int row) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
RowInfo & rowinfo(unsigned int row);
|
2001-08-01 13:28:45 +00:00
|
|
|
|
///
|
|
|
|
|
bool isGrid() const { return true; }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
unsigned int ncols() const { return colinfo_.size(); }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
unsigned int nrows() const { return rowinfo_.size(); }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
unsigned int col(unsigned int idx) const { return idx % ncols(); }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
unsigned int row(unsigned int idx) const { return idx / ncols(); }
|
2001-08-08 09:31:36 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
int cellXOffset(unsigned int idx) const;
|
2001-08-08 09:31:36 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
int cellYOffset(unsigned int idx) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
bool idxUp(unsigned int &, unsigned int &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
bool idxDown(unsigned int &, unsigned int &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
bool idxLeft(unsigned int &, unsigned int &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
bool idxRight(unsigned int &, unsigned int &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
bool idxFirst(unsigned int &, unsigned int &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
bool idxLast(unsigned int &, unsigned int &) const;
|
2001-07-09 16:59:57 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
void idxDelete(unsigned int &, bool &, bool &);
|
2001-07-16 15:53:25 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
void idxDeleteRange(unsigned int, unsigned int);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
void addRow(unsigned int);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
void delRow(unsigned int);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
void addCol(unsigned int);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
void delCol(unsigned int);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
virtual void appendRow();
|
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
unsigned int index(unsigned int row, unsigned int col) const;
|
2001-07-16 15:53:25 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
std::vector<unsigned int> idxBetween(unsigned int from, unsigned int to) const;
|
2001-09-04 13:32:06 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
virtual int defaultColSpace(unsigned int) { return 10; }
|
2001-09-04 13:32:06 +00:00
|
|
|
|
///
|
2001-09-26 15:20:45 +00:00
|
|
|
|
virtual char defaultColAlign(unsigned int) { return 'c'; }
|
2001-09-05 12:57:13 +00:00
|
|
|
|
///
|
|
|
|
|
void setDefaults();
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2001-07-06 12:09:32 +00:00
|
|
|
|
protected:
|
2001-08-10 10:39:56 +00:00
|
|
|
|
/// returns proper 'end of line' code for LaTeX
|
2001-09-26 15:20:45 +00:00
|
|
|
|
string eolString(unsigned int row) const;
|
2001-08-10 10:39:56 +00:00
|
|
|
|
/// returns proper 'end of column' code for LaTeX
|
2001-09-26 15:20:45 +00:00
|
|
|
|
string eocString(unsigned int col) const;
|
2001-08-10 10:39:56 +00:00
|
|
|
|
|
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
|