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_;
|
2001-11-28 13:09:40 +00:00
|
|
|
|
/// how many hlines above this row?
|
|
|
|
|
int lines_;
|
|
|
|
|
/// parameter to the line break
|
|
|
|
|
LyXLength crskip_;
|
|
|
|
|
/// extra distance between lines
|
|
|
|
|
int 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-11-28 13:09:40 +00:00
|
|
|
|
/// how many lines to the left of this column?
|
|
|
|
|
int lines_;
|
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-11-28 13:09:40 +00:00
|
|
|
|
/// constructor from columns description, creates one row
|
|
|
|
|
MathGridInset(char valign, string const & halign);
|
2001-09-26 16:52:34 +00:00
|
|
|
|
/// Note: columns first!
|
|
|
|
|
MathGridInset(col_type m, row_type n);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-11-12 16:45:09 +00:00
|
|
|
|
MathGridInset(col_type m, row_type n, char valign, string const & halign);
|
2001-10-12 12:02:49 +00:00
|
|
|
|
///
|
2001-10-19 11:25:48 +00:00
|
|
|
|
void metrics(MathMetricsInfo const & 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 16:52:34 +00:00
|
|
|
|
void halign(char c, col_type col);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
char halign(col_type col) const;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
///
|
2001-11-28 13:09:40 +00:00
|
|
|
|
string halign() 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-11-28 13:09:40 +00:00
|
|
|
|
void vcrskip(LyXLength const &, row_type row);
|
2001-08-10 11:51:06 +00:00
|
|
|
|
///
|
2001-11-28 13:09:40 +00:00
|
|
|
|
LyXLength vcrskip(row_type row) const;
|
2001-08-10 11:51:06 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
void resize(short int type, col_type cols);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
const RowInfo & rowinfo(row_type row) const;
|
2001-11-28 13:09:40 +00:00
|
|
|
|
/// returns topmost row if passed (-1)
|
2001-09-26 16:52:34 +00:00
|
|
|
|
RowInfo & rowinfo(row_type row);
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// identifies GridInset
|
|
|
|
|
virtual MathGridInset * asGridInset() { return this; }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
///
|
2001-11-28 13:09:40 +00:00
|
|
|
|
col_type ncols() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-11-28 13:09:40 +00:00
|
|
|
|
row_type nrows() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-11-28 13:09:40 +00:00
|
|
|
|
col_type col(idx_type idx) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-11-28 13:09:40 +00:00
|
|
|
|
row_type row(idx_type idx) const;
|
2001-08-08 09:31:36 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
int cellXOffset(idx_type idx) const;
|
2001-08-08 09:31:36 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
int cellYOffset(idx_type idx) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
bool idxUp(idx_type &, pos_type &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
bool idxDown(idx_type &, pos_type &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
bool idxLeft(idx_type &, pos_type &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
bool idxRight(idx_type &, pos_type &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
bool idxFirst(idx_type &, pos_type &) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
bool idxLast(idx_type &, pos_type &) const;
|
2001-07-09 16:59:57 +00:00
|
|
|
|
///
|
2001-10-23 07:33:03 +00:00
|
|
|
|
bool idxHome(idx_type &, pos_type &) const;
|
|
|
|
|
///
|
|
|
|
|
bool idxEnd(idx_type &, pos_type &) const;
|
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
void idxDelete(idx_type &, bool &, bool &);
|
2001-07-16 15:53:25 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
void idxDeleteRange(idx_type, idx_type);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
///
|
2001-12-11 15:04:02 +00:00
|
|
|
|
virtual void addRow(row_type);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-12-11 15:04:02 +00:00
|
|
|
|
virtual void delRow(row_type);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-12-11 15:04:02 +00:00
|
|
|
|
virtual void addCol(col_type);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2001-12-11 15:04:02 +00:00
|
|
|
|
virtual void delCol(col_type);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
|
|
|
|
virtual void appendRow();
|
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
idx_type index(row_type row, col_type col) const;
|
2001-07-16 15:53:25 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
std::vector<idx_type> idxBetween(idx_type from, idx_type to) const;
|
2001-09-04 13:32:06 +00:00
|
|
|
|
///
|
2001-11-28 13:09:40 +00:00
|
|
|
|
virtual int defaultColSpace(col_type) { return 0; }
|
2001-09-04 13:32:06 +00:00
|
|
|
|
///
|
2001-09-26 16:52:34 +00:00
|
|
|
|
virtual char defaultColAlign(col_type) { return 'c'; }
|
2001-09-05 12:57:13 +00:00
|
|
|
|
///
|
|
|
|
|
void setDefaults();
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
|
///
|
|
|
|
|
void write(WriteStream & os) const;
|
|
|
|
|
///
|
|
|
|
|
void normalize(NormalStream &) const;
|
2001-11-07 10:21:51 +00:00
|
|
|
|
///
|
2001-11-09 18:02:20 +00:00
|
|
|
|
//void maplize(MapleStream &) const;
|
2001-11-07 18:15:24 +00:00
|
|
|
|
///
|
|
|
|
|
void mathmlize(MathMLStream &) const;
|
|
|
|
|
///
|
2001-11-09 18:02:20 +00:00
|
|
|
|
//void octavize(OctaveStream &) const;
|
2001-11-07 08:51:35 +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 16:52:34 +00:00
|
|
|
|
string eolString(row_type row) const;
|
2001-08-10 10:39:56 +00:00
|
|
|
|
/// returns proper 'end of column' code for LaTeX
|
2001-09-26 16:52:34 +00:00
|
|
|
|
string eocString(col_type col) const;
|
2001-11-28 13:09:40 +00:00
|
|
|
|
/// extract number of columns from alignment string
|
|
|
|
|
col_type guessColumns(string const & halign) 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
|