mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-20 07:11:12 -06:00
ENH:Show ErrorCode to the Device screen
Change-Id: I481b08a439d07a99f6c06c558e0a7fb3467a7d51
This commit is contained in:
parent
6eb4d671b5
commit
7a041ac2a0
11 changed files with 322 additions and 16 deletions
54
src/slic3r/GUI/Widgets/wxStaticText2.cpp
Normal file
54
src/slic3r/GUI/Widgets/wxStaticText2.cpp
Normal 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);
|
||||
}
|
22
src/slic3r/GUI/Widgets/wxStaticText2.hpp
Normal file
22
src/slic3r/GUI/Widgets/wxStaticText2.hpp
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue