Fixing build against wxWidgets 3.0

The wxString saga continues. wxWidgets 3.0 don't have the wxString::FromUTF8(const std::string&) overload, we must use the GUI::from_u8 helper
Also wxWidgets 3.0 don't allow to disable wxString->const char* conversion, so calling show_info(wxWindow*, wxString, const char*) was ambiguous
Several includes moved around
This commit is contained in:
Lukas Matena 2020-03-04 09:24:13 +01:00
parent a87ba5d6a6
commit eb3b65d8af
15 changed files with 28 additions and 22 deletions

View file

@ -16,8 +16,8 @@
#include "Point.hpp"
#include <boost/algorithm/string/trim.hpp>
#include <boost/format.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/format/format_fwd.hpp>
#include <boost/property_tree/ptree_fwd.hpp>
#include <cereal/access.hpp>
#include <cereal/types/base_class.hpp>

View file

@ -1,4 +1,5 @@
#include "Extruder.hpp"
#include "PrintConfig.hpp"
namespace Slic3r {

View file

@ -3,10 +3,11 @@
#include "libslic3r.h"
#include "Point.hpp"
#include "PrintConfig.hpp"
namespace Slic3r {
class GCodeConfig;
class Extruder
{
public:

View file

@ -36,7 +36,7 @@ void AboutDialogLogo::onRepaint(wxEvent &event)
// CopyrightsDialog
// -----------------------------------------
CopyrightsDialog::CopyrightsDialog()
: DPIDialog(NULL, wxID_ANY, wxString::FromUTF8((boost::format("%1% - %2%")
: DPIDialog(NULL, wxID_ANY, from_u8((boost::format("%1% - %2%")
% SLIC3R_APP_NAME
% _utf8(L("Portions copyright"))).str()),
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
@ -198,7 +198,7 @@ void CopyrightsDialog::onCloseDialog(wxEvent &)
}
AboutDialog::AboutDialog()
: DPIDialog(NULL, wxID_ANY, wxString::FromUTF8((boost::format(_utf8(L("About %s"))) % SLIC3R_APP_NAME).str()), wxDefaultPosition,
: DPIDialog(NULL, wxID_ANY, from_u8((boost::format(_utf8(L("About %s"))) % SLIC3R_APP_NAME).str()), wxDefaultPosition,
wxDefaultSize, /*wxCAPTION*/wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
{
SetFont(wxGetApp().normal_font());
@ -261,7 +261,7 @@ AboutDialog::AboutDialog()
const std::string license_str = _utf8(L("GNU Affero General Public License, version 3"));
const std::string based_on_str = _utf8(L("PrusaSlicer is based on Slic3r by Alessandro Ranellucci and the RepRap community."));
const std::string contributors_str = _utf8(L("Contributions by Henrik Brix Andersen, Nicolas Dandrimont, Mark Hindess, Petr Ledvina, Joseph Lenox, Y. Sapir, Mike Sheldrake, Vojtech Bubnik and numerous others."));
const auto text = wxString::FromUTF8(
const auto text = from_u8(
(boost::format(
"<html>"
"<body bgcolor= %1% link= %2%>"

View file

@ -1,5 +1,6 @@
#include "BackgroundSlicingProcess.hpp"
#include "GUI_App.hpp"
#include "GUI.hpp"
#include <wx/app.h>
#include <wx/panel.h>
@ -219,7 +220,7 @@ void BackgroundSlicingProcess::thread_proc()
// Canceled, this is all right.
assert(m_print->canceled());
} catch (const std::bad_alloc& ex) {
wxString errmsg = wxString::FromUTF8((boost::format(_utf8(L("%s has encountered an error. It was likely caused by running out of memory. "
wxString errmsg = GUI::from_u8((boost::format(_utf8(L("%s has encountered an error. It was likely caused by running out of memory. "
"If you are sure you have enough RAM on your system, this may also be a bug and we would "
"be glad if you reported it."))) % SLIC3R_APP_NAME).str());
error = std::string(errmsg.ToUTF8()) + "\n\n" + std::string(ex.what());

View file

@ -219,10 +219,10 @@ void BonjourDialog::on_timer(wxTimerEvent &)
if (timer_state > 0) {
const std::string dots(timer_state, '.');
label->SetLabel(wxString::FromUTF8((boost::format("%1% %2%") % search_str % dots).str()));
label->SetLabel(GUI::from_u8((boost::format("%1% %2%") % search_str % dots).str()));
timer_state = (timer_state) % 3 + 1;
} else {
label->SetLabel(wxString::FromUTF8((boost::format("%1%: %2%") % search_str % (_utf8(L("Finished"))+".")).str()));
label->SetLabel(GUI::from_u8((boost::format("%1%: %2%") % search_str % (_utf8(L("Finished"))+".")).str()));
timer->Stop();
}
}

View file

@ -72,7 +72,7 @@ static wxString generate_html_row(const Config::Snapshot &snapshot, bool row_eve
}
if (! compatible) {
text += "<p align=\"right\">" + wxString::FromUTF8((boost::format(_utf8(L("Incompatible with this %s"))) % SLIC3R_APP_NAME).str()) + "</p>";
text += "<p align=\"right\">" + from_u8((boost::format(_utf8(L("Incompatible with this %s"))) % SLIC3R_APP_NAME).str()) + "</p>";
}
else if (! snapshot_active)
text += "<p align=\"right\"><a href=\"" + snapshot.id + "\">" + _(L("Activate")) + "</a></p>";

View file

@ -422,14 +422,14 @@ void ConfigWizardPage::append_spacer(int space)
// Wizard pages
PageWelcome::PageWelcome(ConfigWizard *parent)
: ConfigWizardPage(parent, wxString::FromUTF8((boost::format(
: ConfigWizardPage(parent, from_u8((boost::format(
#ifdef __APPLE__
_utf8(L("Welcome to the %s Configuration Assistant"))
#else
_utf8(L("Welcome to the %s Configuration Wizard"))
#endif
) % SLIC3R_APP_NAME).str()), _(L("Welcome")))
, welcome_text(append_text(wxString::FromUTF8((boost::format(
, welcome_text(append_text(from_u8((boost::format(
_utf8(L("Hello, welcome to %s! This %s helps you with the initial configuration; just a few settings and you will be ready to print.")))
% SLIC3R_APP_NAME
% _utf8(ConfigWizard::name())).str())
@ -478,7 +478,7 @@ PagePrinters::PagePrinters(ConfigWizard *parent,
continue;
}
const auto picker_title = family.empty() ? wxString() : wxString::FromUTF8((boost::format(_utf8(L("%s Family"))) % family).str());
const auto picker_title = family.empty() ? wxString() : from_u8((boost::format(_utf8(L("%s Family"))) % family).str());
auto *picker = new PrinterPicker(this, vendor, picker_title, MAX_COLS, *appconfig, filter);
picker->Bind(EVT_PRINTER_PICK, [this, appconfig](const PrinterPickerEvent &evt) {

View file

@ -952,7 +952,7 @@ wxString Control::get_tooltip(int tick/*=-1*/)
return _(L("Discard all custom changes"));
if (m_focus == fiCogIcon)
return m_mode == t_mode::MultiAsSingle ?
wxString::FromUTF8((boost::format(_utf8(L("Jump to height %s or "
GUI::from_u8((boost::format(_utf8(L("Jump to height %s or "
"Set extruder sequence for the entire print"))) % " (Shift + G)\n").str()) :
_(L("Jump to height")) + " (Shift + G)";
if (m_focus == fiColorBand)

View file

@ -1,7 +1,8 @@
#ifndef slic3r_GUI_hpp_
#define slic3r_GUI_hpp_
#include <boost/filesystem/path.hpp>
namespace boost { class any; }
namespace boost::filesystem { class path; }
#include <wx/string.h>

View file

@ -1,7 +1,8 @@
#ifndef slic3r_LambdaObjectDialog_hpp_
#define slic3r_LambdaObjectDialog_hpp_
#include "GUI.hpp"
#include <vector>
#include <memory>
#include <wx/dialog.h>
#include <wx/sizer.h>

View file

@ -1029,7 +1029,7 @@ void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool re
wxGetApp().load_current_presets();
const auto message = wxString::Format(_(L("%d presets successfully imported.")), presets_imported);
Slic3r::GUI::show_info(this, message, "Info");
Slic3r::GUI::show_info(this, message, wxString("Info"));
}
// Load a provied DynamicConfig into the Print / Filament / Printer tabs, thus modifying the active preset.

View file

@ -3,6 +3,7 @@
#include "GLCanvas3D.hpp"
#include "GUI_App.hpp"
#include "GUI.hpp"
#include "GUI_ObjectManipulation.hpp"
#include "GUI_ObjectList.hpp"
#include "Gizmos/GLGizmoBase.hpp"
@ -1470,7 +1471,7 @@ void Selection::toggle_instance_printable_state()
ModelInstance* instance = model_object->instances[instance_idx];
const bool printable = !instance->printable;
wxString snapshot_text = model_object->instances.size() == 1 ? wxString::FromUTF8((boost::format("%1% %2%")
wxString snapshot_text = model_object->instances.size() == 1 ? from_u8((boost::format("%1% %2%")
% (printable ? _utf8(L("Set Printable")) : _utf8(L("Set Unprintable")))
% model_object->name).str()) :
(printable ? _(L("Set Printable Instance")) : _(L("Set Unprintable Instance")));

View file

@ -604,7 +604,7 @@ void apply_extruder_selector(wxBitmapComboBox** ctrl,
}
(*ctrl)->Append(use_full_item_name
? wxString::FromUTF8((boost::format("%1% %2%") % str % i).str())
? Slic3r::GUI::from_u8((boost::format("%1% %2%") % str % i).str())
: wxString::Format("%d", i), *bmp);
++i;
}
@ -703,8 +703,8 @@ ModeButton::ModeButton( wxWindow* parent,
void ModeButton::Init(const wxString &mode)
{
std::string mode_str = std::string(mode.ToUTF8());
m_tt_focused = wxString::FromUTF8((boost::format(_utf8(L("Switch to the %s mode"))) % mode_str).str());
m_tt_selected = wxString::FromUTF8((boost::format(_utf8(L("Current mode is %s"))) % mode_str).str());
m_tt_focused = Slic3r::GUI::from_u8((boost::format(_utf8(L("Switch to the %s mode"))) % mode_str).str());
m_tt_selected = Slic3r::GUI::from_u8((boost::format(_utf8(L("Current mode is %s"))) % mode_str).str());
SetBitmapMargins(3, 0);

View file

@ -70,7 +70,7 @@ wxString FlashAir::get_test_ok_msg () const
wxString FlashAir::get_test_failed_msg (wxString &msg) const
{
return wxString::FromUTF8((boost::format("%s: %s")
return GUI::from_u8((boost::format("%s: %s")
% _utf8(L("Could not connect to FlashAir"))
% std::string(msg.ToUTF8())
% _utf8(L("Note: FlashAir with firmware 2.00.02 or newer and activated upload function is required."))).str());