Fix number of compile errors and warnings with GCC 14
[lsnes.git] / include / platform / wxwidgets / textrender.hpp
blobb561e43ad79a83f813d07da5d075f9c7c2404d5e
1 #ifndef _textrender__hpp__included__
2 #define _textrender__hpp__included__
4 #include <wx/panel.h>
5 #include <cstdint>
6 #include <map>
7 #include <cstdlib>
8 #include <vector>
9 #include <string>
11 struct text_framebuffer
13 text_framebuffer();
14 text_framebuffer(size_t w, size_t h);
15 struct element
17 element() { ch = 32; bg = 0xFFFFFF; fg = 0; }
18 uint32_t ch;
19 uint32_t bg;
20 uint32_t fg;
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)
37 element e;
38 e.ch = ch;
39 e.fg = fg;
40 e.bg = bg;
41 return e;
43 private:
44 std::vector<element> buffer;
45 size_t width;
46 size_t height;
49 struct text_framebuffer_panel : public wxPanel, public text_framebuffer
51 public:
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);
55 void request_paint();
56 bool AcceptsFocus() { return (redirect != NULL); }
57 protected:
58 virtual void prepare_paint() = 0;
59 private:
60 void on_erase(wxEraseEvent& e);
61 void on_paint(wxPaintEvent& e);
62 void on_focus(wxFocusEvent& e);
63 bool paint_requested;
64 bool locked;
65 bool size_changed;
66 std::vector<char> buffer;
67 wxWindow* redirect;
70 #endif