21{
22 auto size = GetSize();
23 wxPaintDC dc(this);
24 auto text_height = dc.GetCharHeight();
25 wxString out_txt =
m_msg;
26 wxString count_txt = "";
27 int line_count = 1;
28 int new_line_pos = 0;
29 bool is_ch = false;
30
31 if (
m_msg[0] > 0x80 &&
m_msg[1] > 0x80)is_ch =
true;
32
33 for (
int i = 0; i <
m_msg.length(); i++) {
34 auto text_size = dc.GetTextExtent(count_txt);
35 if (text_size.x < (size.x)) {
36 count_txt +=
m_msg[i];
37 if (
m_msg[i] ==
' ' ||
41 {
42 new_line_pos = i;
43 }
44 } else {
45 if (!is_ch)
46 {
47 out_txt[new_line_pos] = '\n';
48 i = new_line_pos;
49 } else {
50 out_txt.insert(i-1,'\n');
51 }
52 count_txt = "";
53 line_count++;
54 }
55 }
56 SetSize(wxSize(-1, line_count * text_height));
57 SetMinSize(wxSize(-1, line_count * text_height));
58 SetMaxSize(wxSize(-1, line_count * text_height));
59 dc.DrawText(out_txt, 0, 0);
60}
wxString m_msg
Definition ErrorMsgStaticText.hpp:18