From 6d432f54263a0593234f9a59c69258d59243befe Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 27 May 2020 17:30:35 +0200 Subject: [PATCH] Fixes second part of #4282 (wxWidgets 3.0 compatibility) --- src/slic3r/GUI/Search.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index 9685899855..b8a7af3390 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -28,6 +28,12 @@ using GUI::into_u8; namespace Search { +// Does our wxWidgets version support markup? +// https://github.com/prusa3d/PrusaSlicer/issues/4282#issuecomment-634676371 +#if wxUSE_MARKUP && wxCHECK_VERSION(3, 1, 1) + #define SEARCH_SUPPORTS_MARKUP +#endif + static const std::vector& NameByType() { static std::vector data; @@ -271,8 +277,14 @@ bool OptionsSearcher::search(const std::string& search, bool force/* = false*/) label += L" [" + std::to_wstring(score) + L"]";// add score value std::string label_u8 = into_u8(label); std::string label_plain = label_u8; - boost::replace_all(label_plain, std::string(1, char(ImGui::ColorMarkerStart)), ""); - boost::replace_all(label_plain, std::string(1, char(ImGui::ColorMarkerEnd)), ""); + +#ifdef SEARCH_SUPPORTS_MARKUP + boost::replace_all(label_plain, std::string(1, char(ImGui::ColorMarkerStart)), ""); + boost::replace_all(label_plain, std::string(1, char(ImGui::ColorMarkerEnd)), ""); +#else + boost::erase_all(label_plain, std::string(1, char(ImGui::ColorMarkerStart))); + boost::erase_all(label_plain, std::string(1, char(ImGui::ColorMarkerEnd))); +#endif found.emplace_back(FoundOption{ label_plain, label_u8, boost::nowide::narrow(get_tooltip(opt)), i, score }); } } @@ -443,9 +455,11 @@ SearchDialog::SearchDialog(OptionsSearcher* searcher) search_list->AppendBitmapColumn("", SearchListModel::colIcon); wxDataViewTextRenderer* const markupRenderer = new wxDataViewTextRenderer(); -#if wxUSE_MARKUP + +#ifdef SEARCH_SUPPORTS_MARKUP markupRenderer->EnableMarkup(); -#endif // wxUSE_MARKUP +#endif + search_list->AppendColumn(new wxDataViewColumn("", markupRenderer, SearchListModel::colMarkedText, wxCOL_WIDTH_AUTOSIZE, wxALIGN_LEFT)); search_list->GetColumn(SearchListModel::colIcon )->SetWidth(3 * em_unit());