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