2 #ifndef _F_TEXT_SYMBOL_BUFFER_H_
3 #define _F_TEXT_SYMBOL_BUFFER_H_
6 #include <F_Text_Symbol.H>
14 class F_Text_Symbol_Buffer : public F_Rect {
20 F_Text_Symbol_Buffer(dim_t tw, dim_t th) : F_Rect(tw, th) { buf = new F_Text_Symbol[square()]; }
21 F_Text_Symbol_Buffer(F_Rect &r) : F_Rect(r) { buf = new F_Text_Symbol[square()]; }
22 ~F_Text_Symbol_Buffer() { delete [] buf; }
23 void resize(dim_t tw, dim_t th) {
27 buf = new F_Text_Symbol[square()];
30 inline F_Text_Symbol *operator[](unsigned int idx) {
36 // ËÏÐÉÒÕÅÍ × ÎÁÛ buffer ÉÚ b_src ËÕÓÏÞÅË ÕËÁÚÙ×ÁÅÍÙÊ r_src × ÒÅÇÉÏÎ r_dst
37 inline void copy(F_Region &r_src, F_Text_Symbol_Buffer &b_src, F_Region *r_dst) {
38 // ÏÂÌÁÓÔÉ ÄÏÌÖÎÙ ÂÙÔØ ÒÁ×ÎÙ ÐÏ ÛÉÒÉÎÅ/×ÙÓÏÔÅ
39 // if ((r_src.w() != r_dst->w()) || (r_src.h() != r_dst->h()))
45 register coord_t dst_x, src_x, dst_y = r_dst->y(), src_y = r_src.y();
46 register dim_t copy_w = r_src.w(), copy_h = r_src.h();
47 for (; dst_y < (r_dst->y() + copy_h); dst_y++, src_y++) {
48 if ((dst_y < 0) || (dst_y >= h()) || (src_y < 0) || (src_y >= b_src.h()))
52 for (; dst_x < (r_dst->x() + copy_w); dst_x++, src_x++)
53 if ((dst_x >= 0) && (dst_x < w()) &&
54 (src_x >= 0) && (src_x < b_src.w()))
55 buf[dst_x + dst_y * w()] = b_src.buf[src_x + src_y * b_src.w()];
58 inline void copy(F_Region &r_src, F_Text_Symbol_Buffer &b_src, F_Region &r_dst) {
59 copy(r_src, b_src, &r_dst); }
60 // fill all the region with the given symbol
61 inline void fill(F_Region ®ion, F_Text_Symbol &s) {
63 for (coord_t cur_y = region.y(); cur_y < (region.y() + region.h()); cur_y++)
64 for (coord_t cur_x = region.x(); cur_x < (region.x() + region.w()); cur_x++)
65 buf[cur_x + cur_y * w()] = s;
67 // set the point to the given symbol
68 inline void set(F_Point &p, F_Text_Symbol &s) { buf[p.x() + p.y() * w()] = s; }
69 // fill all the region with the given color
70 void fill(F_Region &r, F_Color &c);
71 // set the point to the given color
72 void set(F_Point &p, F_Color &c);
74 // get one symbol at the given point
75 inline void get(F_Point &p, F_Text_Symbol *sym) { *sym = buf[p.x() + p.y() * w()]; }
76 // get color at the given point
77 F_Color color_draw(F_Point &p);