mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-08 07:27:41 -06:00
Fix compatibility with STL builds of wxWidgets (#2218)
This removes the dependency on legacy wxWidgets configurations, and makes OrcaSlicer compile on STL builds. Also, the wxStringList class has been obsolete for at least 20 years, and disappeared from the documentation. Replace with wxArrayString.
This commit is contained in:
parent
ff992aa650
commit
ca534b5b96
5 changed files with 52 additions and 47 deletions
|
@ -623,11 +623,15 @@ void Slic3r::GUI::ImageGrid::renderContent1(wxDC &dc, wxPoint const &pt, int ind
|
||||||
}
|
}
|
||||||
// Draw buttons on hovered item
|
// Draw buttons on hovered item
|
||||||
wxRect rect{pt.x, pt.y + m_content_rect.GetBottom() - m_buttons_background.GetHeight(), m_content_rect.GetWidth(), m_buttons_background.GetHeight()};
|
wxRect rect{pt.x, pt.y + m_content_rect.GetBottom() - m_buttons_background.GetHeight(), m_content_rect.GetWidth(), m_buttons_background.GetHeight()};
|
||||||
|
wxArrayString texts;
|
||||||
if (hit) {
|
if (hit) {
|
||||||
renderButtons(dc, {_L("Delete"), (wxChar const *) secondAction, thirdAction.IsEmpty() ? nullptr : (wxChar const *) thirdAction, nullptr}, rect,
|
texts.Add(_L("Delete"));
|
||||||
m_hit_type == HIT_ACTION ? m_hit_item & 3 : -1, states);
|
texts.Add(secondAction);
|
||||||
|
texts.Add(thirdAction);
|
||||||
|
renderButtons(dc, texts, rect, m_hit_type == HIT_ACTION ? m_hit_item & 3 : -1, states);
|
||||||
} else if (!nonHoverText.IsEmpty()) {
|
} else if (!nonHoverText.IsEmpty()) {
|
||||||
renderButtons(dc, {(wxChar const *) nonHoverText, nullptr}, rect, -1, states);
|
texts.Add(nonHoverText);
|
||||||
|
renderButtons(dc, texts, rect, -1, states);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dc.SetTextForeground(*wxWHITE); // time text color
|
dc.SetTextForeground(*wxWHITE); // time text color
|
||||||
|
@ -673,7 +677,7 @@ void Slic3r::GUI::ImageGrid::renderContent2(wxDC &dc, wxPoint const &pt, int ind
|
||||||
renderIconText(dc, m_model_weight_icon, file.Metadata("Weight", "0g"), rect);
|
renderIconText(dc, m_model_weight_icon, file.Metadata("Weight", "0g"), rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Slic3r::GUI::ImageGrid::renderButtons(wxDC &dc, wxStringList const &texts, wxRect const &rect2, size_t hit, int states)
|
void Slic3r::GUI::ImageGrid::renderButtons(wxDC &dc, wxArrayString const &texts, wxRect const &rect2, size_t hit, int states)
|
||||||
{
|
{
|
||||||
// Draw background
|
// Draw background
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#define ImageGrid_h
|
#define ImageGrid_h
|
||||||
|
|
||||||
#include <wx/window.h>
|
#include <wx/window.h>
|
||||||
|
#include <wx/arrstr.h>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include "Widgets/StateColor.hpp"
|
#include "Widgets/StateColor.hpp"
|
||||||
|
@ -84,7 +85,7 @@ protected:
|
||||||
|
|
||||||
void renderContent2(wxDC &dc, wxPoint const &pt, int index, bool hit);
|
void renderContent2(wxDC &dc, wxPoint const &pt, int index, bool hit);
|
||||||
|
|
||||||
void renderButtons(wxDC &dc, wxStringList const &texts, wxRect const &rect, size_t hit, int states);
|
void renderButtons(wxDC &dc, wxArrayString const &texts, wxRect const &rect, size_t hit, int states);
|
||||||
|
|
||||||
void renderText(wxDC &dc, wxString const &text, wxRect const &rect, int states);
|
void renderText(wxDC &dc, wxString const &text, wxRect const &rect, int states);
|
||||||
|
|
||||||
|
|
|
@ -9240,49 +9240,49 @@ wxBoxSizer *ProjectDropDialog::create_item_checkbox(wxString title, wxWindow *pa
|
||||||
void ProjectDropDialog::select_radio(int index)
|
void ProjectDropDialog::select_radio(int index)
|
||||||
{
|
{
|
||||||
m_action = index;
|
m_action = index;
|
||||||
RadioSelectorList::Node *node = m_radio_group.GetFirst();
|
RadioSelectorList::compatibility_iterator it = m_radio_group.GetFirst();
|
||||||
auto groupid = 0;
|
auto groupid = 0;
|
||||||
|
|
||||||
while (node) {
|
while (it) {
|
||||||
RadioSelector *rs = node->GetData();
|
RadioSelector *rs = it->GetData();
|
||||||
if (rs->m_select_id == index) groupid = rs->m_groupid;
|
if (rs->m_select_id == index) groupid = rs->m_groupid;
|
||||||
node = node->GetNext();
|
it = it->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
node = m_radio_group.GetFirst();
|
it = m_radio_group.GetFirst();
|
||||||
while (node) {
|
while (it) {
|
||||||
RadioSelector *rs = node->GetData();
|
RadioSelector *rs = it->GetData();
|
||||||
if (rs->m_groupid == groupid && rs->m_select_id == index) rs->m_radiobox->SetValue(true);
|
if (rs->m_groupid == groupid && rs->m_select_id == index) rs->m_radiobox->SetValue(true);
|
||||||
if (rs->m_groupid == groupid && rs->m_select_id != index) rs->m_radiobox->SetValue(false);
|
if (rs->m_groupid == groupid && rs->m_select_id != index) rs->m_radiobox->SetValue(false);
|
||||||
node = node->GetNext();
|
it = it->GetNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ProjectDropDialog::get_select_radio(int groupid)
|
int ProjectDropDialog::get_select_radio(int groupid)
|
||||||
{
|
{
|
||||||
RadioSelectorList::Node *node = m_radio_group.GetFirst();
|
RadioSelectorList::compatibility_iterator it = m_radio_group.GetFirst();
|
||||||
while (node) {
|
while (it) {
|
||||||
RadioSelector *rs = node->GetData();
|
RadioSelector *rs = it->GetData();
|
||||||
if (rs->m_groupid == groupid && rs->m_radiobox->GetValue()) { return rs->m_select_id; }
|
if (rs->m_groupid == groupid && rs->m_radiobox->GetValue()) { return rs->m_select_id; }
|
||||||
node = node->GetNext();
|
it = it->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void ProjectDropDialog::on_select_radio(wxMouseEvent &event)
|
void ProjectDropDialog::on_select_radio(wxMouseEvent &event)
|
||||||
{
|
{
|
||||||
RadioSelectorList::Node *node = m_radio_group.GetFirst();
|
RadioSelectorList::compatibility_iterator it = m_radio_group.GetFirst();
|
||||||
auto groupid = 0;
|
auto groupid = 0;
|
||||||
|
|
||||||
while (node) {
|
while (it) {
|
||||||
RadioSelector *rs = node->GetData();
|
RadioSelector *rs = it->GetData();
|
||||||
if (rs->m_radiobox->GetId() == event.GetId()) groupid = rs->m_groupid;
|
if (rs->m_radiobox->GetId() == event.GetId()) groupid = rs->m_groupid;
|
||||||
node = node->GetNext();
|
it = it->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
node = m_radio_group.GetFirst();
|
it = m_radio_group.GetFirst();
|
||||||
while (node) {
|
while (it) {
|
||||||
RadioSelector *rs = node->GetData();
|
RadioSelector *rs = it->GetData();
|
||||||
if (rs->m_groupid == groupid && rs->m_radiobox->GetId() == event.GetId()) {
|
if (rs->m_groupid == groupid && rs->m_radiobox->GetId() == event.GetId()) {
|
||||||
set_action(rs->m_select_id);
|
set_action(rs->m_select_id);
|
||||||
rs->m_radiobox->SetValue(true);
|
rs->m_radiobox->SetValue(true);
|
||||||
|
@ -9290,7 +9290,7 @@ void ProjectDropDialog::on_select_radio(wxMouseEvent &event)
|
||||||
|
|
||||||
|
|
||||||
if (rs->m_groupid == groupid && rs->m_radiobox->GetId() != event.GetId()) rs->m_radiobox->SetValue(false);
|
if (rs->m_groupid == groupid && rs->m_radiobox->GetId() != event.GetId()) rs->m_radiobox->SetValue(false);
|
||||||
node = node->GetNext();
|
it = it->GetNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1307,31 +1307,31 @@ wxWindow* PreferencesDialog::create_debug_page()
|
||||||
|
|
||||||
void PreferencesDialog::on_select_radio(std::string param)
|
void PreferencesDialog::on_select_radio(std::string param)
|
||||||
{
|
{
|
||||||
RadioSelectorList::Node *node = m_radio_group.GetFirst();
|
RadioSelectorList::compatibility_iterator it = m_radio_group.GetFirst();
|
||||||
auto groupid = 0;
|
auto groupid = 0;
|
||||||
|
|
||||||
while (node) {
|
while (it) {
|
||||||
RadioSelector *rs = node->GetData();
|
RadioSelector *rs = it->GetData();
|
||||||
if (rs->m_param_name == param) groupid = rs->m_groupid;
|
if (rs->m_param_name == param) groupid = rs->m_groupid;
|
||||||
node = node->GetNext();
|
it = it->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
node = m_radio_group.GetFirst();
|
it = m_radio_group.GetFirst();
|
||||||
while (node) {
|
while (it) {
|
||||||
RadioSelector *rs = node->GetData();
|
RadioSelector *rs = it->GetData();
|
||||||
if (rs->m_groupid == groupid && rs->m_param_name == param) rs->m_radiobox->SetValue(true);
|
if (rs->m_groupid == groupid && rs->m_param_name == param) rs->m_radiobox->SetValue(true);
|
||||||
if (rs->m_groupid == groupid && rs->m_param_name != param) rs->m_radiobox->SetValue(false);
|
if (rs->m_groupid == groupid && rs->m_param_name != param) rs->m_radiobox->SetValue(false);
|
||||||
node = node->GetNext();
|
it = it->GetNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString PreferencesDialog::get_select_radio(int groupid)
|
wxString PreferencesDialog::get_select_radio(int groupid)
|
||||||
{
|
{
|
||||||
RadioSelectorList::Node *node = m_radio_group.GetFirst();
|
RadioSelectorList::compatibility_iterator it = m_radio_group.GetFirst();
|
||||||
while (node) {
|
while (it) {
|
||||||
RadioSelector *rs = node->GetData();
|
RadioSelector *rs = it->GetData();
|
||||||
if (rs->m_groupid == groupid && rs->m_radiobox->GetValue()) { return rs->m_param_name; }
|
if (rs->m_groupid == groupid && rs->m_radiobox->GetValue()) { return rs->m_param_name; }
|
||||||
node = node->GetNext();
|
it = it->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
@ -1339,21 +1339,21 @@ wxString PreferencesDialog::get_select_radio(int groupid)
|
||||||
|
|
||||||
void PreferencesDialog::OnSelectRadio(wxMouseEvent &event)
|
void PreferencesDialog::OnSelectRadio(wxMouseEvent &event)
|
||||||
{
|
{
|
||||||
RadioSelectorList::Node *node = m_radio_group.GetFirst();
|
RadioSelectorList::compatibility_iterator it = m_radio_group.GetFirst();
|
||||||
auto groupid = 0;
|
auto groupid = 0;
|
||||||
|
|
||||||
while (node) {
|
while (it) {
|
||||||
RadioSelector *rs = node->GetData();
|
RadioSelector *rs = it->GetData();
|
||||||
if (rs->m_radiobox->GetId() == event.GetId()) groupid = rs->m_groupid;
|
if (rs->m_radiobox->GetId() == event.GetId()) groupid = rs->m_groupid;
|
||||||
node = node->GetNext();
|
it = it->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
node = m_radio_group.GetFirst();
|
it = m_radio_group.GetFirst();
|
||||||
while (node) {
|
while (it) {
|
||||||
RadioSelector *rs = node->GetData();
|
RadioSelector *rs = it->GetData();
|
||||||
if (rs->m_groupid == groupid && rs->m_radiobox->GetId() == event.GetId()) rs->m_radiobox->SetValue(true);
|
if (rs->m_groupid == groupid && rs->m_radiobox->GetId() == event.GetId()) rs->m_radiobox->SetValue(true);
|
||||||
if (rs->m_groupid == groupid && rs->m_radiobox->GetId() != event.GetId()) rs->m_radiobox->SetValue(false);
|
if (rs->m_groupid == groupid && rs->m_radiobox->GetId() != event.GetId()) rs->m_radiobox->SetValue(false);
|
||||||
node = node->GetNext();
|
it = it->GetNext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -745,8 +745,8 @@ bool PrusaLink::get_storage(wxArrayString& storage_path, wxArrayString& storage_
|
||||||
const auto available = section.second.get_optional<bool>("available");
|
const auto available = section.second.get_optional<bool>("available");
|
||||||
if (path && (!available || *available)) {
|
if (path && (!available || *available)) {
|
||||||
StorageInfo si;
|
StorageInfo si;
|
||||||
si.path = boost::nowide::widen(*path);
|
si.path = wxString(*path);
|
||||||
si.name = name ? boost::nowide::widen(*name) : wxString();
|
si.name = name ? wxString(*name) : wxString();
|
||||||
// If read_only is missing, assume it is NOT read only.
|
// If read_only is missing, assume it is NOT read only.
|
||||||
// si.read_only = read_only ? *read_only : false; // version without "ro"
|
// si.read_only = read_only ? *read_only : false; // version without "ro"
|
||||||
si.read_only = (read_only ? *read_only : (ro ? *ro : false));
|
si.read_only = (read_only ? *read_only : (ro ? *ro : false));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue