669 : wxPanel(parent,wxID_ANY,wxDefaultPosition,wxDefaultSize ,wxNO_BORDER)
670{
671 m_web_view = wxWebView::New(
this, wxID_ANY, wxEmptyString, wxDefaultPosition,wxDefaultSize,wxString::FromAscii(wxWebViewBackendDefault),wxNO_BORDER);
672 m_web_view->AddScriptMessageHandler(
"nozzleListTable");
674 fs::path filepath = fs::path(
resources_dir()) /
"web/flush/NozzleListTable.html";
677
678 auto sizer = new wxBoxSizer(wxVERTICAL);
679 sizer->AddStretchSpacer(0);
681 sizer->AddStretchSpacer(0);
682 SetSizer(sizer);
683 Layout();
684
685 m_web_view->Bind(wxEVT_WEBVIEW_SCRIPT_MESSAGE_RECEIVED, [
this](wxWebViewEvent& evt) {
686 std::string message = evt.GetString().ToStdString();
687 BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << "Received message: " << message;
688 try {
689 json j = json::parse(message);
690 if (j["msg"].get<std::string>() == "init") {
693 CallAfter([table_obj_str, text_obj_str, this] {
694 wxString script1 = wxString::Format("initText(%s)", text_obj_str);
696 wxString script2 = wxString::Format("initTable(%s)", table_obj_str);
698 });
699 }
700 else if (j["msg"].get<std::string>() == "updateList") {
702
703 CallAfter([table_obj_str, this] {
704 wxString script1 = wxString::Format("updateTable(%s)", table_obj_str);
706 });
707
708 }
709 else if (j["msg"].get<std::string>() == "onSelect") {
710 int idx = j["index"].get<int>();
713 }
714 else if (j["msg"].get<std::string>() == "layout") {
715 int height = j[
"height"].get<
int>();
716 int width = j[
"width"].get<
int>();
717 wxSize table_size = wxSize(-1, FromDIP(height));
721 this->Layout();
722 this->GetParent()->Layout();
723 this->GetParent()->Fit();
724 }
725 }
726 catch (...) {
727 BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << "Failed to parse json message: " << message;
728 }
729 });
730
731 wxGetApp().UpdateDarkUIWin(this);
732}
wxString BuildTableObjStr()
Definition MultiNozzleSync.cpp:734
int m_selected_idx
Definition MultiNozzleSync.hpp:156
wxWebView * m_web_view
Definition MultiNozzleSync.hpp:154
wxString BuildTextObjStr()
Definition MultiNozzleSync.cpp:766
void SendSelectionChangedEvent()
Definition MultiNozzleSync.cpp:759
wxString file_url_from_path(const boost::filesystem::path &path)
Definition GUI.cpp:569
coord_t width(const BoundingBox &box)
Definition Arrange.cpp:1184
coord_t height(const BoundingBox &box)
Definition Arrange.cpp:1185
nlohmann::json json
Definition AssembleList.cpp:42
const std::string & resources_dir()
Definition utils.cpp:296