ENH:Show ErrorCode to the Device screen

Change-Id: I481b08a439d07a99f6c06c558e0a7fb3467a7d51
This commit is contained in:
xiangdong.yang 2022-07-22 16:43:08 +08:00 committed by Lane.Wei
parent 6eb4d671b5
commit 7a041ac2a0
11 changed files with 322 additions and 16 deletions

View file

@ -0,0 +1,54 @@
#include "wxStaticText2.hpp"
wxStaticText2::wxStaticText2() {}
wxStaticText2::wxStaticText2(wxWindow * parent,
wxWindowID id,
const wxPoint & pos,
const wxSize & size)
{
Create(parent, id, pos, size);
Bind(wxEVT_PAINT, &wxStaticText2::paintEvent, this);
}
void wxStaticText2::paintEvent(wxPaintEvent &evt)
{
auto size = GetSize();
wxPaintDC dc(this);
auto text_height = dc.GetCharHeight();
wxString out_txt = m_msg;
wxString count_txt = "";
int line_count = 1;
int new_line_pos = 0;
bool is_ch = false;
if (m_msg[0] > 0x80 && m_msg[1] > 0x80)is_ch = true;
for (int i = 0; i < m_msg.length(); i++) {
auto text_size = dc.GetTextExtent(count_txt);
if (text_size.x < (size.x)) {
count_txt += m_msg[i];
if (m_msg[i] == ' ' ||
m_msg[i] == ',' ||
m_msg[i] == '.' ||
m_msg[i] == '\n')
{
new_line_pos = i;
}
} else {
if (!is_ch)
{
out_txt[new_line_pos] = '\n';
i = new_line_pos;
} else {
out_txt.insert(i-1,'\n');
}
count_txt = "";
line_count++;
}
}
SetSize(wxSize(-1, line_count * text_height));
SetMinSize(wxSize(-1, line_count * text_height));
SetMaxSize(wxSize(-1, line_count * text_height));
dc.DrawText(out_txt, 0, 0);
}

View file

@ -0,0 +1,22 @@
#ifndef _WX_STATTEXT2_H_
#define _WX_STATTEXT2_H_
#include "wx/stattext.h"
class WXDLLIMPEXP_CORE wxStaticText2 : public wxPanel
{
public:
wxString m_msg;
wxStaticText2();
wxStaticText2(wxWindow *parent,
wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxSize(200,200));
void paintEvent(wxPaintEvent &evt);
void SetLabel(wxString msg){m_msg = msg;};
};
#endif