From f6b6d222dc1a79c95f6756c707c5fcc3a785c030 Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Sun, 6 Feb 2022 16:41:53 -0500 Subject: add upstream 11.17 --- wx+/file_drop.h | 2 +- wx+/graph.h | 2 +- wx+/image_resources.cpp | 14 ++++-- wx+/popup_dlg_generated.cpp | 104 ++++++++++++++++++++++---------------------- wx+/popup_dlg_generated.h | 46 ++++++++++---------- wx+/tooltip.cpp | 2 +- 6 files changed, 89 insertions(+), 81 deletions(-) (limited to 'wx+') diff --git a/wx+/file_drop.h b/wx+/file_drop.h index 68024091..16c2b519 100644 --- a/wx+/file_drop.h +++ b/wx+/file_drop.h @@ -18,7 +18,7 @@ namespace zen { /* register simple file drop event (without issue of freezing dialogs and without wxFileDropTarget overdesign) CAVEAT: a drop target window must not be directly or indirectly contained within a wxStaticBoxSizer until the following wxGTK bug - is fixed. According to wxWidgets release cycles this is expected to be: never https://trac.wxwidgets.org/ticket/2763 + is fixed. According to wxWidgets release cycles this is expected to be: never https://github.com/wxWidgets/wxWidgets/issues/2763 1. setup a window to emit EVENT_DROP_FILE: - simple file system paths: setupFileDrop diff --git a/wx+/graph.h b/wx+/graph.h index 55734a06..e9f6af32 100644 --- a/wx+/graph.h +++ b/wx+/graph.h @@ -54,7 +54,7 @@ private: struct SparseCurveData : public CurveData { - SparseCurveData(bool addSteps = false) : addSteps_(addSteps) {} //addSteps: add points to get a staircase effect or connect points via a direct line + explicit SparseCurveData(bool addSteps = false) : addSteps_(addSteps) {} //addSteps: add points to get a staircase effect or connect points via a direct line virtual std::optional getLessEq (double x) const = 0; virtual std::optional getGreaterEq(double x) const = 0; diff --git a/wx+/image_resources.cpp b/wx+/image_resources.cpp index fbfeb0d8..c7260c55 100644 --- a/wx+/image_resources.cpp +++ b/wx+/image_resources.cpp @@ -73,6 +73,7 @@ ImageHolder xbrzScale(int width, int height, const unsigned char* imageRgb, cons auto getScalerTask(const std::string& imageName, const wxImage& img, int hqScale, Protected>>& result) { + assert(runningOnMainThread()); return [imageName, width = img.GetWidth(), // height = img.GetHeight(), //don't call wxWidgets functions from worker thread @@ -89,18 +90,20 @@ auto getScalerTask(const std::string& imageName, const wxImage& img, int hqScale class HqParallelScaler { public: - HqParallelScaler(int hqScale) : hqScale_(hqScale) { assert(hqScale > 1); } + explicit HqParallelScaler(int hqScale) : hqScale_(hqScale) { assert(hqScale > 1); } ~HqParallelScaler() { threadGroup_ = {}; } //imgKeeper_ must out-live threadGroup!!! void add(const std::string& imageName, const wxImage& img) { + assert(runningOnMainThread()); imgKeeper_.push_back(img); //retain (ref-counted) wxImage so that the rgb/alpha pointers remain valid after passed to threads threadGroup_->run(getScalerTask(imageName, img, hqScale_, result_)); } std::unordered_map waitAndGetResult() { + assert(runningOnMainThread()); threadGroup_->wait(); std::unordered_map output; @@ -184,14 +187,17 @@ ImageBuffer::ImageBuffer(const Zstring& zipPath) //throw FileError //do NOT rely on wxConvLocal! On failure shows unhelpful popup "Cannot convert from the charset 'Unknown encoding (-1)'!" while (const auto& entry = std::unique_ptr(zipStream.GetNextEntry())) //take ownership! - if (std::string stream(entry->GetSize(), '\0'); !stream.empty() && zipStream.ReadAll(&stream[0], stream.size())) + if (std::string stream(entry->GetSize(), '\0'); + zipStream.ReadAll(stream.data(), stream.size())) streams.emplace_back(utfTo(entry->GetName()), std::move(stream)); else assert(false); } catch (FileError&) //fall back to folder { - traverseFolder(beforeLast(zipPath, Zstr(".zip"), IfNotFoundReturn::none), [&](const FileInfo& fi) + const Zstring fallbackFolder = beforeLast(zipPath, Zstr(".zip"), IfNotFoundReturn::none); + if (dirAvailable(fallbackFolder)) //Debug build (only!?) + traverseFolder(fallbackFolder, [&](const FileInfo& fi) { if (endsWith(fi.fullPath, Zstr(".png"))) { @@ -199,6 +205,8 @@ ImageBuffer::ImageBuffer(const Zstring& zipPath) //throw FileError streams.emplace_back(fi.itemName, std::move(stream)); } }, nullptr, nullptr, [](const std::wstring& errorMsg) { throw FileError(errorMsg); }); + else + throw; } //-------------------------------------------------------------------- diff --git a/wx+/popup_dlg_generated.cpp b/wx+/popup_dlg_generated.cpp index 43841437..fb449d13 100644 --- a/wx+/popup_dlg_generated.cpp +++ b/wx+/popup_dlg_generated.cpp @@ -11,88 +11,88 @@ PopupDialogGenerated::PopupDialogGenerated( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) { - this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); - this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); + this->SetSizeHints( wxSize( -1, -1 ), wxDefaultSize ); + this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); - wxBoxSizer* bSizer24; - bSizer24 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizer24; + bSizer24 = new wxBoxSizer( wxVERTICAL ); - m_panel33 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); - m_panel33->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); + m_panel33 = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + m_panel33->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); - wxBoxSizer* bSizer165; - bSizer165 = new wxBoxSizer( wxHORIZONTAL ); + wxBoxSizer* bSizer165; + bSizer165 = new wxBoxSizer( wxHORIZONTAL ); - m_bitmapMsgType = new wxStaticBitmap( m_panel33, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizer165->Add( m_bitmapMsgType, 0, wxALL, 10 ); + m_bitmapMsgType = new wxStaticBitmap( m_panel33, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxSize( -1, -1 ), 0 ); + bSizer165->Add( m_bitmapMsgType, 0, wxALL, 10 ); - wxBoxSizer* bSizer16; - bSizer16 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizer16; + bSizer16 = new wxBoxSizer( wxVERTICAL ); - bSizer16->Add( 0, 10, 0, 0, 5 ); + bSizer16->Add( 0, 10, 0, 0, 5 ); - m_staticTextMain = new wxStaticText( m_panel33, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticTextMain->Wrap( -1 ); - bSizer16->Add( m_staticTextMain, 0, wxBOTTOM|wxRIGHT, 10 ); + m_staticTextMain = new wxStaticText( m_panel33, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticTextMain->Wrap( -1 ); + bSizer16->Add( m_staticTextMain, 0, wxBOTTOM|wxRIGHT, 10 ); - m_richTextDetail = new wxRichTextCtrl( m_panel33, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxBORDER_NONE|wxVSCROLL|wxWANTS_CHARS ); - bSizer16->Add( m_richTextDetail, 1, wxEXPAND, 5 ); + m_richTextDetail = new wxRichTextCtrl( m_panel33, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_READONLY|wxBORDER_NONE|wxVSCROLL|wxWANTS_CHARS ); + bSizer16->Add( m_richTextDetail, 1, wxEXPAND, 5 ); - bSizer165->Add( bSizer16, 1, wxEXPAND, 5 ); + bSizer165->Add( bSizer16, 1, wxEXPAND, 5 ); - m_panel33->SetSizer( bSizer165 ); - m_panel33->Layout(); - bSizer165->Fit( m_panel33 ); - bSizer24->Add( m_panel33, 1, wxEXPAND, 5 ); + m_panel33->SetSizer( bSizer165 ); + m_panel33->Layout(); + bSizer165->Fit( m_panel33 ); + bSizer24->Add( m_panel33, 1, wxEXPAND, 5 ); - m_staticline6 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); - bSizer24->Add( m_staticline6, 0, wxEXPAND, 5 ); + m_staticline6 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bSizer24->Add( m_staticline6, 0, wxEXPAND, 5 ); - wxBoxSizer* bSizer25; - bSizer25 = new wxBoxSizer( wxVERTICAL ); + wxBoxSizer* bSizer25; + bSizer25 = new wxBoxSizer( wxVERTICAL ); - m_checkBoxCustom = new wxCheckBox( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer25->Add( m_checkBoxCustom, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); + m_checkBoxCustom = new wxCheckBox( this, wxID_ANY, _("dummy"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer25->Add( m_checkBoxCustom, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5 ); - bSizerStdButtons = new wxBoxSizer( wxHORIZONTAL ); + bSizerStdButtons = new wxBoxSizer( wxHORIZONTAL ); - m_buttonAccept = new wxButton( this, wxID_YES, _("dummy"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); + m_buttonAccept = new wxButton( this, wxID_YES, _("dummy"), wxDefaultPosition, wxSize( -1, -1 ), 0 ); - m_buttonAccept->SetDefault(); - bSizerStdButtons->Add( m_buttonAccept, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_buttonAccept->SetDefault(); + bSizerStdButtons->Add( m_buttonAccept, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - m_buttonAccept2 = new wxButton( this, wxID_YESTOALL, _("dummy"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizerStdButtons->Add( m_buttonAccept2, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + m_buttonAccept2 = new wxButton( this, wxID_YESTOALL, _("dummy"), wxDefaultPosition, wxSize( -1, -1 ), 0 ); + bSizerStdButtons->Add( m_buttonAccept2, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); - m_buttonDecline = new wxButton( this, wxID_NO, _("dummy"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizerStdButtons->Add( m_buttonDecline, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + m_buttonDecline = new wxButton( this, wxID_NO, _("dummy"), wxDefaultPosition, wxSize( -1, -1 ), 0 ); + bSizerStdButtons->Add( m_buttonDecline, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); - m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1,-1 ), 0 ); - bSizerStdButtons->Add( m_buttonCancel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); + m_buttonCancel = new wxButton( this, wxID_CANCEL, _("Cancel"), wxDefaultPosition, wxSize( -1, -1 ), 0 ); + bSizerStdButtons->Add( m_buttonCancel, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT, 5 ); - bSizer25->Add( bSizerStdButtons, 0, wxALIGN_RIGHT, 5 ); + bSizer25->Add( bSizerStdButtons, 0, wxALIGN_RIGHT, 5 ); - bSizer24->Add( bSizer25, 0, wxEXPAND, 5 ); + bSizer24->Add( bSizer25, 0, wxEXPAND, 5 ); - this->SetSizer( bSizer24 ); - this->Layout(); - bSizer24->Fit( this ); + this->SetSizer( bSizer24 ); + this->Layout(); + bSizer24->Fit( this ); - this->Centre( wxBOTH ); + this->Centre( wxBOTH ); - // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PopupDialogGenerated::onClose ) ); - m_checkBoxCustom->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PopupDialogGenerated::onCheckBoxClick ), NULL, this ); - m_buttonAccept->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::onButtonAccept ), NULL, this ); - m_buttonAccept2->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::onButtonAccept2 ), NULL, this ); - m_buttonDecline->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::onButtonDecline ), NULL, this ); - m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::onCancel ), NULL, this ); + // Connect Events + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PopupDialogGenerated::onClose ) ); + m_checkBoxCustom->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PopupDialogGenerated::onCheckBoxClick ), NULL, this ); + m_buttonAccept->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::onButtonAccept ), NULL, this ); + m_buttonAccept2->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::onButtonAccept2 ), NULL, this ); + m_buttonDecline->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::onButtonDecline ), NULL, this ); + m_buttonCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PopupDialogGenerated::onCancel ), NULL, this ); } PopupDialogGenerated::~PopupDialogGenerated() diff --git a/wx+/popup_dlg_generated.h b/wx+/popup_dlg_generated.h index d7dcf5fd..6218c6d8 100644 --- a/wx+/popup_dlg_generated.h +++ b/wx+/popup_dlg_generated.h @@ -38,35 +38,35 @@ /////////////////////////////////////////////////////////////////////////////// class PopupDialogGenerated : public wxDialog { - private: +private: - protected: - wxPanel* m_panel33; - wxStaticBitmap* m_bitmapMsgType; - wxStaticText* m_staticTextMain; - wxRichTextCtrl* m_richTextDetail; - wxStaticLine* m_staticline6; - wxCheckBox* m_checkBoxCustom; - wxBoxSizer* bSizerStdButtons; - wxButton* m_buttonAccept; - wxButton* m_buttonAccept2; - wxButton* m_buttonDecline; - wxButton* m_buttonCancel; +protected: + wxPanel* m_panel33; + wxStaticBitmap* m_bitmapMsgType; + wxStaticText* m_staticTextMain; + wxRichTextCtrl* m_richTextDetail; + wxStaticLine* m_staticline6; + wxCheckBox* m_checkBoxCustom; + wxBoxSizer* bSizerStdButtons; + wxButton* m_buttonAccept; + wxButton* m_buttonAccept2; + wxButton* m_buttonDecline; + wxButton* m_buttonCancel; - // Virtual event handlers, override them in your derived class - virtual void onClose( wxCloseEvent& event ) { event.Skip(); } - virtual void onCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } - virtual void onButtonAccept( wxCommandEvent& event ) { event.Skip(); } - virtual void onButtonAccept2( wxCommandEvent& event ) { event.Skip(); } - virtual void onButtonDecline( wxCommandEvent& event ) { event.Skip(); } - virtual void onCancel( wxCommandEvent& event ) { event.Skip(); } + // Virtual event handlers, override them in your derived class + virtual void onClose( wxCloseEvent& event ) { event.Skip(); } + virtual void onCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } + virtual void onButtonAccept( wxCommandEvent& event ) { event.Skip(); } + virtual void onButtonAccept2( wxCommandEvent& event ) { event.Skip(); } + virtual void onButtonDecline( wxCommandEvent& event ) { event.Skip(); } + virtual void onCancel( wxCommandEvent& event ) { event.Skip(); } - public: +public: - PopupDialogGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("dummy"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + PopupDialogGenerated( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("dummy"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~PopupDialogGenerated(); + ~PopupDialogGenerated(); }; diff --git a/wx+/tooltip.cpp b/wx+/tooltip.cpp index 63a004bd..4a3c571f 100644 --- a/wx+/tooltip.cpp +++ b/wx+/tooltip.cpp @@ -67,7 +67,7 @@ void Tooltip::show(const wxString& text, wxPoint mousePos, const wxImage* img) tipWindow_->bitmapLeft_->SetBitmap(newImg); tipWindow_->Refresh(); //needed if bitmap size changed! } - + if (text != tipWindow_->staticTextMain_->GetLabelText()) { tipWindow_->staticTextMain_->SetLabelText(text); -- cgit