mirror of
https://github.com/QIDITECH/QIDISlicer.git
synced 2026-02-01 08:28:42 +03:00
Optimize the device list and fix some bugs
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
//B45
|
//B45
|
||||||
#include <wx/regex.h>
|
#include <wx/regex.h>
|
||||||
#include <boost/regex.hpp>
|
#include <boost/regex.hpp>
|
||||||
|
#include <wx/graphics.h>
|
||||||
namespace pt = boost::property_tree;
|
namespace pt = boost::property_tree;
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
@@ -24,51 +24,40 @@ namespace GUI {
|
|||||||
|
|
||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(MachineListButton, wxButton) EVT_PAINT(MachineListButton::OnPaint) EVT_ENTER_WINDOW(MachineListButton::OnMouseEnter)
|
wxBEGIN_EVENT_TABLE(MachineListButton, wxButton) EVT_PAINT(MachineListButton::OnPaint) EVT_ENTER_WINDOW(MachineListButton::OnMouseEnter)
|
||||||
EVT_LEAVE_WINDOW(MachineListButton::OnMouseLeave) EVT_LEFT_DOWN(MachineListButton::OnMouseLeftDown) EVT_LEFT_UP(MachineListButton::OnMouseLeftUp)
|
EVT_LEAVE_WINDOW(MachineListButton::OnMouseLeave)
|
||||||
|
//EVT_LEFT_DOWN(MachineListButton::OnMouseLeftDown)
|
||||||
|
// EVT_LEFT_UP(MachineListButton::OnMouseLeftUp)
|
||||||
|
EVT_SET_FOCUS(MachineListButton::OnSetFocus)
|
||||||
|
EVT_KILL_FOCUS(MachineListButton::OnKillFocus) EVT_KEY_DOWN(MachineListButton::OnKeyDown) EVT_KEY_UP(MachineListButton::OnKeyUp)
|
||||||
wxEND_EVENT_TABLE()
|
wxEND_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
//B45
|
//B45
|
||||||
|
|
||||||
void MachineListButton::OnPaint(wxPaintEvent &event)
|
void MachineListButton::OnPaint(wxPaintEvent &event)
|
||||||
{
|
{
|
||||||
|
|
||||||
wxPaintDC dc(this);
|
wxPaintDC dc(this);
|
||||||
//m_bitmap = get_bmp_bundle("X-MAX 3_thumbnail", 80)->GetBitmapFor(this);
|
|
||||||
//w13
|
|
||||||
wxRect rect = GetClientRect();
|
wxRect rect = GetClientRect();
|
||||||
dc.SetPen(wxPen(wxColour(30, 30, 32)));
|
if (m_isHovered || m_isSelected)
|
||||||
if (mouseOnButton) {
|
|
||||||
//dc.SetPen(wxPen(wxColour(110, 110, 110)));
|
|
||||||
|
|
||||||
dc.SetBrush(wxBrush(wxColour(100, 100, 105)));
|
dc.SetBrush(wxBrush(wxColour(100, 100, 105)));
|
||||||
|
else
|
||||||
dc.DrawRoundedRectangle(rect, 5);
|
|
||||||
} else {
|
|
||||||
//dc.SetPen(wxPen(wxColour(110, 110, 110)));
|
|
||||||
|
|
||||||
dc.SetBrush(wxBrush(wxColour(67, 67, 71)));
|
dc.SetBrush(wxBrush(wxColour(67, 67, 71)));
|
||||||
|
if (full_label == "") {
|
||||||
dc.DrawRoundedRectangle(rect, 5);
|
dc.DrawRoundedRectangle(rect, 5);
|
||||||
|
|
||||||
|
int imgWidth = m_bitmap.GetWidth();
|
||||||
|
int imgHeight = m_bitmap.GetHeight();
|
||||||
|
int x = (rect.GetWidth() - imgWidth) / 2;
|
||||||
|
int y = (rect.GetHeight() - imgHeight) / 2;
|
||||||
|
dc.DrawBitmap(m_bitmap, x, y);
|
||||||
}
|
}
|
||||||
if (m_isSelected) {
|
else if (m_isSimpleMode) {
|
||||||
//dc.SetPen(wxPen(wxColour(110, 110, 110)));
|
dc.DrawRoundedRectangle(rect, 8);
|
||||||
|
|
||||||
dc.SetBrush(wxBrush(wxColour(100, 100, 105)));
|
|
||||||
|
|
||||||
dc.DrawRoundedRectangle(rect, 5);
|
|
||||||
}
|
|
||||||
if (mousePressed) {
|
|
||||||
dc.SetPen(wxPen(wxColour(110, 110, 110)));
|
|
||||||
|
|
||||||
dc.SetBrush(wxBrush(wxColour(109, 109, 113)));
|
|
||||||
|
|
||||||
dc.DrawRoundedRectangle(rect, 5);
|
|
||||||
}
|
|
||||||
if (m_isSimpleMode) {
|
|
||||||
dc.SetFont(wxFont(15, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
|
dc.SetFont(wxFont(15, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
|
||||||
dc.SetTextForeground(wxColour(230, 230, 230));
|
dc.SetTextForeground(wxColour(230, 230, 230));
|
||||||
dc.DrawText(m_name_text, 10 , 10);
|
dc.DrawText(m_name_text, 10, 10);
|
||||||
} else {
|
} else {
|
||||||
|
dc.DrawRoundedRectangle(rect, 8);
|
||||||
dc.DrawBitmap(m_bitmap, 10, (GetSize().GetHeight() - m_bitmap.GetHeight()) / 2, true);
|
dc.DrawBitmap(m_bitmap, 10, (GetSize().GetHeight() - m_bitmap.GetHeight()) / 2, true);
|
||||||
|
|
||||||
dc.SetFont(wxFont(15, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
|
dc.SetFont(wxFont(15, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
|
||||||
@@ -92,48 +81,71 @@ void MachineListButton::OnPaint(wxPaintEvent &event)
|
|||||||
dc.DrawText(m_progress_text, 10 + m_bitmap.GetWidth() + m_bitmap_state.GetWidth() + 77, 62);
|
dc.DrawText(m_progress_text, 10 + m_bitmap.GetWidth() + m_bitmap_state.GetWidth() + 77, 62);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void MachineListButton::OnSetFocus(wxFocusEvent &event)
|
||||||
|
{
|
||||||
|
event.Skip();
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MachineListButton::OnKillFocus(wxFocusEvent &event)
|
||||||
|
{
|
||||||
|
event.Skip();
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MachineListButton::OnKeyDown(wxKeyEvent &event)
|
||||||
|
{
|
||||||
|
event.Skip();
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MachineListButton::OnKeyUp(wxKeyEvent &event)
|
||||||
|
{
|
||||||
|
event.Skip();
|
||||||
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachineListButton::OnMouseEnter(wxMouseEvent &event)
|
void MachineListButton::OnMouseEnter(wxMouseEvent &event)
|
||||||
{
|
{
|
||||||
//w13
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
mouseOnButton = true;
|
m_isHovered = true;
|
||||||
//SetBackgroundColour(wxColour(100, 100, 105));
|
#else
|
||||||
|
SetBackgroundColour(wxColour(100, 100, 105));
|
||||||
|
#endif
|
||||||
Refresh();
|
Refresh();
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachineListButton::OnMouseLeave(wxMouseEvent &event)
|
void MachineListButton::OnMouseLeave(wxMouseEvent &event)
|
||||||
{
|
{
|
||||||
//w13
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
mouseOnButton = false;
|
m_isHovered = false;
|
||||||
/* if (m_isSelected)
|
#else
|
||||||
SetBackgroundColour(wxColour(100, 100, 105));
|
if (m_isSelected)
|
||||||
else
|
SetBackgroundColour(wxColour(100, 100, 105));
|
||||||
SetBackgroundColour(wxColour(100, 100, 105)); */
|
else
|
||||||
|
SetBackgroundColour(wxColour(67, 67, 71));
|
||||||
|
#endif
|
||||||
Refresh();
|
Refresh();
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MachineListButton::OnMouseLeftDown(wxMouseEvent &event)
|
//void MachineListButton::OnMouseLeftDown(wxMouseEvent &event)
|
||||||
{
|
//{
|
||||||
//w13
|
// Refresh();
|
||||||
mousePressed = true;
|
//}
|
||||||
SetBackgroundColour(wxColour(30, 30, 32));
|
//
|
||||||
Refresh();
|
//void MachineListButton::OnMouseLeftUp(wxMouseEvent &event)
|
||||||
}
|
//{
|
||||||
|
// if (m_handlerl) {
|
||||||
void MachineListButton::OnMouseLeftUp(wxMouseEvent &event)
|
// m_handlerl(event);
|
||||||
{
|
// }
|
||||||
//w13
|
// Refresh();
|
||||||
mousePressed = false;
|
//}
|
||||||
//SetBackgroundColour(wxColour(100, 100, 105));
|
|
||||||
if (m_handlerl) {
|
|
||||||
m_handlerl(event);
|
|
||||||
}
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//B45
|
//B45
|
||||||
@@ -147,8 +159,9 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||||||
int leftsizerWidth = 210;
|
int leftsizerWidth = 210;
|
||||||
#endif
|
#endif
|
||||||
topsizer = new wxBoxSizer(wxHORIZONTAL);
|
topsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
|
|
||||||
leftScrolledWindow = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL | wxVSCROLL);
|
leftScrolledWindow = new wxScrolledWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL | wxVSCROLL);
|
||||||
// leftScrolledWindow->ShowScrollbars(wxSHOW_SB_NEVER, wxSHOW_SB_NEVER);
|
//leftScrolledWindow->ShowScrollbars(wxSHOW_SB_NEVER, wxSHOW_SB_NEVER);
|
||||||
leftScrolledWindow->SetBackgroundColour(wxColour(30, 30, 32));
|
leftScrolledWindow->SetBackgroundColour(wxColour(30, 30, 32));
|
||||||
leftsizer = new wxBoxSizer(wxVERTICAL);
|
leftsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
wxFont font(wxFontInfo().Bold());
|
wxFont font(wxFontInfo().Bold());
|
||||||
@@ -157,6 +170,8 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||||||
buttonPanel->SetBackgroundColour(wxColour(30, 30, 32));
|
buttonPanel->SetBackgroundColour(wxColour(30, 30, 32));
|
||||||
wxBoxSizer *buttonSizer = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *buttonSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
leftallsizer = new wxBoxSizer(wxVERTICAL);
|
leftallsizer = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
|
|
||||||
wxBoxSizer *titlesizer = new wxBoxSizer(wxHORIZONTAL);
|
wxBoxSizer *titlesizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
text_static = new wxStaticText(buttonPanel, wxID_ANY, "MACHINE LIST", wxDefaultPosition, wxDefaultSize);
|
text_static = new wxStaticText(buttonPanel, wxID_ANY, "MACHINE LIST", wxDefaultPosition, wxDefaultSize);
|
||||||
text_static->SetForegroundColour(wxColour(255, 255, 255));
|
text_static->SetForegroundColour(wxColour(255, 255, 255));
|
||||||
@@ -174,41 +189,67 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||||||
|
|
||||||
|
|
||||||
buttonPanel->SetSizer(buttonSizer);
|
buttonPanel->SetSizer(buttonSizer);
|
||||||
//w13
|
|
||||||
|
//#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
|
//MachineListButton *add_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT,
|
||||||
|
// wxDefaultValidator, wxButtonNameStr);
|
||||||
|
//wxButton *add_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
||||||
|
MachineListButton *add_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT,
|
||||||
|
wxDefaultValidator, wxButtonNameStr);
|
||||||
#if defined(__WIN32__) || defined(__WXMAC__)
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
MyRoundButton *add_button = new MyRoundButton(buttonPanel, wxID_ANY, "", "add_machine_list", wxDefaultPosition, wxSize(20, 20),
|
add_button->SetBackgroundColour(wxColour(30, 30, 21));
|
||||||
wxBORDER_NONE);
|
add_button->SetBitMap(get_bmp_bundle("add_machine_list", 20)->GetBitmapFor(this));
|
||||||
add_button->SetBackgroundColour(wxColour(30, 30, 32));
|
#else
|
||||||
|
add_button->SetBackgroundColour(wxColour(67, 67, 71));
|
||||||
add_button->SetMinSize(wxSize(40, -1));
|
#endif
|
||||||
buttonsizer->Add(add_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
add_button->SetMinSize(wxSize(40, -1));
|
||||||
add_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnAddButtonClick, this);
|
add_button->SetBitmap(*get_bmp_bundle("add_machine_list", 20));
|
||||||
|
buttonsizer->Add(add_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
||||||
|
add_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnAddButtonClick, this);
|
||||||
|
|
||||||
|
|
||||||
MyRoundButton *delete_button = new MyRoundButton(buttonPanel, wxID_ANY, "", "delete_machine_list", wxDefaultPosition,
|
//wxButton *delete_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
||||||
wxSize(20, 20), wxBORDER_NONE);
|
MachineListButton *delete_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT,
|
||||||
delete_button->SetBackgroundColour(wxColour(30, 30, 32));
|
wxDefaultValidator, wxButtonNameStr);
|
||||||
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
|
delete_button->SetBackgroundColour(wxColour(30, 30, 21));
|
||||||
|
delete_button->SetBitMap(get_bmp_bundle("delete_machine_list", 20)->GetBitmapFor(this));
|
||||||
|
#else
|
||||||
|
delete_button->SetBackgroundColour(wxColour(67, 67, 71));
|
||||||
|
#endif
|
||||||
|
delete_button->SetMinSize(wxSize(40, -1));
|
||||||
|
delete_button->SetBitmap(*get_bmp_bundle("delete_machine_list", 20));
|
||||||
|
buttonsizer->Add(delete_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
||||||
|
delete_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnDeleteButtonClick, this);
|
||||||
|
|
||||||
delete_button->SetMinSize(wxSize(40, -1));
|
MachineListButton *edit_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize, wxBU_LEFT,
|
||||||
buttonsizer->Add(delete_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
wxDefaultValidator, wxButtonNameStr);
|
||||||
delete_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnDeleteButtonClick, this);
|
//wxButton *edit_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
||||||
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
|
edit_button->SetBackgroundColour(wxColour(30, 30, 21));
|
||||||
|
edit_button->SetBitMap(get_bmp_bundle("edit_machine_list", 20)->GetBitmapFor(this));
|
||||||
|
#else
|
||||||
|
edit_button->SetBackgroundColour(wxColour(67, 67, 71));
|
||||||
|
#endif
|
||||||
|
edit_button->SetMinSize(wxSize(40, -1));
|
||||||
|
edit_button->SetBitmap(*get_bmp_bundle("edit_machine_list", 20));
|
||||||
|
buttonsizer->Add(edit_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
||||||
|
edit_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnEditButtonClick, this);
|
||||||
|
|
||||||
MyRoundButton *edit_button = new MyRoundButton(buttonPanel, wxID_ANY, "", "edit_machine_list", wxDefaultPosition, wxSize(20, 20),
|
MachineListButton *refresh_button = new MachineListButton(buttonPanel, wxID_ANY, "", "", wxDefaultPosition, wxDefaultSize,
|
||||||
wxBORDER_NONE);
|
wxBU_LEFT, wxDefaultValidator, wxButtonNameStr);
|
||||||
edit_button->SetBackgroundColour(wxColour(30, 30, 32));
|
//wxButton *refresh_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
||||||
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
edit_button->SetMinSize(wxSize(40, -1));
|
refresh_button->SetBackgroundColour(wxColour(30, 30, 21));
|
||||||
buttonsizer->Add(edit_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
#else
|
||||||
edit_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnEditButtonClick, this);
|
refresh_button->SetBackgroundColour(wxColour(67, 67, 71));
|
||||||
|
#endif
|
||||||
|
refresh_button->SetBitMap(get_bmp_bundle("refresh-line", 20)->GetBitmapFor(this));
|
||||||
MyRoundButton *refresh_button = new MyRoundButton(buttonPanel, wxID_ANY, "", "refresh-line", wxDefaultPosition, wxSize(20, 20),
|
refresh_button->SetMinSize(wxSize(40, -1));
|
||||||
wxBORDER_NONE);
|
refresh_button->SetBitmap(*get_bmp_bundle("refresh-line", 20));
|
||||||
refresh_button->SetBackgroundColour(wxColour(30, 30, 32));
|
buttonsizer->Add(refresh_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
||||||
|
refresh_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnRightButtonClick, this);
|
||||||
refresh_button->SetMinSize(wxSize(40, -1));
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
buttonsizer->Add(refresh_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
|
||||||
refresh_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnRightButtonClick, this);
|
|
||||||
|
|
||||||
arrow_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
arrow_button = new wxButton(buttonPanel, wxID_ANY, "", wxDefaultPosition, wxSize(20, 20), wxBORDER_NONE);
|
||||||
arrow_button->SetFont(font);
|
arrow_button->SetFont(font);
|
||||||
@@ -218,7 +259,7 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||||||
if (m_isSimpleMode)
|
if (m_isSimpleMode)
|
||||||
arrow_button->SetBitmap(*get_bmp_bundle("arrow-right-s-line", 20));
|
arrow_button->SetBitmap(*get_bmp_bundle("arrow-right-s-line", 20));
|
||||||
else
|
else
|
||||||
arrow_button->SetBitmap(*get_bmp_bundle("arrow-left-s-line", 20));
|
arrow_button->SetBitmap(*get_bmp_bundle("arrow-left-s-line", 20));
|
||||||
titlesizer->Add(arrow_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
titlesizer->Add(arrow_button, wxSizerFlags().Align(wxALIGN_LEFT).CenterVertical().Border(wxALL, 2));
|
||||||
arrow_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnLeftButtonClick, this);
|
arrow_button->Bind(wxEVT_BUTTON, &PrinterWebView::OnLeftButtonClick, this);
|
||||||
#endif
|
#endif
|
||||||
@@ -231,8 +272,7 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||||||
buttonPanel->Layout();
|
buttonPanel->Layout();
|
||||||
|
|
||||||
leftsizer->SetMinSize(wxSize(300, -1));
|
leftsizer->SetMinSize(wxSize(300, -1));
|
||||||
//leftsizer->Add(titlesizer, wxSizerFlags().Expand().Align(wxALIGN_TOP).Border(wxALL, 0));
|
|
||||||
//leftsizer->Add(buttonsizer, wxSizerFlags().Expand().Align(wxALIGN_TOP).Border(wxALL, 0));
|
|
||||||
|
|
||||||
leftsizer->Layout();
|
leftsizer->Layout();
|
||||||
leftScrolledWindow->SetSizer(leftsizer);
|
leftScrolledWindow->SetSizer(leftsizer);
|
||||||
@@ -283,6 +323,7 @@ PrinterWebView::PrinterWebView(wxWindow *parent)
|
|||||||
|
|
||||||
topsizer->Layout();
|
topsizer->Layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -315,22 +356,31 @@ void PrinterWebView::AddButton(const wxString & devi
|
|||||||
customButton->SetIPText(ip);
|
customButton->SetIPText(ip);
|
||||||
customButton->SetStateText("standby");
|
customButton->SetStateText("standby");
|
||||||
customButton->SetProgressText("(0%)");
|
customButton->SetProgressText("(0%)");
|
||||||
//customButton->SetMinSize(wxSize(200, -1));
|
|
||||||
customButton->SetClickHandler(handler);
|
customButton->SetClickHandler(handler);
|
||||||
|
//customButton->Bind(wxEVT_BUTTON, std::bind(&PrinterWebView::OnCustomButtonClick, this,handler));
|
||||||
|
customButton->Bind(wxEVT_BUTTON, [this, ip, customButton](wxCommandEvent &event) {
|
||||||
|
wxString host = ip;
|
||||||
|
if (!host.Lower().starts_with("http"))
|
||||||
|
host = wxString::Format("http://%s", host);
|
||||||
|
if (!host.Lower().ends_with("10088"))
|
||||||
|
host = wxString::Format("%s:10088", host);
|
||||||
|
load_url(host);
|
||||||
|
customButton->ResumeStatusThread();
|
||||||
|
});
|
||||||
#if defined(__WIN32__) || defined(__WXMAC__)
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
customButton->SetStatusThread(std::move(customButton->CreatThread(device_name,ip, cfg_t)));
|
customButton->SetStatusThread(std::move(customButton->CreatThread(device_name,ip, cfg_t)));
|
||||||
|
if (m_isSimpleMode) {
|
||||||
|
customButton->SetBitmap(*get_bmp_bundle(std::string("X-MAX 3_thumbnail"), 30));
|
||||||
|
customButton->SetSimpleMode(m_isSimpleMode);
|
||||||
|
customButton->SetSize(wxSize(180, -1));
|
||||||
|
} else {
|
||||||
|
customButton->SetBitmap(*get_bmp_bundle(std::string("X-MAX 3_thumbnail"), 80));
|
||||||
|
customButton->SetSimpleMode(m_isSimpleMode);
|
||||||
|
customButton->SetSize(wxSize(300, -1));
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
customButton->SetSize(wxSize(200, -1));
|
customButton->SetSize(wxSize(200, -1));
|
||||||
#endif
|
#endif
|
||||||
if (m_isSimpleMode) {
|
|
||||||
customButton->SetBitmap(*get_bmp_bundle(std::string("X-MAX 3_thumbnail"), 30));
|
|
||||||
customButton->SetSimpleMode(m_isSimpleMode);
|
|
||||||
customButton->SetSize(wxSize(180, -1));
|
|
||||||
} else {
|
|
||||||
customButton->SetBitmap(*get_bmp_bundle(std::string("X-MAX 3_thumbnail"), 80));
|
|
||||||
customButton->SetSimpleMode(m_isSimpleMode);
|
|
||||||
customButton->SetSize(wxSize(300, -1));
|
|
||||||
}
|
|
||||||
|
|
||||||
leftsizer->Add(customButton, wxSizerFlags().Border(wxALL, 1).Expand());
|
leftsizer->Add(customButton, wxSizerFlags().Border(wxALL, 1).Expand());
|
||||||
leftsizer->Layout();
|
leftsizer->Layout();
|
||||||
@@ -378,7 +428,7 @@ void PrinterWebView::AddButton(const wxString & devi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// B45
|
//B45
|
||||||
void PrinterWebView::UnSelectedButton()
|
void PrinterWebView::UnSelectedButton()
|
||||||
{
|
{
|
||||||
// BOOST_LOG_TRIVIAL(error) << " Resume";
|
// BOOST_LOG_TRIVIAL(error) << " Resume";
|
||||||
@@ -411,7 +461,7 @@ void PrinterWebView::AddButton(const wxString & devi
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// B45
|
//B45
|
||||||
void PrinterWebView::SetButtons(std::vector<MachineListButton *> buttons) { m_buttons = buttons; }
|
void PrinterWebView::SetButtons(std::vector<MachineListButton *> buttons) { m_buttons = buttons; }
|
||||||
|
|
||||||
PrinterWebView::~PrinterWebView()
|
PrinterWebView::~PrinterWebView()
|
||||||
@@ -420,7 +470,6 @@ void PrinterWebView::SetButtons(std::vector<MachineListButton *> buttons) { m_bu
|
|||||||
SetEvtHandlerEnabled(false);
|
SetEvtHandlerEnabled(false);
|
||||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " End";
|
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << " End";
|
||||||
}
|
}
|
||||||
|
|
||||||
//B45
|
//B45
|
||||||
void PrinterWebView::OnLeftButtonClick(wxCommandEvent &event)
|
void PrinterWebView::OnLeftButtonClick(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
@@ -428,6 +477,7 @@ void PrinterWebView::OnLeftButtonClick(wxCommandEvent &event)
|
|||||||
|
|
||||||
if (!m_isSimpleMode) {
|
if (!m_isSimpleMode) {
|
||||||
wxGetApp().app_config->set("machine_list_minification","0");
|
wxGetApp().app_config->set("machine_list_minification","0");
|
||||||
|
|
||||||
leftsizer->SetMinSize(wxSize(300, -1));
|
leftsizer->SetMinSize(wxSize(300, -1));
|
||||||
leftScrolledWindow->SetMinSize(wxSize(300, -1));
|
leftScrolledWindow->SetMinSize(wxSize(300, -1));
|
||||||
arrow_button->SetBitmap(*get_bmp_bundle("arrow-left-s-line", 20));
|
arrow_button->SetBitmap(*get_bmp_bundle("arrow-left-s-line", 20));
|
||||||
@@ -441,6 +491,7 @@ void PrinterWebView::OnLeftButtonClick(wxCommandEvent &event)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
wxGetApp().app_config->set("machine_list_minification", "1");
|
wxGetApp().app_config->set("machine_list_minification", "1");
|
||||||
|
|
||||||
arrow_button->SetBitmap(*get_bmp_bundle("arrow-right-s-line", 20));
|
arrow_button->SetBitmap(*get_bmp_bundle("arrow-right-s-line", 20));
|
||||||
leftsizer->SetMinSize(wxSize(190, -1));
|
leftsizer->SetMinSize(wxSize(190, -1));
|
||||||
leftScrolledWindow->SetMinSize(wxSize(190, -1));
|
leftScrolledWindow->SetMinSize(wxSize(190, -1));
|
||||||
@@ -460,14 +511,20 @@ void PrinterWebView::OnLeftButtonClick(wxCommandEvent &event)
|
|||||||
topsizer->Layout();
|
topsizer->Layout();
|
||||||
UpdateLayout();
|
UpdateLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
//B45
|
//B45
|
||||||
void PrinterWebView::OnRightButtonClick(wxCommandEvent &event)
|
void PrinterWebView::OnRightButtonClick(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
for (MachineListButton *button : m_buttons) {
|
for (MachineListButton *button : m_buttons) {
|
||||||
button->ResumeStatusThread();
|
button->ResumeStatusThread();
|
||||||
}
|
}
|
||||||
//w13
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PrinterWebView::OnCustomButtonClick(std::function<void(wxCommandEvent &)> handler, wxCommandEvent &event)
|
||||||
|
{
|
||||||
|
if (handler) {
|
||||||
|
handler(event);
|
||||||
|
}
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,7 +546,7 @@ void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
|
|||||||
if (!formattedHost.Lower().ends_with("10088"))
|
if (!formattedHost.Lower().ends_with("10088"))
|
||||||
formattedHost = wxString::Format("%s:10088", formattedHost);
|
formattedHost = wxString::Format("%s:10088", formattedHost);
|
||||||
|
|
||||||
std::string fullname = preset_bundle.physical_printers.get_selected_full_printer_name();
|
std::string fullname = preset_bundle.physical_printers.get_selected_full_printer_name();
|
||||||
std::string preset_name = printer.get_preset_name(fullname);
|
std::string preset_name = printer.get_preset_name(fullname);
|
||||||
Preset * preset = wxGetApp().preset_bundle->printers.find_preset(preset_name);
|
Preset * preset = wxGetApp().preset_bundle->printers.find_preset(preset_name);
|
||||||
std::string model_id = "X-MAX 3";
|
std::string model_id = "X-MAX 3";
|
||||||
@@ -497,15 +554,12 @@ void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
|
|||||||
if ((preset->config.opt_string("printer_model").empty()))
|
if ((preset->config.opt_string("printer_model").empty()))
|
||||||
model_id = "X-MAX 3";
|
model_id = "X-MAX 3";
|
||||||
else
|
else
|
||||||
model_id = preset->config.opt_string("printer_model");
|
model_id = preset->config.opt_string("printer_model");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
boost::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)");
|
boost::regex ipRegex(R"(\b(?:\d{1,3}\.){3}\d{1,3}\b)");
|
||||||
bool isValidIPAddress = boost::regex_match(host.ToStdString(), ipRegex);
|
bool isValidIPAddress = boost::regex_match(host.ToStdString(), ipRegex);
|
||||||
DynamicPrintConfig *cfg_t = &(printer.config);
|
DynamicPrintConfig *cfg_t = &(printer.config);
|
||||||
|
|
||||||
UnSelectedButton();
|
UnSelectedButton();
|
||||||
if (isValidIPAddress)
|
if (isValidIPAddress)
|
||||||
@@ -518,10 +572,8 @@ void PrinterWebView::OnAddButtonClick(wxCommandEvent &event)
|
|||||||
true, cfg_t);
|
true, cfg_t);
|
||||||
load_url(formattedHost);
|
load_url(formattedHost);
|
||||||
UpdateLayout();
|
UpdateLayout();
|
||||||
//w13
|
Refresh();
|
||||||
//Refresh();
|
|
||||||
}
|
}
|
||||||
Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrinterWebView::OnDeleteButtonClick(wxCommandEvent &event) {
|
void PrinterWebView::OnDeleteButtonClick(wxCommandEvent &event) {
|
||||||
@@ -539,12 +591,8 @@ void PrinterWebView::OnDeleteButtonClick(wxCommandEvent &event) {
|
|||||||
#else
|
#else
|
||||||
msg += _L("Are you sure you want to delete ") + (button->getLabel()) + _L("printer?");
|
msg += _L("Are you sure you want to delete ") + (button->getLabel()) + _L("printer?");
|
||||||
#endif
|
#endif
|
||||||
//w13
|
if (MessageDialog(this, msg, _L("Delete Physical Printer"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal() != wxID_YES)
|
||||||
if (MessageDialog(this, msg, _L("Delete Physical Printer"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION).ShowModal() !=
|
|
||||||
wxID_YES) {
|
|
||||||
Refresh();
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
button->StopStatusThread();
|
button->StopStatusThread();
|
||||||
preset_bundle.physical_printers.select_printer((button->getLabel()).ToStdString());
|
preset_bundle.physical_printers.select_printer((button->getLabel()).ToStdString());
|
||||||
@@ -575,14 +623,13 @@ void PrinterWebView::OnDeleteButtonClick(wxCommandEvent &event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
UpdateLayout();
|
UpdateLayout();
|
||||||
//Refresh();
|
Refresh();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_handlerl) {
|
if (m_handlerl) {
|
||||||
m_handlerl(event);
|
m_handlerl(event);
|
||||||
}
|
}
|
||||||
Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrinterWebView::OnEditButtonClick(wxCommandEvent &event) {
|
void PrinterWebView::OnEditButtonClick(wxCommandEvent &event) {
|
||||||
@@ -619,13 +666,11 @@ void PrinterWebView::OnEditButtonClick(wxCommandEvent &event) {
|
|||||||
|
|
||||||
button->SetBitMap(get_bmp_bundle(std::string(Machine_Name.mb_str()), 80)->GetBitmapFor(this));
|
button->SetBitMap(get_bmp_bundle(std::string(Machine_Name.mb_str()), 80)->GetBitmapFor(this));
|
||||||
UpdateLayout();
|
UpdateLayout();
|
||||||
//w13
|
Refresh();
|
||||||
//Refresh();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Refresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -700,6 +745,7 @@ void PrinterWebView::OnScrolldown(wxScrollWinEvent &event)
|
|||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PrinterWebView::OnScroll(wxScrollWinEvent &event)
|
void PrinterWebView::OnScroll(wxScrollWinEvent &event)
|
||||||
{
|
{
|
||||||
UpdateLayout();
|
UpdateLayout();
|
||||||
@@ -709,32 +755,19 @@ void PrinterWebView::OnScroll(wxScrollWinEvent &event)
|
|||||||
//B45
|
//B45
|
||||||
void PrinterWebView::load_url(wxString& url)
|
void PrinterWebView::load_url(wxString& url)
|
||||||
{
|
{
|
||||||
// this->Show();
|
|
||||||
// this->Raise();
|
|
||||||
if (m_browser == nullptr || m_web == url)
|
if (m_browser == nullptr || m_web == url)
|
||||||
return;
|
return;
|
||||||
m_web = url;
|
//m_web = url;
|
||||||
m_browser->LoadURL(url);
|
m_browser->LoadURL(url);
|
||||||
|
|
||||||
url.Remove(0, 7);
|
url.Remove(0, 7);
|
||||||
url.Remove(url.length() - 6);
|
url.Remove(url.length() - 6);
|
||||||
for (MachineListButton *button : m_buttons) {
|
for (MachineListButton *button : m_buttons) {
|
||||||
|
|
||||||
if (url == (button->getIPLabel()))
|
if (url == (button->getIPLabel()))
|
||||||
button->SetSelect(true);
|
button->SetSelect(true);
|
||||||
else
|
else
|
||||||
button->SetSelect(false);
|
button->SetSelect(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//const char *data = "Hello from C++!";
|
|
||||||
//std::string switch_dark_mode_script = "SwitchDarkMode(";
|
|
||||||
//switch_dark_mode_script += wxGetApp().app_config->get("dark_color_mode") == "1" ? "true" : "false";
|
|
||||||
//switch_dark_mode_script += ");";
|
|
||||||
//RunScript("var valueFromCpp = '" + std::string(data) + "';");
|
|
||||||
//m_browser->RunScript(switch_dark_mode_script);
|
|
||||||
|
|
||||||
//m_browser->SetFocus();
|
|
||||||
UpdateState();
|
UpdateState();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -759,25 +792,5 @@ void PrinterWebView::RunScript(const wxString &javascript)
|
|||||||
|
|
||||||
WebView::RunScript(m_browser, javascript);
|
WebView::RunScript(m_browser, javascript);
|
||||||
}
|
}
|
||||||
//w13
|
|
||||||
void MyRoundButton::OnPaint(wxPaintEvent &evt)
|
|
||||||
{
|
|
||||||
wxPaintDC dc(this);
|
|
||||||
wxRect rect = GetClientRect();
|
|
||||||
dc.SetPen(wxPen(wxColour(110, 110, 110)));
|
|
||||||
dc.SetBrush(wxBrush(wxColour(85, 85, 90)));
|
|
||||||
dc.DrawRoundedRectangle(rect, 5);
|
|
||||||
wxBitmap m_bitmap_state = get_bmp_bundle(m_name.ToStdString(), 20)->GetBitmapFor(this);
|
|
||||||
int imgWidth = m_bitmap_state.GetWidth();
|
|
||||||
int imgHeight = m_bitmap_state.GetHeight();
|
|
||||||
int x = (rect.GetWidth() - imgWidth) / 2;
|
|
||||||
int y = (rect.GetHeight() - imgHeight) / 2;
|
|
||||||
dc.DrawBitmap(m_bitmap_state, x, y);
|
|
||||||
}
|
|
||||||
void MyRoundButton::OnFocusEvent(wxFocusEvent &evt)
|
|
||||||
{
|
|
||||||
Refresh();
|
|
||||||
evt.Skip();
|
|
||||||
}
|
|
||||||
} // GUI
|
} // GUI
|
||||||
} // Slic3r
|
} // Slic3r
|
||||||
|
|||||||
@@ -56,14 +56,21 @@ public:
|
|||||||
bool isSelected = false)
|
bool isSelected = false)
|
||||||
: wxButton(parent, id, label, pos, size, style, validator, name)
|
: wxButton(parent, id, label, pos, size, style, validator, name)
|
||||||
{
|
{
|
||||||
|
SetBackgroundColour(wxColour(30, 30, 32));
|
||||||
full_label = fullname;
|
full_label = fullname;
|
||||||
m_isSelected = isSelected;
|
m_isSelected = isSelected;
|
||||||
//w13
|
//if (isSelected)
|
||||||
if (isSelected)
|
// SetBackgroundColour(wxColour(100, 100, 105));
|
||||||
|
//else
|
||||||
|
// SetBackgroundColour(wxColour(67, 67, 71));
|
||||||
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
SetBackgroundColour(wxColour(30, 30, 32));
|
SetBackgroundColour(wxColour(30, 30, 32));
|
||||||
else
|
#else
|
||||||
SetBackgroundColour(wxColour(30, 30, 32));
|
if (isSelected)
|
||||||
//Bind(wxEVT_BUTTON, &MachineListButton::OnMouseLeftUp, this);
|
SetBackgroundColour(wxColour(100, 100, 105));
|
||||||
|
else
|
||||||
|
SetBackgroundColour(wxColour(67, 67, 71));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetLabel(const wxString &fullname) { full_label = fullname; }
|
void SetLabel(const wxString &fullname) { full_label = fullname; }
|
||||||
@@ -111,21 +118,20 @@ public:
|
|||||||
void SetSelect(bool isselectd)
|
void SetSelect(bool isselectd)
|
||||||
{
|
{
|
||||||
m_isSelected = isselectd;
|
m_isSelected = isselectd;
|
||||||
//w13
|
#if defined(__WIN32__) || defined(__WXMAC__)
|
||||||
/* if (m_isSelected)
|
SetBackgroundColour(wxColour(30, 30, 32));
|
||||||
SetBackgroundColour(wxColour(100, 100, 105));
|
#else
|
||||||
else
|
if (m_isSelected)
|
||||||
SetBackgroundColour(wxColour(67, 67, 71)); */
|
SetBackgroundColour(wxColour(100, 100, 105));
|
||||||
|
else
|
||||||
|
SetBackgroundColour(wxColour(67, 67, 71));
|
||||||
|
#endif
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
bool GetSelected() { return m_isSelected;}
|
bool GetSelected() { return m_isSelected;}
|
||||||
void SetSimpleMode(bool issimplemode)
|
void SetSimpleMode(bool issimplemode)
|
||||||
{
|
{
|
||||||
m_isSimpleMode = issimplemode;
|
m_isSimpleMode = issimplemode;
|
||||||
//if (m_isSelected)
|
|
||||||
// SetBackgroundColour(wxColour(100, 100, 105));
|
|
||||||
//else
|
|
||||||
// SetBackgroundColour(wxColour(67, 67, 71));
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,17 +143,18 @@ public:
|
|||||||
m_stopThread = true;
|
m_stopThread = true;
|
||||||
if (m_statusThread.joinable()) {
|
if (m_statusThread.joinable()) {
|
||||||
m_statusThread.join();
|
m_statusThread.join();
|
||||||
} else {
|
|
||||||
m_statusThread.detach();
|
|
||||||
std::terminate();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void OnPaint(wxPaintEvent &event);
|
void OnPaint(wxPaintEvent &event);
|
||||||
void OnMouseEnter(wxMouseEvent &event);
|
void OnSetFocus(wxFocusEvent &event);
|
||||||
void OnMouseLeave(wxMouseEvent &event);
|
void OnKillFocus(wxFocusEvent &event);
|
||||||
void OnMouseLeftDown(wxMouseEvent &event);
|
void OnKeyDown(wxKeyEvent &event);
|
||||||
void OnMouseLeftUp(wxMouseEvent &event);
|
void OnKeyUp(wxKeyEvent &event);
|
||||||
void OnClickHandler(wxCommandEvent &event);
|
void OnMouseEnter(wxMouseEvent &event);
|
||||||
|
void OnMouseLeave(wxMouseEvent &event);
|
||||||
|
void OnMouseLeftDown(wxMouseEvent &event);
|
||||||
|
//void OnMouseLeftUp(wxMouseEvent &event);
|
||||||
|
//void OnClickHandler(wxCommandEvent &event);
|
||||||
void SetStatusThread(std::thread thread) { m_statusThread = std::move(thread); }
|
void SetStatusThread(std::thread thread) { m_statusThread = std::move(thread); }
|
||||||
std::thread CreatThread(const wxString &buttonText, const wxString &ip, DynamicPrintConfig *cfg_t)
|
std::thread CreatThread(const wxString &buttonText, const wxString &ip, DynamicPrintConfig *cfg_t)
|
||||||
{
|
{
|
||||||
@@ -158,30 +165,33 @@ public:
|
|||||||
BOOST_LOG_TRIVIAL(error) << ("Could not get a valid Printer Host reference");
|
BOOST_LOG_TRIVIAL(error) << ("Could not get a valid Printer Host reference");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wxString msg;
|
wxString msg;
|
||||||
std::string state = "standby";
|
std::string state = "standby";
|
||||||
float progress = 0;
|
float progress = 0;
|
||||||
|
int timeout_times = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (!m_pauseThread) {
|
if (!m_pauseThread) {
|
||||||
state = printhost->get_status(msg);
|
state = printhost->get_status(msg);
|
||||||
if (state == "offline") {
|
if (state == "offline") {
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%Got state: %2%") % buttonText % state;
|
BOOST_LOG_TRIVIAL(info) << boost::format("%1%Got state: %2%") % buttonText % state;
|
||||||
SetStateText(state);
|
timeout_times += 1;
|
||||||
m_pauseThread = true;
|
if (timeout_times>3)
|
||||||
|
m_pauseThread = true;
|
||||||
}
|
}
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%Got state: %2%") % buttonText % state;
|
BOOST_LOG_TRIVIAL(info) << boost::format("%1%Got state: %2%") % buttonText % state;
|
||||||
SetStateText(state);
|
if (m_state_text != state)
|
||||||
|
SetStateText(state);
|
||||||
|
|
||||||
if (state == "printing") {
|
if (state == "printing") {
|
||||||
progress = (printhost->get_progress(msg)) * 100;
|
timeout_times = 0;
|
||||||
|
progress = (printhost->get_progress(msg)) * 100;
|
||||||
int progressInt = static_cast<int>(progress);
|
int progressInt = static_cast<int>(progress);
|
||||||
SetProgressText(wxString::Format(wxT("(%d%%)"), progressInt));
|
SetProgressText(wxString::Format(wxT("(%d%%)"), progressInt));
|
||||||
|
|
||||||
BOOST_LOG_TRIVIAL(info) << boost::format("%1%Got progress: %2%") % buttonText % progress;
|
BOOST_LOG_TRIVIAL(info) << boost::format("%1%Got progress: %2%") % buttonText % progress;
|
||||||
}
|
} else if (state == "standby")
|
||||||
|
timeout_times = 0;
|
||||||
} else
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(3));
|
|
||||||
if (m_stopThread)
|
if (m_stopThread)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -190,19 +200,19 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//w13
|
|
||||||
bool mousePressed = false;
|
|
||||||
bool mouseOnButton;
|
|
||||||
std::atomic<bool> m_stopThread{false};
|
std::atomic<bool> m_stopThread{false};
|
||||||
std::atomic<bool> m_pauseThread{false};
|
std::atomic<bool> m_pauseThread{false};
|
||||||
|
|
||||||
bool m_isSimpleMode;
|
bool m_isSimpleMode;
|
||||||
bool m_isSelected;
|
bool m_isSelected = false;
|
||||||
|
bool m_isHovered = false;
|
||||||
|
//bool m_isClicked = false;
|
||||||
|
|
||||||
std::thread m_statusThread;
|
std::thread m_statusThread;
|
||||||
|
//wxGraphicsContext *gc;
|
||||||
|
wxPaintDC * m_dc;
|
||||||
|
|
||||||
wxBitmap m_bitmap;
|
wxBitmap m_bitmap;
|
||||||
bool m_isHovered;
|
|
||||||
wxString full_label;
|
wxString full_label;
|
||||||
wxString m_name_text;
|
wxString m_name_text;
|
||||||
wxString m_ip_text;
|
wxString m_ip_text;
|
||||||
@@ -210,7 +220,6 @@ private:
|
|||||||
wxString m_progress_text;
|
wxString m_progress_text;
|
||||||
std::function<void(wxMouseEvent &)> m_handlerl;
|
std::function<void(wxMouseEvent &)> m_handlerl;
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
//wxDECLARE_EVENT_TABLE();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -228,6 +237,7 @@ public:
|
|||||||
//B45
|
//B45
|
||||||
void OnLeftButtonClick(wxCommandEvent &event);
|
void OnLeftButtonClick(wxCommandEvent &event);
|
||||||
void OnRightButtonClick(wxCommandEvent &event);
|
void OnRightButtonClick(wxCommandEvent &event);
|
||||||
|
void OnCustomButtonClick(std::function<void(wxCommandEvent &)> m_handler, wxCommandEvent &event);
|
||||||
void OnAddButtonClick(wxCommandEvent &event);
|
void OnAddButtonClick(wxCommandEvent &event);
|
||||||
void OnDeleteButtonClick(wxCommandEvent &event);
|
void OnDeleteButtonClick(wxCommandEvent &event);
|
||||||
void OnEditButtonClick(wxCommandEvent &event);
|
void OnEditButtonClick(wxCommandEvent &event);
|
||||||
@@ -272,13 +282,11 @@ private:
|
|||||||
wxButton *arrow_button;
|
wxButton *arrow_button;
|
||||||
wxStaticText * text_static;
|
wxStaticText * text_static;
|
||||||
|
|
||||||
|
|
||||||
int height = 0;
|
int height = 0;
|
||||||
wxString m_web;
|
wxString m_web;
|
||||||
std::function<void(wxCommandEvent &)> m_handlerl;
|
std::function<void(wxCommandEvent &)> m_handlerl;
|
||||||
std::function<void(wxCommandEvent &)> m_delete_handlerl;
|
std::function<void(wxCommandEvent &)> m_delete_handlerl;
|
||||||
|
|
||||||
|
|
||||||
wxScrolledWindow * leftScrolledWindow;
|
wxScrolledWindow * leftScrolledWindow;
|
||||||
wxPanel * leftPanel;
|
wxPanel * leftPanel;
|
||||||
|
|
||||||
@@ -290,37 +298,7 @@ private:
|
|||||||
|
|
||||||
// DECLARE_EVENT_TABLE()
|
// DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
//w13
|
|
||||||
class MyRoundButton : public wxButton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxString m_name;
|
|
||||||
|
|
||||||
MyRoundButton(wxWindow * parent,
|
|
||||||
wxWindowID id = wxID_ANY,
|
|
||||||
const wxString &label = "",
|
|
||||||
const wxString &name = "",
|
|
||||||
const wxPoint & pos = wxDefaultPosition,
|
|
||||||
const wxSize & size = wxDefaultSize,
|
|
||||||
long style = 0)
|
|
||||||
: wxButton(parent, id, label, pos, size, style), m_name(name)
|
|
||||||
{
|
|
||||||
//w13
|
|
||||||
//SetBackgroundColour(wxColour(100, 100, 105));
|
|
||||||
//SetMinSize(wxSize(40, -1));
|
|
||||||
|
|
||||||
Bind(wxEVT_PAINT, &MyRoundButton::OnPaint, this);
|
|
||||||
Bind(wxEVT_SET_FOCUS, &MyRoundButton::OnFocusEvent, this);
|
|
||||||
Bind(wxEVT_KILL_FOCUS, &MyRoundButton::OnFocusEvent, this);
|
|
||||||
}
|
|
||||||
void OnFocusEvent(wxFocusEvent &evt);
|
|
||||||
void OnPaint(wxPaintEvent &evt);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void DrawRoundedRect(wxDC &dc, wxRect rect, int radius){
|
|
||||||
dc.DrawRoundedRectangle(rect, radius);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
} // GUI
|
} // GUI
|
||||||
|
|||||||
Reference in New Issue
Block a user