Description: Some of these can be traced back to version 10.23 which was the last to not use Had to revert gui_status_handler.cpp and .h entirely to version 11.0 to avoid the wx 3.1.4-isms here. . Now have to revert wxWidgets 3.1.4 upstreamisms cd 11.1-0 ; git diff HEAD~1 -- $( grep -l -rIE 'wxASCII_STR' ) > ~/foo1 ; ( cd ../11.1-2 ; vi ~/foo1 $( grep -l -rIE 'wxASCII_STR' ) ; ) cd 11.1-0 ; git diff HEAD~1 -- $( grep -l -rIE 'wxDD_SHOW_HIDDEN' ) > ~/foo1 ; ( cd ../11.1-2 ; vi ~/foo1 $( grep -l -rIE 'wxDD_SHOW_HIDDEN' ) ; ) Date: 2022-09-07 Version: 11.26 Author: bgstack15 --- a/wx+/choice_enum.h +++ b/wx+/choice_enum.h @@ -7,7 +7,6 @@ #ifndef CHOICE_ENUM_H_132413545345687 #define CHOICE_ENUM_H_132413545345687 -#include #include #include @@ -47,8 +46,6 @@ struct EnumDescrList using DescrList = std::vector>>; DescrList descrList; - - std::unordered_map> labelsSetLast; }; template void setEnumVal(const EnumDescrList& mapping, wxChoice& ctrl, Enum value); template Enum getEnumVal(const EnumDescrList& mapping, const wxChoice& ctrl); @@ -71,32 +68,24 @@ template void updateTooltip template void setEnumVal(EnumDescrList& mapping, wxChoice& ctrl, Enum value) { - auto& labelsSetLast = mapping.labelsSetLast[&ctrl]; - - std::vector labels; - for (const auto& [val, texts] : mapping.descrList) - labels.push_back(texts.first); + ctrl.Clear(); - if (labels != labelsSetLast) + int selectedPos = 0; + for (auto it = mapping.descrList.begin(); it != mapping.descrList.end(); ++it) { - ctrl.Set(labels); //expensive as fuck! => only call when absolutely needed! - labelsSetLast = std::move(labels); + ctrl.Append(it->second.first); + if (it->first == value) + { + selectedPos = it - mapping.descrList.begin(); + + if (it->second.second.empty()) + ctrl.UnsetToolTip(); + else + ctrl.SetToolTip(it->second.second); + } } - //----------------------------------------------------------------- - const auto it = std::find_if(mapping.descrList.begin(), mapping.descrList.end(), [&](const auto& mapItem) { return mapItem.first == value; }); - if (it != mapping.descrList.end()) - { - if (const wxString& tooltip = it->second.second; - !tooltip.empty()) - ctrl.SetToolTip(tooltip); - else - ctrl.UnsetToolTip(); - - const int selectedPos = it - mapping.descrList.begin(); - ctrl.SetSelection(selectedPos); - } - else assert(false); + ctrl.SetSelection(selectedPos); } template @@ -115,17 +104,11 @@ Enum getEnumVal(const EnumDescrList void updateTooltipEnumVal(const EnumDescrList& mapping, wxChoice& ctrl) { - const int selectedPos = ctrl.GetSelection(); + const Enum currentValue = getEnumVal(mapping, ctrl); - if (0 <= selectedPos && selectedPos < std::ssize(mapping.descrList)) - { - if (const auto& [text, tooltip] = mapping.descrList[selectedPos].second; - !tooltip.empty()) - ctrl.SetToolTip(tooltip); - else - ctrl.UnsetToolTip(); - } - else assert(false); + for (const auto& [enumValue, textAndTooltip] : mapping.descrList) + if (currentValue == enumValue) + ctrl.SetToolTip(textAndTooltip.second); } } --- a/FreeFileSync/Source/RealTimeSync/folder_selector2.cpp +++ b/FreeFileSync/Source/RealTimeSync/folder_selector2.cpp @@ -165,7 +165,7 @@ void FolderSelector2::onSelectDir(wxComm } Zstring newFolderPath; - wxDirDialog folderSelector(parent_, _("Select a folder"), utfTo(defaultFolderPath), wxDD_DEFAULT_STYLE | wxDD_SHOW_HIDDEN); + wxDirDialog folderSelector(parent_, _("Select a folder"), utfTo(defaultFolderPath)); if (folderSelector.ShowModal() != wxID_OK) return; newFolderPath = utfTo(folderSelector.GetPath()); --- a/FreeFileSync/Source/ui/command_box.h +++ b/FreeFileSync/Source/ui/command_box.h @@ -28,7 +28,7 @@ public: const wxString choices[] = nullptr, long style = 0, const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxASCII_STR(wxComboBoxNameStr)); + const wxString& name = wxComboBoxNameStr); void setHistory(const std::vector& history, size_t historyMax) { history_ = history; historyMax_ = historyMax; } std::vector getHistory() const { return history_; } --- a/FreeFileSync/Source/ui/folder_history_box.h +++ b/FreeFileSync/Source/ui/folder_history_box.h @@ -68,7 +68,7 @@ public: const wxString choices[] = nullptr, long style = 0, const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxASCII_STR(wxComboBoxNameStr)); + const wxString& name = wxComboBoxNameStr); void setHistory(std::shared_ptr sharedHistory) { sharedHistory_ = std::move(sharedHistory); } std::shared_ptr getHistory() { return sharedHistory_; } --- a/FreeFileSync/Source/ui/folder_selector.cpp +++ b/FreeFileSync/Source/ui/folder_selector.cpp @@ -239,7 +239,7 @@ void FolderSelector::onSelectFolder(wxCo Zstring shellItemPath; //default size? Windows: not implemented, Linux(GTK2): not implemented, macOS: not implemented => wxWidgets, what is this shit!? - wxDirDialog folderSelector(parent_, _("Select a folder"), utfTo(defaultFolderNative), wxDD_DEFAULT_STYLE | wxDD_SHOW_HIDDEN); + wxDirDialog folderSelector(parent_, _("Select a folder"), utfTo(defaultFolderNative)); //GTK2: "Show hidden" is also available as a context menu option in the folder picker! //It looks like wxDD_SHOW_HIDDEN only sets the default when opening for the first time!? if (folderSelector.ShowModal() != wxID_OK) --- a/wx+/bitmap_button.h +++ b/wx+/bitmap_button.h @@ -28,7 +28,7 @@ public: const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxASCII_STR(wxButtonNameStr)) : + const wxString& name = wxButtonNameStr) : wxBitmapButton(parent, id, wxNullBitmap, pos, size, style, validator, name) { SetLabel(label); @@ -104,7 +104,6 @@ inline wxBitmap renderSelectedButton(const wxSize& sz) { wxBitmap bmp(sz); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes - bmp.SetScaleFactor(getDisplayScaleFactor()); { wxMemoryDC dc(bmp); @@ -120,7 +119,6 @@ inline wxBitmap renderPressedButton(const wxSize& sz) { wxBitmap bmp(sz); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes - bmp.SetScaleFactor(getDisplayScaleFactor()); { //draw rectangle border with gradient const wxColor colFrom = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE); --- a/wx+/dc.h +++ b/wx+/dc.h @@ -12,7 +12,7 @@ #include #include //for macro: wxALWAYS_NATIVE_DOUBLE_BUFFER #include -#include +//#include #include @@ -92,9 +92,6 @@ constexpr int defaultDpi = 96; //on Wind inline int getDPI() { -#ifndef wxHAS_DPI_INDEPENDENT_PIXELS -#error why is wxHAS_DPI_INDEPENDENT_PIXELS not defined? -#endif //GTK2 doesn't properly support high DPI: https://freefilesync.org/forum/viewtopic.php?t=6114 //=> requires general fix at wxWidgets-level @@ -130,7 +127,6 @@ wxBitmap toScaledBitmap(const wxImage& i { //wxBitmap(const wxImage& image, int depth = -1, double WXUNUSED(scale) = 1.0) => wxWidgets just ignores scale parameter! WTF! wxBitmap bmpScaled(img); - bmpScaled.SetScaleFactor(getDisplayScaleFactor()); return bmpScaled; //when testing use 175% scaling: wxWidgets' scaling logic doesn't kick in for 150% only } --- a/wx+/graph.h +++ b/wx+/graph.h @@ -192,7 +192,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL | wxNO_BORDER, - const wxString& name = wxASCII_STR(wxPanelNameStr)); + const wxString& name = wxPanelNameStr); class CurveAttributes { --- a/wx+/grid.cpp +++ b/wx+/grid.cpp @@ -263,7 +263,7 @@ class Grid::SubWindow : public wxWindow { public: SubWindow(Grid& parent) : - wxWindow(&parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxBORDER_NONE, wxASCII_STR(wxPanelNameStr)), + wxWindow(&parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxWANTS_CHARS | wxBORDER_NONE, wxPanelNameStr), parent_(parent) { Bind(wxEVT_PAINT, [this](wxPaintEvent& event) { onPaintEvent(event); }); --- a/wx+/grid.h +++ b/wx+/grid.h @@ -149,7 +149,7 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTAB_TRAVERSAL | wxNO_BORDER, - const wxString& name = wxASCII_STR(wxPanelNameStr)); + const wxString& name = wxPanelNameStr); size_t getRowCount() const; --- a/wx+/toggle_button.h +++ b/wx+/toggle_button.h @@ -24,7 +24,7 @@ public: const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxASCII_STR(wxButtonNameStr)) : + const wxString& name = wxButtonNameStr) : wxBitmapButton(parent, id, bitmap, pos, size, style, validator, name) {} //wxButton constructor @@ -35,7 +35,7 @@ public: const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxASCII_STR(wxButtonNameStr)) : + const wxString& name = wxButtonNameStr) : wxBitmapButton(parent, id, wxNullBitmap, pos, size, style, validator, name) { SetLabel(label); --- a/FreeFileSync/Source/ui/gui_status_handler.cpp +++ b/FreeFileSync/Source/ui/gui_status_handler.cpp @@ -44,8 +44,8 @@ StatusHandlerTemporaryPanel::StatusHandl mainDlg_.Update(); //don't wait until idle event! //register keys - mainDlg_. Bind(wxEVT_CHAR_HOOK, &StatusHandlerTemporaryPanel::onLocalKeyEvent, this); - mainDlg_.m_buttonCancel->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &StatusHandlerTemporaryPanel::onAbortCompare, this); + mainDlg_.Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(StatusHandlerTemporaryPanel::OnKeyPressed), nullptr, this); + mainDlg_.m_buttonCancel->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusHandlerTemporaryPanel::OnAbortCompare), nullptr, this); } @@ -129,9 +129,8 @@ StatusHandlerTemporaryPanel::~StatusHand mainDlg_.auiMgr_.Update(); //unregister keys - [[maybe_unused]] bool ubOk1 = mainDlg_. Unbind(wxEVT_CHAR_HOOK, &StatusHandlerTemporaryPanel::onLocalKeyEvent, this); - [[maybe_unused]] bool ubOk2 = mainDlg_.m_buttonCancel->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, &StatusHandlerTemporaryPanel::onAbortCompare, this); - assert(ubOk1 && ubOk2); + mainDlg_.Disconnect(wxEVT_CHAR_HOOK, wxKeyEventHandler(StatusHandlerTemporaryPanel::OnKeyPressed), nullptr, this); + mainDlg_.m_buttonCancel->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusHandlerTemporaryPanel::OnAbortCompare), nullptr, this); mainDlg_.compareStatus_->teardown(); @@ -336,7 +335,7 @@ void StatusHandlerTemporaryPanel::forceU } -void StatusHandlerTemporaryPanel::onLocalKeyEvent(wxKeyEvent& event) +void StatusHandlerTemporaryPanel::OnKeyPressed(wxKeyEvent& event) { const int keyCode = event.GetKeyCode(); if (keyCode == WXK_ESCAPE) @@ -346,7 +345,7 @@ void StatusHandlerTemporaryPanel::onLoca } -void StatusHandlerTemporaryPanel::onAbortCompare(wxCommandEvent& event) +void StatusHandlerTemporaryPanel::OnAbortCompare(wxCommandEvent& event) { userRequestAbort(); } --- a/FreeFileSync/Source/ui/gui_status_handler.h +++ b/FreeFileSync/Source/ui/gui_status_handler.h @@ -46,8 +46,8 @@ public: Result reportResults(); //noexcept!! private: - void onLocalKeyEvent(wxKeyEvent& event); - void onAbortCompare(wxCommandEvent& event); //handle abort button click + void OnKeyPressed(wxKeyEvent& event); + void OnAbortCompare(wxCommandEvent& event); //handle abort button click void showStatsPanel(); MainDialog& mainDlg_; --- a/wx+/no_flicker.h +++ b/wx+/no_flicker.h @@ -72,7 +72,7 @@ void setTextWithUrls(wxRichTextCtrl& ric ZEN_ON_SCOPE_EXIT(richCtrl.EndSuppressUndo()); //fix mouse scroll speed: why the FUCK is this even necessary! - richCtrl.SetLineHeight(richCtrl.GetCharHeight()); + //richCtrl.SetLineHeight(richCtrl.GetCharHeight()); // this is not even documented in wxWidgets 3.1.5! //get rid of margins and space between text blocks/"paragraphs" richCtrl.SetMargins({0, 0}); --- a/FreeFileSync/Source/ui/progress_indicator.cpp +++ b/FreeFileSync/Source/ui/progress_indicator.cpp @@ -878,12 +878,10 @@ dlgSizeBuf_(dlgSize) auto generateSquareBitmap = [&](const wxColor& fillCol, const wxColor& borderCol) { wxBitmap bmpSquare(this->GetCharHeight(), this->GetCharHeight()); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes - bmpSquare.SetScaleFactor(getDisplayScaleFactor()); { wxMemoryDC dc(bmpSquare); drawInsetRectangle(dc, wxRect(bmpSquare.GetSize()), fastFromDIP(1), borderCol, fillCol); } - bmpSquare.SetScaleFactor(static_cast(getDPI()) / defaultDpi); return bmpSquare; }; pnl_.m_bitmapGraphKeyBytes->SetBitmap(generateSquareBitmap(getColorBytes(), getColorBytesRim())); --- a/wx+/rtl.h +++ b/wx+/rtl.h @@ -70,8 +70,6 @@ void drawBitmapRtlMirror(wxDC& dc, const if (!buffer || buffer->GetSize() != rect.GetSize()) //[!] since we do a mirror, width needs to match exactly! buffer.emplace(rect.GetSize()); - if (buffer->GetScaleFactor() != dc.GetContentScaleFactor()) //needed here? - buffer->SetScaleFactor(dc.GetContentScaleFactor()); // wxMemoryDC memDc(*buffer); //copies scale factor from wxBitmap memDc.Blit(wxPoint(0, 0), rect.GetSize(), &dc, rect.GetTopLeft()); //blit in: background is mirrored due to memDc, dc having different layout direction! --- a/FreeFileSync/Source/ui/main_dlg.cpp +++ b/FreeFileSync/Source/ui/main_dlg.cpp @@ -3586,7 +3586,6 @@ void MainDialog::onCfgGridContext(GridCo auto addColorOption = [&](const wxColor& col, const wxString& name) { wxBitmap bmpSquare(this->GetCharHeight(), this->GetCharHeight()); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes - bmpSquare.SetScaleFactor(getDisplayScaleFactor()); { wxMemoryDC dc(bmpSquare); const wxColor borderCol(0xdd, 0xdd, 0xdd); //light grey @@ -3619,7 +3618,6 @@ void MainDialog::onCfgGridContext(GridCo //show color picker wxBitmap bmpColorPicker(this->GetCharHeight(), this->GetCharHeight()); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes - bmpColorPicker.SetScaleFactor(getDisplayScaleFactor()); { wxMemoryDC dc(bmpColorPicker); const wxColor borderCol(0xdd, 0xdd, 0xdd); //light grey @@ -3633,7 +3631,6 @@ void MainDialog::onCfgGridContext(GridCo { wxColourData colCfg; colCfg.SetChooseFull(true); - colCfg.SetChooseAlpha(false); colCfg.SetColour(defaultColors[1].first); //tentative if (const ConfigView::Details* cfg = cfggrid::getDataView(*m_gridCfgHistory).getItem(selectedRows[0])) @@ -3650,19 +3647,6 @@ void MainDialog::onCfgGridContext(GridCo assert(col.Alpha() == 255); return col; }; - wxColourDialog dlg(this, &colCfg); - dlg.Center(); - - dlg.Bind(wxEVT_COLOUR_CHANGED, [&](wxColourDialogEvent& event2) - { - //show preview during color selection (Windows-only atm) - cfggrid::getDataView(*m_gridCfgHistory).setBackColor(cfgFilePaths, fixColorPickerColor(event2.GetColour()), true /*previewOnly*/); - m_gridCfgHistory->Refresh(); - }); - - if (dlg.ShowModal() == wxID_OK) - applyBackColor(fixColorPickerColor(dlg.GetColourData().GetColour())); - else //shut off color preview { cfggrid::getDataView(*m_gridCfgHistory).setBackColor(cfgFilePaths, wxNullColour, true /*previewOnly*/); m_gridCfgHistory->Refresh(); --- a/wx+/image_tools.cpp +++ b/wx+/image_tools.cpp @@ -188,7 +188,6 @@ wxImage zen::createImageFromText(const w return wxNullImage; wxBitmap newBitmap(maxWidth, lineHeight * lineInfo.size()); //seems we don't need to pass 24-bit depth here even for high-contrast color schemes - newBitmap.SetScaleFactor(getDisplayScaleFactor()); { dc.SelectObject(newBitmap); //copies scale factor from wxBitmap ZEN_ON_SCOPE_EXIT(dc.SelectObject(wxNullBitmap));