]> git.lyx.org Git - lyx.git/blob - src/mathed/math_grid.h
mathed95.diff
[lyx.git] / src / mathed / math_grid.h
1 // -*- C++ -*-
2 #ifndef MATH_GRID_H
3 #define MATH_GRID_H
4
5 #include "math_inset.h"
6
7 #ifdef __GNUG__
8 #pragma interface
9 #endif
10
11 /** Gridded math inset base class.
12     This is the base to all grid-like editable math objects
13     like array and eqnarray.
14     \author André Pönitz 2001
15 */
16
17 class MathGridInset : public MathInset {
18
19         /// additional per-row information
20         struct RowInfo {
21                 ///
22                 RowInfo();
23                 ///
24                 int descent_;
25                 ///
26                 int ascent_;
27                 /// 
28                 int offset_;
29                 ///
30                 bool upperline_;
31                 ///
32                 bool lowerline_;
33         };
34
35         // additional per-row information
36         struct ColInfo {
37                 ///     
38                 ColInfo();
39                 ///
40                 char h_align_;
41                 /// cache for drawing
42                 int h_offset;
43                 ///
44                 int width_;
45                 ///
46                 int offset_;
47                 ///
48                 bool leftline_;
49                 ///
50                 bool rightline_;
51         };
52
53 public: 
54         ///
55         MathGridInset(int m, int n, string const & nm, MathInsetTypes ot);
56         ///
57         virtual MathInset * clone() const = 0;
58         ///
59         void Write(std::ostream &, bool fragile) const;
60         ///
61         void Metrics(MathStyles st);
62         ///
63         void draw(Painter &, int, int);
64         ///
65         void halign(string const &);
66         ///
67         void halign(char c, int col);
68         ///
69         char halign(int col) const;
70         ///
71         void valign(char c);
72         ///
73         char valign() const;
74         ///
75         void resize(short int type, int cols);
76         ///
77         const RowInfo & rowinfo(int row) const;
78         ///
79         RowInfo & rowinfo(int row);
80
81         ///
82         int ncols() const { return colinfo_.size(); }
83         ///
84         int nrows() const { return rowinfo_.size(); }
85         ///
86         int col(int idx) const { return idx % ncols(); }
87         ///
88         int row(int idx) const { return idx / ncols(); }
89
90         ///
91         bool idxUp(int &, int &) const;
92         ///
93         bool idxDown(int &, int &) const;
94         ///
95         bool idxLeft(int &, int &) const;
96         ///
97         bool idxRight(int &, int &) const;
98         ///
99         bool idxFirst(int &, int &) const;
100         ///
101         bool idxLast(int &, int &) const;
102                         
103         ///
104         void addRow(int);
105         ///
106         void delRow(int);
107         ///
108         void addCol(int);
109         ///
110         void delCol(int);
111         ///
112         virtual void appendRow();
113         ///
114         int index(int row, int col) const;
115
116 protected:
117         /// row info
118         std::vector<RowInfo> rowinfo_;
119         /// column info
120         std::vector<ColInfo> colinfo_;
121         /// 
122         char v_align_; // add approp. type
123 };
124
125 #endif