9 #include "math_metricsinfo.h"
18 /** This class extends a MathArray by drawing routines and caches for
24 /// type for positions and sizes
25 typedef MathArray::size_type size_type;
26 /// const iterator into the underlying MathArray
27 typedef MathArray::const_iterator const_iterator;
31 /// rebuild cached metrics information
32 void metrics(MathMetricsInfo const & st) const;
33 /// redraw cell using cache metrics information
34 void draw(Painter & pain, int x, int y) const;
35 /// mark cell for re-drawing
38 /// access to cached x coordinate of last drawing
39 int xo() const { return xo_; }
40 /// access to cached y coordinate of last drawing
41 int yo() const { return yo_; }
42 /// access to cached x coordinate of mid point of last drawing
43 int xm() const { return xo_ + width_ / 2; }
44 /// access to cached y coordinate of mid point of last drawing
45 int ym() const { return yo_ + (descent_ - ascent_) / 2; }
46 /// returns x coordinate of given position in the array
47 int pos2x(size_type pos) const;
48 /// returns position of given x coordinate
49 size_type x2pos(int pos) const;
50 /// returns distance of this cell to the point given by x and y
51 // assumes valid position and size cache
52 int dist(int x, int y) const;
54 /// ascent of this cell above the baseline
55 int ascent() const { return ascent_; }
56 /// descent of this cell below the baseline
57 int descent() const { return descent_; }
58 /// height of the cell
59 int height() const { return ascent_ + descent_; }
60 /// width of this cell
61 int width() const { return width_; }
62 /// bounding box of this cell
63 void boundingBox(int & xlow, int & xhigh, int & ylow, int & yhigh);
64 /// find best position to do things
65 //void findPos(PosFinder &) const;
66 /// gives center coordinates
67 void center(int & x, int & y) const;
68 /// adjust (x,y) to point on boundary on a straight line from the center
69 void towards(int & x, int & y) const;
71 /// begin iterator of the underlying MathArray
72 const_iterator begin() const { return data_.begin(); }
73 /// end iterator of the underlying MathArray
74 const_iterator end() const { return data_.end(); }
77 /// the underlying MathArray
79 /// cached width of cell
81 /// cached ascent of cell
83 /// cached descent of cell
85 /// cached x coordinate of last drawing
87 /// cached y coordinate of last drawing
89 /// cache size information of last drawing
90 mutable MathMetricsInfo size_;
91 /// cached cleaness of cell
93 /// cached draw status of cell
97 /// output cell on a stream
98 std::ostream & operator<<(std::ostream & os, MathXArray const & ar);