#include "OG_CustomCtrl.hpp" #include "OptionsGroup.hpp" #include "Plater.hpp" #include "GUI_App.hpp" #include "MsgDialog.hpp" #include "libslic3r/AppConfig.hpp" #include #include #include "libslic3r/Utils.hpp" #include "I18N.hpp" #include "format.hpp" namespace Slic3r { namespace GUI { static bool is_point_in_rect(const wxPoint& pt, const wxRect& rect) { return rect.GetLeft() <= pt.x && pt.x <= rect.GetRight() && rect.GetTop() <= pt.y && pt.y <= rect.GetBottom(); } static wxSize get_bitmap_size(const wxBitmap& bmp) { #ifdef __APPLE__ return bmp.GetScaledSize(); #else return bmp.GetSize(); #endif } static wxString get_url(const wxString& path_end, bool get_default = false) { if (path_end.IsEmpty()) return wxEmptyString; wxString language = wxGetApp().app_config->get("translation_language"); wxString lang_marker = language.IsEmpty() ? "en" : language.BeforeFirst('_'); return wxString("https://help.prusa3d.com/") + lang_marker + "/article/" + path_end; } OG_CustomCtrl::OG_CustomCtrl( wxWindow* parent, OptionsGroup* og, const wxPoint& pos /* = wxDefaultPosition*/, const wxSize& size/* = wxDefaultSize*/, const wxValidator& val /* = wxDefaultValidator*/, const wxString& name/* = wxEmptyString*/) : wxPanel(parent, wxID_ANY, pos, size, /*wxWANTS_CHARS |*/ wxBORDER_NONE | wxTAB_TRAVERSAL), opt_group(og) { if (!wxOSX) SetDoubleBuffered(true);// SetDoubleBuffered exists on Win and Linux/GTK, but is missing on OSX m_font = wxGetApp().normal_font(); m_em_unit = em_unit(m_parent); m_v_gap = lround(1.0 * m_em_unit); m_h_gap = lround(0.2 * m_em_unit); m_bmp_mode_sz = get_bitmap_size(create_scaled_bitmap("mode_simple", this, wxOSX ? 10 : 12)); m_bmp_blinking_sz = get_bitmap_size(create_scaled_bitmap("search_blink", this)); init_ctrl_lines();// from og.lines() this->Bind(wxEVT_PAINT, &OG_CustomCtrl::OnPaint, this); this->Bind(wxEVT_MOTION, &OG_CustomCtrl::OnMotion, this); this->Bind(wxEVT_LEFT_DOWN, &OG_CustomCtrl::OnLeftDown, this); this->Bind(wxEVT_LEAVE_WINDOW, &OG_CustomCtrl::OnLeaveWin, this); } void OG_CustomCtrl::init_ctrl_lines() { const std::vector& og_lines = opt_group->get_lines(); for (const Line& line : og_lines) { if (line.full_width && ( // description line line.widget != nullptr || // description line with widget (button) !line.get_extra_widgets().empty()) ) continue; const std::vector