1 #ifndef _textrender__hpp__included__
2 #define _textrender__hpp__included__
11 struct text_framebuffer
14 text_framebuffer(size_t w
, size_t h
);
17 element() { ch
= 32; bg
= 0xFFFFFF; fg
= 0; }
21 const static uint32_t white
;
22 const static uint32_t black
;
24 element
* get_buffer() { return &buffer
[0]; }
25 void set_size(size_t _width
, size_t _height
);
26 size_t get_stride() { return width
; }
27 void clear() { for(size_t i
= 0; i
< buffer
.size(); i
++) buffer
[i
] = element(); }
28 std::pair
<size_t, size_t> get_characters() { return std::make_pair(width
, height
); }
29 std::pair
<size_t, size_t> get_cell();
30 std::pair
<size_t, size_t> get_pixels();
31 void render(char* buffer
);
32 size_t write(const std::string
& str
, size_t w
, size_t x
, size_t y
, uint32_t fg
, uint32_t bg
);
33 size_t write(const std::u32string
& str
, size_t w
, size_t x
, size_t y
, uint32_t fg
, uint32_t bg
);
34 static size_t text_width(const std::string
& text
);
35 element
E(char32_t ch
, uint32_t fg
, uint32_t bg
)
44 std::vector
<element
> buffer
;
49 struct text_framebuffer_panel
: public wxPanel
, public text_framebuffer
52 text_framebuffer_panel(wxWindow
* parent
, size_t w
, size_t h
, wxWindowID id
, wxWindow
* redirect
);
53 ~text_framebuffer_panel();
54 void set_size(size_t _width
, size_t _height
);
56 bool AcceptsFocus() { return (redirect
!= NULL
); }
58 virtual void prepare_paint() = 0;
60 void on_erase(wxEraseEvent
& e
);
61 void on_paint(wxPaintEvent
& e
);
62 void on_focus(wxFocusEvent
& e
);
66 std::vector
<char> buffer
;