mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-10-19 23:01:22 -06:00
FIX: [STUDIO-3547] use Label instead of ErrorMsgStaticText
Change-Id: Ibf813bea7ced38a6a303d6d4bac3cac542663ba0
This commit is contained in:
parent
a4b3a5c000
commit
0162fceb98
6 changed files with 98 additions and 94 deletions
|
@ -108,6 +108,11 @@ public:
|
|||
for (bool newLine = false; !line.empty(); newLine = true) {
|
||||
if (newLine) OnNewLine();
|
||||
|
||||
if (1 == line.length()) {
|
||||
DoOutputLine(line);
|
||||
break;
|
||||
}
|
||||
|
||||
wxArrayInt widths;
|
||||
dc.GetPartialTextExtents(line, widths);
|
||||
|
||||
|
@ -136,6 +141,10 @@ public:
|
|||
// No spaces, so can't wrap.
|
||||
lastSpace = posEnd;
|
||||
}
|
||||
if (lastSpace == 0) {
|
||||
// Break at least one char
|
||||
lastSpace = 1;
|
||||
}
|
||||
|
||||
// Output the part that fits.
|
||||
DoOutputLine(line.substr(0, lastSpace));
|
||||
|
@ -184,13 +193,14 @@ private:
|
|||
class wxLabelWrapper2 : public wxTextWrapper2
|
||||
{
|
||||
public:
|
||||
void WrapLabel(wxWindow *text, int widthMax)
|
||||
void WrapLabel(wxWindow *text, wxString const & label, int widthMax)
|
||||
{
|
||||
m_text.clear();
|
||||
Wrap(text, text->GetLabel(), widthMax);
|
||||
text->SetLabel(m_text);
|
||||
Wrap(text, label, widthMax);
|
||||
}
|
||||
|
||||
wxString GetText() const { return m_text; }
|
||||
|
||||
protected:
|
||||
virtual void OnOutputLine(const wxString &line) wxOVERRIDE { m_text += line; }
|
||||
|
||||
|
@ -232,23 +242,32 @@ Label::Label(wxWindow *parent, wxString const &text, long style) : Label(parent,
|
|||
Label::Label(wxWindow *parent, wxFont const &font, wxString const &text, long style)
|
||||
: wxStaticText(parent, wxID_ANY, text, wxDefaultPosition, wxDefaultSize, style)
|
||||
{
|
||||
this->font = font;
|
||||
this->m_font = font;
|
||||
this->m_text = text;
|
||||
SetFont(font);
|
||||
SetForegroundColour(*wxBLACK);
|
||||
SetBackgroundColour(StaticBox::GetParentBackgroundColor(parent));
|
||||
SetForegroundColour("#262E30");
|
||||
if (style & LB_PROPAGATE_MOUSE_EVENT) {
|
||||
for (auto evt : {
|
||||
wxEVT_LEFT_UP, wxEVT_LEFT_DOWN})
|
||||
for (auto evt : { wxEVT_LEFT_UP, wxEVT_LEFT_DOWN })
|
||||
Bind(evt, [this] (auto & e) { GetParent()->GetEventHandler()->ProcessEventLocally(e); });
|
||||
};
|
||||
};
|
||||
if (style & LB_AUTO_WRAP) {
|
||||
Bind(wxEVT_SIZE, &Label::OnSize, this);
|
||||
Wrap(GetSize().x);
|
||||
}
|
||||
}
|
||||
|
||||
void Label::SetLabel(const wxString& label)
|
||||
{
|
||||
if (GetLabel() == label)
|
||||
if (m_text == label)
|
||||
return;
|
||||
wxStaticText::SetLabel(label);
|
||||
m_text = label;
|
||||
if ((GetWindowStyle() & LB_AUTO_WRAP)) {
|
||||
Wrap(GetSize().x);
|
||||
} else {
|
||||
wxStaticText::SetLabel(label);
|
||||
}
|
||||
#ifdef __WXOSX__
|
||||
if ((GetWindowStyle() & LB_HYPERLINK)) {
|
||||
SetLabelMarkup(label);
|
||||
|
@ -263,22 +282,21 @@ void Label::SetWindowStyleFlag(long style)
|
|||
return;
|
||||
wxStaticText::SetWindowStyleFlag(style);
|
||||
if (style & LB_HYPERLINK) {
|
||||
this->color = GetForegroundColour();
|
||||
this->m_color = GetForegroundColour();
|
||||
static wxColor clr_url("#00AE42");
|
||||
SetFont(this->font.Underlined());
|
||||
SetFont(this->m_font.Underlined());
|
||||
SetForegroundColour(clr_url);
|
||||
SetCursor(wxCURSOR_HAND);
|
||||
#ifdef __WXOSX__
|
||||
SetLabelMarkup(GetLabel());
|
||||
SetLabelMarkup(m_text);
|
||||
#endif
|
||||
} else {
|
||||
SetForegroundColour(this->color);
|
||||
SetFont(this->font);
|
||||
SetForegroundColour(this->m_color);
|
||||
SetFont(this->m_font);
|
||||
SetCursor(wxCURSOR_ARROW);
|
||||
#ifdef __WXOSX__
|
||||
auto label = GetLabel();
|
||||
wxStaticText::SetLabel({});
|
||||
wxStaticText::SetLabel(label);
|
||||
SetLabel(m_text);
|
||||
#endif
|
||||
}
|
||||
Refresh();
|
||||
|
@ -287,5 +305,15 @@ void Label::SetWindowStyleFlag(long style)
|
|||
void Label::Wrap(int width)
|
||||
{
|
||||
wxLabelWrapper2 wrapper;
|
||||
wrapper.WrapLabel(this, width);
|
||||
wrapper.Wrap(this, m_text, width);
|
||||
m_skip_size_evt = true;
|
||||
wxStaticText::SetLabel(wrapper.GetText());
|
||||
m_skip_size_evt = false;
|
||||
}
|
||||
|
||||
void Label::OnSize(wxSizeEvent &evt)
|
||||
{
|
||||
evt.Skip();
|
||||
if (m_skip_size_evt) return;
|
||||
Wrap(evt.GetSize().x);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#define LB_HYPERLINK 0x0020
|
||||
#define LB_PROPAGATE_MOUSE_EVENT 0x0040
|
||||
#define LB_AUTO_WRAP 0x0080
|
||||
|
||||
|
||||
class Label : public wxStaticText
|
||||
|
@ -21,8 +22,13 @@ public:
|
|||
void Wrap(int width);
|
||||
|
||||
private:
|
||||
wxFont font;
|
||||
wxColour color;
|
||||
void OnSize(wxSizeEvent & evt);
|
||||
|
||||
private:
|
||||
wxFont m_font;
|
||||
wxColour m_color;
|
||||
wxString m_text;
|
||||
bool m_skip_size_evt = false;
|
||||
|
||||
public:
|
||||
static wxFont Head_48;
|
||||
|
|
|
@ -323,7 +323,7 @@ SideTools::SideTools(wxWindow *parent, wxWindowID id, const wxPoint &pos, const
|
|||
|
||||
auto st_title_error_code = new wxStaticText(m_side_error_panel, wxID_ANY, _L("code"), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
||||
auto st_title_error_code_doc = new wxStaticText(m_side_error_panel, wxID_ANY, ": ");
|
||||
m_st_txt_error_code = new Label(m_side_error_panel, wxEmptyString);
|
||||
m_st_txt_error_code = new Label(m_side_error_panel, wxEmptyString, LB_AUTO_WRAP);
|
||||
st_title_error_code->SetForegroundColour(0x909090);
|
||||
st_title_error_code_doc->SetForegroundColour(0x909090);
|
||||
m_st_txt_error_code->SetForegroundColour(0x909090);
|
||||
|
@ -341,7 +341,7 @@ SideTools::SideTools(wxWindow *parent, wxWindowID id, const wxPoint &pos, const
|
|||
|
||||
auto st_title_error_desc = new wxStaticText(m_side_error_panel, wxID_ANY, wxT("desc"), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
||||
auto st_title_error_desc_doc = new wxStaticText(m_side_error_panel, wxID_ANY, ": ");
|
||||
m_st_txt_error_desc = new Label(m_side_error_panel, wxEmptyString);
|
||||
m_st_txt_error_desc = new Label(m_side_error_panel, wxEmptyString, LB_AUTO_WRAP);
|
||||
st_title_error_desc->SetForegroundColour(0x909090);
|
||||
st_title_error_desc_doc->SetForegroundColour(0x909090);
|
||||
m_st_txt_error_desc->SetForegroundColour(0x909090);
|
||||
|
@ -358,7 +358,7 @@ SideTools::SideTools(wxWindow *parent, wxWindowID id, const wxPoint &pos, const
|
|||
|
||||
auto st_title_extra_info = new wxStaticText(m_side_error_panel, wxID_ANY, wxT("info"), wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END);
|
||||
auto st_title_extra_info_doc = new wxStaticText(m_side_error_panel, wxID_ANY, ": ");
|
||||
m_st_txt_extra_info = new Label(m_side_error_panel, wxEmptyString);
|
||||
m_st_txt_extra_info = new Label(m_side_error_panel, wxEmptyString, LB_AUTO_WRAP);
|
||||
st_title_extra_info->SetForegroundColour(0x909090);
|
||||
st_title_extra_info_doc->SetForegroundColour(0x909090);
|
||||
m_st_txt_extra_info->SetForegroundColour(0x909090);
|
||||
|
@ -381,7 +381,6 @@ SideTools::SideTools(wxWindow *parent, wxWindowID id, const wxPoint &pos, const
|
|||
sizer_print_failed_info->Add(sizer_extra_info, 0, wxLEFT, 5);
|
||||
|
||||
m_st_txt_error_desc->SetLabel("");
|
||||
m_st_txt_error_desc->Wrap(FromDIP(170));
|
||||
|
||||
wxBoxSizer* m_main_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
m_main_sizer->Add(m_connection_info, 0, wxEXPAND, 0);
|
||||
|
@ -432,10 +431,6 @@ void SideTools::update_connect_err_info(int code, wxString desc, wxString info)
|
|||
m_st_txt_error_desc->SetLabelText(desc);
|
||||
m_st_txt_extra_info->SetLabelText(info);
|
||||
|
||||
m_st_txt_error_code->Wrap(FromDIP(175));
|
||||
m_st_txt_error_desc->Wrap(FromDIP(175));
|
||||
m_st_txt_extra_info->Wrap(FromDIP(175));
|
||||
|
||||
if (code == BAMBU_NETWORK_ERR_CONNECTION_TO_PRINTER_FAILED) {
|
||||
m_link_network_state->Hide();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue